using System; using System.Drawing; using System.Collections; using System.ComponentModel; using System.Windows.Forms; using GZTW.AyaNova.BLL; using Infragistics.Win; using Infragistics.Win.UltraWinGrid; using Infragistics.Win.UltraWinToolbars; using log4net; namespace AyaNova { /// /// Summary description for PartRestockRequiredByVendorForm. /// public class PartRestockRequiredByVendorForm : System.Windows.Forms.Form { // Create a logger for use in this class //case 1039 private static readonly log4net.ILog log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); private System.Windows.Forms.CheckBox ckIsDirty; private System.Windows.Forms.ErrorProvider ErrorProvider; private Infragistics.Win.UltraWinToolbars.UltraToolbarsManager tbManager; private Infragistics.Win.UltraWinToolbars.UltraToolbarsDockArea _PartRestockRequiredByVendorForm_Toolbars_Dock_Area_Left; private Infragistics.Win.UltraWinToolbars.UltraToolbarsDockArea _PartRestockRequiredByVendorForm_Toolbars_Dock_Area_Right; private Infragistics.Win.UltraWinToolbars.UltraToolbarsDockArea _PartRestockRequiredByVendorForm_Toolbars_Dock_Area_Top; private Infragistics.Win.UltraWinToolbars.UltraToolbarsDockArea _PartRestockRequiredByVendorForm_Toolbars_Dock_Area_Bottom; private Infragistics.Win.UltraWinGrid.UltraGrid grid; private System.ComponentModel.IContainer components; public PartRestockRequiredByVendorForm() { // // Required for Windows Form Designer support // InitializeComponent(); } /// /// Clean up any resources being used. /// protected override void Dispose( bool disposing ) { if( disposing ) { if(components != null) { components.Dispose(); } } base.Dispose( disposing ); } #region Windows Form Designer generated code /// /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// private void InitializeComponent() { this.components = new System.ComponentModel.Container(); Infragistics.Win.UltraWinToolbars.UltraToolbar ultraToolbar1 = new Infragistics.Win.UltraWinToolbars.UltraToolbar("UltraToolbar1"); Infragistics.Win.UltraWinToolbars.ButtonTool buttonTool1 = new Infragistics.Win.UltraWinToolbars.ButtonTool("LT:UI.Command.OK"); Infragistics.Win.UltraWinToolbars.ButtonTool buttonTool2 = new Infragistics.Win.UltraWinToolbars.ButtonTool("LT:UI.Command.Cancel"); Infragistics.Win.UltraWinToolbars.ButtonTool buttonTool3 = new Infragistics.Win.UltraWinToolbars.ButtonTool("LT:UI.Command.Cancel"); Infragistics.Win.Appearance appearance1 = new Infragistics.Win.Appearance(); Infragistics.Win.Appearance appearance2 = new Infragistics.Win.Appearance(); Infragistics.Win.UltraWinToolbars.ButtonTool buttonTool4 = new Infragistics.Win.UltraWinToolbars.ButtonTool("LT:UI.Command.OK"); Infragistics.Win.Appearance appearance3 = new Infragistics.Win.Appearance(); Infragistics.Win.Appearance appearance4 = new Infragistics.Win.Appearance(); System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(PartRestockRequiredByVendorForm)); this.ckIsDirty = new System.Windows.Forms.CheckBox(); this.tbManager = new Infragistics.Win.UltraWinToolbars.UltraToolbarsManager(this.components); this.ErrorProvider = new System.Windows.Forms.ErrorProvider(this.components); this._PartRestockRequiredByVendorForm_Toolbars_Dock_Area_Left = new Infragistics.Win.UltraWinToolbars.UltraToolbarsDockArea(); this._PartRestockRequiredByVendorForm_Toolbars_Dock_Area_Right = new Infragistics.Win.UltraWinToolbars.UltraToolbarsDockArea(); this._PartRestockRequiredByVendorForm_Toolbars_Dock_Area_Top = new Infragistics.Win.UltraWinToolbars.UltraToolbarsDockArea(); this._PartRestockRequiredByVendorForm_Toolbars_Dock_Area_Bottom = new Infragistics.Win.UltraWinToolbars.UltraToolbarsDockArea(); this.grid = new Infragistics.Win.UltraWinGrid.UltraGrid(); ((System.ComponentModel.ISupportInitialize)(this.tbManager)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.ErrorProvider)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.grid)).BeginInit(); this.SuspendLayout(); // // ckIsDirty // this.ckIsDirty.Location = new System.Drawing.Point(-336, 28); this.ckIsDirty.Name = "ckIsDirty"; this.ckIsDirty.Size = new System.Drawing.Size(191, 27); this.ckIsDirty.TabIndex = 5; // // tbManager // this.tbManager.AlwaysShowMenusExpanded = Infragistics.Win.DefaultableBoolean.True; this.tbManager.DesignerFlags = 1; this.tbManager.DockWithinContainer = this; this.tbManager.DockWithinContainerBaseType = typeof(System.Windows.Forms.Form); this.tbManager.ShowFullMenusDelay = 500; ultraToolbar1.DockedColumn = 0; ultraToolbar1.DockedRow = 0; ultraToolbar1.NonInheritedTools.AddRange(new Infragistics.Win.UltraWinToolbars.ToolBase[] { buttonTool1, buttonTool2}); ultraToolbar1.Text = "ClientSelectorToolbar"; this.tbManager.Toolbars.AddRange(new Infragistics.Win.UltraWinToolbars.UltraToolbar[] { ultraToolbar1}); this.tbManager.ToolbarSettings.AllowCustomize = Infragistics.Win.DefaultableBoolean.False; this.tbManager.ToolbarSettings.AllowFloating = Infragistics.Win.DefaultableBoolean.False; this.tbManager.ToolbarSettings.AllowHiding = Infragistics.Win.DefaultableBoolean.False; appearance1.Image = ((object)(resources.GetObject("appearance1.Image"))); buttonTool3.SharedPropsInternal.AppearancesLarge.Appearance = appearance1; appearance2.Image = ((object)(resources.GetObject("appearance2.Image"))); buttonTool3.SharedPropsInternal.AppearancesSmall.Appearance = appearance2; buttonTool3.SharedPropsInternal.Caption = "LT:UI.Command.Cancel"; appearance3.Image = ((object)(resources.GetObject("appearance3.Image"))); buttonTool4.SharedPropsInternal.AppearancesLarge.Appearance = appearance3; appearance4.Image = ((object)(resources.GetObject("appearance4.Image"))); buttonTool4.SharedPropsInternal.AppearancesSmall.Appearance = appearance4; buttonTool4.SharedPropsInternal.Caption = "LT:UI.Command.OK"; this.tbManager.Tools.AddRange(new Infragistics.Win.UltraWinToolbars.ToolBase[] { buttonTool3, buttonTool4}); this.tbManager.UseLargeImagesOnToolbar = true; this.tbManager.ToolClick += new Infragistics.Win.UltraWinToolbars.ToolClickEventHandler(this.tbManager_ToolClick); // // ErrorProvider // this.ErrorProvider.ContainerControl = this; // // _PartRestockRequiredByVendorForm_Toolbars_Dock_Area_Left // this._PartRestockRequiredByVendorForm_Toolbars_Dock_Area_Left.AccessibleRole = System.Windows.Forms.AccessibleRole.Grouping; this._PartRestockRequiredByVendorForm_Toolbars_Dock_Area_Left.BackColor = System.Drawing.SystemColors.Control; this._PartRestockRequiredByVendorForm_Toolbars_Dock_Area_Left.DockedPosition = Infragistics.Win.UltraWinToolbars.DockedPosition.Left; this._PartRestockRequiredByVendorForm_Toolbars_Dock_Area_Left.ForeColor = System.Drawing.SystemColors.ControlText; this._PartRestockRequiredByVendorForm_Toolbars_Dock_Area_Left.Location = new System.Drawing.Point(0, 43); this._PartRestockRequiredByVendorForm_Toolbars_Dock_Area_Left.Name = "_PartRestockRequiredByVendorForm_Toolbars_Dock_Area_Left"; this._PartRestockRequiredByVendorForm_Toolbars_Dock_Area_Left.Size = new System.Drawing.Size(0, 258); this._PartRestockRequiredByVendorForm_Toolbars_Dock_Area_Left.ToolbarsManager = this.tbManager; // // _PartRestockRequiredByVendorForm_Toolbars_Dock_Area_Right // this._PartRestockRequiredByVendorForm_Toolbars_Dock_Area_Right.AccessibleRole = System.Windows.Forms.AccessibleRole.Grouping; this._PartRestockRequiredByVendorForm_Toolbars_Dock_Area_Right.BackColor = System.Drawing.SystemColors.Control; this._PartRestockRequiredByVendorForm_Toolbars_Dock_Area_Right.DockedPosition = Infragistics.Win.UltraWinToolbars.DockedPosition.Right; this._PartRestockRequiredByVendorForm_Toolbars_Dock_Area_Right.ForeColor = System.Drawing.SystemColors.ControlText; this._PartRestockRequiredByVendorForm_Toolbars_Dock_Area_Right.Location = new System.Drawing.Point(632, 43); this._PartRestockRequiredByVendorForm_Toolbars_Dock_Area_Right.Name = "_PartRestockRequiredByVendorForm_Toolbars_Dock_Area_Right"; this._PartRestockRequiredByVendorForm_Toolbars_Dock_Area_Right.Size = new System.Drawing.Size(0, 258); this._PartRestockRequiredByVendorForm_Toolbars_Dock_Area_Right.ToolbarsManager = this.tbManager; // // _PartRestockRequiredByVendorForm_Toolbars_Dock_Area_Top // this._PartRestockRequiredByVendorForm_Toolbars_Dock_Area_Top.AccessibleRole = System.Windows.Forms.AccessibleRole.Grouping; this._PartRestockRequiredByVendorForm_Toolbars_Dock_Area_Top.BackColor = System.Drawing.SystemColors.Control; this._PartRestockRequiredByVendorForm_Toolbars_Dock_Area_Top.DockedPosition = Infragistics.Win.UltraWinToolbars.DockedPosition.Top; this._PartRestockRequiredByVendorForm_Toolbars_Dock_Area_Top.ForeColor = System.Drawing.SystemColors.ControlText; this._PartRestockRequiredByVendorForm_Toolbars_Dock_Area_Top.Location = new System.Drawing.Point(0, 0); this._PartRestockRequiredByVendorForm_Toolbars_Dock_Area_Top.Name = "_PartRestockRequiredByVendorForm_Toolbars_Dock_Area_Top"; this._PartRestockRequiredByVendorForm_Toolbars_Dock_Area_Top.Size = new System.Drawing.Size(632, 43); this._PartRestockRequiredByVendorForm_Toolbars_Dock_Area_Top.ToolbarsManager = this.tbManager; // // _PartRestockRequiredByVendorForm_Toolbars_Dock_Area_Bottom // this._PartRestockRequiredByVendorForm_Toolbars_Dock_Area_Bottom.AccessibleRole = System.Windows.Forms.AccessibleRole.Grouping; this._PartRestockRequiredByVendorForm_Toolbars_Dock_Area_Bottom.BackColor = System.Drawing.SystemColors.Control; this._PartRestockRequiredByVendorForm_Toolbars_Dock_Area_Bottom.DockedPosition = Infragistics.Win.UltraWinToolbars.DockedPosition.Bottom; this._PartRestockRequiredByVendorForm_Toolbars_Dock_Area_Bottom.ForeColor = System.Drawing.SystemColors.ControlText; this._PartRestockRequiredByVendorForm_Toolbars_Dock_Area_Bottom.Location = new System.Drawing.Point(0, 301); this._PartRestockRequiredByVendorForm_Toolbars_Dock_Area_Bottom.Name = "_PartRestockRequiredByVendorForm_Toolbars_Dock_Area_Bottom"; this._PartRestockRequiredByVendorForm_Toolbars_Dock_Area_Bottom.Size = new System.Drawing.Size(632, 0); this._PartRestockRequiredByVendorForm_Toolbars_Dock_Area_Bottom.ToolbarsManager = this.tbManager; // // grid // this.grid.Dock = System.Windows.Forms.DockStyle.Fill; this.grid.Location = new System.Drawing.Point(0, 43); this.grid.Name = "grid"; this.grid.Size = new System.Drawing.Size(632, 258); this.grid.TabIndex = 101; this.grid.Tag = ""; // // PartRestockRequiredByVendorForm // this.AutoScaleBaseSize = new System.Drawing.Size(6, 15); this.ClientSize = new System.Drawing.Size(632, 301); this.Controls.Add(this.grid); this.Controls.Add(this.ckIsDirty); this.Controls.Add(this._PartRestockRequiredByVendorForm_Toolbars_Dock_Area_Left); this.Controls.Add(this._PartRestockRequiredByVendorForm_Toolbars_Dock_Area_Right); this.Controls.Add(this._PartRestockRequiredByVendorForm_Toolbars_Dock_Area_Bottom); this.Controls.Add(this._PartRestockRequiredByVendorForm_Toolbars_Dock_Area_Top); this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); this.Name = "PartRestockRequiredByVendorForm"; this.ShowInTaskbar = false; this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Show; this.Closing += new System.ComponentModel.CancelEventHandler(this.PartRestockRequiredByVendorForm_Closing); this.Load += new System.EventHandler(this.PartRestockRequiredByVendorForm_Load); ((System.ComponentModel.ISupportInitialize)(this.tbManager)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.ErrorProvider)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.grid)).EndInit(); this.ResumeLayout(false); } #endregion // __ _ _ ___ ____ __ __ __ __ __ ___ ___ // / _)( )( )/ __)(_ _)/ \( \/ ) / _)/ \( \( _) // ( (_ )()( \__ \ )( ( () )) ( ( (_( () )) ) )) _) // \__) \__/ (___/ (__) \__/(_/\/\_) \__)\__/(___/(___) // #region Form Load / Close //variable to hold user form settings //UIUserFormSetting mFormSetting; /// /// Prepare the form /// /// /// private void PartRestockRequiredByVendorForm_Load(object sender, System.EventArgs e) { Cursor.Current = Cursors.WaitCursor; this.Visible=false; grid.DataSource=PartRestockRequiredByVendorList.GetEmptyList(); InitializeGrid(); grid.DataSource=this.mRestock; this.Text=Util.LocaleText.GetLocalizedText("PartRestockRequiredByVendor.Label.List") + " " + mVendorName; Util.LoadFormCustomization("PartRestockRequiredByVendor", this, tbManager, false); Util.LocalizeHelperInsertMenu(tbManager, this); //case 1810 Util.Localize(this); Cursor.Current = Cursors.Default; //Copy over values in grid //case 3196 foreach (UltraGridRow r in grid.Rows) { r.Cells["LT_PartByWarehouseInventory_Label_ReorderQuantity"].Value = (decimal)r.Cells["REQUIRED"].Value; } this.Visible=true; } /// /// Used to track whether the close was done by the program /// or done by the user clicking on the upper left corner X control /// //bool bClosingHandled=false; /// /// Save form layout and grid layout for next time /// /// /// private void PartRestockRequiredByVendorForm_Closing(object sender, System.ComponentModel.CancelEventArgs e) { //case 1039 //log.Debug("PartRestockRequiredByVendorForm_Closing"); Util.SaveFormCustomization("PartRestockRequiredByVendor", this, tbManager, false); Util.SaveGridLayout("PartRestockRequiredByVendor","","",grid); } #endregion #region Form UI commands #region Toolbar menu items /// /// Respond to a click on a toolbar menu item /// /// /// private void tbManager_ToolClick(object sender, Infragistics.Win.UltraWinToolbars.ToolClickEventArgs e) { //case 1039 //if(log.IsDebugEnabled) //case 1039 //log.Debug("ToolClick: "+e.Tool.Key); switch (e.Tool.Key) { case "LT:UI.Command.Cancel": // ButtonTool this.DialogResult=DialogResult.Cancel; this.Close(); break; case "LT:UI.Command.OK": // ButtonTool this.DialogResult=DialogResult.OK; grid.UpdateData(); foreach(UltraGridRow r in grid.Rows) { if((bool)r.Cells["Select"].Value==true) { //MessageBox.Show(r.Cells["LT_O_Part"].Value.ToString()); PurchaseOrderItem poi=mPurchaseOrder.OrderItems.Add(mPurchaseOrder); poi.PartID=(Guid)r.Cells["PartID"].Value; poi.PartWarehouseID=(Guid)r.Cells["PartWarehouseID"].Value; //poi.PurchaseTaxCodeID=(Guid)r.Cells["PartTaxCodeID"].Value; poi.PurchaseOrderCost=(decimal)r.Cells["PartCost"].Value; poi.QuantityOrdered=(decimal)r.Cells["LT_PartByWarehouseInventory_Label_ReorderQuantity"].Value; } } this.Close(); break; } } #endregion Toolbar menu items #endregion Form UI commands #region Business object editing / adding / deletion related code private PartRestockRequiredByVendorList mRestock; /// /// PartRestockRequiredByVendorList inventory records to display /// set by caller /// public PartRestockRequiredByVendorList PartInventoriesToEdit { get { return mRestock; } set { mRestock=value; } } private PurchaseOrder mPurchaseOrder; /// /// PurchaseOrder to insert items selected into /// set by caller /// public PurchaseOrder PurchaseOrderToEdit { get { return mPurchaseOrder; } set { mPurchaseOrder=value; } } private string mVendorName; public string VendorNameToDisplay {set{mVendorName=value;}} //Used to signal to main form that there are changes //which could affect it if true private bool mbChangesMade=false; public bool ChangesMade { get { return mbChangesMade; } } #endregion #region Initialize grid /// /// Get grid ready /// private void InitializeGrid() { //case 1039 //log.Debug("InitializeGrid"); //Changed:12-Oct-2006 (this was commented out, not sure why) Util.FetchGridLayout("PartRestockRequiredByVendor","",grid); //Changed: 12-Oct-2006 //preventive measure to avoid missing column problem //that was experienced in similar grid PartWorkorderItemRequestByVendor foreach (UltraGridColumn cm in grid.DisplayLayout.Bands[0].Columns) cm.Hidden = false; grid.DisplayLayout.Bands[0].Columns["PartWarehouseID"].Hidden=true; grid.DisplayLayout.Bands[0].Columns["PartID"].Hidden=true; grid.DisplayLayout.Bands[0].Columns["REQUIRED"].Hidden=true; //grid.DisplayLayout.Bands[0].Columns["PartTaxCodeID"].Hidden=true; grid.DisplayLayout.Bands[0].Columns["PartCost"].Hidden=true; //When a grid is in a tab control it doesn't seem to be //a part of the controls collection so the //localize(this) above doesn't catch it, need's to be done separately: Util.LocalizeGrid(grid); grid.DisplayLayout.Override.HeaderClickAction=HeaderClickAction.SortSingle; grid.DisplayLayout.Override.AllowAddNew=AllowAddNew.No; grid.DisplayLayout.Bands[0].Override.RowSelectors=DefaultableBoolean.False; //Set the caption to be on the left side of the grid grid.DisplayLayout.CaptionAppearance.TextHAlign=HAlign.Left; //add checkbox column for selecting items if(grid.DisplayLayout.Bands[0].Columns.Exists("Select")) { grid.DisplayLayout.Bands[0].Columns["Select"].Header.Caption= Util.LocaleText.GetLocalizedText("PurchaseOrder.Label.UI.CopyToPurchaseOrder"); } else { grid.DisplayLayout.Bands[0].Columns.Add("Select", Util.LocaleText.GetLocalizedText("PurchaseOrder.Label.UI.CopyToPurchaseOrder")); } grid.DisplayLayout.Bands[0].Columns["Select"].DataType=typeof(bool); grid.DisplayLayout.Bands[0].Columns["Select"].Style=Infragistics.Win.UltraWinGrid.ColumnStyle.CheckBox; //add editable reorder quantity column if(grid.DisplayLayout.Bands[0].Columns.Exists("LT_PartByWarehouseInventory_Label_ReorderQuantity")) { grid.DisplayLayout.Bands[0].Columns["LT_PartByWarehouseInventory_Label_ReorderQuantity"].Header.Caption= Util.LocaleText.GetLocalizedText("PartByWarehouseInventory.Label.ReorderQuantity"); } else { grid.DisplayLayout.Bands[0].Columns.Add("LT_PartByWarehouseInventory_Label_ReorderQuantity", Util.LocaleText.GetLocalizedText("PartByWarehouseInventory.Label.ReorderQuantity")); } grid.DisplayLayout.Bands[0].Columns["LT_PartByWarehouseInventory_Label_ReorderQuantity"].DataType=typeof(decimal); grid.DisplayLayout.Bands[0].Columns["LT_PartByWarehouseInventory_Label_ReorderQuantity"].Style=Infragistics.Win.UltraWinGrid.ColumnStyle.Default; grid.DisplayLayout.Bands[0].Columns["LT_PartByWarehouseInventory_Label_ReorderQuantity"].CellAppearance.FontData.Bold=DefaultableBoolean.True; //decimal number formatting grid.DisplayLayout.Bands[0].Columns["LT_PartByWarehouseInventory_Label_ReorderQuantity"].Format="g29"; grid.DisplayLayout.Bands[0].Columns["LT_PartByWarehouseInventory_Label_QuantityOnHand"].Format="g29"; grid.DisplayLayout.Bands[0].Columns["LT_PartByWarehouseInventory_Label_QuantityOnOrder"].Format="g29"; grid.DisplayLayout.Bands[0].Columns["LT_PartByWarehouseInventory_Label_MinStockLevel"].Format="g29"; // grid.DisplayLayout.Bands[0].Columns["PartWarehouseID"].Header.Caption=Util.LocaleText.GetLocalizedText("O.PartWarehouse"); // // grid.DisplayLayout.Bands[0].Columns["PartWarehouseID"].CellActivation=Activation.Disabled; // grid.DisplayLayout.Bands[0].Columns["QuantityOnHand"].CellActivation=Activation.Disabled; // grid.DisplayLayout.Bands[0].Columns["QuantityOnOrder"].CellActivation=Activation.Disabled; // grid.DisplayLayout.Bands[0].Columns["QtyOnOrderCommitted"].CellActivation=Activation.Disabled; // grid.DisplayLayout.Bands[0].Columns["MinStockLevel"].CellAppearance.FontData.Bold=DefaultableBoolean.True; } #endregion initialize grid #region Grid events //private bool _Initializing=true; //private void grid_InitializeRow(object sender, Infragistics.Win.UltraWinGrid.InitializeRowEventArgs e) //{ // if(_Initializing) // e.Row.Cells["LT_PartByWarehouseInventory_Label_ReorderQuantity"].Value=(decimal)e.Row.Cells["REQUIRED"].Value; //} #endregion } }