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 description for ServiceBankForm. /// public class ServiceBankForm : 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 ServiceBankForm_Fill_Panel; private Infragistics.Win.UltraWinToolbars.UltraToolbarsDockArea _ServiceBankForm_Toolbars_Dock_Area_Left; private Infragistics.Win.UltraWinToolbars.UltraToolbarsDockArea _ServiceBankForm_Toolbars_Dock_Area_Right; private Infragistics.Win.UltraWinToolbars.UltraToolbarsDockArea _ServiceBankForm_Toolbars_Dock_Area_Top; private Infragistics.Win.UltraWinToolbars.UltraToolbarsDockArea _ServiceBankForm_Toolbars_Dock_Area_Bottom; private Infragistics.Win.UltraWinGrid.UltraGrid Grid; private System.Windows.Forms.HelpProvider helpProvider1; private System.ComponentModel.IContainer components; public ServiceBankForm() { // // 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("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.ListTool listTool1 = new Infragistics.Win.UltraWinToolbars.ListTool("REPORTLIST"); Infragistics.Win.UltraWinToolbars.ListToolItem listToolItem1 = new Infragistics.Win.UltraWinToolbars.ListToolItem("sdfsasf"); 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 listTool2 = new Infragistics.Win.UltraWinToolbars.ListTool("REPORTLIST"); this.tbManager = new Infragistics.Win.UltraWinToolbars.UltraToolbarsManager(this.components); this.ServiceBankForm_Fill_Panel = new System.Windows.Forms.Panel(); this.Grid = new Infragistics.Win.UltraWinGrid.UltraGrid(); this._ServiceBankForm_Toolbars_Dock_Area_Left = new Infragistics.Win.UltraWinToolbars.UltraToolbarsDockArea(); this._ServiceBankForm_Toolbars_Dock_Area_Right = new Infragistics.Win.UltraWinToolbars.UltraToolbarsDockArea(); this._ServiceBankForm_Toolbars_Dock_Area_Top = new Infragistics.Win.UltraWinToolbars.UltraToolbarsDockArea(); this._ServiceBankForm_Toolbars_Dock_Area_Bottom = new Infragistics.Win.UltraWinToolbars.UltraToolbarsDockArea(); this.helpProvider1 = new System.Windows.Forms.HelpProvider(); ((System.ComponentModel.ISupportInitialize)(this.tbManager)).BeginInit(); this.ServiceBankForm_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; listTool1.DisplayCheckmark = false; listToolItem1.Key = "sdfsasf"; listToolItem1.Text = "sdfasdf"; listTool1.ListToolItemsInternal.Add(listToolItem1); 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[] { listTool2}); this.tbManager.Tools.AddRange(new Infragistics.Win.UltraWinToolbars.ToolBase[] { buttonTool3, buttonTool4, listTool1, popupMenuTool2}); this.tbManager.ToolClick += new Infragistics.Win.UltraWinToolbars.ToolClickEventHandler(this.tbManager_ToolClick); // // ServiceBankForm_Fill_Panel // this.ServiceBankForm_Fill_Panel.Controls.Add(this.Grid); this.ServiceBankForm_Fill_Panel.Cursor = System.Windows.Forms.Cursors.Default; this.ServiceBankForm_Fill_Panel.Dock = System.Windows.Forms.DockStyle.Fill; this.ServiceBankForm_Fill_Panel.Location = new System.Drawing.Point(0, 26); this.ServiceBankForm_Fill_Panel.Name = "ServiceBankForm_Fill_Panel"; this.ServiceBankForm_Fill_Panel.Size = new System.Drawing.Size(504, 299); this.ServiceBankForm_Fill_Panel.TabIndex = 0; // // Grid // this.Grid.Cursor = System.Windows.Forms.Cursors.Hand; 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); // // _ServiceBankForm_Toolbars_Dock_Area_Left // this._ServiceBankForm_Toolbars_Dock_Area_Left.AccessibleRole = System.Windows.Forms.AccessibleRole.Grouping; this._ServiceBankForm_Toolbars_Dock_Area_Left.BackColor = System.Drawing.SystemColors.Control; this._ServiceBankForm_Toolbars_Dock_Area_Left.DockedPosition = Infragistics.Win.UltraWinToolbars.DockedPosition.Left; this._ServiceBankForm_Toolbars_Dock_Area_Left.ForeColor = System.Drawing.SystemColors.ControlText; this._ServiceBankForm_Toolbars_Dock_Area_Left.Location = new System.Drawing.Point(0, 26); this._ServiceBankForm_Toolbars_Dock_Area_Left.Name = "_ServiceBankForm_Toolbars_Dock_Area_Left"; this._ServiceBankForm_Toolbars_Dock_Area_Left.Size = new System.Drawing.Size(0, 299); this._ServiceBankForm_Toolbars_Dock_Area_Left.ToolbarsManager = this.tbManager; // // _ServiceBankForm_Toolbars_Dock_Area_Right // this._ServiceBankForm_Toolbars_Dock_Area_Right.AccessibleRole = System.Windows.Forms.AccessibleRole.Grouping; this._ServiceBankForm_Toolbars_Dock_Area_Right.BackColor = System.Drawing.SystemColors.Control; this._ServiceBankForm_Toolbars_Dock_Area_Right.DockedPosition = Infragistics.Win.UltraWinToolbars.DockedPosition.Right; this._ServiceBankForm_Toolbars_Dock_Area_Right.ForeColor = System.Drawing.SystemColors.ControlText; this._ServiceBankForm_Toolbars_Dock_Area_Right.Location = new System.Drawing.Point(504, 26); this._ServiceBankForm_Toolbars_Dock_Area_Right.Name = "_ServiceBankForm_Toolbars_Dock_Area_Right"; this._ServiceBankForm_Toolbars_Dock_Area_Right.Size = new System.Drawing.Size(0, 299); this._ServiceBankForm_Toolbars_Dock_Area_Right.ToolbarsManager = this.tbManager; // // _ServiceBankForm_Toolbars_Dock_Area_Top // this._ServiceBankForm_Toolbars_Dock_Area_Top.AccessibleRole = System.Windows.Forms.AccessibleRole.Grouping; this._ServiceBankForm_Toolbars_Dock_Area_Top.BackColor = System.Drawing.SystemColors.Control; this._ServiceBankForm_Toolbars_Dock_Area_Top.DockedPosition = Infragistics.Win.UltraWinToolbars.DockedPosition.Top; this._ServiceBankForm_Toolbars_Dock_Area_Top.ForeColor = System.Drawing.SystemColors.ControlText; this._ServiceBankForm_Toolbars_Dock_Area_Top.Location = new System.Drawing.Point(0, 0); this._ServiceBankForm_Toolbars_Dock_Area_Top.Name = "_ServiceBankForm_Toolbars_Dock_Area_Top"; this._ServiceBankForm_Toolbars_Dock_Area_Top.Size = new System.Drawing.Size(504, 26); this._ServiceBankForm_Toolbars_Dock_Area_Top.ToolbarsManager = this.tbManager; // // _ServiceBankForm_Toolbars_Dock_Area_Bottom // this._ServiceBankForm_Toolbars_Dock_Area_Bottom.AccessibleRole = System.Windows.Forms.AccessibleRole.Grouping; this._ServiceBankForm_Toolbars_Dock_Area_Bottom.BackColor = System.Drawing.SystemColors.Control; this._ServiceBankForm_Toolbars_Dock_Area_Bottom.DockedPosition = Infragistics.Win.UltraWinToolbars.DockedPosition.Bottom; this._ServiceBankForm_Toolbars_Dock_Area_Bottom.ForeColor = System.Drawing.SystemColors.ControlText; this._ServiceBankForm_Toolbars_Dock_Area_Bottom.Location = new System.Drawing.Point(0, 325); this._ServiceBankForm_Toolbars_Dock_Area_Bottom.Name = "_ServiceBankForm_Toolbars_Dock_Area_Bottom"; this._ServiceBankForm_Toolbars_Dock_Area_Bottom.Size = new System.Drawing.Size(504, 0); this._ServiceBankForm_Toolbars_Dock_Area_Bottom.ToolbarsManager = this.tbManager; // // ServiceBankForm // this.AutoScaleBaseSize = new System.Drawing.Size(6, 15); this.ClientSize = new System.Drawing.Size(504, 325); this.Controls.Add(this.ServiceBankForm_Fill_Panel); this.Controls.Add(this._ServiceBankForm_Toolbars_Dock_Area_Left); this.Controls.Add(this._ServiceBankForm_Toolbars_Dock_Area_Right); this.Controls.Add(this._ServiceBankForm_Toolbars_Dock_Area_Bottom); this.Controls.Add(this._ServiceBankForm_Toolbars_Dock_Area_Top); this.helpProvider1.SetHelpKeyword(this, ""); this.helpProvider1.SetHelpNavigator(this, System.Windows.Forms.HelpNavigator.Topic); this.Name = "ServiceBankForm"; this.helpProvider1.SetShowHelp(this, true); this.ShowInTaskbar = false; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; this.Text = "LT:O.ServiceBank"; this.Closing += new System.ComponentModel.CancelEventHandler(this.ServiceBankForm_Closing); this.Load += new System.EventHandler(this.ServiceBankForm_Load); ((System.ComponentModel.ISupportInitialize)(this.tbManager)).EndInit(); this.ServiceBankForm_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 ServiceBankForm_Load(object sender, System.EventArgs e) { // // helpProvider1 // this.helpProvider1.HelpNamespace = Util.BaseHelpUrl + "banked_service.htm"; //case 1039 //log.Debug("ServiceBankForm_Load"); tbManager.Tools["LT:UI.Toolbar.New"].SharedProps.Visible=AyaBizUtils.Right("Object.ServiceBank")> (int)SecurityLevelTypes.ReadOnly; Cursor.Current = Cursors.WaitCursor; this.Visible=false; this.Icon = Resource1.BankedService16icon; //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.ServiceBank")< (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.ServiceBank"))); this.Close(); return; } Grid.DataSource=ServiceBankList.GetEmptyList(); Util.FetchGridLayout("ServiceBank","",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_ServiceBank_Label_SourceRootObjectType"].Style=Infragistics.Win.UltraWinGrid.ColumnStyle.Button; Grid.DisplayLayout.Bands[0].Columns["LT_ServiceBank_Label_ID"].Hidden=true; //format decimal displays Grid.DisplayLayout.Bands[0].Columns["LT_ServiceBank_Label_Incidents"].Format = "g29"; Grid.DisplayLayout.Bands[0].Columns["LT_ServiceBank_Label_IncidentsBalance"].Format = "g29"; Grid.DisplayLayout.Bands[0].Columns["LT_ServiceBank_Label_Currency"].Format = "c"; Grid.DisplayLayout.Bands[0].Columns["LT_ServiceBank_Label_CurrencyBalance"].Format = "c"; Grid.DisplayLayout.Bands[0].Columns["LT_ServiceBank_Label_Hours"].Format = "g29"; Grid.DisplayLayout.Bands[0].Columns["LT_ServiceBank_Label_HoursBalance"].Format = "g29"; foreach(UltraGridColumn c in Grid.DisplayLayout.Bands[0].Columns) { c.CellActivation=Activation.ActivateOnly; } Util.LoadFormCustomization("ServiceBank", this, tbManager, false); //Case 126 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"], ServiceBankList.ReportKey, ""); } //case 668 tbManager.Tools["LT:UI.Toolbar.New"].SharedProps.Visible = (AyaBizUtils.Right("Object.ServiceBank") > (int)SecurityLevelTypes.ReadOnly); Util.LocalizeHelperInsertMenu(tbManager, this); //case 1810 Util.Localize(this); Cursor.Current = Cursors.Default; this.Visible=true; } private void ServiceBankForm_Closing(object sender, System.ComponentModel.CancelEventArgs e) { //case 1039 //log.Debug("ServiceBankForm_Closing"); // MessageBox.Show("Saving grid layout..."); Util.SaveGridLayout("ServiceBank","","",Grid); //MessageBox.Show("Grid layout saved."); Util.SaveFormCustomization("ServiceBank", this, tbManager, false); } private void Grid_BeforeRowFilterDropDown(object sender, Infragistics.Win.UltraWinGrid.BeforeRowFilterDropDownEventArgs e) { //case 1039 //log.Debug("Grid_BeforeRowFilterDropDown"); Util.SetCustomFilters(e); } /// /// Intercept a sort change event /// This is to ensure that no columns other than first /// are sorted on /// /// /// 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); } /// /// 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 /// /// /// /// private void Grid_BeforeRowFilterChanged(object sender, Infragistics.Win.UltraWinGrid.BeforeRowFilterChangedEventArgs e) { //case 1039 //log.Debug("Grid_BeforeRowFilterChanged"); Grid.BeginUpdate(); Grid.DataSource=ServiceBankList.GetEmptyList(); } /// /// called when the user filters rows /// /// /// private void Grid_AfterRowFilterChanged(object sender, Infragistics.Win.UltraWinGrid.AfterRowFilterChangedEventArgs e) { //case 1039 //log.Debug("Grid_AfterRowFilterChanged"); BindGrid(false); } /// /// Called when the user repositions columns /// /// /// 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); } } /// /// Rebind the control to the data source based on the latest /// user filter and sort settings /// private void BindGrid(bool bReverseSort) { //case 1039 //log.Debug("BindGrid - entering"); Cursor.Current=Cursors.WaitCursor; bool bFiltered=false; Grid.DataSource=ServiceBankList.GetList(mObjectType,mObjectID,Util.GetGridSortAndFilterXML(Grid.DisplayLayout.Bands[0], bReverseSort,ref bFiltered)); Grid.Text=Util.LocaleText.GetLocalizedText("ServiceBank.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; /// /// 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. /// /// /// 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_ServiceBank_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); } /// /// Handle a key down in addition to a mouse click /// this allows user to hit enter to select from the grid /// /// /// 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); } } } } /// /// Open record for editing /// Different than in other list forms as it handles opening the workorder here /// /// /// private void EditRecord(GridNameValueCellItem i, int nRowToScrollTo) { //Make sure there is something to edit if(i==null || i.Value==Guid.Empty || i.RootObjectType==RootObjectTypes.ServiceBank) return; Workorder w=null; Guid WorkorderItemID=Guid.Empty; switch(i.RootObjectType) { case RootObjectTypes.WorkorderItemLabor: try { w=Workorder.GetWorkorderByRelative(RootObjectTypes.WorkorderItemLabor,i.Value); } catch(Exception ex) { if(ex.InnerException!=null) MessageBox.Show(ex.InnerException.Message); else MessageBox.Show(ex.Message); return; } 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 SERVICEBANKFORM - 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(); } #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 ServiceBankAddRecord sbar= new ServiceBankAddRecord(); ServiceBank sb=ServiceBank.NewItem(); sb.AppliesToRootObjectType=mObjectType; sb.AppliesToRootObjectID=mObjectID; sb.SourceRootObjectType=RootObjectTypes.ServiceBank; sb.SourceRootObjectID=Guid.Empty; sbar.ServiceBankToEdit=sb; if(sbar.ShowDialog()==DialogResult.OK) { BindGrid(false); } break; case "LT:UI.Toolbar.Refresh": // ButtonTool Grid.BeginUpdate(); BindGrid(false); break; //Added: case 126 case "REPORTLIST": { //if(Util.ReportHandleToolClickIsSummary(e.Tool)) Util.ReportHandleToolClick(e.Tool, ServiceBankList.ReportKey, Grid.DataSource); //else //{ //bool bFiltered=false; //Util.ReportHandleToolClick(e.Tool,ClientListDetailed.ReportKey,ClientListDetailed.GetListByCriteria(Util.GetGridSortAndFilterXML(Grid.DisplayLayout.Bands[0],false,ref bFiltered))); //} Util.ReportFillList(this.tbManager.Tools["REPORTLIST"], ServiceBankList.ReportKey, ""); break; } } } #endregion #region properties /// /// Object to display list for /// private RootObjectTypes mObjectType; public RootObjectTypes ObjectType { set { mObjectType=value; } } private Guid mObjectID; public Guid ObjectID { set { mObjectID=value; } } #endregion //************ E N D O F C L A S S ************************ } }