| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477 |
- /*******************************************************************************
- * Copyright(c) 2019 DongkeSoft All rights reserved. / Confidential
- * 类的信息:
- * 1.程序名称:F_PP_0301.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
- {
- /// <summary>
- /// 日计划窗体
- /// </summary>
- public partial class F_PP_0301 : DKDockPanelBase
- {
- #region 默认方法
- /********************************************************/
- private static F_PP_0301 _instance = null;
- public static F_PP_0301 Instance
- {
- get
- {
- if (_instance == null)
- {
- _instance = new F_PP_0301();
- }
- return _instance;
- }
- }
- private void F_PP_0301_FormClosed(object sender, FormClosedEventArgs e)
- {
- _instance = null;
- }
- //单实例
- public F_PP_0301()
- {
- InitializeComponent();
- this.Text = "日计划";
- this.tsbtnAdaptive.Text = ButtonText.TSBTN_ADAPTIVE;
- this.tsbtnClose.Text = ButtonText.TSBTN_CLOSE;
- this.dgvPlan.AutoGenerateColumns = false;
- }
- //窗体加载
- private void F_PP_0301_Load(object sender, System.EventArgs e)
- {
- try
- {
- // 加载权限
- FormPermissionManager.FormPermissionControl(this.Name, this,
- LogInUserInfo.CurrentUser.CurrentUserEntity.UserRightData,
- LogInUserInfo.CurrentUser.CurrentUserEntity.FunctionData);
- //加载计划类型
- PlanDayTypeLoad();
- //默认清空条件
- SearchEnpty();
- }
- catch (Exception ex)
- {
- // 对异常进行共通处理
- ExceptionManager.HandleEventException(this.ToString(),
- MethodBase.GetCurrentMethod().Name, this.Text, ex);
- }
- }
- #endregion
- #region 窗体事件定义和处理
- /********************************************************/
- //双击进入编辑
- private void DgvPlan_DoubleClick(object sender, EventArgs e)
- {
- PlanDayEdit();
- }
- //清空搜索条件
- private void BtnEmpty_Click(object sender, EventArgs e)
- {
- SearchEnpty();
- }
- //日计划 查询处理
- private void BtnSearch_Click(object sender, EventArgs e)
- {
- PlanDaySearch();
- }
- //自适应列宽
- 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)
- {
- PlanDaySearch();
- }
- //清空
- private void TsbtnClearCondition_Click(object sender, EventArgs e)
- {
- SearchEnpty();
- }
- //显示历史版本处理
- private void ShowVer_Click(object sender, EventArgs e)
- {
- PlanDaySearch();
- }
- //日计划 自由比对
- private void TsbtnVer_Click(object sender, EventArgs e)
- {
- PlanDayVer();
- }
- //日计划 同表比对
- private void TsbtnSame_Click(object sender, EventArgs e)
- {
- PlanDaySame();
- }
- //日计划选中记录后
- 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;
- //显示产品产量列表
- PlanDayGoodsSearch();
- }
- //产量计划选中记录后
- 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)
- {
- PlanDayAdd();
- }
- //保存副本
- private void TsbtnCopy_Click(object sender, EventArgs e)
- {
- PlanDayCopy();
- }
- //双击修改
- private void DgvDetail_DoubleClick(object sender, EventArgs e)
- {
- PlanDayGoodsEdit();
- }
- //产品产量 新建
- private void TsbtnPlanGoodsAdd_Click(object sender, EventArgs e)
- {
- PlanDayGoodsAdd();
- }
- //日计划 修改
- private void TsbtnPlanEdit_Click(object sender, EventArgs e)
- {
- PlanDayEdit();
- }
- //产品产量 修改
- private void TsbtnPlanGoodsEdit_Click(object sender, EventArgs e)
- {
- PlanDayGoodsEdit();
- }
- //日计划 删除
- private void TsbtnPlanDelete_Click(object sender, EventArgs e)
- {
- PlanDayDelete();
- }
- //产品产量 删除
- private void TsbtnPlanGoodsDelete_Click(object sender, EventArgs e)
- {
- PlanDayGoodsDelete();
- }
- #endregion
- #region 日计划处理方法
- /********************************************************/
- //清空搜索条件
- private void SearchEnpty()
- {
- pName.Text = "";
- pYearNo.Text = "";
- pMonthNo.Text = "";
- pDayNo.Text = "";
- pType.SelectedIndex = -1;
- pRemarks.Text = "";
- }
- //加载计划类型
- private void PlanDayTypeLoad()
- {
- 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 PlanDaySearch(int id=0)
- {
- ClientRequestEntity cre = new ClientRequestEntity();
- if (pYearNo.Text.Trim() != "") cre.Properties["YEARNO"] = Convert.ToInt32(pYearNo.Text.Trim());
- if (pMonthNo.Text.Trim() != "") cre.Properties["MONTHNO"] = Convert.ToInt32(pMonthNo.Text.Trim());
- if (pDayNo.Text.Trim() != "") cre.Properties["DAYNO"] = Convert.ToInt32(pDayNo.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.PlanDayVerSearch(cre);
- else
- result = PPModuleProxy.Service.PlanDaySearch(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 PlanDayAdd()
- {
- F_PP_0302 yearForm = new F_PP_0302();
- 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.planMonthNo.Value = pMonthNo.Value;
- yearForm.planDayNo.Value = pDayNo.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)
- PlanDaySearch(PPModuleProxy.Service.Seq("SEQ_PP_PLAN_DAY_PLANID.CURRVAL"));
- }
- //日计划 修改处理
- private void PlanDayEdit()
- {
- if(dgvPlan.SelectedRows.Count>0)
- {
- F_PP_0302 yearForm = new F_PP_0302();
- 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.planMonthNo.Value = Convert.ToDecimal(dgvPlan.SelectedRows[0].Cells["MonthNo"].Value.ToString());
- yearForm.planDayNo.Value = Convert.ToDecimal(dgvPlan.SelectedRows[0].Cells["DayNo"].Value.ToString());
- yearForm.planName.Text = dgvPlan.SelectedRows[0].Cells["PlanName"].Value.ToString();
- yearForm.planType.SelectedValue = dgvPlan.SelectedRows[0].Cells["PlanTypeId"].Value;
- yearForm.planRemarks.Text = dgvPlan.SelectedRows[0].Cells["Remarks"].Value.ToString();
- yearForm.ShowDialog();
- //保存
- if (yearForm.DialogResult == DialogResult.OK)
- PlanDaySearch(Convert.ToInt32(dgvPlan.SelectedRows[0].Cells["PlanId"].Value));
- }
- }
- //日计划 删除处理
- private void PlanDayDelete()
- {
- 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.PlanDayGoodsDelete(cre);
- //删除日计划记录
- PPModuleProxy.Service.PlanDayDelete(cre);
- PlanDaySearch();
- }
- }
- }
- //日计划 保存副本
- private void PlanDayCopy()
- {
- 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.PlanDayCopy(planId);
- PlanDaySearch(newPlanId);
- }
- }
- #endregion
- #region 产品产量计划处理
- /********************************************************/
- //加载产品列表
- private void PlanGoodsLoad(F_PP_0303 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 PlanDayGoodsSearch(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.PlanDayGoodsSearch(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 PlanDayGoodsAdd()
- {
- if(dgvPlan.SelectedRows.Count>0)
- {
- F_PP_0303 goodsForm = new F_PP_0303();
- 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.planMonthNo = Convert.ToInt32(dgvPlan.SelectedRows[0].Cells["MONTHNO"].Value);
- goodsForm.planDayNo = Convert.ToInt32(dgvPlan.SelectedRows[0].Cells["DAYNO"].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)
- PlanDayGoodsSearch(PPModuleProxy.Service.Seq("SEQ_PP_PLAN_DAY_PLANGOODSID.CURRVAL"));
- }
- }
- //产品产量 修改处理
- private void PlanDayGoodsEdit()
- {
- if (dgvDetail.SelectedRows.Count > 0)
- {
- F_PP_0303 goodsForm = new F_PP_0303();
- 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)
- PlanDayGoodsSearch(Convert.ToInt32(dgvDetail.SelectedRows[0].Cells["PlanGoodsId"].Value));
- }
- }
- //产品产量 删除处理
- private void PlanDayGoodsDelete()
- {
- 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.PlanDayGoodsDelete(cre);
- PlanDaySearch();
- }
- }
- }
- #endregion
- #region * 日计划比对
- /********************************************************/
- //自由比对
- private void PlanDayVer()
- {
- F_PP_0110 verForm = new F_PP_0110();
- verForm.ShowDialog();
- }
- //同表比对
- private void PlanDaySame()
- {
- F_PP_0111 verForm = new F_PP_0111();
- verForm.ShowDialog();
- }
- #endregion
- }
- }
|