/******************************************************************************* * 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 单例模式 /// /// 单例模式,防止重复创建窗体 /// public static F_PM_1701 Instance { get { if (_instance == null) { _instance = new F_PM_1701(); } return _instance; } } #endregion #region 事件 /// /// 窗体加载 /// 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; } /// /// 获取数据 /// 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); } } /// /// 清空条件 /// private void btnClearCondition_Click(object sender, EventArgs e) { this.txtRemarks.Text = ""; this.dkThermometer.Text = ""; this.dkThermometer.ThermometerID = null; } /// /// 窗体关闭 /// /// /// private void F_PM_1701_FormClosed(object sender, FormClosedEventArgs e) { _instance = null; } /// /// 新建信息 /// /// /// 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); } } /// /// 编辑信息 /// /// /// 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); } } /// /// 编辑信息 /// 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); } } /// /// 删除 /// /// /// 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); } } /// /// 关闭按钮事件 /// /// /// private void tsbtnClose_Click(object sender, EventArgs e) { this.Close(); } /// /// 自动列宽事件 /// /// /// private void tsbtnAdaptive_Click(object sender, EventArgs e) { this.dgvCelsiusRecord.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells); } #endregion #region 私有方法 /// /// 根据界面查询条件获取数据集 /// 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 } }