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.UltraWinEditors; using log4net; namespace AyaNova { /// /// Summary description for TaxCodesForm. /// public class TaxCodesForm : 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.UltraToolbarsDockArea _TaxCodesForm_Toolbars_Dock_Area_Left; private Infragistics.Win.UltraWinToolbars.UltraToolbarsDockArea _TaxCodesForm_Toolbars_Dock_Area_Right; private Infragistics.Win.UltraWinToolbars.UltraToolbarsDockArea _TaxCodesForm_Toolbars_Dock_Area_Top; private Infragistics.Win.UltraWinToolbars.UltraToolbarsDockArea _TaxCodesForm_Toolbars_Dock_Area_Bottom; private Infragistics.Win.UltraWinToolbars.UltraToolbarsManager ToolBarManager; private System.Windows.Forms.HelpProvider helpProvider1; private System.ComponentModel.IContainer components; public TaxCodesForm() { // // 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("TaxCodes"); Infragistics.Win.UltraWinToolbars.PopupMenuTool popupMenuTool1 = new Infragistics.Win.UltraWinToolbars.PopupMenuTool("LT:UI.Toolbar.Print"); Infragistics.Win.UltraWinToolbars.ListTool listTool1 = new Infragistics.Win.UltraWinToolbars.ListTool("REPORTLIST"); 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"); this.Grid = new Infragistics.Win.UltraWinGrid.UltraGrid(); this.errorProvider1 = new System.Windows.Forms.ErrorProvider(this.components); this.ToolBarManager = new Infragistics.Win.UltraWinToolbars.UltraToolbarsManager(this.components); this._TaxCodesForm_Toolbars_Dock_Area_Left = new Infragistics.Win.UltraWinToolbars.UltraToolbarsDockArea(); this._TaxCodesForm_Toolbars_Dock_Area_Right = new Infragistics.Win.UltraWinToolbars.UltraToolbarsDockArea(); this._TaxCodesForm_Toolbars_Dock_Area_Top = new Infragistics.Win.UltraWinToolbars.UltraToolbarsDockArea(); this._TaxCodesForm_Toolbars_Dock_Area_Bottom = new Infragistics.Win.UltraWinToolbars.UltraToolbarsDockArea(); this.helpProvider1 = new System.Windows.Forms.HelpProvider(); ((System.ComponentModel.ISupportInitialize)(this.Grid)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.errorProvider1)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.ToolBarManager)).BeginInit(); this.SuspendLayout(); // // Grid // this.Grid.Cursor = System.Windows.Forms.Cursors.Hand; this.Grid.DisplayLayout.Override.SelectTypeRow = Infragistics.Win.UltraWinGrid.SelectType.Single; this.Grid.Dock = System.Windows.Forms.DockStyle.Fill; this.Grid.Location = new System.Drawing.Point(0, 23); this.Grid.Name = "Grid"; this.Grid.Size = new System.Drawing.Size(520, 342); this.Grid.TabIndex = 0; this.Grid.InitializeRow += new Infragistics.Win.UltraWinGrid.InitializeRowEventHandler(this.Grid_InitializeRow); this.Grid.BeforeRowsDeleted += new Infragistics.Win.UltraWinGrid.BeforeRowsDeletedEventHandler(this.Grid_BeforeRowsDeleted); this.Grid.MouseEnterElement += new Infragistics.Win.UIElementEventHandler(this.Grid_MouseEnterElement); // // errorProvider1 // this.errorProvider1.ContainerControl = this; // // ToolBarManager // this.ToolBarManager.DesignerFlags = 1; this.ToolBarManager.DockWithinContainer = this; this.ToolBarManager.DockWithinContainerBaseType = typeof(System.Windows.Forms.Form); this.ToolBarManager.ShowFullMenusDelay = 500; ultraToolbar1.DockedColumn = 0; ultraToolbar1.DockedRow = 0; ultraToolbar1.NonInheritedTools.AddRange(new Infragistics.Win.UltraWinToolbars.ToolBase[] { popupMenuTool1}); ultraToolbar1.Text = "TaxCodes"; this.ToolBarManager.Toolbars.AddRange(new Infragistics.Win.UltraWinToolbars.UltraToolbar[] { ultraToolbar1}); this.ToolBarManager.ToolbarSettings.AllowCustomize = Infragistics.Win.DefaultableBoolean.False; this.ToolBarManager.ToolbarSettings.AllowFloating = Infragistics.Win.DefaultableBoolean.False; this.ToolBarManager.ToolbarSettings.AllowHiding = Infragistics.Win.DefaultableBoolean.False; listTool1.DisplayCheckmark = false; 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}); this.ToolBarManager.Tools.AddRange(new Infragistics.Win.UltraWinToolbars.ToolBase[] { listTool1, popupMenuTool2}); this.ToolBarManager.ToolClick += new Infragistics.Win.UltraWinToolbars.ToolClickEventHandler(this.ToolbarManager_ToolClick); // // _TaxCodesForm_Toolbars_Dock_Area_Left // this._TaxCodesForm_Toolbars_Dock_Area_Left.AccessibleRole = System.Windows.Forms.AccessibleRole.Grouping; this._TaxCodesForm_Toolbars_Dock_Area_Left.BackColor = System.Drawing.SystemColors.Control; this._TaxCodesForm_Toolbars_Dock_Area_Left.DockedPosition = Infragistics.Win.UltraWinToolbars.DockedPosition.Left; this._TaxCodesForm_Toolbars_Dock_Area_Left.ForeColor = System.Drawing.SystemColors.ControlText; this._TaxCodesForm_Toolbars_Dock_Area_Left.Location = new System.Drawing.Point(0, 23); this._TaxCodesForm_Toolbars_Dock_Area_Left.Name = "_TaxCodesForm_Toolbars_Dock_Area_Left"; this._TaxCodesForm_Toolbars_Dock_Area_Left.Size = new System.Drawing.Size(0, 342); this._TaxCodesForm_Toolbars_Dock_Area_Left.ToolbarsManager = this.ToolBarManager; // // _TaxCodesForm_Toolbars_Dock_Area_Right // this._TaxCodesForm_Toolbars_Dock_Area_Right.AccessibleRole = System.Windows.Forms.AccessibleRole.Grouping; this._TaxCodesForm_Toolbars_Dock_Area_Right.BackColor = System.Drawing.SystemColors.Control; this._TaxCodesForm_Toolbars_Dock_Area_Right.DockedPosition = Infragistics.Win.UltraWinToolbars.DockedPosition.Right; this._TaxCodesForm_Toolbars_Dock_Area_Right.ForeColor = System.Drawing.SystemColors.ControlText; this._TaxCodesForm_Toolbars_Dock_Area_Right.Location = new System.Drawing.Point(520, 23); this._TaxCodesForm_Toolbars_Dock_Area_Right.Name = "_TaxCodesForm_Toolbars_Dock_Area_Right"; this._TaxCodesForm_Toolbars_Dock_Area_Right.Size = new System.Drawing.Size(0, 342); this._TaxCodesForm_Toolbars_Dock_Area_Right.ToolbarsManager = this.ToolBarManager; // // _TaxCodesForm_Toolbars_Dock_Area_Top // this._TaxCodesForm_Toolbars_Dock_Area_Top.AccessibleRole = System.Windows.Forms.AccessibleRole.Grouping; this._TaxCodesForm_Toolbars_Dock_Area_Top.BackColor = System.Drawing.SystemColors.Control; this._TaxCodesForm_Toolbars_Dock_Area_Top.DockedPosition = Infragistics.Win.UltraWinToolbars.DockedPosition.Top; this._TaxCodesForm_Toolbars_Dock_Area_Top.ForeColor = System.Drawing.SystemColors.ControlText; this._TaxCodesForm_Toolbars_Dock_Area_Top.Location = new System.Drawing.Point(0, 0); this._TaxCodesForm_Toolbars_Dock_Area_Top.Name = "_TaxCodesForm_Toolbars_Dock_Area_Top"; this._TaxCodesForm_Toolbars_Dock_Area_Top.Size = new System.Drawing.Size(520, 23); this._TaxCodesForm_Toolbars_Dock_Area_Top.ToolbarsManager = this.ToolBarManager; // // _TaxCodesForm_Toolbars_Dock_Area_Bottom // this._TaxCodesForm_Toolbars_Dock_Area_Bottom.AccessibleRole = System.Windows.Forms.AccessibleRole.Grouping; this._TaxCodesForm_Toolbars_Dock_Area_Bottom.BackColor = System.Drawing.SystemColors.Control; this._TaxCodesForm_Toolbars_Dock_Area_Bottom.DockedPosition = Infragistics.Win.UltraWinToolbars.DockedPosition.Bottom; this._TaxCodesForm_Toolbars_Dock_Area_Bottom.ForeColor = System.Drawing.SystemColors.ControlText; this._TaxCodesForm_Toolbars_Dock_Area_Bottom.Location = new System.Drawing.Point(0, 365); this._TaxCodesForm_Toolbars_Dock_Area_Bottom.Name = "_TaxCodesForm_Toolbars_Dock_Area_Bottom"; this._TaxCodesForm_Toolbars_Dock_Area_Bottom.Size = new System.Drawing.Size(520, 0); this._TaxCodesForm_Toolbars_Dock_Area_Bottom.ToolbarsManager = this.ToolBarManager; // // TaxCodesForm // 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._TaxCodesForm_Toolbars_Dock_Area_Left); this.Controls.Add(this._TaxCodesForm_Toolbars_Dock_Area_Right); this.Controls.Add(this._TaxCodesForm_Toolbars_Dock_Area_Bottom); this.Controls.Add(this._TaxCodesForm_Toolbars_Dock_Area_Top); this.helpProvider1.SetHelpNavigator(this, System.Windows.Forms.HelpNavigator.Topic); this.Name = "TaxCodesForm"; this.helpProvider1.SetShowHelp(this, true); this.ShowInTaskbar = false; this.Closing += new System.ComponentModel.CancelEventHandler(this.TaxCodesForm_Closing); this.Load += new System.EventHandler(this.TaxCodesForm_Load); ((System.ComponentModel.ISupportInitialize)(this.Grid)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.errorProvider1)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.ToolBarManager)).EndInit(); this.ResumeLayout(false); } #endregion // __ _ _ ___ ____ __ __ __ __ __ ___ ___ // / _)( )( )/ __)(_ _)/ \( \/ ) / _)/ \( \( _) // ( (_ )()( \__ \ )( ( () )) ( ( (_( () )) ) )) _) // \__) \__/ (___/ (__) \__/(_/\/\_) \__)\__/(___/(___) // #region Load / Close //variable to hold user form settings //UIUserFormSetting mFormSetting; TaxCodes r=null; private void TaxCodesForm_Load(object sender, System.EventArgs e) { // // helpProvider1 // this.helpProvider1.HelpNamespace = Util.BaseHelpUrl + "tax_codes.htm"; //case 1039 //log.Debug("TaxCodesForm_Load"); this.Icon = Resource1.TaxCodes16icon; Grid.Text=""; this.Text=Util.LocaleText.GetLocalizedText("TaxCode.Label.List"); r=TaxCodes.GetItems(); Grid.DataSource=r; InitializeGrid(); Util.LoadFormCustomization("TaxCodes", this, ToolBarManager, false); //Move to selected record if one if(mSelectedRecordID!=Guid.Empty) { if(Grid.DisplayLayout.Bands[0].Columns.Exists("ID")) { foreach(UltraGridRow therow in Grid.Rows) { if((Guid)therow.Cells["ID"].Value==mSelectedRecordID) { therow.Selected=true; } } } } if (AyaBizUtils.Right("Object.Report") < (int)SecurityLevelTypes.ReadOnly) { ToolBarManager.Tools["LT:UI.Toolbar.Print"].SharedProps.Visible = false; } else { ToolBarManager.Tools["LT:UI.Toolbar.Print"].SharedProps.Visible = true; Util.ReportFillList(this.ToolBarManager.Tools["REPORTLIST"], TaxCodes.ReportKey, ""); } } private void TaxCodesForm_Closing(object sender, System.ComponentModel.CancelEventArgs e) { //case 1039 //log.Debug("TaxCodesForm_Closing"); //Added to aid in diagnosis of case 249 several debug comments below //case 1039 //log.Debug("TaxCodesForm_Closing::Calling GridUpdateData()"); Grid.UpdateData(); if (r.IsSavable) { //case 1039 //log.Debug("TaxCodesForm_Closing::IsSavable, saving"); mbChangesMade = true; r.Save(); } else {//Case 355 put the following block in this else statement //Is it dirty? //if so, it wasn't saved previously //so we have broken rules here if (r.IsDirty) { //case 1039 //log.Debug("TaxCodesForm_Closing::IsDirty and not savable prompting broken rules cancel save"); if (Util.PromptForBrokenRulesCancelSave() != DialogResult.Yes) { e.Cancel = true; return; } } } //case 1039 //log.Debug("TaxCodesForm_Closing::Saving grid layout"); Util.SaveGridLayout("TaxCodes","","",Grid); Util.SaveFormCustomization("TaxCodes", this, ToolBarManager, false); } #endregion #region Grid Initialization /// /// Get grid ready /// private void InitializeGrid() { //case 1039 //log.Debug("InitializeGrid"); Grid.DisplayLayout.Override.HeaderClickAction=HeaderClickAction.SortSingle; Grid.DisplayLayout.Override.AllowAddNew=AllowAddNew.TemplateOnBottom; //Grid.DisplayLayout.AutoFitColumns=false; Util.GridPreLocalize("TaxCode",Grid.DisplayLayout.Bands[0]); Util.GridHideEditableBizObjectInternalFields(Grid); Util.FetchGridLayout("TaxCodes","",Grid); Util.LocalizeGrid(Grid); //Format cells for percentage format Grid.DisplayLayout.Bands[0].Columns["TaxA"].Format="P"; Grid.DisplayLayout.Bands[0].Columns["TaxA"].CellAppearance.TextHAlign=HAlign.Right; Grid.DisplayLayout.Bands[0].Columns["TaxB"].Format="P"; Grid.DisplayLayout.Bands[0].Columns["TaxB"].CellAppearance.TextHAlign=HAlign.Right; } #endregion #region properties //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; } } private Guid mSelectedRecordID=Guid.Empty; public object SelectedRecordID { set { if(value!=null) mSelectedRecordID=(Guid)value; } get { return mSelectedRecordID; } } #endregion #region GridBrokenRuleFeedBack /// /// Show error icons if rules broken /// /// /// private void Grid_InitializeRow(object sender, Infragistics.Win.UltraWinGrid.InitializeRowEventArgs e) { //If the underlying record is new or dirty (not saved) then //user can not click on button if(!((CSLA.BusinessBase)e.Row.ListObject).IsNew) { foreach(UltraGridCell c in e.Row.Cells) { if(c.Column.Key!="Active" && c.Column.Key!="Name") c.Activation=Activation.Disabled; } } 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 ToolbarManager_ToolClick(object sender, Infragistics.Win.UltraWinToolbars.ToolClickEventArgs e) { switch (e.Tool.Key) { case "REPORTLIST": { //if(Util.ReportHandleToolClickIsSummary(e.Tool)) Util.ReportHandleToolClick(e.Tool,TaxCodes.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.ToolBarManager.Tools["REPORTLIST"],TaxCodes.ReportKey,""); break; } } } private void Grid_BeforeRowsDeleted(object sender, Infragistics.Win.UltraWinGrid.BeforeRowsDeletedEventArgs e) { if(AyaBizUtils.GlobalSettings.TaxCodeIsADefault((Guid)e.Rows[0].Cells["ID"].Value)) { Util.PromptWithIconOKOnlyFromLocaleKey("TaxCode.Error.Default",MessageBoxIcon.Stop); e.Cancel=true; return; } //Changed: 17-Nov-2006 case 150 //taxcode should never be deleteable once saved to db if (!((CSLA.BusinessBase)e.Rows[0].ListObject).IsNew) { e.Cancel = true; MessageBox.Show(string.Format ( Util.LocaleText.GetLocalizedText("Error.Object.NotDeleteable"), Util.LocaleText.GetLocalizedText("O.TaxCode") ), "",MessageBoxButtons.OK,MessageBoxIcon.Error); return; } } } }