| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262 |
- /*******************************************************************************
- * Copyright(c) 2016 DongkeSoft All rights reserved. / Confidential
- * 类的信息:
- * 1.程序名称:F_PC_1004.cs
- * 2.功能描述:模具操作
- * 编辑履历:
- * 作者 日期 版本 修改内容
- * 陈晓野 2017/12/12 1.00 新建
- *******************************************************************************/
- using System;
- using System.Collections.Generic;
- using System.Data;
- 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
- {
- /// <summary>
- /// 模具操作
- /// </summary>
- public partial class F_PC_1004 : DKFormBase
- {
- #region 成员变量
- private string _mouldIDs = null;
- private Constant.MouldOperationType _mouldOperationType;
- #endregion
- #region 构造函数
- /// <summary>
- ///
- /// </summary>
- public F_PC_1004(string mouldIDs, Constant.MouldOperationType mouldOperationType)
- {
- InitializeComponent();
- this.dgvMould.AutoGenerateColumns = false;
- _mouldIDs = mouldIDs;
- _mouldOperationType = mouldOperationType;
- }
- #endregion
- #region 控件事件
- /// <summary>
- /// 画面加载
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void F_PC_1001_Load(object sender, System.EventArgs e)
- {
- try
- {
- bool hasLoad = false;
- ClientRequestEntity cre = new ClientRequestEntity();
- cre.NameSpace = "FPC1001";
- cre.Name = "GetFPC1001QueryData";
- cre.Properties["MouldIDs"] = _mouldIDs;
- switch (_mouldOperationType)
- {
- case Constant.MouldOperationType.ChangeGoodsCode:
- this.Text = "变更型号-【在库、在产、待产】模具";
- this.dkGoodsCode.Visible = true;
- cre.Properties["MouldStatus"] = (int)Constant.MouldStatus.Inv + "," + (int)Constant.MouldStatus.OnLine + "," + (int)Constant.MouldStatus.Out;
- break;
- case Constant.MouldOperationType.InvToOut:
- this.Text = "模具领用-【在库】模具";
- cre.Properties["MouldStatus"] = (int)Constant.MouldStatus.Inv;
- break;
- case Constant.MouldOperationType.OutToInv:
- this.Text = "模具回收-【待产】模具";
- cre.Properties["MouldStatus"] = (int)Constant.MouldStatus.Out;
- break;
- case Constant.MouldOperationType.InvToScrap:
- this.Text = "模具报损-【在库、待产】模具";
- cre.Properties["MouldStatus"] = (int)Constant.MouldStatus.Inv + "," + (int)Constant.MouldStatus.Out;
- this.lblScrapReason.Visible = true;
- this.lblScrapResponsibility.Visible = true;
- this.ftcScrapReason.Visible = true;
- this.txtScrapResponsibility.Visible = true;
- hasLoad = true;
- break;
- case Constant.MouldOperationType.ScrapToInv:
- this.Text = "报损撤销-【报废】模具";
- cre.Properties["MouldStatus"] = (int)Constant.MouldStatus.Scrap;
- break;
- default:
- return;
- }
- ServiceResultEntity sre = PCModuleProxyNew.Service.HandleRequest(cre);
- this.dgvMould.DataSource = sre.Data.Tables[0];
- if (hasLoad)
- {
- ClientRequestEntity creLoad = new ClientRequestEntity();
- creLoad.NameSpace = "FPC1004";
- creLoad.Name = "GetFPC1004LoadData";
- creLoad.Properties["MouldOperationType"] = (int)_mouldOperationType;
- ServiceResultEntity sreLoad = PCModuleProxyNew.Service.HandleRequest(creLoad);
- this.ftcScrapReason.ValueMember = "dictionaryid";
- this.ftcScrapReason.DisplayMember = "dictionaryvalue";
- this.ftcScrapReason.DataSource = sreLoad.Data.Tables[0];
- }
- //this.dgvMould.SelectionMode = DataGridViewSelectionMode.RowHeaderSelect;
- }
- catch (Exception ex)
- {
- // 对异常进行共通处理
- ExceptionManager.HandleEventException(this.ToString(),
- MethodBase.GetCurrentMethod().Name, this.Text, ex);
- }
- }
- /// <summary>
- /// 查询
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void tsbtnSave_Click(object sender, EventArgs e)
- {
- try
- {
- if (!this.CheckInput())
- {
- return;
- }
- ClientRequestEntity cre = new ClientRequestEntity();
- cre.NameSpace = "FPC1004";
- cre.Name = "SetFPC1004Data";
- cre.Properties["MouldOperationType"] = (int)_mouldOperationType;
- if (this.dkGoodsCode.Visible)
- {
- cre.Properties["GoodsID"] = this.dkGoodsCode.GoodsID;
- cre.Properties["GoodsCode"] = this.dkGoodsCode.GoodsCode;
- }
- if (this.ftcScrapReason.Visible)
- {
- cre.Properties["ScrapReason"] = this.ftcScrapReason.SelectedValue;
- cre.Properties["ScrapResponsibility"] = this.txtScrapResponsibility.Text;
- }
- cre.Properties["Remarks"] = this.txtRemarks.Text;
- List<string> ids = new List<string>();
- foreach (DataRow item in (this.dgvMould.DataSource as DataTable).Rows)
- {
- ids.Add(item["MouldID"].ToString());
- }
- cre.Properties["MouldIDs"] = string.Join(",", ids);
- ServiceResultEntity sre = this.DoAsync<ServiceResultEntity>(() =>
- {
- return PCModuleProxyNew.Service.HandleRequest(cre);
- });
- if (sre != null)
- {
- if (sre.Status == Constant.ServiceResultStatus.Success)
- {
- // 提示信息
- MessageBox.Show(string.Format(Messages.MSG_CMN_I001, this.Text, "保存"),
- this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
- this.DialogResult = DialogResult.OK;
- this.Close();
- }
- else if (!string.IsNullOrWhiteSpace(sre.Message))
- {
- MessageBox.Show(sre.Message,
- this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
- }
- }
- else
- {
- // 提示信息
- MessageBox.Show("保存失败",
- this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
- }
- }
- catch (Exception ex)
- {
- // 对异常进行共通处理
- ExceptionManager.HandleEventException(this.ToString(),
- MethodBase.GetCurrentMethod().Name, this.Text, ex);
- }
- }
- /// <summary>
- /// 排序
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void dgvMould_Sorted(object sender, EventArgs e)
- {
- this.dgvMould.IsSetInputColumnsColor = true;
- }
- /// <summary>
- /// 自适应列宽
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void tsbtnAdaptive_Click(object sender, EventArgs e)
- {
- this.dgvMould.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells);
- }
- /// <summary>
- /// 关闭画面
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void tsbtnClose_Click(object sender, EventArgs e)
- {
- this.Close();
- }
- #endregion
- #region 私有方法
- /// <summary>
- /// 保存前画面数据验证
- /// </summary>
- /// <returns></returns>
- private bool CheckInput()
- {
- if ((this.dgvMould.DataSource as DataTable).Rows.Count == 0)
- {
- MessageBox.Show("没有选择任何模具",
- this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning,
- MessageBoxDefaultButton.Button1);
- this.txtRemarks.Focus();
- return false;
- }
- if (this.dkGoodsCode.Visible && this.dkGoodsCode.GoodsID == null)
- {
- MessageBox.Show(string.Format(Messages.MSG_CMN_W005, "产品型号"),
- this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning,
- MessageBoxDefaultButton.Button1);
- this.dkGoodsCode.Focus();
- return false;
- }
- if (this.ftcScrapReason.Visible && this.ftcScrapReason.SelectedValue == null)
- {
- MessageBox.Show(string.Format(Messages.MSG_CMN_W005, "报废原因"),
- this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning,
- MessageBoxDefaultButton.Button1);
- this.ftcScrapReason.Focus();
- return false;
- }
- return true;
- }
- #endregion
- }
- }
|