/*******************************************************************************
* Copyright(c) 2016 DongkeSoft All rights reserved. / Confidential
* 类的信息:
* 1.程序名称:F_PC_1001.cs
* 2.功能描述:模具档案
* 编辑履历:
* 作者 日期 版本 修改内容
* 陈晓野 2017/12/07 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_1001 : DKDockPanelBase
{
#region 成员变量
private static F_PC_1001 _instance = null;
#endregion
#region 单例模式
///
/// 单例模式,防止重复创建窗体
///
public static F_PC_1001 Instance
{
get
{
if (_instance == null)
{
_instance = new F_PC_1001();
}
return _instance;
}
}
#endregion
#region 构造函数
///
///
///
public F_PC_1001()
{
InitializeComponent();
this.tsbtnAdd.Text = ButtonText.TSBTN_ADD;
this.tsbtnEdit.Text = ButtonText.TSBTN_EDIT;
this.tsbtnAdaptive.Text = ButtonText.TSBTN_ADAPTIVE;
this.tsbtnClose.Text = ButtonText.TSBTN_CLOSE;
this.dgvMould.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.dtpPDateBegin.Value = DateTime.Now;
this.dtpPDateEnd.Value = DateTime.Now;
this.dtpScrapDateBegin.Value = DateTime.Now;
this.dtpScrapDateEnd.Value = DateTime.Now;
ClientRequestEntity cre = new ClientRequestEntity();
cre.NameSpace = "FPC1001";
cre.Name = "GetFPC1001LoadData";
ServiceResultEntity sre = PCModuleProxyNew.Service.HandleRequest(cre);
this.ckcMouldType.DataSource = sre.Data.Tables["MouldType"];
this.ckcSuppliers.DataSource = sre.Data.Tables["Suppliers"];
this.calMouldStatus.DataSource = sre.Data.Tables["MouldStatus"];
this.calMouldStatus.SetItemCheckedByValue(true, 1m, 2m, 3m);
this.dgvMould.SelectionMode = DataGridViewSelectionMode.RowHeaderSelect;
}
catch (Exception ex)
{
// 对异常进行共通处理
ExceptionManager.HandleEventException(this.ToString(),
MethodBase.GetCurrentMethod().Name, this.Text, ex);
}
}
///
/// 生产日期
///
///
///
private void chkPDate_CheckedChanged(object sender, EventArgs e)
{
this.dtpPDateBegin.Enabled = this.chkPDate.Checked;
this.dtpPDateEnd.Enabled = this.chkPDate.Checked;
}
///
/// 报废日期
///
///
///
private void chkScrapDate_CheckedChanged(object sender, EventArgs e)
{
this.dtpScrapDateBegin.Enabled = this.chkScrapDate.Checked;
this.dtpScrapDateEnd.Enabled = this.chkScrapDate.Checked;
}
///
/// 清除查询条件
///
///
///
private void tsbtnClearCondition_Click(object sender, EventArgs e)
{
this.txtModelBarcode.Clear();
this.txtUserCode.Clear();
this.txtGoodsCode.Clear();
this.txtRemarks.Clear();
this.ckcMouldType.ClearValue();
this.ckcSuppliers.ClearValue();
this.chkPDate.Checked = true;
this.chkScrapDate.Checked = false;
this.dtpPDateBegin.Value = DateTime.Now;
this.dtpPDateEnd.Value = DateTime.Now;
this.dtpScrapDateBegin.Value = DateTime.Now;
this.dtpScrapDateEnd.Value = DateTime.Now;
this.calMouldStatus.SetItemCheckedByValue(true, 1m, 2m, 3m);
}
///
/// 查询
///
///
///
private void tsbtnSearch_Click(object sender, EventArgs e)
{
try
{
this.QueryDataFromOther();
this.dgvMould.IsSetInputColumnsColor = true;
}
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();
}
///
/// 新建
///
///
///
private void tsbtnAdd_Click(object sender, EventArgs e)
{
try
{
F_PC_1002 fpc1002 = new F_PC_1002(0);
if (fpc1002.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
this.tsbtnSearch_Click(null, null);
}
}
catch (Exception ex)
{
// 对异常进行共通处理
ExceptionManager.HandleEventException(this.ToString(),
MethodBase.GetCurrentMethod().Name, this.Text, ex);
}
}
///
/// 编辑
///
///
///
private void tsbtnEdit_Click(object sender, EventArgs e)
{
if (this.dgvMould.CurrentRow == null || this.dgvMould.CurrentRow.Index < 0)
{
return;
}
try
{
int mouldID = Convert.ToInt32(this.dgvMould.CurrentRow.Cells["MouldID"].Value);
F_PC_1002 fpc1002 = new F_PC_1002(mouldID);
if (fpc1002.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
this.tsbtnSearch_Click(null, null);
}
}
catch (Exception ex)
{
// 对异常进行共通处理
ExceptionManager.HandleEventException(this.ToString(),
MethodBase.GetCurrentMethod().Name, this.Text, ex);
}
}
///
/// 打印
///
///
///
private void tsbtnPrint_Click(object sender, EventArgs e)
{
if (this.dgvMould.CurrentRow == null || this.dgvMould.CurrentRow.Index < 0)
{
return;
}
try
{
string barcode = this.dgvMould.CurrentRow.Cells["MouldBarcode"].Value.ToString();
F_MST_013006.PrintBarcode(barcode, 1, this);
}
catch (Exception ex)
{
// 对异常进行共通处理
ExceptionManager.HandleEventException(this.ToString(),
MethodBase.GetCurrentMethod().Name, this.Text, ex);
}
}
///
/// 双击编辑
///
///
///
private void dgvMould_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
{
if (!this.tsbtnEdit.Visible || !this.tsbtnEdit.Enabled)
{
return;
}
if (e.ColumnIndex < 0 || e.RowIndex < 0 || "Sel" == dgvMould.Columns[e.ColumnIndex].Name)
{
return;
}
try
{
int mouldID = Convert.ToInt32(this.dgvMould.CurrentRow.Cells["MouldID"].Value);
F_PC_1002 fpc1002 = new F_PC_1002(mouldID);
if (fpc1002.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
this.tsbtnSearch_Click(null, null);
}
}
catch (Exception ex)
{
// 对异常进行共通处理
ExceptionManager.HandleEventException(this.ToString(),
MethodBase.GetCurrentMethod().Name, this.Text, ex);
}
}
///
/// 报废
///
///
///
private void tsbtnScrap_Click(object sender, EventArgs e)
{
try
{
DataTable dt = this.dgvMould.DataSource as DataTable;
if (dt == null || dt.Rows.Count == 0)
{
return;
}
DataRow[] items = dt.Select("Sel = 1 and MouldStatus in (1,3)");
if (items == null || items.Length == 0)
{
MessageBox.Show("没有选择任何模具,或所选模具不是【在库】、【待产】状态",
this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning,
MessageBoxDefaultButton.Button1);
return;
}
List ids = new List();
foreach (DataRow item in items)
{
ids.Add(item["MouldID"].ToString());
}
F_PC_1004 fpc1004 = new F_PC_1004(string.Join(",", ids), Constant.MouldOperationType.InvToScrap);
if (fpc1004.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
this.tsbtnSearch_Click(null, null);
}
}
catch (Exception ex)
{
// 对异常进行共通处理
ExceptionManager.HandleEventException(this.ToString(),
MethodBase.GetCurrentMethod().Name, this.Text, ex);
}
}
///
/// 撤销报废
///
///
///
private void tsbtnUndoScrap_Click(object sender, EventArgs e)
{
try
{
DataTable dt = this.dgvMould.DataSource as DataTable;
if (dt == null || dt.Rows.Count == 0)
{
return;
}
DataRow[] items = dt.Select("Sel = 1 and MouldStatus = 4");
if (items == null || items.Length == 0)
{
MessageBox.Show("没有选择任何模具,或所选模具不是【报废】状态",
this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning,
MessageBoxDefaultButton.Button1);
return;
}
List ids = new List();
foreach (DataRow item in items)
{
ids.Add(item["MouldID"].ToString());
}
F_PC_1004 fpc1004 = new F_PC_1004(string.Join(",", ids), Constant.MouldOperationType.ScrapToInv);
if (fpc1004.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
this.tsbtnSearch_Click(null, null);
}
}
catch (Exception ex)
{
// 对异常进行共通处理
ExceptionManager.HandleEventException(this.ToString(),
MethodBase.GetCurrentMethod().Name, this.Text, ex);
}
}
///
/// 领用
///
///
///
private void tsbtnOut_Click(object sender, EventArgs e)
{
try
{
DataTable dt = this.dgvMould.DataSource as DataTable;
if (dt == null || dt.Rows.Count == 0)
{
return;
}
DataRow[] items = dt.Select("Sel = 1 and MouldStatus = 1");
if (items == null || items.Length == 0)
{
MessageBox.Show("没有选择任何模具,或所选模具不是【在库】状态",
this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning,
MessageBoxDefaultButton.Button1);
return;
}
List ids = new List();
foreach (DataRow item in items)
{
ids.Add(item["MouldID"].ToString());
}
F_PC_1004 fpc1004 = new F_PC_1004(string.Join(",", ids), Constant.MouldOperationType.InvToOut);
if (fpc1004.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
this.tsbtnSearch_Click(null, null);
}
}
catch (Exception ex)
{
// 对异常进行共通处理
ExceptionManager.HandleEventException(this.ToString(),
MethodBase.GetCurrentMethod().Name, this.Text, ex);
}
}
///
/// 回收
///
///
///
private void tsbtnIn_Click(object sender, EventArgs e)
{
try
{
DataTable dt = this.dgvMould.DataSource as DataTable;
if (dt == null || dt.Rows.Count == 0)
{
return;
}
DataRow[] items = dt.Select("Sel = 1 and MouldStatus = 3");
if (items == null || items.Length == 0)
{
MessageBox.Show("没有选择任何模具,或所选模具不是【待产】状态",
this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning,
MessageBoxDefaultButton.Button1);
return;
}
List ids = new List();
foreach (DataRow item in items)
{
ids.Add(item["MouldID"].ToString());
}
F_PC_1004 fpc1004 = new F_PC_1004(string.Join(",", ids), Constant.MouldOperationType.OutToInv);
if (fpc1004.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
this.tsbtnSearch_Click(null, null);
}
}
catch (Exception ex)
{
// 对异常进行共通处理
ExceptionManager.HandleEventException(this.ToString(),
MethodBase.GetCurrentMethod().Name, this.Text, ex);
}
}
///
/// 替换条码
///
///
///
private void tsbtnChangeBarcode_Click(object sender, EventArgs e)
{
if (this.dgvMould.CurrentRow == null || this.dgvMould.CurrentRow.Index < 0)
{
return;
}
try
{
int mouldID = Convert.ToInt32(this.dgvMould.CurrentRow.Cells["MouldID"].Value);
F_PC_1003 fpc1003 = new F_PC_1003(mouldID);
if (fpc1003.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
this.tsbtnSearch_Click(null, null);
}
}
catch (Exception ex)
{
// 对异常进行共通处理
ExceptionManager.HandleEventException(this.ToString(),
MethodBase.GetCurrentMethod().Name, this.Text, ex);
}
}
///
/// 变更型号
///
///
///
private void tsbtnChangeGoodsCode_Click(object sender, EventArgs e)
{
try
{
DataTable dt = this.dgvMould.DataSource as DataTable;
if(dt == null || dt.Rows.Count == 0)
{
return;
}
DataRow[] items = dt.Select("Sel = 1 and MouldStatus in (1,2,3)");
if (items == null || items.Length == 0)
{
MessageBox.Show("没有选择任何模具,或所选模具不是【在库】、【在产】、【待产】状态",
this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning,
MessageBoxDefaultButton.Button1);
return;
}
List ids = new List();
foreach (DataRow item in items)
{
ids.Add(item["MouldID"].ToString());
}
F_PC_1004 fpc1004 = new F_PC_1004(string.Join(",", ids), Constant.MouldOperationType.ChangeGoodsCode);
if (fpc1004.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
this.tsbtnSearch_Click(null, null);
}
}
catch (Exception ex)
{
// 对异常进行共通处理
ExceptionManager.HandleEventException(this.ToString(),
MethodBase.GetCurrentMethod().Name, this.Text, ex);
}
}
///
///
///
///
///
private void dgvMould_SelectionChanged(object sender, EventArgs e)
{
try
{
}
catch (Exception ex)
{
// 对异常进行共通处理
ExceptionManager.HandleEventException(this.ToString(),
MethodBase.GetCurrentMethod().Name, this.Text, ex);
}
}
///
///
///
///
///
private void dgvMould_CurrentCellDirtyStateChanged(object sender, EventArgs e)
{
if (dgvMould.CurrentCell == null ||
dgvMould.CurrentCell.RowIndex < 0 ||
dgvMould.CurrentCell.ColumnIndex < 0)
{
return;
}
try
{
if (dgvMould.Columns[dgvMould.CurrentCell.ColumnIndex].Name == "Sel")
{
this.dgvMould.CommitEdit(DataGridViewDataErrorContexts.Commit);
this.dgvMould.EndEdit();
DataRowView drv = (this.dgvMould.CurrentRow.DataBoundItem as DataRowView);
if (drv != null)
{
drv.EndEdit();
}
}
}
catch (Exception ex)
{
// 对异常进行共通处理
ExceptionManager.HandleEventException(this.ToString(),
MethodBase.GetCurrentMethod().Name, this.Text, ex);
}
}
///
/// 全选
///
///
///
private void tsbtnSelectAll_Click(object sender, EventArgs e)
{
try
{
DataTable dt = this.dgvMould.DataSource as DataTable;
if (dt == null || dt.DefaultView.Count == 0)
{
return;
}
foreach (DataRowView item in dt.DefaultView)
{
item["Sel"] = 1;
item.EndEdit();
}
}
catch (Exception ex)
{
// 对异常进行共通处理
ExceptionManager.HandleEventException(this.ToString(),
MethodBase.GetCurrentMethod().Name, this.Text, ex);
}
}
///
/// 不选
///
///
///
private void tsbtnUnSelect_Click(object sender, EventArgs e)
{
try
{
DataTable dt = this.dgvMould.DataSource as DataTable;
if (dt == null || dt.Rows.Count == 0)
{
return;
}
foreach (DataRow item in dt.Rows)
{
item["Sel"] = 0;
item.EndEdit();
}
}
catch (Exception ex)
{
// 对异常进行共通处理
ExceptionManager.HandleEventException(this.ToString(),
MethodBase.GetCurrentMethod().Name, this.Text, ex);
}
}
///
/// 反选
///
///
///
private void tsbtnReSelect_Click(object sender, EventArgs e)
{
try
{
DataTable dt = this.dgvMould.DataSource as DataTable;
if (dt == null || dt.DefaultView.Count == 0)
{
return;
}
foreach (DataRowView item in dt.DefaultView)
{
if (Convert.ToInt32(item["Sel"]) == 0)
{
item["Sel"] = 1;
}
else
{
item["Sel"] = 0;
}
item.EndEdit();
}
}
catch (Exception ex)
{
// 对异常进行共通处理
ExceptionManager.HandleEventException(this.ToString(),
MethodBase.GetCurrentMethod().Name, this.Text, ex);
}
}
#endregion
#region 私有方法
///
/// 查询数据
///
/// 验证通过true,其他false
private void QueryDataFromOther()
{
try
{
ClientRequestEntity cre = new ClientRequestEntity();
cre.NameSpace = "FPC1001";
cre.Name = "GetFPC1001QueryData";
cre.Properties["MouldBarcode"] = this.txtModelBarcode.Text.Trim();
cre.Properties["UserCode"] = this.txtUserCode.Text.Trim();
cre.Properties["GoodsCode"] = this.txtGoodsCode.Text.Trim();
cre.Properties["Remarks"] = this.txtRemarks.Text;
cre.Properties["MouldTypes"] = this.ckcMouldType.CheckedValue;
cre.Properties["Suppliers"] = this.ckcSuppliers.CheckedValue;
if (this.chkPDate.Checked)
{
cre.Properties["PDateBegin"] = this.dtpPDateBegin.BeginTime;
cre.Properties["PDateEnd"] = this.dtpPDateEnd.EndTime;
}
if (this.chkScrapDate.Checked)
{
cre.Properties["ScrapDateBegin"] = this.dtpScrapDateBegin.BeginTime;
cre.Properties["ScrapDateEnd"] = this.dtpScrapDateEnd.EndTime;
}
cre.Properties["MouldStatus"] = this.calMouldStatus.CheckedValue;
this.dgvMould.DataSource = null;
ServiceResultEntity sre = DoAsync(() =>
{
return PCModuleProxyNew.Service.HandleRequest(cre);
}
);
if (sre.Status == Constant.ServiceResultStatus.Success)
{
// 查询成功
this.dgvMould.DataSource = sre.Data.Tables[0];
}
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
}
}