| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332 |
- /*******************************************************************************
- * Copyright(c) 2014 DongkeSoft All rights reserved. / Confidential
- * 类的信息:
- * 1.程序名称:F_MST_0602.cs
- * 2.功能描述:新建/编辑温湿计信息
- * 编辑履历:
- * 作者 日期 版本 修改内容
- * 任海 2014/12/25 1.00 新建
- *******************************************************************************/
- using System;
- using System.Data;
- using System.Windows.Forms;
- using Dongke.IBOSS.PRD.Basics.BaseControls;
- using Dongke.IBOSS.PRD.Basics.BaseResources;
- using Dongke.IBOSS.PRD.Client.CommonModule;
- using Dongke.IBOSS.PRD.WCF.DataModels;
- using Dongke.IBOSS.PRD.WCF.Proxys;
- using Dongke.IBOSS.PRD.WCF.Proxys.SystemModuleService;
- namespace Dongke.IBOSS.PRD.Client.SystemModule
- {
- /// <summary>
- /// 新建/编辑温湿计信息
- /// </summary>
- public partial class F_MST_0602 : FormBase
- {
- #region 成员变量
- //页面状态
- private Constant.FormMode _formStatus;
- // 温湿计ID
- private int? _formThermometerID;
- // 当前编辑实体
- private ThermometerEntity _thermometerEntity = new ThermometerEntity();
- #endregion
- #region 构造函数
- public F_MST_0602(Constant.FormMode status, int ThermometerID)
- {
- InitializeComponent();
- this._formStatus = status;
- this._formThermometerID = ThermometerID;
- if (this._formStatus == Constant.FormMode.Add)
- {
- this.Text = FormTitles.F_MST_0602_ADD;
- }
- else
- {
- this.Text = FormTitles.F_MST_0602_EDIT;
- }
- this.btnSave.Text = ButtonText.BTN_SAVE;
- this.btnCancel.Text = ButtonText.BTN_CLOSE;
- }
- #endregion
- #region 事件处理
- /// <summary>
- /// 页面加载事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void F_MST_0602_Load(object sender, System.EventArgs e)
- {
- try
- {
- //如果是修改,要绑定选中的信息
- if (this._formStatus == Constant.FormMode.Edit)
- {
- this.BindPage();
- }
- //如果是新建,选项默认值设定
- if (this._formStatus == Constant.FormMode.Add)
- {
- this.cbValueFlag.Checked = true;
- }
- this.txtBuildingNo.Focus();
- }
- catch (Exception ex)
- {
- // 对异常进行共通处理
- ExceptionManager.HandleEventException(this.ToString(),
- System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
- }
- }
- /// <summary>
- /// 提交操作
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void btnSave_Click(object sender, System.EventArgs e)
- {
- try
- {
- //基础数据验证
- int ErrorId = ValidationText();
- if (ErrorId != Constant.INT_IS_ZERO)
- {
- string errorAddress = "";
- switch (ErrorId)
- {
- case 1:
- this.txtBuildingNo.Focus();
- errorAddress = "楼号";
- break;
- case 3:
- this.txtFloorNo.Focus();
- errorAddress = "楼层";
- break;
- case 6:
- this.txtLocationCode.Focus();
- errorAddress = "位置编码";
- break;
- case 7:
- this.txtManagerName.Focus();
- errorAddress = "责任人";
- break;
- default:
- break;
- };
- MessageBox.Show(string.Format(Messages.MSG_CMN_W005, errorAddress),
- this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
- return;
- }
- //为实体绑定属性
- this.BindEntity();
- if (this._formStatus == Constant.FormMode.Add)
- {
- int MyReturn = (int)DoAsync(new BaseAsyncMethod(() =>
- {
- return SystemModuleProxy.Service.AddThermometerEntity(this._thermometerEntity);
- }));
- if (MyReturn == Constant.INT_IS_ONE)
- {
- MessageBox.Show(string.Format(Messages.MSG_CMN_I001, "温湿计信息", "保存"),
- this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
- this.PageInitialization();
- }
- else
- {
- MessageBox.Show(string.Format(Messages.MSG_CMN_W001, "温湿计信息", "保存"),
- this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
- }
- }
- else if (this._formStatus == Constant.FormMode.Edit)
- {
- int MyReturn = (int)DoAsync(new BaseAsyncMethod(() =>
- {
- return SystemModuleProxy.Service.UpdateThermometerEntity(this._thermometerEntity);
- }));
- if (MyReturn == Constant.INT_IS_ONE)
- {
- MessageBox.Show(string.Format(Messages.MSG_CMN_I001, "温湿计信息", "编辑"),
- this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
- this.Close();
- }
- else
- {
- MessageBox.Show(string.Format(Messages.MSG_CMN_W001, "温湿计信息", "编辑"),
- this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
- }
- }
- }
- catch (Exception ex)
- {
- // 对异常进行共通处理
- ExceptionManager.HandleEventException(this.ToString(),
- System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
- }
- }
- /// <summary>
- /// 窗体关闭
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void btnCancel_Click(object sender, System.EventArgs e)
- {
- this.DialogResult = DialogResult.OK;
- }
- /// <summary>
- /// 楼号变更
- /// </summary>
- private void txtBuildingNo_TextChanged(object sender, EventArgs e)
- {
- this.txtThermometerCode.Text = this.txtBuildingNo.Text + this.txtFloorNo.Text.PadLeft(2, '0')
- + "-" + this.txtLocationCode.Text.Trim();
- }
- /// <summary>
- /// 楼层变更
- /// </summary>
- private void txtFloorNo_TextChanged(object sender, EventArgs e)
- {
- this.txtThermometerCode.Text = this.txtBuildingNo.Text + this.txtFloorNo.Text.PadLeft(2, '0')
- + "-" + this.txtLocationCode.Text.Trim();
- }
- /// <summary>
- /// 位置变更
- /// </summary>
- private void txtLocationCode_TextChanged(object sender, EventArgs e)
- {
- this.txtThermometerCode.Text = this.txtBuildingNo.Text + this.txtFloorNo.Text.PadLeft(2, '0')
- + "-" + this.txtLocationCode.Text.Trim();
- }
- #endregion
- #region 私有方法/函数
- /// <summary>
- /// 绑定需要操作的实体信息
- /// </summary>
- private void BindPage()
- {
- try
- {
- if (this._formThermometerID != 0 && this._formThermometerID != null)
- {
- this._thermometerEntity.ThermometerID = this._formThermometerID;
- DataSet srEntity = SystemModuleProxy.Service.GetThermometer(_thermometerEntity);
- if (srEntity != null && srEntity.Tables.Count != 0
- && srEntity.Tables[0].Rows.Count != 0)
- {
- DataSet dsEntityData = (DataSet)srEntity;
- DataRow drEntityRow = dsEntityData.Tables[0].Rows[0];
- this.txtBuildingNo.Text = drEntityRow["BuildingNo"].ToString();
- this.txtFloorNo.Text = drEntityRow["FloorNo"].ToString();
- this.txtLocationCode.Text = drEntityRow["LocationCode"].ToString();
- this.txtThermometerCode.Text = drEntityRow["ThermometerCode"].ToString();
- this.txtManagerName.Text = drEntityRow["ManagerName"].ToString();
- this.txtRemarks.Text = drEntityRow["Remarks"].ToString();
- if (Convert.ToInt32(drEntityRow["ValueFlag"]) == Constant.INT_IS_ONE)
- {
- this.cbValueFlag.Checked = true;
- }
- else
- {
- this.cbValueFlag.Checked = false;
- }
- //将时间戳给到要修改的实体中
- this._thermometerEntity.OPTimeStamp = Convert.ToDateTime(drEntityRow["OPTimeStamp"]);
- }
- }
- }
- catch (Exception ex)
- {
- // 对异常进行共通处理
- ExceptionManager.HandleEventException(this.ToString(),
- System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
- }
- }
- /// <summary>
- /// 为实体绑定页面属性
- /// </summary>
- private void BindEntity()
- {
- try
- {
- this._thermometerEntity.BuildingNo = this.txtBuildingNo.Text.Trim();
- this._thermometerEntity.FloorNo = this.txtFloorNo.Text.Trim();
- this._thermometerEntity.LocationCode = this.txtLocationCode.Text.Trim();
- this._thermometerEntity.ManagerName = this.txtManagerName.Text.Trim();
- this._thermometerEntity.Remarks = this.txtRemarks.Text.Trim();
- this._thermometerEntity.ThermometerCode = this.txtThermometerCode.Text.Trim();
- if (this.cbValueFlag.Checked)
- {
- this._thermometerEntity.ValueFlag = 1;
- }
- else
- {
- this._thermometerEntity.ValueFlag = 0;
- }
- }
- catch (Exception ex)
- {
- // 对异常进行共通处理
- ExceptionManager.HandleEventException(this.ToString(),
- System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
- }
- }
- /// <summary>
- /// 页面控件初始化
- /// </summary>
- private void PageInitialization()
- {
- this.txtBuildingNo.Text = string.Empty;
- this.txtFloorNo.Text = string.Empty;
- this.txtLocationCode.Text = string.Empty;
- this.txtManagerName.Text = string.Empty;
- this.txtRemarks.Text = string.Empty;
- this.txtThermometerCode.Text = string.Empty;
- }
- /// <summary>
- /// 验证添加项
- /// </summary>
- private int ValidationText()
- {
- int ErrorID = 0;
- if (this.txtBuildingNo.Text == string.Empty)
- {
- ErrorID = 1;
- }
- if (this.txtFloorNo.Text == string.Empty)
- {
- ErrorID = 3;
- }
- if (this.txtLocationCode.Text == string.Empty)
- {
- ErrorID = 6;
- }
- if (this.txtManagerName.Text == string.Empty)
- {
- ErrorID = 7;
- }
- return ErrorID;
- }
- #endregion
- }
- }
|