This commit is contained in:
708
source/WinFormApp/PartByWarehouseInventoryForm.cs
Normal file
708
source/WinFormApp/PartByWarehouseInventoryForm.cs
Normal file
@@ -0,0 +1,708 @@
|
||||
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>
|
||||
/// Summary description for PartByWarehouseInventoryForm.
|
||||
/// This form is only available from teh Part info form and the only thing you can edit is the restock quantity
|
||||
/// Seems like overkill.
|
||||
/// </summary>
|
||||
public class PartByWarehouseInventoryForm : 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 _PartByWarehouseInventoryForm_Toolbars_Dock_Area_Left;
|
||||
private Infragistics.Win.UltraWinToolbars.UltraToolbarsDockArea _PartByWarehouseInventoryForm_Toolbars_Dock_Area_Right;
|
||||
private Infragistics.Win.UltraWinToolbars.UltraToolbarsDockArea _PartByWarehouseInventoryForm_Toolbars_Dock_Area_Top;
|
||||
private Infragistics.Win.UltraWinToolbars.UltraToolbarsDockArea _PartByWarehouseInventoryForm_Toolbars_Dock_Area_Bottom;
|
||||
private Infragistics.Win.UltraWinGrid.UltraGrid grid;
|
||||
private System.ComponentModel.IContainer components;
|
||||
|
||||
|
||||
public PartByWarehouseInventoryForm()
|
||||
{
|
||||
//
|
||||
// Required for Windows Form Designer support
|
||||
//
|
||||
InitializeComponent();
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
protected override void Dispose( bool disposing )
|
||||
{
|
||||
if( disposing )
|
||||
{
|
||||
if(components != null)
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
}
|
||||
base.Dispose( disposing );
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.components = new System.ComponentModel.Container();
|
||||
Infragistics.Win.UltraWinToolbars.UltraToolbar ultraToolbar1 = new Infragistics.Win.UltraWinToolbars.UltraToolbar("SecurityGroupEntryMenuBar");
|
||||
Infragistics.Win.UltraWinToolbars.ButtonTool buttonTool1 = new Infragistics.Win.UltraWinToolbars.ButtonTool("LT:UI.Command.SaveClose");
|
||||
Infragistics.Win.UltraWinToolbars.ButtonTool buttonTool2 = new Infragistics.Win.UltraWinToolbars.ButtonTool("LT:UI.Command.Save");
|
||||
Infragistics.Win.UltraWinToolbars.ButtonTool buttonTool3 = new Infragistics.Win.UltraWinToolbars.ButtonTool("LT:UI.Command.Close");
|
||||
Infragistics.Win.UltraWinToolbars.ButtonTool buttonTool4 = new Infragistics.Win.UltraWinToolbars.ButtonTool("LT:UI.Command.SaveClose");
|
||||
Infragistics.Win.Appearance appearance1 = new Infragistics.Win.Appearance();
|
||||
Infragistics.Win.Appearance appearance2 = new Infragistics.Win.Appearance();
|
||||
Infragistics.Win.UltraWinToolbars.ButtonTool buttonTool5 = new Infragistics.Win.UltraWinToolbars.ButtonTool("LT:UI.Command.Save");
|
||||
Infragistics.Win.UltraWinToolbars.ButtonTool buttonTool6 = new Infragistics.Win.UltraWinToolbars.ButtonTool("LT:UI.Command.Close");
|
||||
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._PartByWarehouseInventoryForm_Toolbars_Dock_Area_Left = new Infragistics.Win.UltraWinToolbars.UltraToolbarsDockArea();
|
||||
this._PartByWarehouseInventoryForm_Toolbars_Dock_Area_Right = new Infragistics.Win.UltraWinToolbars.UltraToolbarsDockArea();
|
||||
this._PartByWarehouseInventoryForm_Toolbars_Dock_Area_Top = new Infragistics.Win.UltraWinToolbars.UltraToolbarsDockArea();
|
||||
this._PartByWarehouseInventoryForm_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(190, 27);
|
||||
this.ckIsDirty.TabIndex = 5;
|
||||
//
|
||||
// tbManager
|
||||
//
|
||||
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,
|
||||
buttonTool3});
|
||||
ultraToolbar1.Text = "SecurityGroupEntryMenuBar";
|
||||
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;
|
||||
buttonTool4.SharedPropsInternal.AccessibleDescription = "recorddd";
|
||||
appearance1.Image = global::AyaNova.Resource1.SaveExit32;
|
||||
buttonTool4.SharedPropsInternal.AppearancesLarge.Appearance = appearance1;
|
||||
appearance2.Image = global::AyaNova.Resource1.SaveExit16;
|
||||
buttonTool4.SharedPropsInternal.AppearancesSmall.Appearance = appearance2;
|
||||
buttonTool4.SharedPropsInternal.Caption = "LT:UI.Command.SaveClose";
|
||||
buttonTool5.SharedPropsInternal.Caption = "LT:UI.Command.Save";
|
||||
buttonTool5.SharedPropsInternal.DisplayStyle = Infragistics.Win.UltraWinToolbars.ToolDisplayStyle.TextOnlyAlways;
|
||||
buttonTool6.SharedPropsInternal.Caption = "LT:UI.Command.Close";
|
||||
buttonTool6.SharedPropsInternal.DisplayStyle = Infragistics.Win.UltraWinToolbars.ToolDisplayStyle.TextOnlyAlways;
|
||||
this.tbManager.Tools.AddRange(new Infragistics.Win.UltraWinToolbars.ToolBase[] {
|
||||
buttonTool4,
|
||||
buttonTool5,
|
||||
buttonTool6});
|
||||
this.tbManager.UseLargeImagesOnToolbar = true;
|
||||
this.tbManager.ToolClick += new Infragistics.Win.UltraWinToolbars.ToolClickEventHandler(this.tbManager_ToolClick);
|
||||
//
|
||||
// ErrorProvider
|
||||
//
|
||||
this.ErrorProvider.ContainerControl = this;
|
||||
//
|
||||
// _PartByWarehouseInventoryForm_Toolbars_Dock_Area_Left
|
||||
//
|
||||
this._PartByWarehouseInventoryForm_Toolbars_Dock_Area_Left.AccessibleRole = System.Windows.Forms.AccessibleRole.Grouping;
|
||||
this._PartByWarehouseInventoryForm_Toolbars_Dock_Area_Left.BackColor = System.Drawing.SystemColors.Control;
|
||||
this._PartByWarehouseInventoryForm_Toolbars_Dock_Area_Left.DockedPosition = Infragistics.Win.UltraWinToolbars.DockedPosition.Left;
|
||||
this._PartByWarehouseInventoryForm_Toolbars_Dock_Area_Left.ForeColor = System.Drawing.SystemColors.ControlText;
|
||||
this._PartByWarehouseInventoryForm_Toolbars_Dock_Area_Left.Location = new System.Drawing.Point(0, 43);
|
||||
this._PartByWarehouseInventoryForm_Toolbars_Dock_Area_Left.Name = "_PartByWarehouseInventoryForm_Toolbars_Dock_Area_Left";
|
||||
this._PartByWarehouseInventoryForm_Toolbars_Dock_Area_Left.Size = new System.Drawing.Size(0, 258);
|
||||
this._PartByWarehouseInventoryForm_Toolbars_Dock_Area_Left.ToolbarsManager = this.tbManager;
|
||||
//
|
||||
// _PartByWarehouseInventoryForm_Toolbars_Dock_Area_Right
|
||||
//
|
||||
this._PartByWarehouseInventoryForm_Toolbars_Dock_Area_Right.AccessibleRole = System.Windows.Forms.AccessibleRole.Grouping;
|
||||
this._PartByWarehouseInventoryForm_Toolbars_Dock_Area_Right.BackColor = System.Drawing.SystemColors.Control;
|
||||
this._PartByWarehouseInventoryForm_Toolbars_Dock_Area_Right.DockedPosition = Infragistics.Win.UltraWinToolbars.DockedPosition.Right;
|
||||
this._PartByWarehouseInventoryForm_Toolbars_Dock_Area_Right.ForeColor = System.Drawing.SystemColors.ControlText;
|
||||
this._PartByWarehouseInventoryForm_Toolbars_Dock_Area_Right.Location = new System.Drawing.Point(632, 43);
|
||||
this._PartByWarehouseInventoryForm_Toolbars_Dock_Area_Right.Name = "_PartByWarehouseInventoryForm_Toolbars_Dock_Area_Right";
|
||||
this._PartByWarehouseInventoryForm_Toolbars_Dock_Area_Right.Size = new System.Drawing.Size(0, 258);
|
||||
this._PartByWarehouseInventoryForm_Toolbars_Dock_Area_Right.ToolbarsManager = this.tbManager;
|
||||
//
|
||||
// _PartByWarehouseInventoryForm_Toolbars_Dock_Area_Top
|
||||
//
|
||||
this._PartByWarehouseInventoryForm_Toolbars_Dock_Area_Top.AccessibleRole = System.Windows.Forms.AccessibleRole.Grouping;
|
||||
this._PartByWarehouseInventoryForm_Toolbars_Dock_Area_Top.BackColor = System.Drawing.SystemColors.Control;
|
||||
this._PartByWarehouseInventoryForm_Toolbars_Dock_Area_Top.DockedPosition = Infragistics.Win.UltraWinToolbars.DockedPosition.Top;
|
||||
this._PartByWarehouseInventoryForm_Toolbars_Dock_Area_Top.ForeColor = System.Drawing.SystemColors.ControlText;
|
||||
this._PartByWarehouseInventoryForm_Toolbars_Dock_Area_Top.Location = new System.Drawing.Point(0, 0);
|
||||
this._PartByWarehouseInventoryForm_Toolbars_Dock_Area_Top.Name = "_PartByWarehouseInventoryForm_Toolbars_Dock_Area_Top";
|
||||
this._PartByWarehouseInventoryForm_Toolbars_Dock_Area_Top.Size = new System.Drawing.Size(632, 43);
|
||||
this._PartByWarehouseInventoryForm_Toolbars_Dock_Area_Top.ToolbarsManager = this.tbManager;
|
||||
//
|
||||
// _PartByWarehouseInventoryForm_Toolbars_Dock_Area_Bottom
|
||||
//
|
||||
this._PartByWarehouseInventoryForm_Toolbars_Dock_Area_Bottom.AccessibleRole = System.Windows.Forms.AccessibleRole.Grouping;
|
||||
this._PartByWarehouseInventoryForm_Toolbars_Dock_Area_Bottom.BackColor = System.Drawing.SystemColors.Control;
|
||||
this._PartByWarehouseInventoryForm_Toolbars_Dock_Area_Bottom.DockedPosition = Infragistics.Win.UltraWinToolbars.DockedPosition.Bottom;
|
||||
this._PartByWarehouseInventoryForm_Toolbars_Dock_Area_Bottom.ForeColor = System.Drawing.SystemColors.ControlText;
|
||||
this._PartByWarehouseInventoryForm_Toolbars_Dock_Area_Bottom.Location = new System.Drawing.Point(0, 301);
|
||||
this._PartByWarehouseInventoryForm_Toolbars_Dock_Area_Bottom.Name = "_PartByWarehouseInventoryForm_Toolbars_Dock_Area_Bottom";
|
||||
this._PartByWarehouseInventoryForm_Toolbars_Dock_Area_Bottom.Size = new System.Drawing.Size(632, 0);
|
||||
this._PartByWarehouseInventoryForm_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 = "";
|
||||
this.grid.InitializeRow += new Infragistics.Win.UltraWinGrid.InitializeRowEventHandler(this.grid_InitializeRow);
|
||||
//
|
||||
// PartByWarehouseInventoryForm
|
||||
//
|
||||
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._PartByWarehouseInventoryForm_Toolbars_Dock_Area_Left);
|
||||
this.Controls.Add(this._PartByWarehouseInventoryForm_Toolbars_Dock_Area_Right);
|
||||
this.Controls.Add(this._PartByWarehouseInventoryForm_Toolbars_Dock_Area_Bottom);
|
||||
this.Controls.Add(this._PartByWarehouseInventoryForm_Toolbars_Dock_Area_Top);
|
||||
this.Name = "PartByWarehouseInventoryForm";
|
||||
this.ShowInTaskbar = false;
|
||||
this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Show;
|
||||
this.Closing += new System.ComponentModel.CancelEventHandler(this.PartByWarehouseInventoryForm_Closing);
|
||||
this.Load += new System.EventHandler(this.PartByWarehouseInventoryForm_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;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Prepare the form
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void PartByWarehouseInventoryForm_Load(object sender, System.EventArgs e)
|
||||
{
|
||||
//case 1039 //log.Debug("PartByWarehouseInventoryForm_Load");
|
||||
|
||||
|
||||
Cursor.Current = Cursors.WaitCursor;
|
||||
this.Visible=false;
|
||||
this.Icon = Resource1.Part16icon;
|
||||
|
||||
//See if user has any rights to be here...
|
||||
//(this is done here to ensure that no matter what happens if a user has no rights they can't get here
|
||||
//useful in case we miss a way of getting to a SecurityGroup edit screen from elsewhere in the program)
|
||||
if(AyaBizUtils.Right("Object.PartByWarehouseInventory")< (int)SecurityLevelTypes.ReadOnly)//Less than read only instead of NoAccess to catch records where it's zero instead of 1
|
||||
{
|
||||
//Inform them of their wicked ways and boot them out of here...
|
||||
|
||||
MessageBox.Show(string.Format(
|
||||
Util.LocaleText.GetLocalizedText("Error.Security.NotAuthorizedToRetrieve"),
|
||||
Util.LocaleText.GetLocalizedText("O.PartByWarehouseInventory")));
|
||||
|
||||
this.Close();
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
grid.DataSource=this.mInventories;
|
||||
|
||||
//DataBind();
|
||||
InitializeGrid();
|
||||
|
||||
this.Text=Util.LocaleText.GetLocalizedText("PartByWarehouseInventory.Label.List") + " " + mPartName;
|
||||
Util.LoadFormCustomization("PartByWarehouseInventory", this, tbManager, false);
|
||||
|
||||
//restrict UI based on security settings
|
||||
RestrictUI();
|
||||
Util.LocalizeHelperInsertMenu(tbManager, this); //case 1810
|
||||
Util.Localize(this);
|
||||
|
||||
Cursor.Current = Cursors.Default;
|
||||
//Application.Idle+= new EventHandler(Application_Idle);
|
||||
|
||||
this.Visible=true;
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Used to track whether the close was done by the program
|
||||
/// or done by the user clicking on the upper left corner X control
|
||||
/// </summary>
|
||||
bool bClosingHandled=false;
|
||||
/// <summary>
|
||||
/// Save form layout and grid layout for next time
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void PartByWarehouseInventoryForm_Closing(object sender, System.ComponentModel.CancelEventArgs e)
|
||||
{
|
||||
//case 1039 //log.Debug("PartByWarehouseInventoryForm_Closing");
|
||||
|
||||
|
||||
if(!bClosingHandled)
|
||||
{
|
||||
//Save record if necessary
|
||||
//User may opt to not cancel exit
|
||||
if(!RecordUpdate(RecordActionType.PromptToSave) )
|
||||
{
|
||||
e.Cancel=true;
|
||||
return;
|
||||
}
|
||||
}
|
||||
//Application.Idle-= new EventHandler(Application_Idle);
|
||||
|
||||
Util.SaveGridLayout("PartByWarehouseInventory","","",grid);
|
||||
Util.SaveFormCustomization("PartByWarehouseInventory", this, tbManager, false);
|
||||
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Form UI commands
|
||||
|
||||
#region Toolbar menu items
|
||||
|
||||
/// <summary>
|
||||
/// Respond to a click on a toolbar menu item
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
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.SaveClose": // ButtonTool
|
||||
RecordUpdate(RecordActionType.SaveAndExit);
|
||||
break;
|
||||
|
||||
|
||||
|
||||
case "LT:UI.Command.Save": // ButtonTool
|
||||
RecordUpdate(RecordActionType.SaveOnly);
|
||||
break;
|
||||
|
||||
|
||||
|
||||
case "LT:UI.Command.Close": // ButtonTool
|
||||
this.Close();
|
||||
break;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
#endregion Toolbar menu items
|
||||
|
||||
|
||||
|
||||
|
||||
#endregion Form UI commands
|
||||
|
||||
#region Form UI / Business object synchronization
|
||||
|
||||
/// <summary>
|
||||
/// Adapt UI to accomodate users security access level
|
||||
/// by default form is set with full rights in mind
|
||||
/// so this code just needs to restrict them as required
|
||||
/// </summary>
|
||||
private void RestrictUI()
|
||||
{
|
||||
|
||||
//case 1039 //if(log.IsDebugEnabled) //case 1039 //log.Debug("RestrictUI: " + ((SecurityLevelTypes)AyaBizUtils.Right("Object.PartByWarehouseInventory")).ToString());
|
||||
bool ReadOnly=AyaBizUtils.Right("Object.PartByWarehouseInventory")< (int)SecurityLevelTypes.ReadWrite;
|
||||
|
||||
|
||||
tbManager.Tools["LT:UI.Command.SaveClose"].SharedProps.Visible=!ReadOnly;
|
||||
tbManager.Tools["LT:UI.Command.Save"].SharedProps.Visible=!ReadOnly;
|
||||
tbManager.Tools["LT:UI.Command.Close"].SharedProps.Visible=true;
|
||||
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Form DataBinding and BrokenRules handling
|
||||
|
||||
|
||||
// /// <summary>
|
||||
// /// Bind controls to business objects
|
||||
// /// </summary>
|
||||
// private void DataBind()
|
||||
// {
|
||||
// //case 1039 //log.Debug("DataBind");
|
||||
// //prevent initialze row from firing and throwing errors when it finds there is no data
|
||||
// //
|
||||
// grid.EventManager.SetEnabled(GridEventIds.InitializeRow,false);
|
||||
//
|
||||
// //Subscribe to broken rules changed event OnBrokenRulesChanged
|
||||
// mInventories.GetBrokenRulesCollection().ListChanged += new System.ComponentModel.ListChangedEventHandler(OnBrokenRulesChanged);
|
||||
//
|
||||
//
|
||||
// //=-=-=-=-=-=- Form Field bindings =-=-=-=-=-=-=-=-=-=-=-=
|
||||
//
|
||||
//
|
||||
// //Grids
|
||||
// //Util.BindField(grid,"DataSource",mInventories,"Rights");
|
||||
//
|
||||
//
|
||||
//
|
||||
// //=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
|
||||
//
|
||||
// //Bind IsDirty property to hidden checkbox to
|
||||
// //ensure isdirtychanged event is available
|
||||
// //to data binding infrastructure
|
||||
// Util.BindField(ckIsDirty,"Checked",mInventories,"IsDirty");
|
||||
//
|
||||
// //Setup initial link to broken rules
|
||||
// OnBrokenRulesChanged(null,null);
|
||||
// //turn initialize row event back on
|
||||
// grid.EventManager.SetEnabled(GridEventIds.InitializeRow,true);
|
||||
//
|
||||
//
|
||||
// }
|
||||
//
|
||||
//
|
||||
// /// <summary>
|
||||
// /// Handle a change in broken rules
|
||||
// /// </summary>
|
||||
// /// <param name="sender"></param>
|
||||
// /// <param name="e"></param>
|
||||
// private void OnBrokenRulesChanged(object sender, System.ComponentModel.ListChangedEventArgs e)
|
||||
// {
|
||||
// Util.BrokenRuleFeedback(this,mInventories,ErrorProvider);
|
||||
//
|
||||
// }
|
||||
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
#region Business object editing / adding / deletion related code
|
||||
|
||||
|
||||
private PartByWarehouseInventories mInventories;
|
||||
/// <summary>
|
||||
/// PartByWarehouseInventories inventory records to display
|
||||
/// set by caller
|
||||
/// </summary>
|
||||
public PartByWarehouseInventories PartInventoriesToEdit
|
||||
{
|
||||
get
|
||||
{
|
||||
return mInventories;
|
||||
}
|
||||
set
|
||||
{
|
||||
mInventories=value;
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private string mPartName;
|
||||
public string PartNameToDisplay {set{mPartName=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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Update record and quit if requested
|
||||
///
|
||||
/// </summary>
|
||||
/// <returns>True if handled, false if not handled</returns>
|
||||
private bool RecordUpdate(RecordActionType SaveType)
|
||||
{
|
||||
//case 1039 //if(log.IsDebugEnabled) //case 1039 //log.Debug("SaveHandler(Action="+SaveType.ToString()+")");
|
||||
|
||||
//ensure pending updates are saved
|
||||
grid.UpdateData();
|
||||
switch(SaveType)
|
||||
{
|
||||
|
||||
|
||||
case RecordActionType.SaveAndExit:
|
||||
//Save if necessary and exit
|
||||
if(mInventories.IsSavable)
|
||||
{
|
||||
mInventories.ApplyEdit();
|
||||
mInventories.Save();
|
||||
bClosingHandled=true;
|
||||
mbChangesMade=true;
|
||||
this.Close();
|
||||
return true;
|
||||
}
|
||||
if(mInventories.IsDirty)//dirty and unsaveable due to broken rules
|
||||
{
|
||||
if(Util.PromptForBrokenRulesCancelSave()==DialogResult.Yes)
|
||||
{
|
||||
bClosingHandled=true;
|
||||
this.Close();
|
||||
return true;
|
||||
}
|
||||
else
|
||||
return false;
|
||||
}
|
||||
//not dirty so just exit
|
||||
bClosingHandled=true;
|
||||
this.Close();
|
||||
return true;
|
||||
|
||||
|
||||
|
||||
case RecordActionType.SaveOnly:
|
||||
if(mInventories.IsSavable)
|
||||
{
|
||||
mInventories.ApplyEdit();
|
||||
mInventories=(GZTW.AyaNova.BLL.PartByWarehouseInventories)mInventories.Save();
|
||||
grid.DataSource=mInventories;
|
||||
mbChangesMade=true;
|
||||
return true;
|
||||
|
||||
}
|
||||
return true;
|
||||
|
||||
case RecordActionType.PromptToSave:
|
||||
//Prompt to save and save if
|
||||
//required
|
||||
if(mInventories.IsDirty)
|
||||
{
|
||||
DialogResult dr=Util.PromptForSave();
|
||||
if(dr==DialogResult.Cancel)
|
||||
{
|
||||
//Cancel
|
||||
return false;
|
||||
}
|
||||
if(dr==DialogResult.Yes)
|
||||
{
|
||||
//Save before exit
|
||||
|
||||
if(mInventories.IsSavable)
|
||||
{
|
||||
mInventories.ApplyEdit();
|
||||
mInventories.Save();
|
||||
mbChangesMade=true;
|
||||
return true;
|
||||
}
|
||||
if(mInventories.IsDirty)//dirty and unsaveable due to broken rules
|
||||
{
|
||||
if(Util.PromptForBrokenRulesCancelSave()==DialogResult.Yes)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
#region Initialize grid
|
||||
|
||||
/// <summary>
|
||||
/// Get grid ready
|
||||
/// </summary>
|
||||
private void InitializeGrid()
|
||||
{
|
||||
//case 1039 //log.Debug("InitializeGrid");
|
||||
|
||||
|
||||
Util.GridPreLocalize("PartByWarehouseInventory",grid.DisplayLayout.Bands[0]);
|
||||
|
||||
Util.FetchGridLayout("PartByWarehouseInventory","",grid);
|
||||
Util.GridHideEditableBizObjectInternalFields(grid);
|
||||
//grid.DisplayLayout.Bands[0].Columns["Active"].Hidden=true;
|
||||
grid.DisplayLayout.Bands[0].Columns["PartID"].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.Override.AllowDelete=DefaultableBoolean.False;
|
||||
|
||||
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;
|
||||
|
||||
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;
|
||||
//Ensure a read only user can't make changes
|
||||
if(AyaBizUtils.Right("Object.PartByWarehouseInventory")< (int)SecurityLevelTypes.ReadWrite)
|
||||
grid.DisplayLayout.Bands[0].Override.AllowUpdate=DefaultableBoolean.False;
|
||||
|
||||
|
||||
#region ======= Warehouses value list =======
|
||||
|
||||
//-------------------------------------------------------------------------------------------------
|
||||
//Warehouses
|
||||
ValueList vl=grid.DisplayLayout.ValueLists.Add("Warehouses");
|
||||
//NVCHANGED
|
||||
GenericNVList l = GenericNVList.GetList("aPartWarehouse", "aID", "aName", true, false, false);
|
||||
|
||||
|
||||
|
||||
//Loop through the items in the list and put them
|
||||
//into the valuelist
|
||||
for(int x=0;x<l.Count;x++)
|
||||
{
|
||||
vl.ValueListItems.Add(new Guid(((DictionaryEntry)l.BindableList[x]).Key.ToString()),
|
||||
((DictionaryEntry)l.BindableList[x]).Value.ToString());
|
||||
}
|
||||
|
||||
|
||||
//Bind value lists to correct columns in grid
|
||||
grid.DisplayLayout.Bands[0].Columns["PartWarehouseID"].ValueList=grid.DisplayLayout.ValueLists["Warehouses"];
|
||||
|
||||
//Set column to dropdownlist style so that user can not type an invalid value in a cell
|
||||
//but must select from the list only
|
||||
grid.DisplayLayout.Bands[0].Columns["PartWarehouseID"].Style=Infragistics.Win.UltraWinGrid.ColumnStyle.DropDownValidate;//Case 96 for autocomplete (was DropDownList)
|
||||
grid.DisplayLayout.Bands[0].Columns["PartWarehouseID"].AutoCompleteMode = Infragistics.Win.AutoCompleteMode.SuggestAppend;
|
||||
|
||||
|
||||
|
||||
#endregion
|
||||
}
|
||||
#endregion initialize grid
|
||||
|
||||
#region Grid events
|
||||
private void grid_InitializeRow(object sender, Infragistics.Win.UltraWinGrid.InitializeRowEventArgs e)
|
||||
{
|
||||
//e.Row.Cells["Object"].Value=Util.LocaleText.GetLocalizedText(((string)e.Row.Cells["Right"].Value).Replace("Object","O"));
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
#region Accelerator keys
|
||||
/// <summary>
|
||||
/// Case 37
|
||||
/// </summary>
|
||||
/// <param name="msg"></param>
|
||||
/// <param name="keyData"></param>
|
||||
/// <returns></returns>
|
||||
protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
|
||||
{
|
||||
//Short circuit:
|
||||
//Only process modified keystrokes (i.e. when a modifier like ctrl-alt-or shift is also
|
||||
//being held down
|
||||
if (ModifierKeys == Keys.None) return base.ProcessCmdKey(ref msg, keyData);
|
||||
|
||||
switch (Util.HotKeys(keyData))
|
||||
{
|
||||
//Close form
|
||||
case HotKeyAction.CloseForm:
|
||||
this.Close();
|
||||
return true;
|
||||
}
|
||||
return base.ProcessCmdKey(ref msg, keyData);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user