/******************************************************************************* * Copyright(c) 2015 DongkeSoft All rights reserved. / Confidential * 类的信息: * 1.程序名称:F_RPT_030117.cs * 2.功能描述:产成品交接撤销汇总表 * 编辑履历: * 作者 日期 版本 修改内容 * 付斌 2015/08/08 1.00 新建 *******************************************************************************/ using System; using System.Data; using System.Windows.Forms; using Dongke.IBOSS.PRD.Basics.BaseResources; using Dongke.IBOSS.PRD.Basics.DockPanel; using Dongke.IBOSS.PRD.Basics.Library; using Dongke.IBOSS.PRD.Client.CommonModule; using Dongke.IBOSS.PRD.Client.Controls; using Dongke.IBOSS.PRD.Client.DataModels; using Dongke.IBOSS.PRD.WCF.DataModels; using Dongke.IBOSS.PRD.WCF.DataModels.PMModule; using Dongke.IBOSS.PRD.WCF.Proxys; namespace Dongke.IBOSS.PRD.Client.ReportModule { public partial class F_RPT_030117 : DKDockPanelBase { #region 成员变量 private static F_RPT_030117 _instance; // 窗体的单例模式 private SearchFinishedProductEntity _orderEntityBySearch; // 按钮查询条件实体类 private SearchFinishedProductEntity _orderEntityByDouble; // 双击查询条件实体类 #endregion #region 构造函数 /// /// 构造函数 /// private F_RPT_030117() { InitializeComponent(); // 控件赋值 this.Text = FormTitles.F_RPT_030117; this.gbxCondition.Text = Constant.LABEL_QUERY_CONDITIONS; this.tsbtnAdaptive.Text = ButtonText.TSBTN_ADAPTIVE; this.tsbtnClose.Text = ButtonText.TSBTN_CLOSE; this.btnSearch.Text = ButtonText.BTN_SEARCH; this.btnClearCondition.Text = ButtonText.BTN_CLEARCONDITION; } /// /// 单例模式,防止重复创建窗体 /// public static F_RPT_030117 Instance { get { if (_instance == null || _instance.IsDisposed) { _instance = new F_RPT_030117(); } return _instance; } } #endregion #region 事件 /// /// 窗体加载事件 /// /// /// private void F_RPT_030102_1_Load(object sender, EventArgs e) { try { // 加载权限 FormPermissionManager.FormPermissionControl(this.Name, this, LogInUserInfo.CurrentUser.CurrentUserEntity.UserRightData, LogInUserInfo.CurrentUser.CurrentUserEntity.FunctionData); // 设置表格不自动创建列 this.dgvUndoTotal.AutoGenerateColumns = false; this.dgvUndoDetail.AutoGenerateColumns = false; this.dtpStartTime.Value = DateTime.Now.Date; this.dtpEndTime.Value = DateTime.Now.Date.AddDays(1).AddMinutes(-1); } catch (Exception ex) { // 对异常进行共通处理 ExceptionManager.HandleEventException(this.ToString(), System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex); } } /// /// 查询按钮点击事件 /// /// /// private void btnSearch_Click(object sender, EventArgs e) { try { // 设置查询实体类 GetOrderEntityFromLayout(); this.btnSearch.Enabled = false; this.btnClearCondition.Enabled = false; // 汇总表查询 if (this.tblUndo.SelectedIndex == Constant.INT_IS_ZERO) { this.dgvUndoTotal.DataSource = null; this.dgvUndoTotal.DataSource = this.GetSearchTotalData(); } // 明细表查询 else { this.dgvUndoDetail.DataSource = null; this.dgvUndoDetail.DataSource = this.GetSearchDetailData(); } } catch (Exception ex) { // 对异常进行共通处理 ExceptionManager.HandleEventException(this.ToString(), System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex); } finally { this.btnSearch.Enabled = true; this.btnClearCondition.Enabled = true; } } /// /// 双击单元格事件 /// /// /// private void dgvScrapTotalModule_CellDoubleClick(object sender, DataGridViewCellEventArgs e) { try { // 判断是否为空 if (this.dgvUndoTotal.CurrentRow == null) { return; } // 创建实体,获取数据信息 this._orderEntityByDouble = new SearchFinishedProductEntity(); DataGridViewRow dgvr = dgvUndoTotal.CurrentRow; string goodsModel = dgvr.Cells["GoodsModel"].Value.ToString(); DateTime createTime = new DateTime(); DateTime.TryParse(dgvr.Cells["CreateTime"].Value + "", out createTime); this.btnSearch.Enabled = false; this.btnClearCondition.Enabled = false; // 正常选择统计行 if (!goodsModel.Equals("--")) { this.tblUndo.SelectTab(1); // 获取查询条件 this._orderEntityByDouble.GoodsModel = goodsModel; this._orderEntityByDouble.UndoTimeStart = createTime; this._orderEntityByDouble.UndoTimeEnd = createTime.AddDays(1).AddMinutes(-1); this.dgvUndoDetail.DataSource = null; this.dgvUndoDetail.DataSource = GetSearchDetailDataByDouble(); return; } // 小计行 if (dgvr.Cells["CreateTime"].Value.ToString().StartsWith("小计")) { this.tblUndo.SelectTab(1); dgvr = dgvUndoTotal.Rows[this.dgvUndoTotal.CurrentCell.RowIndex - 1]; // 获取查询条件 createTime = Convert.ToDateTime(dgvr.Cells["CreateTime"].Value); this._orderEntityByDouble.UndoTimeStart = createTime; this._orderEntityByDouble.UndoTimeEnd = createTime.AddDays(1).AddMinutes(-1); // 导入上一次查询的商品规格的条件 this._orderEntityByDouble.GoodsModel = _orderEntityBySearch.GoodsModel; this.dgvUndoDetail.DataSource = null; this.dgvUndoDetail.DataSource = GetSearchDetailDataByDouble(); return; } // 合计行 if (dgvr.Cells["CreateTime"].Value.ToString().StartsWith("合计")) { this.tblUndo.SelectTab(1); dgvr = dgvUndoTotal.Rows[this.dgvUndoTotal.CurrentCell.RowIndex - 2]; // 获取查询条件 this._orderEntityByDouble.UndoTimeStart = _orderEntityBySearch.UndoTimeStart; this._orderEntityByDouble.UndoTimeEnd = _orderEntityBySearch.UndoTimeEnd; this._orderEntityByDouble.GoodsModel = _orderEntityBySearch.GoodsModel; this.dgvUndoDetail.DataSource = null; this.dgvUndoDetail.DataSource = GetSearchDetailDataByDouble(); return; } } catch (Exception ex) { // 对异常进行共通处理 ExceptionManager.HandleEventException(this.ToString(), System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex); } finally { this.btnSearch.Enabled = true; this.btnClearCondition.Enabled = true; } } /// /// 清空条件按钮点击事件 /// /// /// private void btnClearCondition_Click(object sender, EventArgs e) { this.chkDateTime.Checked = true; this.dtpStartTime.Value = DateTime.Now.Date; this.dtpEndTime.Value = DateTime.Now.Date.AddDays(1).AddMinutes(-1); this.txtGoodsModel.Clear(); } /// /// 复选框改变事件 /// /// /// private void chkDateTime_CheckedChanged(object sender, EventArgs e) { this.dtpStartTime.Enabled = chkDateTime.Checked; this.dtpEndTime.Enabled = chkDateTime.Checked; } /// /// 自动适应列宽按钮点击事件 /// /// /// private void tsbtnAdaptive_Click(object sender, EventArgs e) { if (this.tblUndo.SelectedIndex == Constant.INT_IS_ZERO) { this.dgvUndoTotal.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells); } else { this.dgvUndoDetail.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells); } } /// /// 关闭按钮点击事件 /// /// /// private void tsbtnClose_Click(object sender, EventArgs e) { this.Close(); } /// /// 窗体关闭事件 /// /// /// private void F_RPT_030102_1_FormClosed(object sender, FormClosedEventArgs e) { _instance = null; } #endregion #region 私有方法 /// /// 查询按钮搜索条件 /// /// private SearchFinishedProductEntity GetOrderEntityFromLayout() { this._orderEntityBySearch = new SearchFinishedProductEntity(); if (this.chkDateTime.Checked) { this._orderEntityBySearch.UndoTimeStart = this.dtpStartTime.Value; this._orderEntityBySearch.UndoTimeEnd = this.dtpEndTime.Value; } this._orderEntityBySearch.GoodsModel = this.txtGoodsModel.Text.Trim(); return this._orderEntityBySearch; } /// /// 查询汇总表 /// private DataTable GetSearchTotalData() { try { // 异步处理,验证挂起条码 ClientRequestEntity cre = new ClientRequestEntity(); cre.NameSpace = "F_RPT_030117"; cre.Name = "GetSearchTotalData"; cre.Request = JsonHelper.ToJson(_orderEntityBySearch); // 调用服务器端获取数据集 ServiceResultEntity sre = (ServiceResultEntity)DoAsync(new AsyncMethod(() => { return ReportModuleProxy.Service.DoRequest(cre); })); if (sre.Status == Constant.ServiceResultStatus.NoSearchResults) { // 提示未查找到数据 MessageBox.Show(Messages.MSG_CMN_I002, this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning); return null; } return sre.Data.Tables[0]; } catch (Exception ex) { // 对异常进行共通处理 ExceptionManager.HandleEventException(this.ToString(), System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex); return null; } } /// /// 查询明细表 /// private DataTable GetSearchDetailData() { try { // 异步处理,验证挂起条码 ClientRequestEntity cre = new ClientRequestEntity(); cre.NameSpace = "F_RPT_030117"; cre.Name = "GetSearchDetailData"; cre.Request = JsonHelper.ToJson(_orderEntityBySearch); // 调用服务器端获取数据集 ServiceResultEntity sre = (ServiceResultEntity)DoAsync(new AsyncMethod(() => { return ReportModuleProxy.Service.DoRequest(cre); })); if (sre.Status == Constant.ServiceResultStatus.NoSearchResults) { // 提示未查找到数据 MessageBox.Show(Messages.MSG_CMN_I002, tapUndoDetail.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning); return null; } return sre.Data.Tables[0]; } catch (Exception ex) { // 对异常进行共通处理 ExceptionManager.HandleEventException(this.ToString(), System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex); return null; } } /// /// 查询明细表(通过汇总表双击事件) /// private DataTable GetSearchDetailDataByDouble() { try { // 异步处理,验证挂起条码 ClientRequestEntity cre = new ClientRequestEntity(); cre.NameSpace = "F_RPT_030117"; cre.Name = "GetSearchDetailData"; cre.Request = JsonHelper.ToJson(_orderEntityByDouble); // 调用服务器端获取数据集 ServiceResultEntity sre = (ServiceResultEntity)DoAsync(new AsyncMethod(() => { return ReportModuleProxy.Service.DoRequest(cre); })); if (sre.Status == Constant.ServiceResultStatus.NoSearchResults) { // 提示未查找到数据 MessageBox.Show(Messages.MSG_CMN_I002, tapUndoDetail.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning); return null; } return sre.Data.Tables[0]; } catch (Exception ex) { // 对异常进行共通处理 ExceptionManager.HandleEventException(this.ToString(), System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex); return null; } } #endregion } }