| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338 |
- /*******************************************************************************
- * Copyright(c) 2016 DongkeSoft All rights reserved. / Confidential
- * 类的信息:
- * 1.程序名称:F_RPT_030115.cs
- * 2.功能描述:废品损失汇总表
- * 编辑履历:
- * 作者 日期 版本 修改内容
- * 陈晓野 2016/07/12 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.Client.CommonModule;
- using Dongke.IBOSS.PRD.WCF.DataModels;
- using Dongke.IBOSS.PRD.WCF.Proxys;
- using Dongke.IBOSS.PRD.WCF.Proxys.PMModuleService;
- using Dongke.IBOSS.PRD.WCF.DataModels.PMModule;
- using Dongke.IBOSS.PRD.Client.Controls;
- using System.Collections.Generic;
- namespace Dongke.IBOSS.PRD.Client.ReportModule
- {
- /// <summary>
- /// 废品损失汇总表
- /// </summary>
- public partial class F_RPT_030115 : DKDockPanelBase
- {
- #region 成员变量
- //单例模式
- private static F_RPT_030115 _instance;
- #endregion
- #region 构造函数
- /// <summary>
- /// 废弃一览构造
- /// </summary>
- public F_RPT_030115()
- {
- InitializeComponent();
- this.Text = "废品损失汇总表";
- this.tsbtnAdaptive.Text = ButtonText.TSBTN_ADAPTIVE;
- this.tsbtnClose.Text = ButtonText.TSBTN_CLOSE;
- this.btnSearch.Text = ButtonText.BTN_SEARCH;
- this.btnClearCondition.Text = ButtonText.BTN_CLEARCONDITION;
- }
- #endregion
- #region 单例模式
- /// <summary>
- /// 单例模式,防止重复创建窗体
- /// </summary>
- public static F_RPT_030115 Instance
- {
- get
- {
- if (_instance == null)
- {
- _instance = new F_RPT_030115();
- }
- return _instance;
- }
- }
- #endregion
- #region 事件
- /// <summary>
- /// 查询事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void btnSearch_Click(object sender, EventArgs e)
- {
- try
- {
- //object value = this.cboPT.SelectedValue;
- //if (value == null || value == DBNull.Value)
- //{
- // MessageBox.Show(string.Format(Messages.MSG_CMN_W005, "工序配置"), this.Text,
- // MessageBoxButtons.OK, MessageBoxIcon.Warning);
- //}
- // 汇总表
- if (this.tabControl1.SelectedIndex == 0)
- {
- this.dgvSemi.DataSource = null;
- List<DataGridViewTextBoxColumn> cols = new List<DataGridViewTextBoxColumn>();
- foreach (DataGridViewTextBoxColumn item in dgvSemi.Columns)
- {
- if (item != null && item.Tag != null)
- {
- cols.Add(item);
- }
- }
- foreach (DataGridViewTextBoxColumn item in cols)
- {
- dgvSemi.Columns.Remove(item);
- }
- ClientRequestEntity cre = new ClientRequestEntity();
- cre.NameSpace = "R03";
- cre.Name = "R030115S";
- cre.Properties["PTID"] = (this.cboPT.SelectedValue == DBNull.Value ? null : this.cboPT.SelectedValue);
- cre.Properties["GoodsTypeCode"] = scbGoodsType.SearchedValue + "";
- cre.Properties["GoodsCode"] = this.txtGoodsCode.Text.Trim();
- cre.Properties["DateBegin"] = this.txtTimeStart.Value;
- cre.Properties["DateEnd"] = this.txtTimeEnd.Value;
- ServiceResultEntity resultEntity = DoAsync<ServiceResultEntity>(() =>
- {
- return ReportModuleProxy.Service.DoRequest(cre);
- });
- if (resultEntity == null || resultEntity.Data == null ||
- resultEntity.Data.Tables.Count == 0 ||
- resultEntity.Data.Tables[0].Rows.Count == 0)
- {
- return;
- }
- else
- {
- for (int i = 8; i < resultEntity.Data.Tables[0].Columns.Count; i++)
- {
- DataColumn d = resultEntity.Data.Tables[0].Columns[i];
- DataGridViewTextBoxColumn dc = new DataGridViewTextBoxColumn();
- dc.Name = "D" + i;
- dc.DataPropertyName = d.ColumnName;
- dc.HeaderText = d.ColumnName;
- dc.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight;
- dc.DefaultCellStyle.Format = "N0";
- dc.Tag = 1;
- this.dgvSemi.Columns.Add(dc);
- }
- this.dgvSemi.DataSource = resultEntity.Data.Tables[0];
- this.dgvSemi.ReadOnly = true;
- this.dgvSemi.Rows[0].Selected = true;
- this.dgvSemi.AutoResizeColumns();
- }
- }
- else if (this.tabControl1.SelectedIndex == 1)
- {
- this.dgvPT.DataSource = null;
- ClientRequestEntity cre = new ClientRequestEntity();
- cre.NameSpace = "R03";
- cre.Name = "R030115";
- cre.Properties["PTID"] = (this.cboPT.SelectedValue == DBNull.Value ? null : this.cboPT.SelectedValue);
- cre.Properties["GoodsTypeCode"] = scbGoodsType.SearchedValue + "";
- cre.Properties["GoodsCode"] = this.txtGoodsCode.Text.Trim();
- cre.Properties["DateBegin"] = this.txtTimeStart.Value;
- cre.Properties["DateEnd"] = this.txtTimeEnd.Value;
- ServiceResultEntity resultEntity = DoAsync<ServiceResultEntity>(() =>
- {
- return ReportModuleProxy.Service.DoRequest(cre);
- });
- if (resultEntity == null || resultEntity.Data == null ||
- resultEntity.Data.Tables.Count == 0 ||
- resultEntity.Data.Tables[0].Rows.Count == 0)
- {
- return;
- }
- else
- {
- this.dgvPT.DataSource = resultEntity.Data.Tables[0];
- this.dgvPT.ReadOnly = true;
- this.dgvPT.Rows[0].Selected = true;
- }
- }
- // 明细表
- else
- {
- this.dgvDetail.DataSource = null;
- ClientRequestEntity cre = new ClientRequestEntity();
- cre.NameSpace = "R03";
- cre.Name = "R030115D";
- cre.Properties["PTID"] = (this.cboPT.SelectedValue == DBNull.Value ? null : this.cboPT.SelectedValue);
- cre.Properties["GoodsTypeCode"] = scbGoodsType.SearchedValue + "";
- cre.Properties["GoodsCode"] = this.txtGoodsCode.Text.Trim();
- cre.Properties["DateBegin"] = this.txtTimeStart.Value;
- cre.Properties["DateEnd"] = this.txtTimeEnd.Value;
- ServiceResultEntity resultEntity = DoAsync<ServiceResultEntity>(() =>
- {
- return ReportModuleProxy.Service.DoRequest(cre);
- });
- if (resultEntity == null || resultEntity.Data == null ||
- resultEntity.Data.Tables.Count == 0 ||
- resultEntity.Data.Tables[0].Rows.Count == 0)
- {
- return;
- }
- else
- {
- this.dgvDetail.DataSource = resultEntity.Data.Tables[0];
- this.dgvDetail.ReadOnly = true;
- this.dgvDetail.Rows[0].Selected = true;
- }
- }
- }
- 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 btnClearCondition_Click(object sender, EventArgs e)
- {
- if (this.cboPT.Items.Count > 0)
- {
- this.cboPT.SelectedIndex = 0;
- }
- this.scbGoodsType.ClearValue();
- this.txtGoodsCode.Text = string.Empty;
- DateTime date = DateTime.Now;
- this.txtTimeStart.Value = new DateTime(date.Year, date.Month, 1);
- this.txtTimeEnd.Value = this.txtTimeStart.Value.AddMonths(1).AddSeconds(-1);
- }
- /// <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 F_RPT_030110_FormClosed(object sender, FormClosedEventArgs e)
- {
- _instance = null;
- }
- /// <summary>
- /// 自动列宽
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void tsbtnAdaptive_Click(object sender, EventArgs e)
- {
- this.dgvPT.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells);
- this.dgvDetail.AutoResizeColumns();
- this.dgvSemi.AutoResizeColumns();
- }
- /// <summary>
- /// 窗体加载
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void F_RPT_030110_Load(object sender, EventArgs e)
- {
- try
- {
- // 加载权限
- FormPermissionManager.FormPermissionControl(this.Name, this,
- Dongke.IBOSS.PRD.Client.DataModels.LogInUserInfo.CurrentUser.CurrentUserEntity.UserRightData,
- Dongke.IBOSS.PRD.Client.DataModels.LogInUserInfo.CurrentUser.CurrentUserEntity.FunctionData);
- this.dgvPT.AutoGenerateColumns = false;
- // 设置日期控件默认值
- DateTime date = DateTime.Now;
- this.txtTimeStart.Value = new DateTime(date.Year, date.Month, 1);
- this.txtTimeEnd.Value = this.txtTimeStart.Value.AddMonths(1).AddSeconds(-1);
- // 加载初始化数据源 工序配置
- ServiceResultEntity sre = ReportModuleProxy.Service.GetRPT030111IData();
- if (sre != null && sre.Data != null && sre.Data.Tables.Count > 0)
- {
- sre.Data.Tables[0].Rows.InsertAt(sre.Data.Tables[0].NewRow(), 0);
- this.cboPT.DataSource = sre.Data.Tables[0];
- this.cboPT.DisplayMember = "Name";
- this.cboPT.ValueMember = "ptid";
- if (this.cboPT.Items.Count > 1)
- {
- this.cboPT.SelectedIndex = 1;
- }
- }
- }
- catch (Exception ex)
- {
- // 对异常进行共通处理
- ExceptionManager.HandleEventException(this.ToString(),
- System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
- }
- }
- #endregion
- #region 私有方法
- /// <summary>
- /// 根据界面查询条件获取数据集
- /// </summary>
- private DataTable GetData(ClientRequestEntity cre)
- {
- try
- {
- ServiceResultEntity resultEntity = ReportModuleProxy.Service.DoRequest(cre);
- if (resultEntity == null || resultEntity.Data == null || resultEntity.Data.Tables.Count == 0)
- {
- return null;
- }
- return resultEntity.Data.Tables[0];
- }
- catch (Exception ex)
- {
- throw ex;
- }
- }
- #endregion
- }
- }
|