| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376 |
- /*******************************************************************************
- * Copyright(c) 2015 DongkeSoft All rights reserved. / Confidential
- * 类的信息:
- * 1.程序名称:F_RPT_030120.cs
- * 2.功能描述:工厂调出汇总表
- * 编辑履历:
- * 作者 日期 版本 修改内容
- * 付斌 2020/11/06 1.00 新建
- *******************************************************************************/
- using System;
- using System.Data;
- using System.Windows.Forms;
- using Dongke.IBOSS.PRD.Basics.BaseResources;
- 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.Proxys;
- namespace Dongke.IBOSS.PRD.Client.ReportModule
- {
- public partial class F_RPT_030120 : DKDockPanelBase
- {
- #region 成员变量
- private static F_RPT_030120 _instance; // 窗体的单例模式
- #endregion
- #region 构造函数
- /// <summary>
- /// 构造函数
- /// </summary>
- private F_RPT_030120()
- {
- InitializeComponent();
- // 控件赋值
- Text = FormTitles.F_RPT_030120;
- gbxCondition.Text = Constant.LABEL_QUERY_CONDITIONS;
- tsbtnAdaptive.Text = ButtonText.TSBTN_ADAPTIVE;
- tsbtnClose.Text = ButtonText.TSBTN_CLOSE;
- btnSearch.Text = ButtonText.BTN_SEARCH;
- btnClearCondition.Text = ButtonText.BTN_CLEARCONDITION;
- }
- /// <summary>
- /// 单例模式,防止重复创建窗体
- /// </summary>
- public static F_RPT_030120 Instance
- {
- get
- {
- if (_instance == null || _instance.IsDisposed)
- {
- _instance = new F_RPT_030120();
- }
- return _instance;
- }
- }
- #endregion
- #region 事件
- /// <summary>
- /// 窗体加载事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void F_RPT_030102_1_Load(object sender, EventArgs e)
- {
- try
- {
- // 加载权限
- FormPermissionManager.FormPermissionControl(Name, this,
- LogInUserInfo.CurrentUser.CurrentUserEntity.UserRightData,
- LogInUserInfo.CurrentUser.CurrentUserEntity.FunctionData);
- // 损坯原因
- DataSet dsRreason = DoAsync(
- () => { return SystemModuleProxy.Service.GetDictionaryData(0, "TPC009"); });
- DataRow row = dsRreason.Tables[0].NewRow();
- row["DictionaryValue"] = "";
- row["DictionaryID"] = 0;
- dsRreason.Tables[0].Rows.InsertAt(row, 0);
- cmbRreason.DisplayMember = "DictionaryValue";
- cmbRreason.ValueMember = "DictionaryID";
- cmbRreason.DataSource = dsRreason.Tables[0];
- // 设置表格不自动创建列
- dgvScrapProductTotal.AutoGenerateColumns = false;
- dgvScrapProductDetail.AutoGenerateColumns = false;
- dtpScrapDateStart.Value = DateTime.Now.Date;
- dtpScrapDateEnd.Value = DateTime.Now.Date;
- }
- catch (Exception ex)
- {
- // 对异常进行共通处理
- ExceptionManager.HandleEventException(ToString(),
- System.Reflection.MethodBase.GetCurrentMethod().Name, Text, ex);
- }
- }
- /// <summary>
- /// 查询按钮点击事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void btnSearch_Click(object sender, EventArgs e)
- {
- try
- {
- btnSearch.Enabled = false;
- btnClearCondition.Enabled = false;
- // 汇总表查询
- if (page.SelectedIndex == Constant.INT_IS_ZERO)
- {
- dgvScrapProductTotal.DataSource = null;
- dgvScrapProductTotal.DataSource = GetSearchTotalData();
- }
- // 明细表查询
- else
- {
- dgvScrapProductDetail.DataSource = null;
- dgvScrapProductDetail.DataSource = GetSearchDetailData();
- }
- }
- catch (Exception ex)
- {
- // 对异常进行共通处理
- ExceptionManager.HandleEventException(ToString(),
- System.Reflection.MethodBase.GetCurrentMethod().Name, Text, ex);
- }
- finally
- {
- btnSearch.Enabled = true;
- btnClearCondition.Enabled = true;
- }
- }
- /// <summary>
- /// 双击单元格事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void dgvScrapProductTotal_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
- {
- try
- {
- // 判断是否为空
- if (this.dgvScrapProductTotal.CurrentRow == null)
- {
- return;
- }
- dgvScrapProductDetail.DataSource = null;
- DataGridViewRow dgvr = dgvScrapProductTotal.CurrentRow;
- // 异步处理,验证挂起条码
- ClientRequestEntity cre = new ClientRequestEntity();
- cre.NameSpace = "F_RPT_030120";
- cre.Name = "GetAllocateOutDetail";
- // 创建实体,获取数据信息
- DateTime scrapDate = new DateTime();
- DateTime.TryParse(dgvr.Cells["ScrapDate1"].Value + "", out scrapDate);
- string rreason = dgvr.Cells["rreason1"].Value + "";
- string goodsCode = dgvr.Cells["GoodsCode1"].Value + "";
- // 正常选择统计行
- if (!goodsCode.Equals("--"))
- {
- page.SelectTab(1);
- // 获取查询条件
- cre.Properties["goodscode"] = goodsCode;
- cre.Properties["rreason"] = rreason;
- cre.Properties["scrapdatestart"] = scrapDate;
- cre.Properties["scrapdateend"] = scrapDate.AddDays(1);
- }
- // 调出类型小计行
- if (rreason.StartsWith("小计"))
- {
- page.SelectTab(1);
- dgvr = dgvScrapProductTotal.Rows[dgvScrapProductTotal.CurrentCell.RowIndex - 1];
- // 获取查询条件
- rreason = dgvr.Cells["rreason1"].Value + "";
- cre.Properties["rreason"] = rreason;
- cre.Properties["scrapdatestart"] = scrapDate;
- cre.Properties["scrapdateend"] = scrapDate.AddDays(1);
- }
- // 日期小计行
- if ((dgvr.Cells["ScrapDate1"].Value + "").StartsWith("小计"))
- {
- page.SelectTab(1);
- dgvr = dgvScrapProductTotal.Rows[dgvScrapProductTotal.CurrentCell.RowIndex - 1];
- // 获取查询条件
- scrapDate = Convert.ToDateTime(dgvr.Cells["ScrapDate1"].Value);
- cre.Properties["scrapdatestart"] = scrapDate;
- cre.Properties["scrapdateend"] = scrapDate.AddDays(1);
- }
- // 合计行
- if ((dgvr.Cells["ScrapDate1"].Value + "").StartsWith("合计"))
- {
- page.SelectTab(1);
- dgvr = dgvScrapProductTotal.Rows[dgvScrapProductTotal.CurrentCell.RowIndex - 2];
- DataGridViewRow dgvr1 = dgvScrapProductTotal.Rows[0];
- cre.Properties["scrapdatestart"] = Convert.ToDateTime(dgvr1.Cells["ScrapDate1"].Value);
- scrapDate = Convert.ToDateTime(dgvr.Cells["ScrapDate1"].Value);
- cre.Properties["scrapdateend"] = scrapDate.AddDays(1);
- }
- // 调用服务器端获取数据集
- ServiceResultEntity sre = DoAsync(
- () => { return PMModuleProxyNew.Service.HandleRequest(cre); });
- if (sre.Data.Tables[0].Rows.Count == 0)
- {
- // 提示未查找到数据
- MessageBox.Show(Messages.MSG_CMN_I002, Text,
- MessageBoxButtons.OK, MessageBoxIcon.Warning);
- }
- dgvScrapProductDetail.DataSource = sre.Data.Tables[0];
- }
- catch (Exception ex)
- {
- // 对异常进行共通处理
- ExceptionManager.HandleEventException(ToString(),
- System.Reflection.MethodBase.GetCurrentMethod().Name, Text, ex);
- }
- finally
- {
- btnSearch.Enabled = true;
- btnClearCondition.Enabled = true;
- }
- }
- /// <summary>
- /// 清空条件按钮点击事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void btnClearCondition_Click(object sender, EventArgs e)
- {
- dtpScrapDateStart.Value = DateTime.Now.Date;
- dtpScrapDateEnd.Value = DateTime.Now.Date;
- txtGoodsCode.Clear();
- cmbRreason.SelectedIndex = 0;
- txtBarCode.Clear();
- }
- /// <summary>
- /// 自动适应列宽按钮点击事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void tsbtnAdaptive_Click(object sender, EventArgs e)
- {
- if (page.SelectedIndex == Constant.INT_IS_ZERO)
- {
- dgvScrapProductTotal.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells);
- }
- else
- {
- dgvScrapProductDetail.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells);
- }
- }
- /// <summary>
- /// 关闭按钮点击事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void tsbtnClose_Click(object sender, EventArgs e)
- {
- Close();
- }
- /// <summary>
- /// 窗体关闭事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void F_RPT_030102_1_FormClosed(object sender, FormClosedEventArgs e)
- {
- _instance = null;
- }
- #endregion
- #region 私有方法
- /// <summary>
- /// 查询汇总表
- /// </summary>
- private DataTable GetSearchTotalData()
- {
- try
- {
- // 异步处理,验证挂起条码
- ClientRequestEntity cre = new ClientRequestEntity();
- cre.NameSpace = "F_RPT_030120";
- cre.Name = "GetAllocateOutTotal";
- cre.Properties["barcode"] = txtBarCode.Text.Trim();
- cre.Properties["goodscode"] = txtGoodsCode.Text.Trim();
- cre.Properties["scrapdatestart"] = dtpScrapDateStart.Value;
- cre.Properties["scrapdateend"] = dtpScrapDateEnd.Value.AddDays(1);
- cre.Properties["rreason"] = cmbRreason.Text.Trim();
- // 调用服务器端获取数据集
- ServiceResultEntity sre = DoAsync(
- () => { return PMModuleProxyNew.Service.HandleRequest(cre); });
- if (sre.Data.Tables[0].Rows.Count == 0)
- {
- // 提示未查找到数据
- MessageBox.Show(Messages.MSG_CMN_I002, Text,
- MessageBoxButtons.OK, MessageBoxIcon.Warning);
- return null;
- }
- return sre.Data.Tables[0];
- }
- catch (Exception ex)
- {
- // 对异常进行共通处理
- ExceptionManager.HandleEventException(ToString(),
- System.Reflection.MethodBase.GetCurrentMethod().Name, Text, ex);
- return null;
- }
- }
- /// <summary>
- /// 查询明细表
- /// </summary>
- private DataTable GetSearchDetailData()
- {
- try
- {
- // 异步处理,验证挂起条码
- ClientRequestEntity cre = new ClientRequestEntity();
- cre.NameSpace = "F_RPT_030120";
- cre.Name = "GetAllocateOutDetail";
- cre.Properties["barcode"] = txtBarCode.Text.Trim();
- cre.Properties["goodscode"] = txtGoodsCode.Text.Trim();
- cre.Properties["scrapdatestart"] = dtpScrapDateStart.Value;
- cre.Properties["scrapdateend"] = dtpScrapDateEnd.Value.AddDays(1);
- cre.Properties["rreason"] = cmbRreason.Text.Trim();
- // 调用服务器端获取数据集
- ServiceResultEntity sre = DoAsync(
- () => { return PMModuleProxyNew.Service.HandleRequest(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(ToString(),
- System.Reflection.MethodBase.GetCurrentMethod().Name, Text, ex);
- return null;
- }
- }
- #endregion
- }
- }
|