435 lines
15 KiB
C#
435 lines
15 KiB
C#
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>
|
|
/// Summary description for UnitMeterReadingAddRecord.
|
|
/// </summary>
|
|
public class UnitMeterReadingAddRecord : 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 System.Windows.Forms.ErrorProvider epUnitMeterReading;
|
|
private Infragistics.Win.UltraWinEditors.UltraNumericEditor edMeter;
|
|
private Infragistics.Win.Misc.UltraLabel lblMeter;
|
|
private GZTW.WinForm.Controls.GZDateTimePicker dtMeterDate;
|
|
private Infragistics.Win.Misc.UltraLabel lblMeterDate;
|
|
private Infragistics.Win.Misc.UltraLabel lblDescription;
|
|
private Infragistics.Win.UltraWinEditors.UltraTextEditor edDescription;
|
|
private Button btnCancel;
|
|
private Button btnOK;
|
|
private IContainer components;
|
|
|
|
public UnitMeterReadingAddRecord()
|
|
{
|
|
//
|
|
// Required for Windows Form Designer support
|
|
//
|
|
InitializeComponent();
|
|
|
|
//
|
|
//
|
|
//
|
|
}
|
|
|
|
/// <summary>
|
|
/// Clean up any resources being used.
|
|
/// </summary>
|
|
protected override void Dispose( bool disposing )
|
|
{
|
|
if( disposing )
|
|
{
|
|
if(components != null)
|
|
{
|
|
components.Dispose();
|
|
}
|
|
}
|
|
base.Dispose( disposing );
|
|
}
|
|
|
|
#region Windows Form Designer generated code
|
|
/// <summary>
|
|
/// Required method for Designer support - do not modify
|
|
/// the contents of this method with the code editor.
|
|
/// </summary>
|
|
private void InitializeComponent()
|
|
{
|
|
this.components = new System.ComponentModel.Container();
|
|
this.lblDescription = new Infragistics.Win.Misc.UltraLabel();
|
|
this.edDescription = new Infragistics.Win.UltraWinEditors.UltraTextEditor();
|
|
this.edMeter = new Infragistics.Win.UltraWinEditors.UltraNumericEditor();
|
|
this.lblMeter = new Infragistics.Win.Misc.UltraLabel();
|
|
this.dtMeterDate = new GZTW.WinForm.Controls.GZDateTimePicker();
|
|
this.lblMeterDate = new Infragistics.Win.Misc.UltraLabel();
|
|
this.ckIsDirty = new System.Windows.Forms.CheckBox();
|
|
this.epUnitMeterReading = new System.Windows.Forms.ErrorProvider(this.components);
|
|
this.btnCancel = new System.Windows.Forms.Button();
|
|
this.btnOK = new System.Windows.Forms.Button();
|
|
((System.ComponentModel.ISupportInitialize)(this.edDescription)).BeginInit();
|
|
((System.ComponentModel.ISupportInitialize)(this.edMeter)).BeginInit();
|
|
((System.ComponentModel.ISupportInitialize)(this.dtMeterDate)).BeginInit();
|
|
((System.ComponentModel.ISupportInitialize)(this.epUnitMeterReading)).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(306, 19);
|
|
this.lblDescription.TabIndex = 133;
|
|
this.lblDescription.Tag = "";
|
|
this.lblDescription.Text = "LT:UnitMeterReading.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(315, 92);
|
|
this.edDescription.TabIndex = 132;
|
|
//
|
|
// edMeter
|
|
//
|
|
this.edMeter.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
|
|
| System.Windows.Forms.AnchorStyles.Right)));
|
|
this.edMeter.Location = new System.Drawing.Point(10, 148);
|
|
this.edMeter.Name = "edMeter";
|
|
this.edMeter.Size = new System.Drawing.Size(315, 24);
|
|
this.edMeter.TabIndex = 139;
|
|
//
|
|
// lblMeter
|
|
//
|
|
this.lblMeter.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
|
|
| System.Windows.Forms.AnchorStyles.Right)));
|
|
this.lblMeter.Location = new System.Drawing.Point(10, 129);
|
|
this.lblMeter.Name = "lblMeter";
|
|
this.lblMeter.Size = new System.Drawing.Size(315, 19);
|
|
this.lblMeter.TabIndex = 141;
|
|
this.lblMeter.Tag = "";
|
|
this.lblMeter.Text = "LT:UnitMeterReading.Label.Meter";
|
|
//
|
|
// dtMeterDate
|
|
//
|
|
this.dtMeterDate.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
|
|
| System.Windows.Forms.AnchorStyles.Right)));
|
|
this.dtMeterDate.GZEnabled = true;
|
|
this.dtMeterDate.GZReadOnly = false;
|
|
this.dtMeterDate.Location = new System.Drawing.Point(10, 212);
|
|
this.dtMeterDate.Name = "dtMeterDate";
|
|
this.dtMeterDate.Size = new System.Drawing.Size(315, 24);
|
|
this.dtMeterDate.TabIndex = 166;
|
|
//
|
|
// lblMeterDate
|
|
//
|
|
this.lblMeterDate.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
|
|
| System.Windows.Forms.AnchorStyles.Right)));
|
|
this.lblMeterDate.Location = new System.Drawing.Point(10, 194);
|
|
this.lblMeterDate.Name = "lblMeterDate";
|
|
this.lblMeterDate.Size = new System.Drawing.Size(315, 18);
|
|
this.lblMeterDate.TabIndex = 167;
|
|
this.lblMeterDate.Tag = "";
|
|
this.lblMeterDate.Text = "LT:UnitMeterReading.Label.MeterDate";
|
|
//
|
|
// 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;
|
|
//
|
|
// epUnitMeterReading
|
|
//
|
|
this.epUnitMeterReading.ContainerControl = this;
|
|
//
|
|
// btnCancel
|
|
//
|
|
this.btnCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
|
|
this.btnCancel.Image = global::AyaNova.Resource1.Cancel24;
|
|
this.btnCancel.Location = new System.Drawing.Point(10, 257);
|
|
this.btnCancel.Name = "btnCancel";
|
|
this.btnCancel.Size = new System.Drawing.Size(90, 41);
|
|
this.btnCancel.TabIndex = 172;
|
|
this.btnCancel.Click += new System.EventHandler(this.btnCancel_Click);
|
|
//
|
|
// btnOK
|
|
//
|
|
this.btnOK.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
|
|
this.btnOK.DialogResult = System.Windows.Forms.DialogResult.OK;
|
|
this.btnOK.Image = global::AyaNova.Resource1.OK24;
|
|
this.btnOK.Location = new System.Drawing.Point(235, 257);
|
|
this.btnOK.Name = "btnOK";
|
|
this.btnOK.Size = new System.Drawing.Size(90, 41);
|
|
this.btnOK.TabIndex = 171;
|
|
this.btnOK.Click += new System.EventHandler(this.btnOK_Click);
|
|
//
|
|
// UnitMeterReadingAddRecord
|
|
//
|
|
this.AcceptButton = this.btnOK;
|
|
this.AutoScaleBaseSize = new System.Drawing.Size(6, 15);
|
|
this.CancelButton = this.btnCancel;
|
|
this.ClientSize = new System.Drawing.Size(346, 336);
|
|
this.Controls.Add(this.btnCancel);
|
|
this.Controls.Add(this.btnOK);
|
|
this.Controls.Add(this.ckIsDirty);
|
|
this.Controls.Add(this.dtMeterDate);
|
|
this.Controls.Add(this.lblMeterDate);
|
|
this.Controls.Add(this.lblMeter);
|
|
this.Controls.Add(this.edMeter);
|
|
this.Controls.Add(this.lblDescription);
|
|
this.Controls.Add(this.edDescription);
|
|
this.MinimumSize = new System.Drawing.Size(294, 360);
|
|
this.Name = "UnitMeterReadingAddRecord";
|
|
this.ShowInTaskbar = false;
|
|
this.Text = "LT:O.UnitMeterReading";
|
|
this.Closing += new System.ComponentModel.CancelEventHandler(this.UnitMeterReadingAddRecord_Closing);
|
|
this.Load += new System.EventHandler(this.UnitMeterReadingAddRecord_Load);
|
|
((System.ComponentModel.ISupportInitialize)(this.edDescription)).EndInit();
|
|
((System.ComponentModel.ISupportInitialize)(this.edMeter)).EndInit();
|
|
((System.ComponentModel.ISupportInitialize)(this.dtMeterDate)).EndInit();
|
|
((System.ComponentModel.ISupportInitialize)(this.epUnitMeterReading)).EndInit();
|
|
this.ResumeLayout(false);
|
|
this.PerformLayout();
|
|
|
|
}
|
|
#endregion
|
|
|
|
|
|
// __ _ _ ___ ____ __ __ __ __ __ ___ ___
|
|
// / _)( )( )/ __)(_ _)/ \( \/ ) / _)/ \( \( _)
|
|
// ( (_ )()( \__ \ )( ( () )) ( ( (_( () )) ) )) _)
|
|
// \__) \__/ (___/ (__) \__/(_/\/\_) \__)\__/(___/(___)
|
|
//
|
|
|
|
#region Load / close
|
|
|
|
//variable to hold user form settings
|
|
//UIUserFormSetting mFormSetting;
|
|
|
|
private void UnitMeterReadingAddRecord_Load(object sender, System.EventArgs e)
|
|
{
|
|
//case 1039 //log.Debug("UnitMeterReadingAddRecord_Load");
|
|
|
|
//dtMeterDate.MaskInput=Util.LocaleDateTimeMask();
|
|
Cursor.Current = Cursors.WaitCursor;
|
|
this.Visible=false;
|
|
this.Icon = Resource1.UnitMeterReading16icon;
|
|
|
|
Util.Localize(this);
|
|
|
|
DataBind();
|
|
Util.LoadFormCustomization("UnitMeterReadingAddRecord", this, null, false);
|
|
|
|
|
|
this.Visible=true;
|
|
|
|
//Case 152
|
|
(new TabOrderManager(this)).SetTabOrder(TabOrderManager.TabScheme.AcrossFirst);
|
|
|
|
Cursor.Current = Cursors.Default;
|
|
}
|
|
|
|
|
|
private void UnitMeterReadingAddRecord_Closing(object sender, System.ComponentModel.CancelEventArgs e)
|
|
{
|
|
//case 1039 //log.Debug("UnitMeterReadingAddRecord_Closing");
|
|
Util.SaveFormCustomization("UnitMeterReadingAddRecord", this, null, false);
|
|
|
|
}
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
#region Form DataBinding and BrokenRules handling
|
|
|
|
|
|
/// <summary>
|
|
/// Bind controls to business objects
|
|
/// </summary>
|
|
private void DataBind()
|
|
{
|
|
//case 1039 //log.Debug("DataBind");
|
|
|
|
//Subscribe to broken rules changed event OnBrokenRulesChanged
|
|
mUnitMeterReading.GetBrokenRulesCollection().ListChanged += new System.ComponentModel.ListChangedEventHandler(OnBrokenRulesChanged);
|
|
|
|
|
|
//=-=-=-=-=-=- Form Field bindings =-=-=-=-=-=-=-=-=-=-=-=
|
|
// mUnitMeterReading.UnitID=mUnitID;
|
|
// mUnitMeterReading.WorkorderItemID=mWorkorderItemID;
|
|
|
|
//Text editors
|
|
Util.BindField(edDescription,"Text",mUnitMeterReading,"Description");
|
|
Util.BindField(edMeter,"Value",mUnitMeterReading,"Meter");
|
|
Util.BindField(dtMeterDate,"Value",mUnitMeterReading,"MeterDate");
|
|
//=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
|
|
|
|
//Bind IsDirty property to hidden checkbox to
|
|
//ensure isdirtychanged event is available
|
|
//to data binding infrastructure
|
|
Util.BindField(ckIsDirty,"Checked",mUnitMeterReading,"IsDirty");
|
|
|
|
//Setup initial link to broken rules
|
|
OnBrokenRulesChanged(null,null);
|
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// Handle a change in broken rules
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
private void OnBrokenRulesChanged(object sender, System.ComponentModel.ListChangedEventArgs e)
|
|
{
|
|
Util.BrokenRuleFeedback(this,mUnitMeterReading,epUnitMeterReading);
|
|
|
|
}
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
#region Business object editing / adding / deletion related code
|
|
|
|
|
|
private UnitMeterReading mUnitMeterReading;
|
|
public UnitMeterReading UnitMeterReadingToEdit
|
|
{
|
|
set
|
|
{
|
|
mUnitMeterReading=value;
|
|
//mUnitMeterReading.BeginEdit();
|
|
}
|
|
}
|
|
|
|
|
|
// private Guid mUnitID=Guid.Empty;
|
|
// public Guid UnitID
|
|
// {
|
|
// set
|
|
// {
|
|
// mUnitID=value;
|
|
//
|
|
// }
|
|
// }
|
|
//
|
|
//
|
|
// private Guid mWorkorderItemID=Guid.Empty;
|
|
// public Guid WorkorderItemID
|
|
// {
|
|
// set
|
|
// {
|
|
// mWorkorderItemID=value;
|
|
// }
|
|
// }
|
|
|
|
|
|
/// <summary>
|
|
/// Save record and process
|
|
///
|
|
/// </summary>
|
|
/// <returns>True if handled, false if not handled</returns>
|
|
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
|
|
btnOK.Focus();
|
|
|
|
switch(SaveType)
|
|
{
|
|
case RecordActionType.SaveAndExit:
|
|
//Save if necessary and exit
|
|
if(mUnitMeterReading.IsSavable)
|
|
{
|
|
mUnitMeterReading.ApplyEdit();
|
|
mUnitMeterReading.Save();
|
|
this.DialogResult=DialogResult.OK;
|
|
this.Close();
|
|
return true;
|
|
}
|
|
if(mUnitMeterReading.IsDirty)//dirty and unsaveable due to broken rules
|
|
{
|
|
if(Util.PromptForBrokenRulesCancelSave()==DialogResult.Yes)
|
|
{
|
|
//mUnitMeterReading.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 btnOK_Click(object sender, EventArgs e)
|
|
{
|
|
//case 1039 //log.Debug("btnOK_Click");
|
|
SaveHandler(RecordActionType.SaveAndExit);
|
|
|
|
}
|
|
|
|
private void btnCancel_Click(object sender, EventArgs e)
|
|
{
|
|
//case 1039 //log.Debug("btnCancel_Click");
|
|
|
|
//mUnitMeterReading.CancelEdit();
|
|
this.DialogResult = DialogResult.Cancel;
|
|
this.Close();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//------------------------END OF CLASS------------------------
|
|
}
|
|
}
|