/******************************************************************************* * Copyright(c) 2016 DongkeSoft All rights reserved. / Confidential * 类的信息: * 1.程序名称:F_PC_1201.cs * 2.功能描述:模具库存结转一览 * 编辑履历: * 作者 日期 版本 修改内容 * 陈晓野 2017/12/07 1.00 新建 *******************************************************************************/ using System; using System.Reflection; 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.PCModule { /// /// 模具档案 /// public partial class F_PC_1201 : DKDockPanelBase { #region 成员变量 private static F_PC_1201 _instance = null; private bool _isSearch = false; #endregion #region 单例模式 /// /// 单例模式,防止重复创建窗体 /// public static F_PC_1201 Instance { get { if (_instance == null) { _instance = new F_PC_1201(); } return _instance; } } #endregion #region 构造函数 /// /// /// public F_PC_1201() { InitializeComponent(); this.Text = "模具库存结转"; this.tsbtnAdaptive.Text = ButtonText.TSBTN_ADAPTIVE; this.tsbtnClose.Text = ButtonText.TSBTN_CLOSE; this.dgvCarryOver.AutoGenerateColumns = false; this.dgvDetail.AutoGenerateColumns = false; } #endregion #region 控件事件 /// /// 关闭 /// /// /// private void F_PC_1001_FormClosed(object sender, FormClosedEventArgs e) { _instance = null; } /// /// 画面加载 /// /// /// private void F_PC_1001_Load(object sender, System.EventArgs e) { try { FormPermissionManager.FormPermissionControl(this.Name, this, LogInUserInfo.CurrentUser.CurrentUserEntity.UserRightData, LogInUserInfo.CurrentUser.CurrentUserEntity.FunctionData); this.dtpMonthEnd.Value = DateTime.Now.AddMonths(-1); this.dtpMonthBegin.Value = DateTime.Now.AddMonths(-7); } catch (Exception ex) { // 对异常进行共通处理 ExceptionManager.HandleEventException(this.ToString(), MethodBase.GetCurrentMethod().Name, this.Text, ex); } } /// /// 自适应列宽 /// /// /// private void tsbtnAdaptive_Click(object sender, EventArgs e) { this.dgvCarryOver.AutoResizeColumns(); this.dgvDetail.AutoResizeColumns(); } /// /// 清除查询条件 /// /// /// private void tsbtnClearCondition_Click(object sender, EventArgs e) { this.dtpMonthEnd.Value = DateTime.Now.AddMonths(-1); this.dtpMonthBegin.Value = DateTime.Now.AddMonths(-7); this.txtRemarks.Clear(); } /// /// 查询 /// /// /// private void tsbtnSearch_Click(object sender, EventArgs e) { try { this.QueryDataFromOther(); } catch (Exception ex) { // 对异常进行共通处理 ExceptionManager.HandleEventException(this.ToString(), MethodBase.GetCurrentMethod().Name, this.Text, ex); } } /// /// /// /// /// private void dgvCarryOver_SelectionChanged(object sender, EventArgs e) { if (_isSearch || this.dgvCarryOver.CurrentRow == null || this.dgvCarryOver.CurrentRow.Index < 0) { return; } try { ClientRequestEntity cre = new ClientRequestEntity(); cre.NameSpace = "FPC1201"; cre.Name = "GetFPC1201QueryDetailData"; cre.Properties["YYYYMM"] = this.dgvCarryOver.CurrentRow.Cells["YYYYMM"].Value.ToString(); this.dgvDetail.DataSource = null; ServiceResultEntity sre = DoAsync(() => { return PCModuleProxyNew.Service.HandleRequest(cre); } ); if (sre.Status == Constant.ServiceResultStatus.Success) { // 查询成功 this.dgvDetail.DataSource = sre.Data.Tables[0]; } } catch (Exception ex) { // 对异常进行共通处理 ExceptionManager.HandleEventException(this.ToString(), MethodBase.GetCurrentMethod().Name, this.Text, ex); } } /// /// 设置自动结转 /// /// /// private void tsbtnAutoCarryover_Click(object sender, EventArgs e) { try { F_PC_1204 f1204 = new F_PC_1204(); f1204.ShowDialog(); } catch (Exception ex) { // 对异常进行共通处理 ExceptionManager.HandleEventException(this.ToString(), System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex); } } /// /// 结转 /// /// /// private void tsbtnCarryover_Click(object sender, EventArgs e) { try { F_PC_1202 f1202 = F_PC_1202.Instance; f1202.Show(); f1202.ActivateForm(); f1202.BringToFront(); } catch (Exception ex) { // 对异常进行共通处理 ExceptionManager.HandleEventException(this.ToString(), System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex); } } /// /// 反结 /// /// /// private void tsbtnUndoCarryover_Click(object sender, EventArgs e) { if (this.dgvCarryOver.CurrentRow == null || this.dgvCarryOver.CurrentRow.Index < 0) { return; } try { string yyyymm = this.dgvCarryOver.CurrentRow.Cells["YYYYMM"].Value.ToString(); DialogResult dialogResult = MessageBox.Show(string.Format("确定要对【{0}】及以后的库存结转进行反结转?", yyyymm), "模具库存反结转", MessageBoxButtons.OKCancel, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2); if (dialogResult != System.Windows.Forms.DialogResult.OK) { return; } dialogResult = MessageBox.Show("反结转将会删除已结转数据,是否继续?", "模具库存反结转", MessageBoxButtons.YesNo, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button2); if (dialogResult != System.Windows.Forms.DialogResult.Yes) { return; } // 异步处理,获取系统参数信息 ClientRequestEntity cre = new ClientRequestEntity(); cre.NameSpace = "FPC1201"; cre.Name = "SetFPC1203Data"; cre.Properties["YYYYMM"] = yyyymm; ServiceResultEntity sre = (ServiceResultEntity)DoAsync(() => { return PCModuleProxyNew.Service.HandleRequest(cre); } ); if (sre.Status == Constant.ServiceResultStatus.Success) { MessageBox.Show(string.Format(Messages.MSG_CMN_I001, "【" + yyyymm + "】及以后", "库存反结转"), this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show(string.Format(Messages.MSG_CMN_W001, "【" + yyyymm + "】及以后", "库存反结转"), this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning); } this.tsbtnSearch_Click(null, null); } 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(); } #endregion #region 私有方法 /// /// 查询数据 /// /// 验证通过true,其他false private void QueryDataFromOther() { try { _isSearch = true; ClientRequestEntity cre = new ClientRequestEntity(); cre.NameSpace = "FPC1201"; cre.Name = "GetFPC1201QueryData"; cre.Properties["DateBegin"] = this.dtpMonthBegin.Value.Value.ToString("yyyyMM"); cre.Properties["DateEnd"] = this.dtpMonthEnd.Value.Value.ToString("yyyyMM"); this.dgvCarryOver.DataSource = null; this.dgvDetail.DataSource = null; ServiceResultEntity sre = DoAsync(() => { return PCModuleProxyNew.Service.HandleRequest(cre); } ); if (sre.Status == Constant.ServiceResultStatus.Success) { // 查询成功 this.dgvCarryOver.DataSource = sre.Data.Tables[0]; this.dgvDetail.DataSource = sre.Data.Tables[1]; } } catch (Exception ex) { throw ex; } finally { _isSearch = false; } } #endregion } }