/******************************************************************************* * Copyright(c) 2014 DongkeSoft All rights reserved. / Confidential * 类的信息: * 1.程序名称:F_PM_1501.cs * 2.功能描述:产成品数据 * 编辑履历: * 作者 日期 版本 修改内容 * 宋扬 2014/10/24 1.00 新建 *******************************************************************************/ using System; using System.Data; using System.Text; 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.Client.DataModels; using Dongke.IBOSS.PRD.WCF.DataModels.PMModule; using Dongke.IBOSS.PRD.WCF.Proxys; using Dongke.IBOSS.PRD.WCF.Proxys.PMModuleService; namespace Dongke.IBOSS.PRD.Client.PMModule { /// /// 产成品数据 /// public partial class F_PM_1501 : DockPanelBase { #region 成员变量 // 窗体的单例模式 private static F_PM_1501 _instance; //完成产品实体类 SearchFinishedProductEntity _finishedProductionEntity = new SearchFinishedProductEntity(); //生产线权限集 private string _productionLinePurviews = string.Empty; //成型线权限集 private string _groutingLinePurviews = string.Empty; #endregion #region 构造函数 public F_PM_1501() { InitializeComponent(); //自动适应列宽 this.tsbtnAdaptive.Text = ButtonText.TSBTN_ADAPTIVE; //关闭 this.tsbtnClose.Text = ButtonText.TSBTN_CLOSE; //查询 this.btnSearch.Text = ButtonText.BTN_SEARCH; //清空条件 this.btnClearCondition.Text = ButtonText.BTN_CLEARCONDITION; //查询条件 this.gbxCondition.Text = Constant.LABEL_QUERY_CONDITIONS; // 窗体显示的Title this.Text = FormTitles.F_PM_1501; } #endregion #region 单例模式 /// /// 单例模式,防止重复创建窗体 /// public static F_PM_1501 Instance { get { if (_instance == null || _instance.IsDisposed) { _instance = new F_PM_1501(); } return _instance; } } #endregion #region 事件 /// /// 窗体加载事件 /// /// /// private void F_PM_1501_Load(object sender, EventArgs e) { try { // 设置表格不自动创建列 this.dgvFinishedProduction.AutoGenerateColumns = false; // 加载权限 FormPermissionManager.FormPermissionControl(this.Name, this, LogInUserInfo.CurrentUser.CurrentUserEntity.UserRightData, LogInUserInfo.CurrentUser.CurrentUserEntity.FunctionData); // 初始化时间控件为当前日期 this.dtpCreateTimeStart.Value = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day); this.dtpCreateTimeEnd.Value = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day); this.dtpAccountDateStart.Value = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day); this.dtpAccountDateEnd.Value = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day); } catch (Exception ex) { // 对异常进行共通处理 ExceptionManager.HandleEventException(this.ToString(), System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex); } } /// /// 查询按钮事件 /// /// /// private void btnSearch_Click(object sender, EventArgs e) { try { SearchFinishedProductEntity requestFinishedEntity = CreatesearchFinishedProductionDataRequestEntity(); DataSet dsfinishedProductioData = (DataSet)DoAsync(new AsyncMethod(() => { return PMModuleProxy.Service.GetFinishedProductionData(requestFinishedEntity); })); if (dsfinishedProductioData != null) { if (dsfinishedProductioData.Tables[Constant.INT_IS_ZERO].Rows.Count <= Constant.INT_IS_ZERO) { // 提示未查找到数据 MessageBox.Show(Messages.MSG_CMN_I002, this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information); //清空数据 this.dgvFinishedProduction.DataSource = null; } else { this.dgvFinishedProduction.DataSource = dsfinishedProductioData.Tables[Constant.INT_IS_ZERO]; } } } catch (Exception ex) { this.btnSearch.Enabled = true; this.btnClearCondition.Enabled = true; // 对异常进行共通处理 ExceptionManager.HandleEventException(this.ToString(), System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex); } } /// /// 窗体关闭事件 /// /// /// private void F_PM_1501_FormClosed(object sender, FormClosedEventArgs e) { _instance = null; } /// /// 关闭按钮事件 /// /// /// private void tsbtnClose_Click(object sender, EventArgs e) { this.Close(); } /// /// 更多条件按钮事件 /// /// /// private void tsbtnMoreCondition_Click(object sender, EventArgs e) { F_PM_1502 fpm1502 = new F_PM_1502(); fpm1502.searchFinishedProductionEntity = _finishedProductionEntity; if (fpm1502.ShowDialog() == DialogResult.OK) { this._finishedProductionEntity = fpm1502.searchFinishedProductionEntity; } } /// /// 清空条件按钮事件 /// /// /// private void btnClearCondition_Click(object sender, EventArgs e) { this.txtBarCode.Text = string.Empty; this.scbGMouldType.ClearValue(); this.scbGoods.ClearValue(); this.scbGroutingLine.ClearValue(); this.dkproductionLineSearchBox.ClearControl(); this.dtpCreateTimeStart.Value = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day); this.dtpCreateTimeEnd.Value = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day); this.dtpAccountDateStart.Value = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day); this.dtpAccountDateEnd.Value = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day); } /// /// 自动适应列宽 /// /// /// private void tsbtnAdaptive_Click(object sender, EventArgs e) { this.dgvFinishedProduction.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells); } #endregion #region 私有方法 #region 获取查询条件 private SearchFinishedProductEntity CreatesearchFinishedProductionDataRequestEntity() { SearchFinishedProductEntity searchFinishedProductionEntity = new SearchFinishedProductEntity(); searchFinishedProductionEntity.BarCode = this.txtBarCode.Text.Trim(); searchFinishedProductionEntity.ProductionLineIDS = this.dkproductionLineSearchBox.ProductionLineIDS; searchFinishedProductionEntity.GMouldTypeIDS = this.scbGMouldType.CheckedPKMember; searchFinishedProductionEntity.GoodsIDS = this.scbGoods.CheckedPKMember; searchFinishedProductionEntity.GroutingLineIDS = this.scbGroutingLine.CheckedPKMember; string createTimeStart = this.dtpCreateTimeStart.Value.ToString("yyyy-MM-dd") + " 0:0:0"; searchFinishedProductionEntity.CreateTimeStart = Convert.ToDateTime(createTimeStart); string createTimeEnd = this.dtpCreateTimeEnd.Value.ToString("yyyy-MM-dd") + " 23:59:59"; searchFinishedProductionEntity.CreateTimeEnd = Convert.ToDateTime(createTimeEnd); string accountDateStart = this.dtpAccountDateStart.Value.ToString("yyyy-MM-dd") + " 0:0:0"; searchFinishedProductionEntity.AccountDateStart = Convert.ToDateTime(accountDateStart); string accountDateEnd = this.dtpAccountDateEnd.Value.ToString("yyyy-MM-dd") + " 23:59:59"; searchFinishedProductionEntity.AccountDateEnd = Convert.ToDateTime(accountDateEnd); return searchFinishedProductionEntity; } #endregion /// /// 获取当前用户的权限 /// protected void getPurview() { try { //得到生产线查看权限 StringBuilder sbProductionlinePurview = new StringBuilder(); DataSet dsProductionlinePurview = (DataSet)DoAsync(new AsyncMethod(() => { return SystemModuleProxy.Service.GetUserPurview(7, LogInUserInfo.CurrentUser.UserID); })); if (dsProductionlinePurview != null) { foreach (DataRow dr in dsProductionlinePurview.Tables[Constant.INT_IS_ZERO].Rows) { sbProductionlinePurview.Append(dr[Constant.INT_IS_ZERO].ToString() + ","); } if (sbProductionlinePurview.Length != Constant.INT_IS_ZERO) { this._productionLinePurviews = sbProductionlinePurview.ToString().Substring(Constant.INT_IS_ZERO, sbProductionlinePurview.Length - 1); this.dkproductionLineSearchBox.Purview = this._productionLinePurviews; } } //得到成型线查看权限 //StringBuilder sbGroutingLinePurview = new StringBuilder(); //DataSet dsGroutingLinePurview = (DataSet)DoAsync(new AsyncMethod(() => //{ // return SystemModuleProxy.Service.GetUserPurview(5, LogInUserInfo.CurrentUser.UserID); //})); //if (dsGroutingLinePurview != null) //{ // foreach (DataRow dr in dsGroutingLinePurview.Tables[Constant.INT_IS_ZERO].Rows) // { // sbGroutingLinePurview.Append(dr[Constant.INT_IS_ZERO].ToString() + ","); // } // if (sbGroutingLinePurview.Length != Constant.INT_IS_ZERO) // { // this._groutingLinePurviews = sbGroutingLinePurview.ToString().Substring(Constant.INT_IS_ZERO, sbGroutingLinePurview.Length - 1); // this.dkGroutingLineSearchBox.Purview = this._groutingLinePurviews; // } //} } catch (Exception ex) { throw ex; } } #endregion } }