/*******************************************************************************
* 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
{
///
/// 模具操作
///
public partial class F_PC_1004 : DKFormBase
{
#region 成员变量
private string _mouldIDs = null;
private Constant.MouldOperationType _mouldOperationType;
#endregion
#region 构造函数
///
///
///
public F_PC_1004(string mouldIDs, Constant.MouldOperationType mouldOperationType)
{
InitializeComponent();
this.dgvMould.AutoGenerateColumns = false;
_mouldIDs = mouldIDs;
_mouldOperationType = mouldOperationType;
}
#endregion
#region 控件事件
///
/// 画面加载
///
///
///
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);
}
}
///
/// 查询
///
///
///
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 ids = new List();
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(() =>
{
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);
}
}
///
/// 排序
///
///
///
private void dgvMould_Sorted(object sender, EventArgs e)
{
this.dgvMould.IsSetInputColumnsColor = true;
}
///
/// 自适应列宽
///
///
///
private void tsbtnAdaptive_Click(object sender, EventArgs e)
{
this.dgvMould.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells);
}
///
/// 关闭画面
///
///
///
private void tsbtnClose_Click(object sender, EventArgs e)
{
this.Close();
}
#endregion
#region 私有方法
///
/// 保存前画面数据验证
///
///
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
}
}