704 lines
29 KiB
C#
704 lines
29 KiB
C#
using System;
|
|
using System.Drawing;
|
|
using System.Collections;
|
|
using System.ComponentModel;
|
|
using System.Windows.Forms;
|
|
using GZTW.AyaNova.BLL;
|
|
using Infragistics.Win.UltraWinGrid;
|
|
using Infragistics.Win;
|
|
using log4net;
|
|
|
|
namespace AyaNova
|
|
{
|
|
/// <summary>
|
|
/// Summary description for UnitMeterReadingForm.
|
|
/// </summary>
|
|
public class UnitMeterReadingForm : 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 Infragistics.Win.UltraWinToolbars.UltraToolbarsManager tbManager;
|
|
private System.Windows.Forms.Panel UnitMeterReadingForm_Fill_Panel;
|
|
private Infragistics.Win.UltraWinToolbars.UltraToolbarsDockArea _UnitMeterReadingForm_Toolbars_Dock_Area_Left;
|
|
private Infragistics.Win.UltraWinToolbars.UltraToolbarsDockArea _UnitMeterReadingForm_Toolbars_Dock_Area_Right;
|
|
private Infragistics.Win.UltraWinToolbars.UltraToolbarsDockArea _UnitMeterReadingForm_Toolbars_Dock_Area_Top;
|
|
private Infragistics.Win.UltraWinToolbars.UltraToolbarsDockArea _UnitMeterReadingForm_Toolbars_Dock_Area_Bottom;
|
|
private Infragistics.Win.UltraWinGrid.UltraGrid Grid;
|
|
private System.Windows.Forms.HelpProvider helpProvider1;
|
|
private System.ComponentModel.IContainer components;
|
|
|
|
public UnitMeterReadingForm()
|
|
{
|
|
//
|
|
// 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("PurchaseOrders");
|
|
Infragistics.Win.UltraWinToolbars.PopupMenuTool popupMenuTool1 = new Infragistics.Win.UltraWinToolbars.PopupMenuTool("LT:UI.Toolbar.Print");
|
|
Infragistics.Win.UltraWinToolbars.ButtonTool buttonTool1 = new Infragistics.Win.UltraWinToolbars.ButtonTool("LT:UI.Toolbar.New");
|
|
Infragistics.Win.UltraWinToolbars.ButtonTool buttonTool2 = new Infragistics.Win.UltraWinToolbars.ButtonTool("LT:UI.Toolbar.Refresh");
|
|
Infragistics.Win.UltraWinToolbars.ButtonTool buttonTool3 = new Infragistics.Win.UltraWinToolbars.ButtonTool("LT:UI.Toolbar.New");
|
|
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.Toolbar.Refresh");
|
|
Infragistics.Win.Appearance appearance3 = new Infragistics.Win.Appearance();
|
|
Infragistics.Win.Appearance appearance4 = new Infragistics.Win.Appearance();
|
|
Infragistics.Win.UltraWinToolbars.PopupMenuTool popupMenuTool2 = new Infragistics.Win.UltraWinToolbars.PopupMenuTool("LT:UI.Toolbar.Print");
|
|
Infragistics.Win.Appearance appearance5 = new Infragistics.Win.Appearance();
|
|
Infragistics.Win.Appearance appearance6 = new Infragistics.Win.Appearance();
|
|
Infragistics.Win.UltraWinToolbars.ListTool listTool1 = new Infragistics.Win.UltraWinToolbars.ListTool("REPORTLIST");
|
|
Infragistics.Win.UltraWinToolbars.ListTool listTool2 = new Infragistics.Win.UltraWinToolbars.ListTool("REPORTLIST");
|
|
this.tbManager = new Infragistics.Win.UltraWinToolbars.UltraToolbarsManager(this.components);
|
|
this.UnitMeterReadingForm_Fill_Panel = new System.Windows.Forms.Panel();
|
|
this.Grid = new Infragistics.Win.UltraWinGrid.UltraGrid();
|
|
this._UnitMeterReadingForm_Toolbars_Dock_Area_Left = new Infragistics.Win.UltraWinToolbars.UltraToolbarsDockArea();
|
|
this._UnitMeterReadingForm_Toolbars_Dock_Area_Right = new Infragistics.Win.UltraWinToolbars.UltraToolbarsDockArea();
|
|
this._UnitMeterReadingForm_Toolbars_Dock_Area_Top = new Infragistics.Win.UltraWinToolbars.UltraToolbarsDockArea();
|
|
this._UnitMeterReadingForm_Toolbars_Dock_Area_Bottom = new Infragistics.Win.UltraWinToolbars.UltraToolbarsDockArea();
|
|
this.helpProvider1 = new System.Windows.Forms.HelpProvider();
|
|
((System.ComponentModel.ISupportInitialize)(this.tbManager)).BeginInit();
|
|
this.UnitMeterReadingForm_Fill_Panel.SuspendLayout();
|
|
((System.ComponentModel.ISupportInitialize)(this.Grid)).BeginInit();
|
|
this.SuspendLayout();
|
|
//
|
|
// tbManager
|
|
//
|
|
this.tbManager.DesignerFlags = 1;
|
|
this.tbManager.DockWithinContainer = this;
|
|
this.tbManager.DockWithinContainerBaseType = typeof(System.Windows.Forms.Form);
|
|
this.tbManager.MdiMergeable = false;
|
|
this.tbManager.ShowFullMenusDelay = 500;
|
|
ultraToolbar1.DockedColumn = 0;
|
|
ultraToolbar1.DockedRow = 0;
|
|
ultraToolbar1.NonInheritedTools.AddRange(new Infragistics.Win.UltraWinToolbars.ToolBase[] {
|
|
popupMenuTool1,
|
|
buttonTool1,
|
|
buttonTool2});
|
|
ultraToolbar1.Text = "PurchaseOrders";
|
|
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 = global::AyaNova.Resource1.New32;
|
|
buttonTool3.SharedPropsInternal.AppearancesLarge.Appearance = appearance1;
|
|
appearance2.Image = global::AyaNova.Resource1.New16;
|
|
buttonTool3.SharedPropsInternal.AppearancesSmall.Appearance = appearance2;
|
|
buttonTool3.SharedPropsInternal.Caption = "LT:UI.Toolbar.New";
|
|
buttonTool3.SharedPropsInternal.DisplayStyle = Infragistics.Win.UltraWinToolbars.ToolDisplayStyle.ImageAndText;
|
|
appearance3.Image = global::AyaNova.Resource1.Refresh32;
|
|
buttonTool4.SharedPropsInternal.AppearancesLarge.Appearance = appearance3;
|
|
appearance4.Image = global::AyaNova.Resource1.Refresh16;
|
|
buttonTool4.SharedPropsInternal.AppearancesSmall.Appearance = appearance4;
|
|
buttonTool4.SharedPropsInternal.Caption = "LT:UI.Toolbar.Refresh";
|
|
buttonTool4.SharedPropsInternal.DisplayStyle = Infragistics.Win.UltraWinToolbars.ToolDisplayStyle.ImageAndText;
|
|
appearance5.Image = global::AyaNova.Resource1.Print32;
|
|
popupMenuTool2.SharedPropsInternal.AppearancesLarge.Appearance = appearance5;
|
|
appearance6.Image = global::AyaNova.Resource1.Print16;
|
|
popupMenuTool2.SharedPropsInternal.AppearancesSmall.Appearance = appearance6;
|
|
popupMenuTool2.SharedPropsInternal.Caption = "LT:UI.Toolbar.Print";
|
|
popupMenuTool2.SharedPropsInternal.DisplayStyle = Infragistics.Win.UltraWinToolbars.ToolDisplayStyle.ImageOnlyOnToolbars;
|
|
popupMenuTool2.Tools.AddRange(new Infragistics.Win.UltraWinToolbars.ToolBase[] {
|
|
listTool1});
|
|
listTool2.DisplayCheckmark = false;
|
|
listTool2.SharedPropsInternal.Caption = "REPORTLIST";
|
|
this.tbManager.Tools.AddRange(new Infragistics.Win.UltraWinToolbars.ToolBase[] {
|
|
buttonTool3,
|
|
buttonTool4,
|
|
popupMenuTool2,
|
|
listTool2});
|
|
this.tbManager.ToolClick += new Infragistics.Win.UltraWinToolbars.ToolClickEventHandler(this.tbManager_ToolClick);
|
|
//
|
|
// UnitMeterReadingForm_Fill_Panel
|
|
//
|
|
this.UnitMeterReadingForm_Fill_Panel.Controls.Add(this.Grid);
|
|
this.UnitMeterReadingForm_Fill_Panel.Cursor = System.Windows.Forms.Cursors.Default;
|
|
this.UnitMeterReadingForm_Fill_Panel.Dock = System.Windows.Forms.DockStyle.Fill;
|
|
this.UnitMeterReadingForm_Fill_Panel.Location = new System.Drawing.Point(0, 26);
|
|
this.UnitMeterReadingForm_Fill_Panel.Name = "UnitMeterReadingForm_Fill_Panel";
|
|
this.UnitMeterReadingForm_Fill_Panel.Size = new System.Drawing.Size(504, 299);
|
|
this.UnitMeterReadingForm_Fill_Panel.TabIndex = 0;
|
|
//
|
|
// Grid
|
|
//
|
|
this.Grid.Cursor = System.Windows.Forms.Cursors.Default;
|
|
this.Grid.DisplayLayout.Override.AllowAddNew = Infragistics.Win.UltraWinGrid.AllowAddNew.No;
|
|
this.Grid.DisplayLayout.Override.AllowDelete = Infragistics.Win.DefaultableBoolean.False;
|
|
this.Grid.DisplayLayout.Override.AllowUpdate = Infragistics.Win.DefaultableBoolean.False;
|
|
this.Grid.DisplayLayout.Override.RowSelectors = Infragistics.Win.DefaultableBoolean.False;
|
|
this.Grid.Dock = System.Windows.Forms.DockStyle.Fill;
|
|
this.Grid.Location = new System.Drawing.Point(0, 0);
|
|
this.Grid.Name = "Grid";
|
|
this.Grid.Size = new System.Drawing.Size(504, 299);
|
|
this.Grid.TabIndex = 0;
|
|
this.Grid.ClickCellButton += new Infragistics.Win.UltraWinGrid.CellEventHandler(this.Grid_ClickCellButton);
|
|
this.Grid.BeforeSortChange += new Infragistics.Win.UltraWinGrid.BeforeSortChangeEventHandler(this.Grid_BeforeSortChange);
|
|
this.Grid.AfterColPosChanged += new Infragistics.Win.UltraWinGrid.AfterColPosChangedEventHandler(this.Grid_AfterColPosChanged);
|
|
this.Grid.BeforeRowFilterChanged += new Infragistics.Win.UltraWinGrid.BeforeRowFilterChangedEventHandler(this.Grid_BeforeRowFilterChanged);
|
|
this.Grid.AfterRowFilterChanged += new Infragistics.Win.UltraWinGrid.AfterRowFilterChangedEventHandler(this.Grid_AfterRowFilterChanged);
|
|
this.Grid.BeforeRowFilterDropDown += new Infragistics.Win.UltraWinGrid.BeforeRowFilterDropDownEventHandler(this.Grid_BeforeRowFilterDropDown);
|
|
this.Grid.KeyUp += new System.Windows.Forms.KeyEventHandler(this.Grid_KeyUp);
|
|
this.Grid.MouseDown += new System.Windows.Forms.MouseEventHandler(this.Grid_MouseDown);
|
|
//
|
|
// _UnitMeterReadingForm_Toolbars_Dock_Area_Left
|
|
//
|
|
this._UnitMeterReadingForm_Toolbars_Dock_Area_Left.AccessibleRole = System.Windows.Forms.AccessibleRole.Grouping;
|
|
this._UnitMeterReadingForm_Toolbars_Dock_Area_Left.BackColor = System.Drawing.SystemColors.Control;
|
|
this._UnitMeterReadingForm_Toolbars_Dock_Area_Left.DockedPosition = Infragistics.Win.UltraWinToolbars.DockedPosition.Left;
|
|
this._UnitMeterReadingForm_Toolbars_Dock_Area_Left.ForeColor = System.Drawing.SystemColors.ControlText;
|
|
this._UnitMeterReadingForm_Toolbars_Dock_Area_Left.Location = new System.Drawing.Point(0, 26);
|
|
this._UnitMeterReadingForm_Toolbars_Dock_Area_Left.Name = "_UnitMeterReadingForm_Toolbars_Dock_Area_Left";
|
|
this._UnitMeterReadingForm_Toolbars_Dock_Area_Left.Size = new System.Drawing.Size(0, 299);
|
|
this._UnitMeterReadingForm_Toolbars_Dock_Area_Left.ToolbarsManager = this.tbManager;
|
|
//
|
|
// _UnitMeterReadingForm_Toolbars_Dock_Area_Right
|
|
//
|
|
this._UnitMeterReadingForm_Toolbars_Dock_Area_Right.AccessibleRole = System.Windows.Forms.AccessibleRole.Grouping;
|
|
this._UnitMeterReadingForm_Toolbars_Dock_Area_Right.BackColor = System.Drawing.SystemColors.Control;
|
|
this._UnitMeterReadingForm_Toolbars_Dock_Area_Right.DockedPosition = Infragistics.Win.UltraWinToolbars.DockedPosition.Right;
|
|
this._UnitMeterReadingForm_Toolbars_Dock_Area_Right.ForeColor = System.Drawing.SystemColors.ControlText;
|
|
this._UnitMeterReadingForm_Toolbars_Dock_Area_Right.Location = new System.Drawing.Point(504, 26);
|
|
this._UnitMeterReadingForm_Toolbars_Dock_Area_Right.Name = "_UnitMeterReadingForm_Toolbars_Dock_Area_Right";
|
|
this._UnitMeterReadingForm_Toolbars_Dock_Area_Right.Size = new System.Drawing.Size(0, 299);
|
|
this._UnitMeterReadingForm_Toolbars_Dock_Area_Right.ToolbarsManager = this.tbManager;
|
|
//
|
|
// _UnitMeterReadingForm_Toolbars_Dock_Area_Top
|
|
//
|
|
this._UnitMeterReadingForm_Toolbars_Dock_Area_Top.AccessibleRole = System.Windows.Forms.AccessibleRole.Grouping;
|
|
this._UnitMeterReadingForm_Toolbars_Dock_Area_Top.BackColor = System.Drawing.SystemColors.Control;
|
|
this._UnitMeterReadingForm_Toolbars_Dock_Area_Top.DockedPosition = Infragistics.Win.UltraWinToolbars.DockedPosition.Top;
|
|
this._UnitMeterReadingForm_Toolbars_Dock_Area_Top.ForeColor = System.Drawing.SystemColors.ControlText;
|
|
this._UnitMeterReadingForm_Toolbars_Dock_Area_Top.Location = new System.Drawing.Point(0, 0);
|
|
this._UnitMeterReadingForm_Toolbars_Dock_Area_Top.Name = "_UnitMeterReadingForm_Toolbars_Dock_Area_Top";
|
|
this._UnitMeterReadingForm_Toolbars_Dock_Area_Top.Size = new System.Drawing.Size(504, 26);
|
|
this._UnitMeterReadingForm_Toolbars_Dock_Area_Top.ToolbarsManager = this.tbManager;
|
|
//
|
|
// _UnitMeterReadingForm_Toolbars_Dock_Area_Bottom
|
|
//
|
|
this._UnitMeterReadingForm_Toolbars_Dock_Area_Bottom.AccessibleRole = System.Windows.Forms.AccessibleRole.Grouping;
|
|
this._UnitMeterReadingForm_Toolbars_Dock_Area_Bottom.BackColor = System.Drawing.SystemColors.Control;
|
|
this._UnitMeterReadingForm_Toolbars_Dock_Area_Bottom.DockedPosition = Infragistics.Win.UltraWinToolbars.DockedPosition.Bottom;
|
|
this._UnitMeterReadingForm_Toolbars_Dock_Area_Bottom.ForeColor = System.Drawing.SystemColors.ControlText;
|
|
this._UnitMeterReadingForm_Toolbars_Dock_Area_Bottom.Location = new System.Drawing.Point(0, 325);
|
|
this._UnitMeterReadingForm_Toolbars_Dock_Area_Bottom.Name = "_UnitMeterReadingForm_Toolbars_Dock_Area_Bottom";
|
|
this._UnitMeterReadingForm_Toolbars_Dock_Area_Bottom.Size = new System.Drawing.Size(504, 0);
|
|
this._UnitMeterReadingForm_Toolbars_Dock_Area_Bottom.ToolbarsManager = this.tbManager;
|
|
//
|
|
// UnitMeterReadingForm
|
|
//
|
|
this.AutoScaleBaseSize = new System.Drawing.Size(6, 15);
|
|
this.ClientSize = new System.Drawing.Size(504, 325);
|
|
this.Controls.Add(this.UnitMeterReadingForm_Fill_Panel);
|
|
this.Controls.Add(this._UnitMeterReadingForm_Toolbars_Dock_Area_Left);
|
|
this.Controls.Add(this._UnitMeterReadingForm_Toolbars_Dock_Area_Right);
|
|
this.Controls.Add(this._UnitMeterReadingForm_Toolbars_Dock_Area_Bottom);
|
|
this.Controls.Add(this._UnitMeterReadingForm_Toolbars_Dock_Area_Top);
|
|
this.helpProvider1.SetHelpKeyword(this, "");
|
|
this.helpProvider1.SetHelpNavigator(this, System.Windows.Forms.HelpNavigator.Topic);
|
|
this.Name = "UnitMeterReadingForm";
|
|
this.helpProvider1.SetShowHelp(this, true);
|
|
this.ShowInTaskbar = false;
|
|
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
|
|
this.Text = "LT:O.UnitMeterReading";
|
|
this.Closing += new System.ComponentModel.CancelEventHandler(this.UnitMeterReadingForm_Closing);
|
|
this.Load += new System.EventHandler(this.UnitMeterReadingForm_Load);
|
|
((System.ComponentModel.ISupportInitialize)(this.tbManager)).EndInit();
|
|
this.UnitMeterReadingForm_Fill_Panel.ResumeLayout(false);
|
|
((System.ComponentModel.ISupportInitialize)(this.Grid)).EndInit();
|
|
this.ResumeLayout(false);
|
|
|
|
}
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
// __ _ _ ___ ____ __ __ __ __ __ ___ ___
|
|
// / _)( )( )/ __)(_ _)/ \( \/ ) / _)/ \( \( _)
|
|
// ( (_ )()( \__ \ )( ( () )) ( ( (_( () )) ) )) _)
|
|
// \__) \__/ (___/ (__) \__/(_/\/\_) \__)\__/(___/(___)
|
|
//
|
|
|
|
#region Load / Close and Grid preparation display and events
|
|
|
|
//variable to hold user form settings
|
|
//UIUserFormSetting mFormSetting;
|
|
|
|
private void UnitMeterReadingForm_Load(object sender, System.EventArgs e)
|
|
{
|
|
//
|
|
// helpProvider1
|
|
//
|
|
this.helpProvider1.HelpNamespace = Util.BaseHelpUrl + "unit_meter_reading.htm";
|
|
|
|
//case 1039 //log.Debug("UnitMeterReadingForm_Load");
|
|
tbManager.Tools["LT:UI.Toolbar.New"].SharedProps.Visible=AyaBizUtils.Right("Object.UnitMeterReading")> (int)SecurityLevelTypes.ReadOnly;
|
|
|
|
|
|
Cursor.Current = Cursors.WaitCursor;
|
|
this.Visible=false;
|
|
this.Icon = Resource1.UnitMeterReading16icon;
|
|
|
|
//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 client edit screen from elsewhere in the program)
|
|
if(AyaBizUtils.Right("Object.UnitMeterReading")< (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.UnitMeterReading")));
|
|
|
|
this.Close();
|
|
return;
|
|
}
|
|
|
|
|
|
Grid.DataSource=UnitMeterReadingList.GetEmptyList();
|
|
Util.FetchGridLayout("UnitMeterReading","",Grid);
|
|
|
|
//Prepare grid with our own preferences
|
|
//to facilitate sorting / searching etc
|
|
Util.PrepareGrid(Grid);
|
|
Grid.DisplayLayout.Override.AllowRowFiltering=DefaultableBoolean.True;
|
|
|
|
|
|
|
|
|
|
BindGrid(false);
|
|
|
|
Grid.DisplayLayout.Bands[0].Columns["LT_UnitMeterReading_Label_WorkorderItemID"].Style=Infragistics.Win.UltraWinGrid.ColumnStyle.Default;
|
|
Grid.DisplayLayout.Bands[0].Columns["LT_UnitMeterReading_Label_ID"].Hidden=true;
|
|
|
|
|
|
|
|
foreach(UltraGridColumn c in Grid.DisplayLayout.Bands[0].Columns)
|
|
{
|
|
c.CellActivation=Activation.ActivateOnly;
|
|
|
|
}
|
|
|
|
Util.LoadFormCustomization("UnitMeterReading", this, tbManager, false);
|
|
Util.Localize(this);
|
|
Cursor.Current = Cursors.Default;
|
|
|
|
//Added:24-Oct-2006
|
|
if (AyaBizUtils.Right("Object.Report") < (int)SecurityLevelTypes.ReadOnly)
|
|
{
|
|
tbManager.Tools["LT:UI.Toolbar.Print"].SharedProps.Visible = false;
|
|
}
|
|
else
|
|
{
|
|
tbManager.Tools["LT:UI.Toolbar.Print"].SharedProps.Visible = true;
|
|
Util.ReportFillList(this.tbManager.Tools["REPORTLIST"], UnitMeterReadingList.ReportKey, "");
|
|
}
|
|
|
|
//case 668
|
|
tbManager.Tools["LT:UI.Toolbar.New"].SharedProps.Visible = (AyaBizUtils.Right("Object.UnitMeterReading") > (int)SecurityLevelTypes.ReadOnly);
|
|
|
|
this.Visible=true;
|
|
|
|
}
|
|
|
|
private void UnitMeterReadingForm_Closing(object sender, System.ComponentModel.CancelEventArgs e)
|
|
{
|
|
//case 1039 //log.Debug("UnitMeterReadingForm_Closing");
|
|
|
|
Util.SaveGridLayout("UnitMeterReading","","",Grid);
|
|
Util.SaveFormCustomization("UnitMeterReading", this, tbManager, false);
|
|
|
|
}
|
|
|
|
|
|
|
|
private void Grid_BeforeRowFilterDropDown(object sender, Infragistics.Win.UltraWinGrid.BeforeRowFilterDropDownEventArgs e)
|
|
{
|
|
//case 1039 //log.Debug("Grid_BeforeRowFilterDropDown");
|
|
|
|
Util.SetCustomFilters(e);
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// Intercept a sort change event
|
|
/// This is to ensure that no columns other than first
|
|
/// are sorted on
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
private void Grid_BeforeSortChange(object sender, Infragistics.Win.UltraWinGrid.BeforeSortChangeEventArgs e)
|
|
{
|
|
//case 1039 //log.Debug("Grid_BeforeSortChange");
|
|
|
|
//Did the user click on any other column than the first visible one?
|
|
if(e.SortedColumns[0].Key!=Util.GetLeftMostColumnInBand(Grid.DisplayLayout.Bands[0]).Key)
|
|
{
|
|
e.Cancel=true;
|
|
//Yes they did so don't do anything or allow sorting to happen
|
|
return;
|
|
}
|
|
|
|
Grid.BeginUpdate();
|
|
//display new list
|
|
BindGrid(true);
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
/// Intercept a filter change event
|
|
/// Set the grid to an empty list, this effectively
|
|
/// stops the grid from doing any time consuming work to filter the data
|
|
/// which we want done in the sql server in the afterfilterchanged event
|
|
///
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
private void Grid_BeforeRowFilterChanged(object sender, Infragistics.Win.UltraWinGrid.BeforeRowFilterChangedEventArgs e)
|
|
{
|
|
//case 1039 //log.Debug("Grid_BeforeRowFilterChanged");
|
|
|
|
|
|
Grid.BeginUpdate();
|
|
Grid.DataSource=UnitMeterReadingList.GetEmptyList();
|
|
|
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// called when the user filters rows
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
private void Grid_AfterRowFilterChanged(object sender, Infragistics.Win.UltraWinGrid.AfterRowFilterChangedEventArgs e)
|
|
{
|
|
//case 1039 //log.Debug("Grid_AfterRowFilterChanged");
|
|
|
|
BindGrid(false);
|
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// Called when the user repositions columns
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
private void Grid_AfterColPosChanged(object sender, Infragistics.Win.UltraWinGrid.AfterColPosChangedEventArgs e)
|
|
{
|
|
//case 1039 //log.Debug("Grid_AfterColPosChanged");
|
|
|
|
//rebind if columns were moved only
|
|
//i.e.don't do it if they were just resized
|
|
if(e.PosChanged==Infragistics.Win.UltraWinGrid.PosChanged.Moved)
|
|
{
|
|
//disable refresh for a time
|
|
Grid.BeginUpdate();
|
|
|
|
//Deal with sort indicators on
|
|
//newly positioned columns
|
|
Util.HandleColPosChanged(Grid);
|
|
|
|
//rebind to data source
|
|
BindGrid(false);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// Rebind the control to the data source based on the latest
|
|
/// user filter and sort settings
|
|
/// </summary>
|
|
private void BindGrid(bool bReverseSort)
|
|
{
|
|
//case 1039 //log.Debug("BindGrid - entering");
|
|
|
|
Cursor.Current=Cursors.WaitCursor;
|
|
bool bFiltered=false;
|
|
Grid.DataSource=UnitMeterReadingList.GetList(mUnitID,Util.GetGridSortAndFilterXML(Grid.DisplayLayout.Bands[0], bReverseSort,ref bFiltered));
|
|
Grid.Text=Util.LocaleText.GetLocalizedText("UnitMeterReading.Label.List")+" ("+Grid.Rows.FilteredInRowCount.ToString()+")";
|
|
Util.SetGridFilteredStyle(Grid,bFiltered);
|
|
//case 1039 //if(log.IsDebugEnabled) //case 1039 //log.Debug("BindGrid - finished (" + Grid.Text + ")");
|
|
Grid.EndUpdate();
|
|
Cursor.Current = Cursors.Default;
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
#region Selection and Editing
|
|
|
|
Infragistics.Win.UIElement ElementLastClicked;
|
|
|
|
/// <summary>
|
|
/// This is whacky Infragistics stuff, where normally we would
|
|
/// just do someting like override Row.OnDoubleClick we can't
|
|
/// do that with a grid because it's rows don't have a click event
|
|
///
|
|
/// To know which row is clicked on we need to always keep
|
|
/// track of what element of the grid was last clicked on
|
|
/// so that later on we can (in doubleclick) pre-know what was
|
|
/// clicked in the first click of the double click.
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
private void Grid_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
|
|
{
|
|
ElementLastClicked = Grid.DisplayLayout.UIElement.ElementFromPoint(new System.Drawing.Point(e.X, e.Y));
|
|
|
|
//Handle right click
|
|
if( e.Button == MouseButtons.Right)
|
|
{
|
|
GridNameValueCellItem nvb=Util.NameValueButtonRightClicked(Grid,e);
|
|
if(nvb!=null)
|
|
{
|
|
Util.DisplayObjectContextMenu(nvb.RootObjectType,nvb.Value,this);
|
|
|
|
}
|
|
else
|
|
{
|
|
UltraGridBand b=Util.BandRightClicked(Grid/*NAME OF GRID HERE, REST IS STOCK TO ANY FORM*/,e);
|
|
if(b!=null)
|
|
{
|
|
UtilGridColumnSelector c = new UtilGridColumnSelector();
|
|
c.HideColumns.Add("LT_UnitMeterReading_Label_ID",0);
|
|
c.BandToEdit=b;
|
|
c.ShowDialog(this);
|
|
|
|
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void Grid_ClickCellButton(object sender, Infragistics.Win.UltraWinGrid.CellEventArgs e)
|
|
{
|
|
EditRecord((GridNameValueCellItem)e.Cell.Value,e.Cell.Row.Index);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Handle a key down in addition to a mouse click
|
|
/// this allows user to hit enter to select from the grid
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
private void Grid_KeyUp(object sender, System.Windows.Forms.KeyEventArgs e)
|
|
{
|
|
if(e.KeyCode==Keys.Space || e.KeyCode==Keys.Enter)
|
|
{
|
|
UltraGridCell c = Grid.ActiveCell;
|
|
if(c!=null)
|
|
{
|
|
if(c.Value.GetType().ToString()=="GZTW.AyaNova.BLL.GridNameValueCellItem")
|
|
{
|
|
e.Handled=true;
|
|
EditRecord((GridNameValueCellItem)c.Value,c.Row.Index);
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
/// Open record for editing
|
|
/// Different than in other list forms as it handles opening the workorder here
|
|
/// </summary>
|
|
/// <param name="i"></param>
|
|
/// <param name="nRowToScrollTo"></param>
|
|
private void EditRecord(GridNameValueCellItem i, int nRowToScrollTo)
|
|
{
|
|
//Make sure there is something to edit
|
|
if(i==null || i.Value==Guid.Empty || i.RootObjectType==RootObjectTypes.UnitMeterReading)
|
|
return;
|
|
|
|
|
|
Workorder w=null;
|
|
Guid WorkorderItemID=Guid.Empty;
|
|
switch(i.RootObjectType)
|
|
{
|
|
case RootObjectTypes.WorkorderItemLabor:
|
|
w=Workorder.GetWorkorderByRelative(RootObjectTypes.WorkorderItemLabor,i.Value);
|
|
foreach(WorkorderItem wi in w.WorkorderItems)
|
|
{
|
|
if(WorkorderItemID!=Guid.Empty) break;
|
|
|
|
foreach(WorkorderItemLabor wil in wi.Labors)
|
|
{
|
|
if(wil.ID==i.Value)
|
|
{
|
|
WorkorderItemID=wi.ID;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
break;
|
|
|
|
case RootObjectTypes.WorkorderItemTravel:
|
|
w=Workorder.GetWorkorderByRelative(RootObjectTypes.WorkorderItemTravel,i.Value);
|
|
foreach(WorkorderItem wi in w.WorkorderItems)
|
|
{
|
|
if(WorkorderItemID!=Guid.Empty) break;
|
|
|
|
foreach(WorkorderItemTravel wit in wi.Travels)
|
|
{
|
|
if(wit.ID==i.Value)
|
|
{
|
|
WorkorderItemID=wi.ID;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
break;
|
|
|
|
}
|
|
|
|
if(w==null)
|
|
throw new System.Exception("NULL WO IN UnitMeterReadingFORM - DAMAGED CHILD RECORD?\r\nObjectType:"+i.RootObjectType.ToString()+"\r\nID:"+i.Value.ToString());
|
|
|
|
//case 677
|
|
WorkorderForm wf = Util.GetWorkorderForm(w.ID);
|
|
if (wf.WorkorderToEdit == null)
|
|
{
|
|
wf.WorkorderToEdit = w;
|
|
wf.GoTo = i.RootObjectType;
|
|
wf.GoToWorkorderItemID = WorkorderItemID;
|
|
wf.GoToWorkorderItemSubItemID = i.Value;
|
|
}
|
|
wf.Show();
|
|
//wf.Dispose();
|
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
#region Menu tool items
|
|
|
|
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.Toolbar.New": // ButtonTool
|
|
UnitMeterReadingAddRecord umrar = new UnitMeterReadingAddRecord();
|
|
UnitMeterReading umr=UnitMeterReading.NewItem();
|
|
umr.UnitID=mUnitID;
|
|
umr.WorkorderItemID=mWorkorderItemID;
|
|
umrar.UnitMeterReadingToEdit=umr;
|
|
if(umrar.ShowDialog()==DialogResult.OK)
|
|
{
|
|
BindGrid(false);
|
|
}
|
|
break;
|
|
|
|
case "LT:UI.Toolbar.Refresh": // ButtonTool
|
|
Grid.BeginUpdate();
|
|
BindGrid(false);
|
|
break;
|
|
|
|
//Added:24-Oct-2006 to support reporting on unit meter reading
|
|
case "REPORTLIST":
|
|
{
|
|
|
|
Util.ReportHandleToolClick(e.Tool, UnitMeterReadingList.ReportKey, Grid.DataSource);
|
|
Util.ReportFillList(this.tbManager.Tools["REPORTLIST"], UnitMeterReadingList.ReportKey, "");
|
|
|
|
break;
|
|
}
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
#region properties
|
|
|
|
//Unit being metered
|
|
private Guid mUnitID=Guid.Empty;
|
|
public Guid UnitID
|
|
{
|
|
set
|
|
{
|
|
mUnitID=value;
|
|
|
|
}
|
|
}
|
|
|
|
//If came here from a workorder item then this
|
|
//contains the workorder item ID so that
|
|
//any new records created will have been set to this
|
|
private Guid mWorkorderItemID=Guid.Empty;
|
|
public Guid WorkorderItemID
|
|
{
|
|
set
|
|
{
|
|
mWorkorderItemID=value;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
//************ E N D O F C L A S S ************************
|
|
|
|
}
|
|
}
|