using System; using System.Drawing; using System.Collections; using System.ComponentModel; using System.Windows.Forms; using GZTW.AyaNova.BLL; using Infragistics.Win; using log4net; namespace AyaNova { /// /// Summary description for ServiceBankAddRecord. /// public class ServiceBankAddRecord : 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 GZTW.WinForm.Controls.GZDateTimePicker dtEffectiveDate; private Infragistics.Win.Misc.UltraLabel lblDescription; private Infragistics.Win.UltraWinEditors.UltraTextEditor edDescription; private Infragistics.Win.Misc.UltraLabel lblCurrency; private Infragistics.Win.UltraWinEditors.UltraCurrencyEditor edCurrency; private Infragistics.Win.UltraWinEditors.UltraNumericEditor edHours; private Infragistics.Win.Misc.UltraLabel lblHours; private Infragistics.Win.Misc.UltraLabel lblIncidents; private Infragistics.Win.UltraWinEditors.UltraNumericEditor edIncidents; private Infragistics.Win.Misc.UltraLabel lblEffectiveDate; private System.Windows.Forms.CheckBox ckIsDirty; private System.Windows.Forms.ErrorProvider epServiceBank; private Button button1; private Button button2; private IContainer components; public ServiceBankAddRecord() { // // 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(); this.lblDescription = new Infragistics.Win.Misc.UltraLabel(); this.edDescription = new Infragistics.Win.UltraWinEditors.UltraTextEditor(); this.lblCurrency = new Infragistics.Win.Misc.UltraLabel(); this.edCurrency = new Infragistics.Win.UltraWinEditors.UltraCurrencyEditor(); this.edHours = new Infragistics.Win.UltraWinEditors.UltraNumericEditor(); this.edIncidents = new Infragistics.Win.UltraWinEditors.UltraNumericEditor(); this.lblHours = new Infragistics.Win.Misc.UltraLabel(); this.lblIncidents = new Infragistics.Win.Misc.UltraLabel(); this.dtEffectiveDate = new GZTW.WinForm.Controls.GZDateTimePicker(); this.lblEffectiveDate = new Infragistics.Win.Misc.UltraLabel(); this.ckIsDirty = new System.Windows.Forms.CheckBox(); this.epServiceBank = new System.Windows.Forms.ErrorProvider(this.components); this.button1 = new System.Windows.Forms.Button(); this.button2 = new System.Windows.Forms.Button(); ((System.ComponentModel.ISupportInitialize)(this.edDescription)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.edCurrency)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.edHours)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.edIncidents)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.dtEffectiveDate)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.epServiceBank)).BeginInit(); this.SuspendLayout(); // // lblDescription // this.lblDescription.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); this.lblDescription.Location = new System.Drawing.Point(10, 9); this.lblDescription.Name = "lblDescription"; this.lblDescription.Size = new System.Drawing.Size(232, 19); this.lblDescription.TabIndex = 133; this.lblDescription.Tag = ""; this.lblDescription.Text = "LT:ServiceBank.Label.Description"; // // edDescription // this.edDescription.AcceptsReturn = true; this.edDescription.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); this.edDescription.Location = new System.Drawing.Point(10, 28); this.edDescription.Multiline = true; this.edDescription.Name = "edDescription"; this.edDescription.Size = new System.Drawing.Size(242, 92); this.edDescription.TabIndex = 132; // // lblCurrency // this.lblCurrency.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); this.lblCurrency.Location = new System.Drawing.Point(10, 138); this.lblCurrency.Name = "lblCurrency"; this.lblCurrency.Size = new System.Drawing.Size(242, 19); this.lblCurrency.TabIndex = 136; this.lblCurrency.Tag = ""; this.lblCurrency.Text = "LT:ServiceBank.Label.Currency"; // // edCurrency // this.edCurrency.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); this.edCurrency.Location = new System.Drawing.Point(10, 157); this.edCurrency.MaskInput = "{LOC}$ -n,nnn,nnn.nn"; this.edCurrency.Name = "edCurrency"; this.edCurrency.Size = new System.Drawing.Size(242, 24); this.edCurrency.TabIndex = 137; // // edHours // this.edHours.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); this.edHours.Location = new System.Drawing.Point(10, 212); this.edHours.MaskInput = "{LOC}-nnnnnnnnnn.nn"; this.edHours.Name = "edHours"; this.edHours.NumericType = Infragistics.Win.UltraWinEditors.NumericType.Double; this.edHours.Size = new System.Drawing.Size(242, 24); this.edHours.TabIndex = 138; // // edIncidents // this.edIncidents.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); this.edIncidents.Location = new System.Drawing.Point(10, 268); this.edIncidents.MaskInput = "{LOC}-nnnnnnnnnn.nn"; this.edIncidents.Name = "edIncidents"; this.edIncidents.NumericType = Infragistics.Win.UltraWinEditors.NumericType.Double; this.edIncidents.Size = new System.Drawing.Size(242, 24); this.edIncidents.TabIndex = 139; // // lblHours // this.lblHours.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); this.lblHours.Location = new System.Drawing.Point(10, 194); this.lblHours.Name = "lblHours"; this.lblHours.Size = new System.Drawing.Size(242, 18); this.lblHours.TabIndex = 140; this.lblHours.Tag = ""; this.lblHours.Text = "LT:ServiceBank.Label.Hours"; // // lblIncidents // this.lblIncidents.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); this.lblIncidents.Location = new System.Drawing.Point(10, 249); this.lblIncidents.Name = "lblIncidents"; this.lblIncidents.Size = new System.Drawing.Size(242, 19); this.lblIncidents.TabIndex = 141; this.lblIncidents.Tag = ""; this.lblIncidents.Text = "LT:ServiceBank.Label.Incidents"; // // dtEffectiveDate // this.dtEffectiveDate.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); this.dtEffectiveDate.GZEnabled = true; this.dtEffectiveDate.GZReadOnly = false; this.dtEffectiveDate.Location = new System.Drawing.Point(10, 332); this.dtEffectiveDate.Name = "dtEffectiveDate"; this.dtEffectiveDate.Size = new System.Drawing.Size(242, 24); this.dtEffectiveDate.TabIndex = 166; // // lblEffectiveDate // this.lblEffectiveDate.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); this.lblEffectiveDate.Location = new System.Drawing.Point(10, 314); this.lblEffectiveDate.Name = "lblEffectiveDate"; this.lblEffectiveDate.Size = new System.Drawing.Size(242, 18); this.lblEffectiveDate.TabIndex = 167; this.lblEffectiveDate.Tag = ""; this.lblEffectiveDate.Text = "LT:ServiceBank.Label.EffectiveDate"; // // ckIsDirty // this.ckIsDirty.Location = new System.Drawing.Point(-374, 231); this.ckIsDirty.Name = "ckIsDirty"; this.ckIsDirty.Size = new System.Drawing.Size(129, 27); this.ckIsDirty.TabIndex = 168; // // epServiceBank // this.epServiceBank.ContainerControl = this; // // button1 // this.button1.DialogResult = System.Windows.Forms.DialogResult.Cancel; this.button1.Image = global::AyaNova.Resource1.Cancel24; this.button1.Location = new System.Drawing.Point(10, 393); this.button1.Name = "button1"; this.button1.Size = new System.Drawing.Size(90, 41); this.button1.TabIndex = 170; this.button1.Click += new System.EventHandler(this.button1_Click); // // button2 // this.button2.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); this.button2.DialogResult = System.Windows.Forms.DialogResult.OK; this.button2.Image = global::AyaNova.Resource1.OK24; this.button2.Location = new System.Drawing.Point(162, 393); this.button2.Name = "button2"; this.button2.Size = new System.Drawing.Size(90, 41); this.button2.TabIndex = 169; this.button2.Click += new System.EventHandler(this.button2_Click); // // ServiceBankAddRecord // this.AcceptButton = this.button2; this.AutoScaleBaseSize = new System.Drawing.Size(6, 15); this.CancelButton = this.button1; this.ClientSize = new System.Drawing.Size(277, 452); this.Controls.Add(this.button1); this.Controls.Add(this.button2); this.Controls.Add(this.ckIsDirty); this.Controls.Add(this.dtEffectiveDate); this.Controls.Add(this.lblEffectiveDate); this.Controls.Add(this.lblIncidents); this.Controls.Add(this.lblHours); this.Controls.Add(this.edIncidents); this.Controls.Add(this.edHours); this.Controls.Add(this.edCurrency); this.Controls.Add(this.lblCurrency); this.Controls.Add(this.lblDescription); this.Controls.Add(this.edDescription); this.MinimumSize = new System.Drawing.Size(289, 489); this.Name = "ServiceBankAddRecord"; this.ShowInTaskbar = false; this.Text = "LT:O.ServiceBank"; this.Closing += new System.ComponentModel.CancelEventHandler(this.ServiceBankAddRecord_Closing); this.Load += new System.EventHandler(this.ServiceBankAddRecord_Load); ((System.ComponentModel.ISupportInitialize)(this.edDescription)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.edCurrency)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.edHours)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.edIncidents)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.dtEffectiveDate)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.epServiceBank)).EndInit(); this.ResumeLayout(false); this.PerformLayout(); } #endregion // __ _ _ ___ ____ __ __ __ __ __ ___ ___ // / _)( )( )/ __)(_ _)/ \( \/ ) / _)/ \( \( _) // ( (_ )()( \__ \ )( ( () )) ( ( (_( () )) ) )) _) // \__) \__/ (___/ (__) \__/(_/\/\_) \__)\__/(___/(___) // #region Load / close //variable to hold user form settings //UIUserFormSetting mFormSetting; private void ServiceBankAddRecord_Load(object sender, System.EventArgs e) { //case 1039 //log.Debug("ServiceBankAddRecord_Load"); //dtEffectiveDate.MaskInput=Util.LocaleDateTimeMask(); Cursor.Current = Cursors.WaitCursor; this.Visible=false; this.Icon = Resource1.BankedService16icon; Util.LoadFormCustomization("ServiceBankAddRecord", this, null, false); Util.Localize(this); DataBind(); this.Visible=true; //Case 152 (new TabOrderManager(this)).SetTabOrder(TabOrderManager.TabScheme.AcrossFirst); Cursor.Current = Cursors.Default; } private void ServiceBankAddRecord_Closing(object sender, System.ComponentModel.CancelEventArgs e) { //case 1039 //log.Debug("ServiceBankAddRecord_Closing"); Util.SaveFormCustomization("ServiceBankAddRecord", this, null, false); } #endregion #region Form DataBinding and BrokenRules handling /// /// Bind controls to business objects /// private void DataBind() { //case 1039 //log.Debug("DataBind"); //Subscribe to broken rules changed event OnBrokenRulesChanged mServiceBank.GetBrokenRulesCollection().ListChanged += new System.ComponentModel.ListChangedEventHandler(OnBrokenRulesChanged); //=-=-=-=-=-=- Form Field bindings =-=-=-=-=-=-=-=-=-=-=-= //Text editors Util.BindField(edDescription,"Text",mServiceBank,"Description"); Util.BindField(edCurrency,"Value",mServiceBank,"Currency"); Util.BindField(edHours,"Value",mServiceBank,"Hours"); Util.BindField(edIncidents,"Value",mServiceBank,"Incidents"); Util.BindField(dtEffectiveDate,"Value",mServiceBank,"EffectiveDate"); //=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- //Bind IsDirty property to hidden checkbox to //ensure isdirtychanged event is available //to data binding infrastructure Util.BindField(ckIsDirty,"Checked",mServiceBank,"IsDirty"); //Setup initial link to broken rules OnBrokenRulesChanged(null,null); } /// /// Handle a change in broken rules /// /// /// private void OnBrokenRulesChanged(object sender, System.ComponentModel.ListChangedEventArgs e) { Util.BrokenRuleFeedback(this,mServiceBank,epServiceBank); } #endregion #region Business object editing / adding / deletion related code private ServiceBank mServiceBank; public ServiceBank ServiceBankToEdit { set { mServiceBank=value; //mServiceBank.BeginEdit(); } } /// /// Save record and process /// /// /// True if handled, false if not handled private bool SaveHandler(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 this.button2.Focus(); switch(SaveType) { case RecordActionType.SaveAndExit: //Save if necessary and exit if(mServiceBank.IsSavable) { mServiceBank.ApplyEdit(); mServiceBank.Save(); this.DialogResult=DialogResult.OK; this.Close(); return true; } if(mServiceBank.IsDirty)//dirty and unsaveable due to broken rules { if(Util.PromptForBrokenRulesCancelSave()==DialogResult.Yes) { //mServiceBank.CancelEdit(); this.DialogResult=DialogResult.Cancel; this.Close(); return true; } else return false; } //not dirty so just exit this.DialogResult=DialogResult.Cancel; this.Close(); break; } return false; } #endregion private void button2_Click(object sender, EventArgs e) { //case 1039 //log.Debug("btnOK_Click"); SaveHandler(RecordActionType.SaveAndExit); } private void button1_Click(object sender, EventArgs e) { //case 1039 //log.Debug("btnCancel_Click"); //mServiceBank.CancelEdit(); this.DialogResult = DialogResult.Cancel; this.Close(); } //------------------------END OF CLASS------------------------ } }