| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376 |
- /*******************************************************************************
- * Copyright(c) 2014 DongkeSoft All rights reserved. / Confidential
- * 类的信息:
- * 1.程序名称:F_PM_1701.cs
- * 2.功能描述:温湿度记录
- * 编辑履历:
- * 作者 日期 版本 修改内容
- * 庄天威 2014/09/17 1.00 新建
- *******************************************************************************/
- using System;
- using System.Collections.Generic;
- using System.Data;
- using System.Windows.Forms;
- using Dongke.IBOSS.PRD.Basics.BaseResources;
- using Dongke.IBOSS.PRD.Basics.DockPanel;
- using Dongke.IBOSS.PRD.WCF.Proxys;
- using Dongke.IBOSS.PRD.WCF.Proxys.PMModuleService;
- using Dongke.IBOSS.PRD.WCF.Proxys.SystemModuleService;
- using Dongke.IBOSS.PRD.Client.CommonModule;
- using Dongke.IBOSS.PRD.WCF.DataModels;
- namespace Dongke.IBOSS.PRD.Client.PMModule
- {
- public partial class F_PM_1701 : DockPanelBase
- {
- #region 成员变量
- //单例模式
- private static F_PM_1701 _instance;
- #endregion
- #region 构造函数
- public F_PM_1701()
- {
- InitializeComponent();
- }
- #endregion
- #region 单例模式
- /// <summary>
- /// 单例模式,防止重复创建窗体
- /// </summary>
- public static F_PM_1701 Instance
- {
- get
- {
- if (_instance == null)
- {
- _instance = new F_PM_1701();
- }
- return _instance;
- }
- }
- #endregion
- #region 事件
- /// <summary>
- /// 窗体加载
- /// </summary>
- private void F_PM_1701_Load(object sender, EventArgs e)
- {
- // 加载权限
- FormPermissionManager.FormPermissionControl(this.Name, this,
- Dongke.IBOSS.PRD.Client.DataModels.LogInUserInfo.CurrentUser.CurrentUserEntity.UserRightData,
- Dongke.IBOSS.PRD.Client.DataModels.LogInUserInfo.CurrentUser.CurrentUserEntity.FunctionData);
- this.dgvCelsiusRecord.AutoGenerateColumns = false;
- this.Text = FormTitles.F_PM_1701;
- }
- /// <summary>
- /// 获取数据
- /// </summary>
- private void btnSearch_Click(object sender, System.EventArgs e)
- {
- try
- {
- DataSet dsThermometer = (DataSet)DoAsync(new Dongke.IBOSS.PRD.Basics.DockPanel.AsyncMethod(() =>
- {
- return this.GetCelsiusRecord();
- }));
- if (dsThermometer != null)
- {
- if (dsThermometer.Tables.Count != Constant.INT_IS_ZERO)
- {
- this.dgvCelsiusRecord.DataSource = ((DataSet)dsThermometer).Tables[Constant.INT_IS_ZERO];
- this.dgvCelsiusRecord.ReadOnly = true;
- if (this.dgvCelsiusRecord.Rows.Count == Constant.INT_IS_ZERO)
- {
- // 提示未查找到数据
- MessageBox.Show(Messages.MSG_CMN_I002, this.Text,
- MessageBoxButtons.OK, MessageBoxIcon.Information);
- }
- }
- }
- else
- {
- this.dgvCelsiusRecord.DataSource = null;
- // 提示未查找到数据
- MessageBox.Show(Messages.MSG_CMN_I002, this.Text,
- MessageBoxButtons.OK, MessageBoxIcon.Warning);
- }
- }
- catch (Exception ex)
- {
- // 对异常进行共通处理
- ExceptionManager.HandleEventException(this.ToString(),
- System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
- }
- }
- /// <summary>
- /// 清空条件
- /// </summary>
- private void btnClearCondition_Click(object sender, EventArgs e)
- {
- this.txtRemarks.Text = "";
- this.dkThermometer.Text = "";
- this.dkThermometer.ThermometerID = null;
- }
- /// <summary>
- /// 窗体关闭
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void F_PM_1701_FormClosed(object sender, FormClosedEventArgs e)
- {
- _instance = null;
- }
- /// <summary>
- /// 新建信息
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void tsbtnAdd_Click(object sender, EventArgs e)
- {
- try
- {
- F_PM_1702 frmFPM1702 = new F_PM_1702(Constant.FormMode.Add, DateTime.Now);
- DialogResult dialogresult = frmFPM1702.ShowDialog();
- if (dialogresult.Equals(DialogResult.OK))
- {
- this.dgvCelsiusRecord.DataSource = null;
- DataSet dsCelsiusRecord = (DataSet)DoAsync(new Dongke.IBOSS.PRD.Basics.DockPanel.AsyncMethod(() =>
- {
- return this.GetCelsiusRecord();
- }));
- if (dsCelsiusRecord != null)
- {
- if (dsCelsiusRecord.Tables.Count != Constant.INT_IS_ZERO)
- {
- this.dgvCelsiusRecord.DataSource = ((DataSet)dsCelsiusRecord).Tables[Constant.INT_IS_ZERO];
- this.dgvCelsiusRecord.ReadOnly = true;
- }
- }
- else
- {
- this.dgvCelsiusRecord.DataSource = null;
- }
- }
- }
- 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 tsbtnEdit_Click(object sender, EventArgs e)
- {
- try
- {
- DataGridViewRow currentRow = this.dgvCelsiusRecord.CurrentRow;
- if (currentRow != null)
- {
- DateTime recordTime = Convert.ToDateTime(currentRow.Cells["RecordDate"].Value);
- F_PM_1702 frmFPM1702 = new F_PM_1702(Constant.FormMode.Edit, recordTime);
- DialogResult dialogresult = frmFPM1702.ShowDialog();
- if (dialogresult.Equals(DialogResult.OK))
- {
- this.dgvCelsiusRecord.DataSource = null;
- object obDailyResult = DoAsync(new AsyncMethod(GetCelsiusRecord));
- if (obDailyResult != null)
- {
- DataSet dsCelsiusRecord = (DataSet)obDailyResult;
- if (dsCelsiusRecord.Tables.Count != Constant.INT_IS_ZERO)
- {
- this.dgvCelsiusRecord.DataSource = dsCelsiusRecord.Tables[Constant.INT_IS_ZERO];
- this.dgvCelsiusRecord.ReadOnly = true;
- }
- }
- else
- {
- this.dgvCelsiusRecord.DataSource = null;
- }
- }
- }
- else
- {
- MessageBox.Show(Messages.MSG_CMN_W020, this.Text,
- MessageBoxButtons.OK, MessageBoxIcon.Warning);
- }
- }
- catch (Exception ex)
- {
- // 对异常进行共通处理
- ExceptionManager.HandleEventException(this.ToString(),
- System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
- }
- }
- /// <summary>
- /// 编辑信息
- /// </summary>
- private void dgvThermometer_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
- {
- try
- {
- if (!this.tsbtnEdit.Visible || e.RowIndex == -Constant.INT_IS_ONE || e.ColumnIndex == -Constant.INT_IS_ONE)
- {
- return;
- }
- DateTime recordTime = Convert.ToDateTime(this.dgvCelsiusRecord.Rows[e.RowIndex].Cells["RecordDate"].Value);
- F_PM_1702 frmFPM1702 = new F_PM_1702(Constant.FormMode.Edit, recordTime);
- DialogResult dialogresult = frmFPM1702.ShowDialog();
- if (dialogresult.Equals(DialogResult.OK))
- {
- this.dgvCelsiusRecord.DataSource = null;
- object obDailyResult = DoAsync(new AsyncMethod(GetCelsiusRecord));
- if (obDailyResult != null)
- {
- DataSet dsCelsiusRecord = (DataSet)obDailyResult;
- if (dsCelsiusRecord.Tables.Count != Constant.INT_IS_ZERO)
- {
- this.dgvCelsiusRecord.DataSource = dsCelsiusRecord.Tables[Constant.INT_IS_ZERO];
- this.dgvCelsiusRecord.ReadOnly = true;
- }
- }
- else
- {
- this.dgvCelsiusRecord.DataSource = null;
- }
- }
- }
- 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 tsbtnDelete_Click(object sender, EventArgs e)
- {
- try
- {
- DialogResult dr = MessageBox.Show("是否删除当前选择数据。", this.Text,
- MessageBoxButtons.YesNo, MessageBoxIcon.Question);
- if (dr != DialogResult.Yes)
- {
- return;
- }
- DataGridViewRow currentRow = this.dgvCelsiusRecord.CurrentRow;
- if (currentRow != null)
- {
- int recordID = Convert.ToInt32(currentRow.Cells["RecordID"].Value);
- int result = (int)DoAsync(new Dongke.IBOSS.PRD.Basics.DockPanel.AsyncMethod(() =>
- {
- return PMModuleProxy.Service.DeleteCelsiusRecord(recordID);
- }));
- if (result == 0)
- {
- MessageBox.Show(string.Format(Messages.MSG_CMN_W007, "数据不存在"), this.Text,
- MessageBoxButtons.OK, MessageBoxIcon.Warning);
- }
- this.dgvCelsiusRecord.DataSource = null;
- object obDailyResult = DoAsync(new AsyncMethod(GetCelsiusRecord));
- if (obDailyResult != null)
- {
- DataSet dsCelsiusRecord = (DataSet)obDailyResult;
- if (dsCelsiusRecord.Tables.Count != Constant.INT_IS_ZERO)
- {
- this.dgvCelsiusRecord.DataSource = dsCelsiusRecord.Tables[Constant.INT_IS_ZERO];
- this.dgvCelsiusRecord.ReadOnly = true;
- }
- }
- else
- {
- this.dgvCelsiusRecord.DataSource = null;
- }
- }
- else
- {
- MessageBox.Show(Messages.MSG_CMN_W020, 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 tsbtnClose_Click(object sender, EventArgs e)
- {
- this.Close();
- }
- /// <summary>
- /// 自动列宽事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void tsbtnAdaptive_Click(object sender, EventArgs e)
- {
- this.dgvCelsiusRecord.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells);
- }
- #endregion
- #region 私有方法
- /// <summary>
- /// 根据界面查询条件获取数据集
- /// </summary>
- private DataSet GetCelsiusRecord()
- {
- try
- {
- CelsiusRecordEntity crEntity = new CelsiusRecordEntity();
- if(this.dkThermometer.ThermometerID != null)
- {
- crEntity.ThermometerID = this.dkThermometer.ThermometerID;
- }
- crEntity.RecordDate = this.txtRecordDateStart.Value.Date;
- crEntity.RecordDateEnd = this.txtRecordDateEnd.Value.Date.AddDays(1);
- crEntity.PurviewType = 12;// 操作权限
- if(string.IsNullOrWhiteSpace(this.txtRemarks.Text))
- {
- crEntity.Remarks = this.txtRemarks.Text;
- }
-
- return PMModuleProxy.Service.GetCelsiusRecord(crEntity);
- }
- catch (Exception ex)
- {
- throw ex;
- }
- }
- #endregion
- }
- }
|