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 description for SecurityGroupInfoForm. /// public class SecurityGroupInfoForm : 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 Infragistics.Win.UltraWinEditors.UltraTextEditor edName; private Infragistics.Win.Misc.UltraLabel lblName; private System.Windows.Forms.ErrorProvider ErrorProvider; private Infragistics.Win.UltraWinToolbars.UltraToolbarsManager tbManager; private Infragistics.Win.UltraWinToolbars.UltraToolbarsDockArea _SecurityGroupInfoForm_Toolbars_Dock_Area_Left; private Infragistics.Win.UltraWinToolbars.UltraToolbarsDockArea _SecurityGroupInfoForm_Toolbars_Dock_Area_Right; private Infragistics.Win.UltraWinToolbars.UltraToolbarsDockArea _SecurityGroupInfoForm_Toolbars_Dock_Area_Top; private Infragistics.Win.UltraWinToolbars.UltraToolbarsDockArea _SecurityGroupInfoForm_Toolbars_Dock_Area_Bottom; private System.Windows.Forms.Panel panelTop; private Infragistics.Win.UltraWinGrid.UltraGrid grid; private System.Windows.Forms.HelpProvider helpProvider1; private System.ComponentModel.IContainer components; public SecurityGroupInfoForm() { // // 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("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.RecordHistory"); Infragistics.Win.UltraWinToolbars.ButtonTool buttonTool3 = new Infragistics.Win.UltraWinToolbars.ButtonTool("LT:UI.Command.SaveNew"); Infragistics.Win.UltraWinToolbars.ButtonTool buttonTool4 = new Infragistics.Win.UltraWinToolbars.ButtonTool("LT:UI.Command.Save"); Infragistics.Win.UltraWinToolbars.ComboBoxTool comboBoxTool1 = new Infragistics.Win.UltraWinToolbars.ComboBoxTool("LT:UserRight.Label.SecurityLevel"); Infragistics.Win.UltraWinToolbars.ButtonTool buttonTool5 = new Infragistics.Win.UltraWinToolbars.ButtonTool("LT:UI.Toolbar.SecurityGroupForm.SetAll"); Infragistics.Win.UltraWinToolbars.ButtonTool buttonTool6 = new Infragistics.Win.UltraWinToolbars.ButtonTool("LT:UI.Command.Delete"); Infragistics.Win.UltraWinToolbars.ButtonTool buttonTool7 = new Infragistics.Win.UltraWinToolbars.ButtonTool("LT:UI.Command.Close"); Infragistics.Win.UltraWinToolbars.ButtonTool buttonTool16 = new Infragistics.Win.UltraWinToolbars.ButtonTool("LT:UI.Command.Duplicate"); Infragistics.Win.UltraWinToolbars.ButtonTool buttonTool8 = 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 buttonTool9 = new Infragistics.Win.UltraWinToolbars.ButtonTool("LT:UI.Command.RecordHistory"); Infragistics.Win.Appearance appearance3 = new Infragistics.Win.Appearance(); Infragistics.Win.Appearance appearance4 = new Infragistics.Win.Appearance(); Infragistics.Win.UltraWinToolbars.ButtonTool buttonTool10 = new Infragistics.Win.UltraWinToolbars.ButtonTool("LT:UI.Command.Save"); Infragistics.Win.UltraWinToolbars.ButtonTool buttonTool11 = new Infragistics.Win.UltraWinToolbars.ButtonTool("LT:UI.Command.SaveNew"); Infragistics.Win.Appearance appearance5 = new Infragistics.Win.Appearance(); Infragistics.Win.Appearance appearance6 = new Infragistics.Win.Appearance(); Infragistics.Win.UltraWinToolbars.ButtonTool buttonTool12 = new Infragistics.Win.UltraWinToolbars.ButtonTool("LT:UI.Command.Close"); Infragistics.Win.UltraWinToolbars.ButtonTool buttonTool13 = new Infragistics.Win.UltraWinToolbars.ButtonTool("LT:UI.Command.Delete"); Infragistics.Win.Appearance appearance7 = new Infragistics.Win.Appearance(); Infragistics.Win.Appearance appearance8 = new Infragistics.Win.Appearance(); Infragistics.Win.UltraWinToolbars.ComboBoxTool comboBoxTool2 = new Infragistics.Win.UltraWinToolbars.ComboBoxTool("LT:UserRight.Label.SecurityLevel"); Infragistics.Win.ValueList valueList1 = new Infragistics.Win.ValueList(0); Infragistics.Win.UltraWinToolbars.ButtonTool buttonTool14 = new Infragistics.Win.UltraWinToolbars.ButtonTool("LT:UI.Toolbar.SecurityGroupForm.SetAll"); Infragistics.Win.Appearance appearance9 = new Infragistics.Win.Appearance(); Infragistics.Win.Appearance appearance10 = new Infragistics.Win.Appearance(); Infragistics.Win.UltraWinToolbars.ButtonTool buttonTool15 = new Infragistics.Win.UltraWinToolbars.ButtonTool("LT:UI.Command.Duplicate"); Infragistics.Win.Appearance appearance11 = new Infragistics.Win.Appearance(); Infragistics.Win.Appearance appearance12 = new Infragistics.Win.Appearance(); this.ckIsDirty = new System.Windows.Forms.CheckBox(); this.panelTop = new System.Windows.Forms.Panel(); this.lblName = new Infragistics.Win.Misc.UltraLabel(); this.edName = new Infragistics.Win.UltraWinEditors.UltraTextEditor(); this.ErrorProvider = new System.Windows.Forms.ErrorProvider(this.components); this._SecurityGroupInfoForm_Toolbars_Dock_Area_Left = new Infragistics.Win.UltraWinToolbars.UltraToolbarsDockArea(); this.tbManager = new Infragistics.Win.UltraWinToolbars.UltraToolbarsManager(this.components); this._SecurityGroupInfoForm_Toolbars_Dock_Area_Right = new Infragistics.Win.UltraWinToolbars.UltraToolbarsDockArea(); this._SecurityGroupInfoForm_Toolbars_Dock_Area_Top = new Infragistics.Win.UltraWinToolbars.UltraToolbarsDockArea(); this._SecurityGroupInfoForm_Toolbars_Dock_Area_Bottom = new Infragistics.Win.UltraWinToolbars.UltraToolbarsDockArea(); this.grid = new Infragistics.Win.UltraWinGrid.UltraGrid(); this.helpProvider1 = new System.Windows.Forms.HelpProvider(); this.panelTop.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.edName)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.ErrorProvider)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.tbManager)).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(193, 27); this.ckIsDirty.TabIndex = 5; // // panelTop // this.panelTop.Controls.Add(this.lblName); this.panelTop.Controls.Add(this.edName); this.panelTop.Dock = System.Windows.Forms.DockStyle.Top; this.panelTop.Location = new System.Drawing.Point(0, 43); this.panelTop.Name = "panelTop"; this.panelTop.Size = new System.Drawing.Size(632, 64); this.panelTop.TabIndex = 96; // // lblName // this.lblName.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); this.lblName.Location = new System.Drawing.Point(10, 9); this.lblName.Name = "lblName"; this.lblName.Size = new System.Drawing.Size(613, 19); this.lblName.TabIndex = 92; this.lblName.Tag = ""; this.lblName.Text = "LT:SecurityGroup.Label.Name"; // // edName // this.edName.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); this.edName.Location = new System.Drawing.Point(10, 28); this.edName.Name = "edName"; this.edName.Size = new System.Drawing.Size(594, 24); this.edName.TabIndex = 0; this.edName.AfterExitEditMode += new System.EventHandler(this.edName_AfterExitEditMode); // // ErrorProvider // this.ErrorProvider.ContainerControl = this; // // _SecurityGroupInfoForm_Toolbars_Dock_Area_Left // this._SecurityGroupInfoForm_Toolbars_Dock_Area_Left.AccessibleRole = System.Windows.Forms.AccessibleRole.Grouping; this._SecurityGroupInfoForm_Toolbars_Dock_Area_Left.BackColor = System.Drawing.SystemColors.Control; this._SecurityGroupInfoForm_Toolbars_Dock_Area_Left.DockedPosition = Infragistics.Win.UltraWinToolbars.DockedPosition.Left; this._SecurityGroupInfoForm_Toolbars_Dock_Area_Left.ForeColor = System.Drawing.SystemColors.ControlText; this._SecurityGroupInfoForm_Toolbars_Dock_Area_Left.Location = new System.Drawing.Point(0, 43); this._SecurityGroupInfoForm_Toolbars_Dock_Area_Left.Name = "_SecurityGroupInfoForm_Toolbars_Dock_Area_Left"; this._SecurityGroupInfoForm_Toolbars_Dock_Area_Left.Size = new System.Drawing.Size(0, 258); this._SecurityGroupInfoForm_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; ultraToolbar1.DockedColumn = 0; ultraToolbar1.DockedRow = 0; ultraToolbar1.NonInheritedTools.AddRange(new Infragistics.Win.UltraWinToolbars.ToolBase[] { buttonTool1, buttonTool2, buttonTool3, buttonTool4, comboBoxTool1, buttonTool5, buttonTool6, buttonTool7, buttonTool16}); 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; buttonTool8.SharedPropsInternal.AccessibleDescription = "recorddd"; appearance1.Image = global::AyaNova.Resource1.SaveExit32; buttonTool8.SharedPropsInternal.AppearancesLarge.Appearance = appearance1; appearance2.Image = global::AyaNova.Resource1.SaveExit16; buttonTool8.SharedPropsInternal.AppearancesSmall.Appearance = appearance2; buttonTool8.SharedPropsInternal.Caption = "LT:UI.Command.SaveClose"; appearance3.Image = global::AyaNova.Resource1.RecordHistory32; buttonTool9.SharedPropsInternal.AppearancesLarge.Appearance = appearance3; appearance4.Image = global::AyaNova.Resource1.RecordHistory16; buttonTool9.SharedPropsInternal.AppearancesSmall.Appearance = appearance4; buttonTool9.SharedPropsInternal.Caption = "LT:UI.Command.RecordHistory"; buttonTool10.SharedPropsInternal.Caption = "LT:UI.Command.Save"; buttonTool10.SharedPropsInternal.DisplayStyle = Infragistics.Win.UltraWinToolbars.ToolDisplayStyle.TextOnlyAlways; appearance5.Image = global::AyaNova.Resource1.SaveNew32; buttonTool11.SharedPropsInternal.AppearancesLarge.Appearance = appearance5; appearance6.Image = global::AyaNova.Resource1.SaveNew16; buttonTool11.SharedPropsInternal.AppearancesSmall.Appearance = appearance6; buttonTool11.SharedPropsInternal.Caption = "LT:UI.Command.SaveNew"; buttonTool12.SharedPropsInternal.Caption = "LT:UI.Command.Close"; buttonTool12.SharedPropsInternal.DisplayStyle = Infragistics.Win.UltraWinToolbars.ToolDisplayStyle.TextOnlyAlways; appearance7.Image = global::AyaNova.Resource1.Delete32; buttonTool13.SharedPropsInternal.AppearancesLarge.Appearance = appearance7; appearance8.Image = global::AyaNova.Resource1.Delete16; buttonTool13.SharedPropsInternal.AppearancesSmall.Appearance = appearance8; buttonTool13.SharedPropsInternal.Caption = "LT:UI.Command.Delete"; comboBoxTool2.SharedPropsInternal.Caption = "LT:UserRight.Label.SecurityLevel"; comboBoxTool2.ValueList = valueList1; appearance9.Image = global::AyaNova.Resource1.SetSecurityLevelToSameLevel32; buttonTool14.SharedPropsInternal.AppearancesLarge.Appearance = appearance9; appearance10.Image = global::AyaNova.Resource1.SetSecurityLevelToSameLevel16; buttonTool14.SharedPropsInternal.AppearancesSmall.Appearance = appearance10; buttonTool14.SharedPropsInternal.Caption = "LT:UI.Toolbar.SecurityGroupForm.SetAll"; appearance11.Image = global::AyaNova.Resource1.Duplicate32; buttonTool15.SharedPropsInternal.AppearancesLarge.Appearance = appearance11; appearance12.Image = global::AyaNova.Resource1.Duplicate16; buttonTool15.SharedPropsInternal.AppearancesSmall.Appearance = appearance12; buttonTool15.SharedPropsInternal.Caption = "LT:UI.Command.Duplicate"; this.tbManager.Tools.AddRange(new Infragistics.Win.UltraWinToolbars.ToolBase[] { buttonTool8, buttonTool9, buttonTool10, buttonTool11, buttonTool12, buttonTool13, comboBoxTool2, buttonTool14, buttonTool15}); this.tbManager.UseLargeImagesOnToolbar = true; this.tbManager.ToolClick += new Infragistics.Win.UltraWinToolbars.ToolClickEventHandler(this.tbManager_ToolClick); // // _SecurityGroupInfoForm_Toolbars_Dock_Area_Right // this._SecurityGroupInfoForm_Toolbars_Dock_Area_Right.AccessibleRole = System.Windows.Forms.AccessibleRole.Grouping; this._SecurityGroupInfoForm_Toolbars_Dock_Area_Right.BackColor = System.Drawing.SystemColors.Control; this._SecurityGroupInfoForm_Toolbars_Dock_Area_Right.DockedPosition = Infragistics.Win.UltraWinToolbars.DockedPosition.Right; this._SecurityGroupInfoForm_Toolbars_Dock_Area_Right.ForeColor = System.Drawing.SystemColors.ControlText; this._SecurityGroupInfoForm_Toolbars_Dock_Area_Right.Location = new System.Drawing.Point(632, 43); this._SecurityGroupInfoForm_Toolbars_Dock_Area_Right.Name = "_SecurityGroupInfoForm_Toolbars_Dock_Area_Right"; this._SecurityGroupInfoForm_Toolbars_Dock_Area_Right.Size = new System.Drawing.Size(0, 258); this._SecurityGroupInfoForm_Toolbars_Dock_Area_Right.ToolbarsManager = this.tbManager; // // _SecurityGroupInfoForm_Toolbars_Dock_Area_Top // this._SecurityGroupInfoForm_Toolbars_Dock_Area_Top.AccessibleRole = System.Windows.Forms.AccessibleRole.Grouping; this._SecurityGroupInfoForm_Toolbars_Dock_Area_Top.BackColor = System.Drawing.SystemColors.Control; this._SecurityGroupInfoForm_Toolbars_Dock_Area_Top.DockedPosition = Infragistics.Win.UltraWinToolbars.DockedPosition.Top; this._SecurityGroupInfoForm_Toolbars_Dock_Area_Top.ForeColor = System.Drawing.SystemColors.ControlText; this._SecurityGroupInfoForm_Toolbars_Dock_Area_Top.Location = new System.Drawing.Point(0, 0); this._SecurityGroupInfoForm_Toolbars_Dock_Area_Top.Name = "_SecurityGroupInfoForm_Toolbars_Dock_Area_Top"; this._SecurityGroupInfoForm_Toolbars_Dock_Area_Top.Size = new System.Drawing.Size(632, 43); this._SecurityGroupInfoForm_Toolbars_Dock_Area_Top.ToolbarsManager = this.tbManager; // // _SecurityGroupInfoForm_Toolbars_Dock_Area_Bottom // this._SecurityGroupInfoForm_Toolbars_Dock_Area_Bottom.AccessibleRole = System.Windows.Forms.AccessibleRole.Grouping; this._SecurityGroupInfoForm_Toolbars_Dock_Area_Bottom.BackColor = System.Drawing.SystemColors.Control; this._SecurityGroupInfoForm_Toolbars_Dock_Area_Bottom.DockedPosition = Infragistics.Win.UltraWinToolbars.DockedPosition.Bottom; this._SecurityGroupInfoForm_Toolbars_Dock_Area_Bottom.ForeColor = System.Drawing.SystemColors.ControlText; this._SecurityGroupInfoForm_Toolbars_Dock_Area_Bottom.Location = new System.Drawing.Point(0, 301); this._SecurityGroupInfoForm_Toolbars_Dock_Area_Bottom.Name = "_SecurityGroupInfoForm_Toolbars_Dock_Area_Bottom"; this._SecurityGroupInfoForm_Toolbars_Dock_Area_Bottom.Size = new System.Drawing.Size(632, 0); this._SecurityGroupInfoForm_Toolbars_Dock_Area_Bottom.ToolbarsManager = this.tbManager; // // grid // this.grid.Dock = System.Windows.Forms.DockStyle.Fill; this.grid.Location = new System.Drawing.Point(0, 107); this.grid.Name = "grid"; this.grid.Size = new System.Drawing.Size(632, 194); this.grid.TabIndex = 101; this.grid.Tag = ""; this.grid.Text = "LT:UserRight.Label.List"; this.grid.InitializeRow += new Infragistics.Win.UltraWinGrid.InitializeRowEventHandler(this.grid_InitializeRow); // // SecurityGroupInfoForm // 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.panelTop); this.Controls.Add(this.ckIsDirty); this.Controls.Add(this._SecurityGroupInfoForm_Toolbars_Dock_Area_Left); this.Controls.Add(this._SecurityGroupInfoForm_Toolbars_Dock_Area_Right); this.Controls.Add(this._SecurityGroupInfoForm_Toolbars_Dock_Area_Bottom); this.Controls.Add(this._SecurityGroupInfoForm_Toolbars_Dock_Area_Top); this.helpProvider1.SetHelpKeyword(this, ""); this.helpProvider1.SetHelpNavigator(this, System.Windows.Forms.HelpNavigator.Topic); this.Name = "SecurityGroupInfoForm"; this.helpProvider1.SetShowHelp(this, true); this.ShowInTaskbar = false; this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Show; this.Closing += new System.ComponentModel.CancelEventHandler(this.SecurityGroupInfoForm_Closing); this.Load += new System.EventHandler(this.SecurityGroupInfoForm_Load); this.panelTop.ResumeLayout(false); this.panelTop.PerformLayout(); ((System.ComponentModel.ISupportInitialize)(this.edName)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.ErrorProvider)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.tbManager)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.grid)).EndInit(); this.ResumeLayout(false); } #endregion // __ _ _ ___ ____ __ __ __ __ __ ___ ___ // / _)( )( )/ __)(_ _)/ \( \/ ) / _)/ \( \( _) // ( (_ )()( \__ \ )( ( () )) ( ( (_( () )) ) )) _) // \__) \__/ (___/ (__) \__/(_/\/\_) \__)\__/(___/(___) // #region Form Load / Close //variable to hold user form settings //UIUserFormSetting mFormSetting; /// /// Prepare the form /// /// /// private void SecurityGroupInfoForm_Load(object sender, System.EventArgs e) { // // helpProvider1 // this.helpProvider1.HelpNamespace = Util.BaseHelpUrl + "security_groups_entry_screen.htm"; //case 1039 //log.Debug("SecurityGroupInfoForm_Load"); Cursor.Current = Cursors.WaitCursor; this.Visible=false; this.Icon = Resource1.SecurityGroup16icon; //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.SecurityGroup")< (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.SecurityGroup"))); this.Close(); return; } DataBind(); InitializeGrid(); Util.LoadFormCustomization("SecurityGroupInfo", this, tbManager, false); //Changed: 15-March-2005, workaround in case users have //these menu options stuck as disabled //this goes with fix below that uses visible properly instead of enabled //improperly in SyncUI tbManager.Tools["LT:UserRight.Label.SecurityLevel"].SharedProps.Enabled=true; tbManager.Tools["LT:UI.Toolbar.SecurityGroupForm.SetAll"].SharedProps.Enabled=true; tbManager.Tools["LT:UI.Command.Delete"].SharedProps.Enabled=true; Util.PluginInsertMenu(tbManager, new Util.PluginMenuOptionData(true, RootObjectTypes.SecurityGroup, mSecurityGroup, null));//case 941 //restrict UI based on security settings RestrictUI(); Util.LocalizeHelperInsertMenu(tbManager, this); //case 1810 Util.Localize(this); FillToolBarSecurityLevelList(); Cursor.Current = Cursors.Default; Application.Idle+= new EventHandler(Application_Idle); //get the localized object names retrieved if(grid.Rows.Count>0) { foreach(UltraGridRow r in grid.Rows) { r.Refresh(RefreshRow.FireInitializeRow); } } //Changed: 15-March-2005 because syncUI is no longer needed so moved this here //display group name in title bar this.Text=mSecurityGroup.Name; //Case 152 (new TabOrderManager(this)).SetTabOrder(TabOrderManager.TabScheme.AcrossFirst); this.Visible=true; } /// /// Used to track whether the close was done by the program /// or done by the user clicking on the upper left corner X control /// bool bClosingHandled=false; /// /// Save form layout and grid layout for next time /// /// /// private void SecurityGroupInfoForm_Closing(object sender, System.ComponentModel.CancelEventArgs e) { //case 1039 //log.Debug("SecurityGroupInfoForm_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("UserRights","","",grid); Util.SaveFormCustomization("SecurityGroupInfo", this, tbManager, false); } #endregion #region Form UI commands #region Toolbar menu items /// /// Respond to a click on a toolbar menu item /// /// /// 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.RecordHistory": // ButtonTool RecordHistoryForm RH=new RecordHistoryForm(mSecurityGroup.Creator,mSecurityGroup.Modifier,mSecurityGroup.Created,mSecurityGroup.Modified); RH.ShowDialog(); RH.Dispose(); break; case "LT:UI.Command.Save": // ButtonTool RecordUpdate(RecordActionType.SaveOnly); break; case "LT:UI.Command.SaveNew": // ButtonTool RecordUpdate(RecordActionType.SaveAndNew); break; case "LT:UI.Command.Close": // ButtonTool this.Close(); break; case "LT:UI.Command.Delete": // ButtonTool RecordUpdate(RecordActionType.DeleteAndExit); break; case "LT:UI.Toolbar.SecurityGroupForm.SetAll": // ButtonTool ComboBoxTool cbt = (ComboBoxTool)tbManager.Tools["LT:UserRight.Label.SecurityLevel"]; SecurityLevelTypes SelectedLevel=(SecurityLevelTypes)cbt.Value; foreach(UserRight r in this.mSecurityGroup.Rights) { r.SecurityLevel=SelectedLevel; } grid.Refresh(); break; case "LT:UI.Command.Duplicate": // ButtonTool SecurityGroupInfoForm si = new SecurityGroupInfoForm(); si.SecurityGroupToEdit = mSecurityGroup.Duplicate(); this.Visible = false; si.ShowDialog(); si.Dispose(); Close(); break; } } #endregion Toolbar menu items #endregion Form UI commands #region Form UI / Business object synchronization /// /// Synchronize the state of the UI to the BO's /// private void SyncUI() { tbManager.Tools["LT:UI.Command.Duplicate"].SharedProps.Visible = mSecurityGroup.CanDuplicate; } /// /// When the application enters an idle state /// update the UI to reflect changs in BO status /// (required because grids don't tell the UI to update when they are /// bound to a business object and are edited) /// /// /// private void Application_Idle(object sender, EventArgs e) { SyncUI(); } /// /// 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 /// private void RestrictUI() { //case 1039 //if(log.IsDebugEnabled) //case 1039 //log.Debug("RestrictUI: " + ((SecurityLevelTypes)AyaBizUtils.Right("Object.SecurityGroup")).ToString()); bool bDelete=AyaBizUtils.Right("Object.SecurityGroup")== (int)SecurityLevelTypes.ReadWriteDelete; bool bReadOnly=AyaBizUtils.Right("Object.SecurityGroup") < (int)SecurityLevelTypes.ReadWrite; //Changed: 15-March-2005 - Moved here from syncui because syncui is not necessary for this form if(mSecurityGroup.IsAyaNovaAdministrator) { bDelete=false; bReadOnly=true; } tbManager.Tools["LT:UI.Command.Delete"].SharedProps.Visible=bDelete; tbManager.Tools["LT:UI.Command.SaveClose"].SharedProps.Visible=!bReadOnly; tbManager.Tools["LT:UI.Command.SaveNew"].SharedProps.Visible=!bReadOnly; tbManager.Tools["LT:UI.Command.Save"].SharedProps.Visible=!bReadOnly; tbManager.Tools["LT:UserRight.Label.SecurityLevel"].SharedProps.Visible=!bReadOnly; tbManager.Tools["LT:UI.Toolbar.SecurityGroupForm.SetAll"].SharedProps.Visible=!bReadOnly; //Case 181 tbManager.Tools["LT:UI.Command.Close"].SharedProps.Visible=false; //Text editors edName.Enabled=!bReadOnly; //grid if(bReadOnly) { grid.DisplayLayout.Override.AllowUpdate=DefaultableBoolean.False; } else { grid.DisplayLayout.Override.AllowUpdate=DefaultableBoolean.True; } } #endregion #region Form DataBinding and BrokenRules handling /// /// Bind controls to business objects /// 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 mSecurityGroup.GetBrokenRulesCollection().ListChanged += new System.ComponentModel.ListChangedEventHandler(OnBrokenRulesChanged); //=-=-=-=-=-=- Form Field bindings =-=-=-=-=-=-=-=-=-=-=-= //Text editors Util.BindField(edName,"Text",mSecurityGroup,"Name"); //Grids Util.BindField(grid,"DataSource",mSecurityGroup,"Rights"); //=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- //Bind IsDirty property to hidden checkbox to //ensure isdirtychanged event is available //to data binding infrastructure Util.BindField(ckIsDirty,"Checked",mSecurityGroup,"IsDirty"); //Setup initial link to broken rules OnBrokenRulesChanged(null,null); //turn initialize row event back on grid.EventManager.SetEnabled(GridEventIds.InitializeRow,true); } /// /// Handle a change in broken rules /// /// /// private void OnBrokenRulesChanged(object sender, System.ComponentModel.ListChangedEventArgs e) { Util.BrokenRuleFeedback(this,mSecurityGroup,ErrorProvider); } #endregion #region Business object editing / adding / deletion related code private GZTW.AyaNova.BLL.SecurityGroup mSecurityGroup; /// /// SecurityGroup record to display /// set by caller /// public GZTW.AyaNova.BLL.SecurityGroup SecurityGroupToEdit { get { return mSecurityGroup; } set { mSecurityGroup=value; //mSecurityGroup.BeginEdit(); } } //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; } } /// /// Update record and quit if requested /// /// /// True if handled, false if not handled private bool RecordUpdate(RecordActionType SaveType) { //case 1039 //if(log.IsDebugEnabled) //case 1039 //log.Debug("SaveHandler(Action="+SaveType.ToString()+")"); //switch the focus to a non-editable control //so that any changes in the current editable control //will get updated before attempting to save lblName.Focus(); switch(SaveType) { case RecordActionType.DeleteAndExit: //ensure no deletion of AyaNova Administrator SecurityGroup if(mSecurityGroup.ID==new Guid("{FF0DE42A-0EA0-429B-9643-64355703E8D1}")) { MessageBox.Show( string.Format( Util.LocaleText.GetLocalizedText("Error.Security.NotAuthorizedToDeleteDefaultObject"), Util.LocaleText.GetLocalizedText("O.SecurityGroup"))); return false; } if(Util.PromptForDelete()==DialogResult.Yes) { //Delete, then exit try{ GZTW.AyaNova.BLL.SecurityGroup.DeleteItem(mSecurityGroup.ID); } catch(Exception ex) { Util.ReportSQLError(ex); return false; } bClosingHandled=true; this.Close(); mbChangesMade=true; return true; } else return false; case RecordActionType.SaveAndExit: //Save if necessary and exit if(mSecurityGroup.IsSavable) { mSecurityGroup.ApplyEdit(); mSecurityGroup.Save(); bClosingHandled=true; mbChangesMade=true; this.Close(); return true; } if(mSecurityGroup.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.SaveAndNew: if(mSecurityGroup.IsSavable) { mSecurityGroup.ApplyEdit(); mSecurityGroup.Save(); AddNewRecord(); mbChangesMade=true; return true; } if(mSecurityGroup.IsDirty)//dirty and unsaveable due to broken rules { //User says that's ok, continue on? if(Util.PromptForBrokenRulesCancelSave()==DialogResult.Yes) { //Ok, add new SecurityGroup and don't save old record AddNewRecord(); return true; } else return false; } //Current record isn't dirty so just add a new one AddNewRecord(); return true; case RecordActionType.SaveOnly: if(mSecurityGroup.IsSavable) { mSecurityGroup.ApplyEdit(); mSecurityGroup=(GZTW.AyaNova.BLL.SecurityGroup)mSecurityGroup.Save(); DataBind(); mbChangesMade=true; return true; } return true; case RecordActionType.PromptToSave: //Prompt to save and save if //required if(mSecurityGroup.IsDirty) { DialogResult dr=Util.PromptForSave(); if(dr==DialogResult.Cancel) { //Cancel return false; } if(dr==DialogResult.Yes) { //Save before exit if(mSecurityGroup.IsSavable) { mSecurityGroup.ApplyEdit(); mSecurityGroup.Save(); mbChangesMade=true; return true; } if(mSecurityGroup.IsDirty)//dirty and unsaveable due to broken rules { if(Util.PromptForBrokenRulesCancelSave()==DialogResult.Yes) { return true; } else return false; } } } return true; } return false; } /// /// ///Creates a new SecurityGroup record and opens it for editing /// private void AddNewRecord() { //case 1039 //log.Debug("AddNewRecord"); try { mSecurityGroup=GZTW.AyaNova.BLL.SecurityGroup.NewItem(); //mSecurityGroup.BeginEdit(); DataBind(); } catch(Exception ex) { //log.Error("AddNewRecord",ex); MessageBox.Show(ex.Message+"\r\n"+ex.Source); } } #endregion #region Initialize grid /// /// Get grid ready /// private void InitializeGrid() { //case 1039 //log.Debug("InitializeGrid"); Util.GridPreLocalize("UserRight",grid.DisplayLayout.Bands[0]); Util.FetchGridLayout("UserRights","",grid); Util.GridHideEditableBizObjectInternalFields(grid); grid.DisplayLayout.Bands[0].Columns["SecurityGroupID"].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.Bands[0].Override.RowSelectors=DefaultableBoolean.False; //Set the caption to be on the left side of the grid grid.DisplayLayout.CaptionAppearance.TextHAlign=HAlign.Left; if(grid.DisplayLayout.Bands[0].Columns.Exists("Object")) { grid.DisplayLayout.Bands[0].Columns["Object"].Header.Caption=Util.LocaleText.GetLocalizedText("UI.Label.Object"); } else { grid.DisplayLayout.Bands[0].Columns.Add("Object",Util.LocaleText.GetLocalizedText("UI.Label.Object")); } grid.DisplayLayout.Bands[0].Columns["Object"].CellActivation=Activation.ActivateOnly; grid.DisplayLayout.Bands[0].Columns["Right"].CellActivation=Activation.ActivateOnly; grid.DisplayLayout.Bands[0].Columns["SecurityLevel"].CellActivation=Activation.AllowEdit; //Populate RateTypes value list ValueList vl=grid.DisplayLayout.ValueLists.Add("SecurityLevelTypes"); vl.ValueListItems.Add(SecurityLevelTypes.NoAccess,Util.LocaleText.GetLocalizedText("SecurityLevelTypes.Label.NoAccess")); vl.ValueListItems.Add(SecurityLevelTypes.ReadOnly,Util.LocaleText.GetLocalizedText("SecurityLevelTypes.Label.ReadOnly")); vl.ValueListItems.Add(SecurityLevelTypes.ReadWrite,Util.LocaleText.GetLocalizedText("SecurityLevelTypes.Label.ReadWrite")); vl.ValueListItems.Add(SecurityLevelTypes.ReadWriteDelete,Util.LocaleText.GetLocalizedText("SecurityLevelTypes.Label.ReadWriteDelete")); //Bind value lists to correct columns in grid grid.DisplayLayout.Bands[0].Columns["SecurityLevel"].ValueList=grid.DisplayLayout.ValueLists["SecurityLevelTypes"]; //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["SecurityLevel"].Style=Infragistics.Win.UltraWinGrid.ColumnStyle.DropDownValidate;//Case 96 for autocomplete (was DropDownList) grid.DisplayLayout.Bands[0].Columns["SecurityLevel"].AutoCompleteMode = Infragistics.Win.AutoCompleteMode.SuggestAppend; // PopulateGridValueLists(); } #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 Fill tool bar security level list combo private void FillToolBarSecurityLevelList() { //case 1039 //log.Debug("FillToolBarSecurityLevelList"); ComboBoxTool cbt = (ComboBoxTool)tbManager.Tools["LT:UserRight.Label.SecurityLevel"]; cbt.AutoComplete=true; cbt.ValueList.ValueListItems.Clear(); cbt.ValueList.ValueListItems.Add(SecurityLevelTypes.NoAccess,Util.LocaleText.GetLocalizedText("SecurityLevelTypes.Label.NoAccess")); cbt.ValueList.ValueListItems.Add(SecurityLevelTypes.ReadOnly,Util.LocaleText.GetLocalizedText("SecurityLevelTypes.Label.ReadOnly")); cbt.ValueList.ValueListItems.Add(SecurityLevelTypes.ReadWrite,Util.LocaleText.GetLocalizedText("SecurityLevelTypes.Label.ReadWrite")); cbt.ValueList.ValueListItems.Add(SecurityLevelTypes.ReadWriteDelete,Util.LocaleText.GetLocalizedText("SecurityLevelTypes.Label.ReadWriteDelete")); cbt.SelectedIndex=0; } #endregion private void edName_AfterExitEditMode(object sender, System.EventArgs e) { //Changed: 15-March-2005 because syncUI is no longer needed so moved this here //display group name in title bar if it's changed this.Text=edName.Text; } #region Accelerator keys /// /// Case 37 /// /// /// /// 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 } }