/******************************************************************************* * Copyright(c) 2019 DongkeSoft All rights reserved. / Confidential * 类的信息: * 1.程序名称:F_PP_0101.cs * 2.功能描述:年计划 * 编辑履历: * 作者 日期 版本 修改内容 * 徐伟 2019/08/27 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.PPModule { /// /// 年计划窗体 /// public partial class F_PP_0101 : DKDockPanelBase { #region 默认方法 /********************************************************/ private static F_PP_0101 _instance = null; public static F_PP_0101 Instance { get { if (_instance == null) { _instance = new F_PP_0101(); } return _instance; } } private void F_PP_0101_FormClosed(object sender, FormClosedEventArgs e) { _instance = null; } //单实例 public F_PP_0101() { InitializeComponent(); this.Text = "年计划"; this.tsbtnAdaptive.Text = ButtonText.TSBTN_ADAPTIVE; this.tsbtnClose.Text = ButtonText.TSBTN_CLOSE; this.dgvPlan.AutoGenerateColumns = false; } //窗体加载 private void F_PP_0101_Load(object sender, System.EventArgs e) { try { // 加载权限 FormPermissionManager.FormPermissionControl(this.Name, this, LogInUserInfo.CurrentUser.CurrentUserEntity.UserRightData, LogInUserInfo.CurrentUser.CurrentUserEntity.FunctionData); //加载计划类型 PlanYearTypeLoad(); //默认清空条件 SearchEnpty(); } catch (Exception ex) { // 对异常进行共通处理 ExceptionManager.HandleEventException(this.ToString(), MethodBase.GetCurrentMethod().Name, this.Text, ex); } } #endregion #region 窗体事件定义和处理 /********************************************************/ //双击进入编辑 private void DgvPlan_DoubleClick(object sender, EventArgs e) { PlanYearEdit(); } //清空搜索条件 private void BtnEmpty_Click(object sender, EventArgs e) { SearchEnpty(); } //年计划 查询处理 private void BtnSearch_Click(object sender, EventArgs e) { PlanYearSearch(); } //自适应列宽 private void tsbtnAdaptive_Click(object sender, EventArgs e) { this.dgvPlan.AutoResizeColumns(); } //关闭画面 private void tsbtnClose_Click(object sender, EventArgs e) { this.Close(); } //搜索 private void TsbtnSearch_Click(object sender, EventArgs e) { PlanYearSearch(); } //清空 private void TsbtnClearCondition_Click(object sender, EventArgs e) { SearchEnpty(); } //显示历史版本处理 private void ShowVer_Click(object sender, EventArgs e) { PlanYearSearch(); } //年计划 自由比对 private void TsbtnVer_Click(object sender, EventArgs e) { PlanYearVer(); } //年计划 同表比对 private void TsbtnSame_Click(object sender, EventArgs e) { PlanYearSame(); } //年计划选中记录后 private void DgvPlan_SelectionChanged(object sender, EventArgs e) { //切换编辑和删除菜单按钮变为可用 tsbtnPlanGoodsAdd.Enabled = dgvPlan.SelectedRows.Count > 0; //副本 tsbtnCopy.Enabled = dgvPlan.SelectedRows.Count > 0; //编辑组 tsbtnEdit.Enabled = dgvPlan.SelectedRows.Count > 0; tsbtnDelete.Enabled = dgvPlan.SelectedRows.Count > 0; //年计划编辑和删除 tsbtnPlanEdit.Enabled = dgvPlan.SelectedRows.Count > 0; tsbtnPlanDelete.Enabled = dgvPlan.SelectedRows.Count > 0; //显示产品产量列表 PlanYearGoodsSearch(); } //产量计划选中记录后 private void DgvDetail_SelectionChanged(object sender, EventArgs e) { //产量计划编辑和删除 tsbtnPlanGoodsEdit.Enabled = dgvDetail.SelectedRows.Count > 0; tsbtnPlanGoodsDelete.Enabled = dgvDetail.SelectedRows.Count > 0; } //年计划 新建 private void TsbtnPlanAdd_Click(object sender, EventArgs e) { PlanYearAdd(); } //保存副本 private void TsbtnCopy_Click(object sender, EventArgs e) { PlanYearCopy(); } //双击修改 private void DgvDetail_DoubleClick(object sender, EventArgs e) { PlanYearGoodsEdit(); } //产品产量 新建 private void TsbtnPlanGoodsAdd_Click(object sender, EventArgs e) { PlanYearGoodsAdd(); } //年计划 修改 private void TsbtnPlanEdit_Click(object sender, EventArgs e) { PlanYearEdit(); } //产品产量 修改 private void TsbtnPlanGoodsEdit_Click(object sender, EventArgs e) { PlanYearGoodsEdit(); } //年计划 删除 private void TsbtnPlanDelete_Click(object sender, EventArgs e) { PlanYearDelete(); } //产品产量 删除 private void TsbtnPlanGoodsDelete_Click(object sender, EventArgs e) { PlanYearGoodsDelete(); } #endregion #region 年计划处理方法 /********************************************************/ //清空搜索条件 private void SearchEnpty() { pName.Text = ""; pYearNo.Text = ""; pType.SelectedIndex = -1; pRemarks.Text = ""; } //加载计划类型 private void PlanYearTypeLoad() { ClientRequestEntity cre = new ClientRequestEntity(); ServiceResultEntity result = PPModuleProxy.Service.PlanTypeSearch(cre); pType.DisplayMember = "PLANTYPENAME"; pType.ValueMember = "PLANTYPEID"; pType.DataSource = result.Data.Tables[0]; pType.SelectedIndex = -1; } //年计划 查询处理 private void PlanYearSearch(int id=0) { ClientRequestEntity cre = new ClientRequestEntity(); if (pYearNo.Text.Trim() != "") cre.Properties["YEARNO"] = Convert.ToInt32(pYearNo.Text.Trim()); if (pName.Text.Trim() != "") cre.Properties["PLANNAME"] = pName.Text.Trim(); if (pType.SelectedValue != null) cre.Properties["PLANTYPEID"] = pType.SelectedValue.ToString().Trim(); if (pRemarks.Text.Trim() != "") cre.Properties["REMARKS"] = pRemarks.Text.Trim(); ServiceResultEntity result; //是否显示版本数据 if (showVer.Checked) result = PPModuleProxy.Service.PlanYearVerSearch(cre); else result = PPModuleProxy.Service.PlanYearSearch(cre); dgvPlan.DataSource = result.Data.Tables[0]; //选中原来的行 默认选择0行 if (dgvPlan.Rows.Count == 0) dgvDetail.DataSource = null; else { if(id==0) dgvPlan.Rows[0].Selected = true; else for (int i = 0; i < dgvPlan.Rows.Count; i++) if (dgvPlan.Rows[i].Cells["PLANID"].Value.ToString() == id.ToString()) dgvPlan.Rows[i].Selected = true; } } //年计划 添加处理 private void PlanYearAdd() { F_PP_0102 yearForm = new F_PP_0102(); yearForm.planId = 0; //加载计划类型 ClientRequestEntity cre = new ClientRequestEntity(); ServiceResultEntity result = PPModuleProxy.Service.PlanTypeSearch(cre); yearForm.planType.DisplayMember = "PLANTYPENAME"; yearForm.planType.ValueMember = "PLANTYPEID"; yearForm.planType.DataSource = result.Data.Tables[0]; yearForm.planType.SelectedValue = -1; yearForm.planYearNo.Value = pYearNo.Value; yearForm.planName.Text = pName.Text; if(pType.SelectedValue is object) yearForm.planType.SelectedValue = pType.SelectedValue; yearForm.planRemarks.Text = pRemarks.Text; yearForm.ShowDialog(); if (yearForm.DialogResult == DialogResult.OK) PlanYearSearch(PPModuleProxy.Service.Seq("SEQ_PP_PLAN_YEAR_PLANID.CURRVAL")); } //年计划 修改处理 private void PlanYearEdit() { if(dgvPlan.SelectedRows.Count>0) { F_PP_0102 yearForm = new F_PP_0102(); yearForm.planId = Convert.ToInt32(dgvPlan.SelectedRows[0].Cells["PlanId"].Value.ToString()); //加载计划类型 ClientRequestEntity cre = new ClientRequestEntity(); ServiceResultEntity result = PPModuleProxy.Service.PlanTypeSearch(cre); yearForm.planType.DisplayMember = "PLANTYPENAME"; yearForm.planType.ValueMember = "PLANTYPEID"; yearForm.planType.DataSource = result.Data.Tables[0]; yearForm.planType.SelectedValue = -1; //更新操作 直接从datagrid中取值 yearForm.planYearNo.Value = Convert.ToDecimal(dgvPlan.SelectedRows[0].Cells["YearNo"].Value.ToString()); yearForm.planName.Text = dgvPlan.SelectedRows[0].Cells["PlanName"].Value.ToString(); yearForm.planType.SelectedValue = dgvPlan.SelectedRows[0].Cells["PlanTypeId"].Value; yearForm.planStartMonth.Value = Convert.ToDecimal(dgvPlan.SelectedRows[0].Cells["StartMonth"].Value.ToString().Trim()); yearForm.planEndMonth.Value = Convert.ToDecimal(dgvPlan.SelectedRows[0].Cells["EndMonth"].Value.ToString().Trim()); yearForm.planRemarks.Text = dgvPlan.SelectedRows[0].Cells["Remarks"].Value.ToString(); yearForm.ShowDialog(); //保存 if (yearForm.DialogResult == DialogResult.OK) PlanYearSearch(Convert.ToInt32(dgvPlan.SelectedRows[0].Cells["PlanId"].Value)); } } //年计划 删除处理 private void PlanYearDelete() { if(dgvPlan.SelectedRows.Count>0) { if(MessageBox.Show($"您确认要删除【计划名称:{dgvPlan.SelectedRows[0].Cells["PLANNAME"].Value}】的记录吗?\n产品产量计划【{dgvDetail.Rows.Count}】条记录会一同被删除!","提示信息",MessageBoxButtons.OKCancel,MessageBoxIcon.Warning)== DialogResult.OK) { ClientRequestEntity cre = new ClientRequestEntity(); cre.Properties["PLANID"] = Convert.ToInt32(dgvPlan.SelectedRows[0].Cells["PLANID"].Value); //删除产品产量记录 PPModuleProxy.Service.PlanYearGoodsDelete(cre); //删除年计划记录 PPModuleProxy.Service.PlanYearDelete(cre); PlanYearSearch(); } } } //年计划 保存副本 private void PlanYearCopy() { if(MessageBox.Show($"您确认要保存【计划名称:{dgvPlan.SelectedRows[0].Cells["PLANNAME"].Value}】的副本吗?","提示信息", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning)== DialogResult.OK) { int planId = Convert.ToInt32(dgvPlan.SelectedRows[0].Cells["PlanId"].Value.ToString()); int newPlanId = PPModuleProxy.Service.PlanYearCopy(planId); PlanYearSearch(newPlanId); } } #endregion #region 产品产量计划处理 /********************************************************/ //加载产品列表 private void PlanGoodsLoad(F_PP_0103 goodsForm) { //加载产品 ClientRequestEntity cre = new ClientRequestEntity(); //只找出有效标识为1的产品 cre.Properties["CEASEFLAG"] = "1"; ServiceResultEntity result = PPModuleProxy.Service.PlanGoodsSearch(cre); //产品编码 goodsForm.goodsCode.DisplayMember = "GOODSCODE"; goodsForm.goodsCode.ValueMember = "GOODSID"; goodsForm.goodsCode.DataSource = result.Data.Tables[0]; goodsForm.goodsCode.SelectedValue = -1; //产品名称 goodsForm.goodsName.DisplayMember = "GOODSNAME"; goodsForm.goodsName.ValueMember = "GOODSID"; goodsForm.goodsName.DataSource = result.Data.Tables[0]; goodsForm.goodsName.SelectedValue = -1; //产品规格 goodsForm.goodsSpecification.DisplayMember = "GOODSSPECIFICATION"; goodsForm.goodsSpecification.ValueMember = "GOODSID"; goodsForm.goodsSpecification.DataSource = result.Data.Tables[0]; goodsForm.goodsSpecification.SelectedValue = -1; //产品型号 goodsForm.goodsModel.DisplayMember = "GOODSMODEL"; goodsForm.goodsModel.ValueMember = "GOODSID"; goodsForm.goodsModel.DataSource = result.Data.Tables[0]; goodsForm.goodsModel.SelectedValue = -1; } //产品产量 查询处理 private void PlanYearGoodsSearch(int id=0) { if (dgvPlan.SelectedRows.Count > 0) { ClientRequestEntity cre = new ClientRequestEntity(); cre.Properties["PLANID"] = Convert.ToInt32(dgvPlan.SelectedRows[0].Cells["PLANID"].Value); ServiceResultEntity result = PPModuleProxy.Service.PlanYearGoodsSearch(cre); dgvDetail.DataSource = result.Data.Tables[0]; //选中原来的行 默认选择0行 if (id == 0 && dgvDetail.Rows.Count > 0) dgvDetail.Rows[0].Selected = true; else { for (int i = 0; i < dgvDetail.Rows.Count; i++) if (dgvDetail.Rows[i].Cells["PLANGOODSID"].Value.ToString() == id.ToString()) dgvDetail.Rows[i].Selected = true; } } } //产品产量 添加处理 private void PlanYearGoodsAdd() { if(dgvPlan.SelectedRows.Count>0) { F_PP_0103 goodsForm = new F_PP_0103(); goodsForm.planGoodsId = 0; //传入计划ID和冗余数据 goodsForm.planId = Convert.ToInt32(dgvPlan.SelectedRows[0].Cells["PLANID"].Value); goodsForm.planYearNo = Convert.ToInt32(dgvPlan.SelectedRows[0].Cells["YEARNO"].Value); goodsForm.planStartDate = Convert.ToDateTime(dgvPlan.SelectedRows[0].Cells["STARTDATE"].Value); goodsForm.planEndDate = Convert.ToDateTime(dgvPlan.SelectedRows[0].Cells["ENDDATE"].Value); //加载产品选择选项 PlanGoodsLoad(goodsForm); goodsForm.ShowDialog(); if (goodsForm.DialogResult == DialogResult.OK) PlanYearGoodsSearch(PPModuleProxy.Service.Seq("SEQ_PP_PLAN_YEAR_PLANGOODSID.CURRVAL")); } } //产品产量 修改处理 private void PlanYearGoodsEdit() { if (dgvDetail.SelectedRows.Count > 0) { F_PP_0103 goodsForm = new F_PP_0103(); goodsForm.planGoodsId = Convert.ToInt32(dgvDetail.SelectedRows[0].Cells["PlanGoodsId"].Value.ToString()); //加载产品选择选项 PlanGoodsLoad(goodsForm); //更新操作 直接从datagrid中取值 goodsForm.goodsCode.SelectedValue = dgvDetail.SelectedRows[0].Cells["GOODSID"].Value; goodsForm.goodsName.SelectedValue = dgvDetail.SelectedRows[0].Cells["GOODSID"].Value; goodsForm.goodsSpecification.SelectedValue = dgvDetail.SelectedRows[0].Cells["GOODSID"].Value; goodsForm.goodsModel.SelectedValue = dgvDetail.SelectedRows[0].Cells["GOODSID"].Value; goodsForm.planQuantity.Value = Convert.ToDecimal(dgvDetail.SelectedRows[0].Cells["PlanQuantity"].Value); goodsForm.planRemarks.Text = dgvDetail.SelectedRows[0].Cells["PlanRemarks"].Value.ToString(); goodsForm.ShowDialog(); if (goodsForm.DialogResult == DialogResult.OK) PlanYearGoodsSearch(Convert.ToInt32(dgvDetail.SelectedRows[0].Cells["PlanGoodsId"].Value)); } } //产品产量 删除处理 private void PlanYearGoodsDelete() { if (dgvDetail.SelectedRows.Count > 0) { if (MessageBox.Show($"您确认要删除【产品编码:{dgvDetail.SelectedRows[0].Cells["GOODSCODE"].Value} 产品名称:{dgvDetail.SelectedRows[0].Cells["GOODSNAME"].Value}】的记录吗?", "提示信息", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) == DialogResult.OK) { ClientRequestEntity cre = new ClientRequestEntity(); cre.Properties["PLANGOODSID"] = Convert.ToInt32(dgvDetail.SelectedRows[0].Cells["PLANGOODSID"].Value); //删除产品产量记录 PPModuleProxy.Service.PlanYearGoodsDelete(cre); PlanYearSearch(); } } } #endregion #region * 年计划比对 /********************************************************/ //自由比对 private void PlanYearVer() { F_PP_0110 verForm = new F_PP_0110(); verForm.ShowDialog(); } //同表比对 private void PlanYearSame() { F_PP_0111 verForm = new F_PP_0111(); verForm.ShowDialog(); } #endregion } }