using System; using System.Drawing; using System.Collections; using System.Collections.Generic; using System.ComponentModel; using System.Windows.Forms; using GZTW.AyaNova.BLL; using Infragistics.Win; using Infragistics.Win.UltraWinGrid; using Infragistics.Win.UltraWinEditors; using log4net; namespace AyaNova { /// /// Summary description for ClientNotesForm. /// public class ClientNotesForm : 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.UltraWinGrid.UltraGrid Grid; private System.Windows.Forms.ErrorProvider errorProvider1; private Infragistics.Win.UltraWinToolbars.UltraToolbarsManager tbManager; private Infragistics.Win.UltraWinToolbars.UltraToolbarsDockArea _ClientNotesForm_Toolbars_Dock_Area_Left; private Infragistics.Win.UltraWinToolbars.UltraToolbarsDockArea _ClientNotesForm_Toolbars_Dock_Area_Right; private Infragistics.Win.UltraWinToolbars.UltraToolbarsDockArea _ClientNotesForm_Toolbars_Dock_Area_Top; private Infragistics.Win.UltraWinToolbars.UltraToolbarsDockArea _ClientNotesForm_Toolbars_Dock_Area_Bottom; private GZTW.WinForm.Controls.GZDateTimePicker GridCalendar; private System.ComponentModel.IContainer components; public ClientNotesForm() { // // 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("ClientNotesToolBar"); 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:ClientNoteType.Label.List"); Infragistics.Win.UltraWinToolbars.ButtonTool buttonTool2 = new Infragistics.Win.UltraWinToolbars.ButtonTool("LT:ClientNoteType.Label.List"); Infragistics.Win.UltraWinToolbars.PopupMenuTool popupMenuTool2 = new Infragistics.Win.UltraWinToolbars.PopupMenuTool("LT:UI.Toolbar.Print"); Infragistics.Win.Appearance appearance1 = new Infragistics.Win.Appearance(); Infragistics.Win.Appearance appearance2 = new Infragistics.Win.Appearance(); Infragistics.Win.UltraWinToolbars.ListTool listTool2 = new Infragistics.Win.UltraWinToolbars.ListTool("REPORTLIST"); Infragistics.Win.UltraWinToolbars.ListTool listTool1 = new Infragistics.Win.UltraWinToolbars.ListTool("REPORTLIST"); this.Grid = new Infragistics.Win.UltraWinGrid.UltraGrid(); this.errorProvider1 = new System.Windows.Forms.ErrorProvider(this.components); this._ClientNotesForm_Toolbars_Dock_Area_Left = new Infragistics.Win.UltraWinToolbars.UltraToolbarsDockArea(); this.tbManager = new Infragistics.Win.UltraWinToolbars.UltraToolbarsManager(this.components); this._ClientNotesForm_Toolbars_Dock_Area_Right = new Infragistics.Win.UltraWinToolbars.UltraToolbarsDockArea(); this._ClientNotesForm_Toolbars_Dock_Area_Top = new Infragistics.Win.UltraWinToolbars.UltraToolbarsDockArea(); this._ClientNotesForm_Toolbars_Dock_Area_Bottom = new Infragistics.Win.UltraWinToolbars.UltraToolbarsDockArea(); this.GridCalendar = new GZTW.WinForm.Controls.GZDateTimePicker(); ((System.ComponentModel.ISupportInitialize)(this.Grid)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.errorProvider1)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.tbManager)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.GridCalendar)).BeginInit(); this.SuspendLayout(); // // Grid // this.Grid.Cursor = System.Windows.Forms.Cursors.Default; this.Grid.Dock = System.Windows.Forms.DockStyle.Fill; this.Grid.Location = new System.Drawing.Point(0, 26); this.Grid.Name = "Grid"; this.Grid.Size = new System.Drawing.Size(520, 339); this.Grid.TabIndex = 0; this.Grid.InitializeRow += new Infragistics.Win.UltraWinGrid.InitializeRowEventHandler(this.Grid_InitializeRow); this.Grid.CellChange += new Infragistics.Win.UltraWinGrid.CellEventHandler(this.Grid_CellChange); this.Grid.BeforeAutoSizeEdit += new Infragistics.Win.UltraWinGrid.CancelableAutoSizeEditEventHandler(this.Grid_BeforeAutoSizeEdit); this.Grid.BeforeRowInsert += new Infragistics.Win.UltraWinGrid.BeforeRowInsertEventHandler(this.Grid_BeforeRowInsert); this.Grid.MouseEnterElement += new Infragistics.Win.UIElementEventHandler(this.Grid_MouseEnterElement); // // errorProvider1 // this.errorProvider1.ContainerControl = this; // // _ClientNotesForm_Toolbars_Dock_Area_Left // this._ClientNotesForm_Toolbars_Dock_Area_Left.AccessibleRole = System.Windows.Forms.AccessibleRole.Grouping; this._ClientNotesForm_Toolbars_Dock_Area_Left.BackColor = System.Drawing.SystemColors.Control; this._ClientNotesForm_Toolbars_Dock_Area_Left.DockedPosition = Infragistics.Win.UltraWinToolbars.DockedPosition.Left; this._ClientNotesForm_Toolbars_Dock_Area_Left.ForeColor = System.Drawing.SystemColors.ControlText; this._ClientNotesForm_Toolbars_Dock_Area_Left.Location = new System.Drawing.Point(0, 26); this._ClientNotesForm_Toolbars_Dock_Area_Left.Name = "_ClientNotesForm_Toolbars_Dock_Area_Left"; this._ClientNotesForm_Toolbars_Dock_Area_Left.Size = new System.Drawing.Size(0, 339); this._ClientNotesForm_Toolbars_Dock_Area_Left.ToolbarsManager = this.tbManager; // // tbManager // this.tbManager.DesignerFlags = 1; this.tbManager.DockWithinContainer = this; this.tbManager.DockWithinContainerBaseType = typeof(System.Windows.Forms.Form); this.tbManager.ShowFullMenusDelay = 500; this.tbManager.ShowQuickCustomizeButton = false; ultraToolbar1.DockedColumn = 0; ultraToolbar1.DockedRow = 0; ultraToolbar1.NonInheritedTools.AddRange(new Infragistics.Win.UltraWinToolbars.ToolBase[] { popupMenuTool1, buttonTool1}); ultraToolbar1.Text = "ClientNotesToolBar"; 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; buttonTool2.SharedPropsInternal.Caption = "LT:ClientNoteType.Label.List"; buttonTool2.SharedPropsInternal.DisplayStyle = Infragistics.Win.UltraWinToolbars.ToolDisplayStyle.TextOnlyAlways; appearance1.Image = global::AyaNova.Resource1.Print32; popupMenuTool2.SharedPropsInternal.AppearancesLarge.Appearance = appearance1; appearance2.Image = global::AyaNova.Resource1.Print16; popupMenuTool2.SharedPropsInternal.AppearancesSmall.Appearance = appearance2; popupMenuTool2.SharedPropsInternal.Caption = "LT:UI.Toolbar.Print"; popupMenuTool2.SharedPropsInternal.DisplayStyle = Infragistics.Win.UltraWinToolbars.ToolDisplayStyle.ImageOnlyOnToolbars; popupMenuTool2.Tools.AddRange(new Infragistics.Win.UltraWinToolbars.ToolBase[] { listTool2}); listTool1.SharedPropsInternal.Caption = "REPORTLIST"; this.tbManager.Tools.AddRange(new Infragistics.Win.UltraWinToolbars.ToolBase[] { buttonTool2, popupMenuTool2, listTool1}); this.tbManager.ToolClick += new Infragistics.Win.UltraWinToolbars.ToolClickEventHandler(this.tbManager_ToolClick); // // _ClientNotesForm_Toolbars_Dock_Area_Right // this._ClientNotesForm_Toolbars_Dock_Area_Right.AccessibleRole = System.Windows.Forms.AccessibleRole.Grouping; this._ClientNotesForm_Toolbars_Dock_Area_Right.BackColor = System.Drawing.SystemColors.Control; this._ClientNotesForm_Toolbars_Dock_Area_Right.DockedPosition = Infragistics.Win.UltraWinToolbars.DockedPosition.Right; this._ClientNotesForm_Toolbars_Dock_Area_Right.ForeColor = System.Drawing.SystemColors.ControlText; this._ClientNotesForm_Toolbars_Dock_Area_Right.Location = new System.Drawing.Point(520, 26); this._ClientNotesForm_Toolbars_Dock_Area_Right.Name = "_ClientNotesForm_Toolbars_Dock_Area_Right"; this._ClientNotesForm_Toolbars_Dock_Area_Right.Size = new System.Drawing.Size(0, 339); this._ClientNotesForm_Toolbars_Dock_Area_Right.ToolbarsManager = this.tbManager; // // _ClientNotesForm_Toolbars_Dock_Area_Top // this._ClientNotesForm_Toolbars_Dock_Area_Top.AccessibleRole = System.Windows.Forms.AccessibleRole.Grouping; this._ClientNotesForm_Toolbars_Dock_Area_Top.BackColor = System.Drawing.SystemColors.Control; this._ClientNotesForm_Toolbars_Dock_Area_Top.DockedPosition = Infragistics.Win.UltraWinToolbars.DockedPosition.Top; this._ClientNotesForm_Toolbars_Dock_Area_Top.ForeColor = System.Drawing.SystemColors.ControlText; this._ClientNotesForm_Toolbars_Dock_Area_Top.Location = new System.Drawing.Point(0, 0); this._ClientNotesForm_Toolbars_Dock_Area_Top.Name = "_ClientNotesForm_Toolbars_Dock_Area_Top"; this._ClientNotesForm_Toolbars_Dock_Area_Top.Size = new System.Drawing.Size(520, 26); this._ClientNotesForm_Toolbars_Dock_Area_Top.ToolbarsManager = this.tbManager; // // _ClientNotesForm_Toolbars_Dock_Area_Bottom // this._ClientNotesForm_Toolbars_Dock_Area_Bottom.AccessibleRole = System.Windows.Forms.AccessibleRole.Grouping; this._ClientNotesForm_Toolbars_Dock_Area_Bottom.BackColor = System.Drawing.SystemColors.Control; this._ClientNotesForm_Toolbars_Dock_Area_Bottom.DockedPosition = Infragistics.Win.UltraWinToolbars.DockedPosition.Bottom; this._ClientNotesForm_Toolbars_Dock_Area_Bottom.ForeColor = System.Drawing.SystemColors.ControlText; this._ClientNotesForm_Toolbars_Dock_Area_Bottom.Location = new System.Drawing.Point(0, 365); this._ClientNotesForm_Toolbars_Dock_Area_Bottom.Name = "_ClientNotesForm_Toolbars_Dock_Area_Bottom"; this._ClientNotesForm_Toolbars_Dock_Area_Bottom.Size = new System.Drawing.Size(520, 0); this._ClientNotesForm_Toolbars_Dock_Area_Bottom.ToolbarsManager = this.tbManager; // // GridCalendar // this.GridCalendar.GZEnabled = true; this.GridCalendar.GZReadOnly = false; this.GridCalendar.Location = new System.Drawing.Point(250, 198); this.GridCalendar.Name = "GridCalendar"; this.GridCalendar.Size = new System.Drawing.Size(124, 24); this.GridCalendar.TabIndex = 154; this.GridCalendar.Visible = false; // // ClientNotesForm // this.AutoScaleBaseSize = new System.Drawing.Size(6, 15); this.ClientSize = new System.Drawing.Size(520, 365); this.Controls.Add(this.Grid); this.Controls.Add(this.GridCalendar); this.Controls.Add(this._ClientNotesForm_Toolbars_Dock_Area_Left); this.Controls.Add(this._ClientNotesForm_Toolbars_Dock_Area_Right); this.Controls.Add(this._ClientNotesForm_Toolbars_Dock_Area_Bottom); this.Controls.Add(this._ClientNotesForm_Toolbars_Dock_Area_Top); this.Name = "ClientNotesForm"; this.ShowInTaskbar = false; this.Tag = ""; this.Text = "LT:ClientNote.Label.List"; this.Closing += new System.ComponentModel.CancelEventHandler(this.ClientNotesForm_Closing); this.Load += new System.EventHandler(this.ClientNotesForm_Load); ((System.ComponentModel.ISupportInitialize)(this.Grid)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.errorProvider1)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.tbManager)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.GridCalendar)).EndInit(); this.ResumeLayout(false); this.PerformLayout(); } #endregion // __ _ _ ___ ____ __ __ __ __ __ ___ ___ // / _)( )( )/ __)(_ _)/ \( \/ ) / _)/ \( \( _) // ( (_ )()( \__ \ )( ( () )) ( ( (_( () )) ) )) _) // \__) \__/ (___/ (__) \__/(_/\/\_) \__)\__/(___/(___) // #region Load / Close //variable to hold user form settings //UIUserFormSetting mFormSetting; ClientNotes r=null; private ControlContainerEditor ccGridDateTimeEditor = null; private void ClientNotesForm_Load(object sender, System.EventArgs e) { //case 1039 //log.Debug("ClientNotesForm_Load"); this.Icon = Resource1.ClientNotes16icon; Grid.Text=""; ccGridDateTimeEditor = new ControlContainerEditor(); ccGridDateTimeEditor.EditingControl = GridCalendar; this.Text=Util.LocaleText.GetLocalizedText("ClientNote.Label.List"); r=ClientNotes.GetItems(mClientID); Grid.DataSource=r; InitializeGrid(); Util.LoadFormCustomization("ClientNotes", this, null, false); if (AyaBizUtils.Right("Object.Report") < (int)SecurityLevelTypes.ReadOnly) { tbManager.Tools["LT:UI.Toolbar.Print"].SharedProps.Visible = false; }//LT:UI.Toolbar.Print else { tbManager.Tools["LT:UI.Toolbar.Print"].SharedProps.Visible = true; Util.ReportFillList(this.tbManager.Tools["REPORTLIST"], ClientNotesReportList.ReportKey, ""); } Util.LocalizeHelperInsertMenu(tbManager, this); //case 1810 Util.Localize(this); this.Text = Util.LocaleText.GetLocalizedText("ClientNote.Label.List") + " - " + AyaBizUtils.GetBizObjectName("Client", mClientID); } private void ClientNotesForm_Closing(object sender, System.ComponentModel.CancelEventArgs e) { //case 1039 //log.Debug("ClientNotesForm_Closing"); Grid.UpdateData(); if(r.IsSavable) { mbChangesMade=true; r=(ClientNotes)r.Save(); } //Is it dirty? //if so, it wasn't saved previously //so we have broken rules here if(r.IsDirty) { if(Util.PromptForBrokenRulesCancelSave()!=DialogResult.Yes) { e.Cancel=true; return; } } Util.SaveGridLayout("ClientNotes","","",Grid); Util.SaveFormCustomization("ClientNotes", this, null, false); } #endregion #region Grid Initialization /// /// Get grid ready /// private void InitializeGrid() { //case 1039 //log.Debug("InitializeGrid"); Grid.DisplayLayout.Override.HeaderClickAction=HeaderClickAction.SortSingle; bool ReadOnly=AyaBizUtils.Right("Object.Client") < (int)SecurityLevelTypes.ReadWrite; if(ReadOnly) { Grid.DisplayLayout.Override.AllowAddNew=AllowAddNew.No; Grid.DisplayLayout.Override.AllowDelete=DefaultableBoolean.False; Grid.DisplayLayout.Override.AllowUpdate=DefaultableBoolean.False; } else { Grid.DisplayLayout.Override.AllowAddNew=AllowAddNew.TemplateOnBottom; Grid.DisplayLayout.Override.AllowDelete=DefaultableBoolean.True; Grid.DisplayLayout.Override.AllowUpdate=DefaultableBoolean.True; } Util.GridPreLocalize("ClientNote",Grid.DisplayLayout.Bands[0]); Util.GridHideEditableBizObjectInternalFields(Grid); Util.FetchGridLayout("ClientNotes","",Grid); Grid.DisplayLayout.Bands[0].Columns["Notes"].CellMultiLine=DefaultableBoolean.True; Grid.DisplayLayout.Bands[0].Columns["Notes"].AutoSizeEdit=DefaultableBoolean.True; Grid.DisplayLayout.Bands[0].Columns["Notes"].VertScrollBar=true; Grid.DisplayLayout.Bands[0].Columns["ClientID"].Hidden=true; //=-=-=-=-=- //Case 153 Grid.DisplayLayout.Bands[0].Columns["NoteDate"].CellActivation=Activation.AllowEdit; Grid.DisplayLayout.Bands[0].Columns["NoteDate"].Editor = ccGridDateTimeEditor; Grid.DisplayLayout.Bands[0].Columns["Created"].Hidden = false; //=-=-=-=-=- //=-=-=-=-=-=- //Case 30 //=-=-=-=-=-=- Grid.DisplayLayout.Bands[0].Columns["Creator"].Hidden = false; Grid.DisplayLayout.Bands[0].Columns["Creator"].CellActivation = Activation.NoEdit; #region ======== Users value list ======== //Clear any previous value list from this column //gridScheduledUsers.DisplayLayout.Bands[0].Columns["UserID"].ValueList=null; //Add all potential active items ValueList vlUsers = new ValueList(); UserPickList UList = UserPickList.GetList(false); foreach (UserPickList.UserPickListInfo ui in UList) { vlUsers.ValueListItems.Add(ui.ID, ui.Name); } //Show sorted alphabetically vlUsers.SortStyle = ValueListSortStyle.Ascending; //Bind value lists to correct columns in grid Grid.DisplayLayout.Bands[0].Columns["Creator"].ValueList = vlUsers; //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["Creator"].Style = Infragistics.Win.UltraWinGrid.ColumnStyle.DropDownValidate;//Case 96 for autocomplete (was DropDownList) //Grid.DisplayLayout.Bands[0].Columns["Creator"].AutoCompleteMode = Infragistics.Win.AutoCompleteMode.SuggestAppend; #endregion //=-=-=-=-=-=- PopulateGridValueLists(); Util.LocalizeGrid(Grid); //Allow empty string entry on grid Util.SetTextColumnsNullable(Grid); //Case 153 Case 30 //Very important as if their caption is not changed it will result in their grid position //not being saved (which is actually a bug to be addressed) Grid.DisplayLayout.Bands[0].Columns["Creator"].Header.Caption = Util.LocaleText.GetLocalizedText("Common.Label.Creator"); Grid.DisplayLayout.Bands[0].Columns["Created"].Header.Caption = Util.LocaleText.GetLocalizedText("Common.Label.Created"); } /// /// Populate the drop down lists inside the grid /// so they display and can select the correct underlying /// value /// private void PopulateGridValueLists() { Grid.DisplayLayout.ValueLists.Clear(); //Populate Rateunitchargedescription lists ValueList vl=Grid.DisplayLayout.ValueLists.Add("ClientNoteTypes"); //NVCHANGED GenericNVList l=GenericNVList.GetList("aClientNoteType","aID","aName",true,false, false); //Add initial empty guid value //so that records with no value yet entered in the //field will be shown as an empty string vl.ValueListItems.Add(Guid.Empty, Util.NoSelectionString);//Case 318 //Loop through the items in the list and put them //into the valuelist for(int x=0;x /// Show error icons if rules broken /// /// /// private void Grid_InitializeRow(object sender, Infragistics.Win.UltraWinGrid.InitializeRowEventArgs e) { Util.GridShowBrokenRulesErrorIcons(e); } //Tool tip to use for displaying broken rules private System.Windows.Forms.ToolTip tipError = new System.Windows.Forms.ToolTip(); /// /// Display broken rules in tool tip if hovering over /// error icon /// /// /// private void Grid_MouseEnterElement(object sender, Infragistics.Win.UIElementEventArgs e) { Util.GridShowBrokenRulesToolTip(e,tipError); } #endregion 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:ClientNoteType.Label.List": // ButtonTool GenericListForm f=new GenericListForm(); ClientNoteTypes o=ClientNoteTypes.GetItems(); // f.SelectedRecordID=ID; f.GridDataSource=o; f.Visible=false; f.ShowDialog(); if(f.ChangesMade) PopulateGridValueLists(); break; case "REPORTLIST": { if (this.Grid.Selected.Rows.Count == 0) { Util.ReportHandleToolClick(e.Tool, ClientNotesReportList.ReportKey, ClientNotesReportList.GetList(mClientID)); } else { Util.ReportHandleToolClick(e.Tool, ClientNotesReportList.ReportKey, ClientNotesReportList.GetListFromIDList(SelectedIDs())); } Util.ReportFillList(this.tbManager.Tools["REPORTLIST"], ClientNotesReportList.ReportKey, ""); break; } } } //Get selected rows for printing public List SelectedIDs() { List l = new List(); //Get the id's for the selected rows foreach (UltraGridRow r in Grid.Selected.Rows) l.Add((Guid)r.Cells["ID"].Value); return l; } private void Grid_BeforeRowInsert(object sender, Infragistics.Win.UltraWinGrid.BeforeRowInsertEventArgs e) { //case 1039 //log.Debug("Grid_BeforeRowInsert"); e.Cancel=true; ClientNote c=r.Add(); c.ClientID=mClientID; } private void Grid_BeforeAutoSizeEdit(object sender, CancelableAutoSizeEditEventArgs e) { System.Drawing.Point p = Grid.ActiveCell.GetUIElement().Rect.Location; e.StartWidth = this.ClientRectangle.Width - 25 - p.X; e.StartHeight = this.ClientRectangle.Height - 60 - p.Y; e.MaxHeight = e.StartHeight; e.MaxWidth = e.StartWidth; } } }