/*******************************************************************************
* Copyright(c) 2014 DongkeSoft All rights reserved. / Confidential
* 类的信息:
* 1.程序名称:F_PM_0602.cs
* 2.功能描述:入窑、出窑、卸车计件新建
* 编辑履历:
* 作者 日期 版本 修改内容
* 张国印 2014/09/28 1.00 新建
*******************************************************************************/
using System;
using System.Collections.Generic;
using System.Data;
using System.Windows.Forms;
using Dongke.IBOSS.PRD.Basics.BaseControls;
using Dongke.IBOSS.PRD.Basics.BaseResources;
using Dongke.IBOSS.PRD.Basics.Library;
using Dongke.IBOSS.PRD.Client.CommonModule;
using Dongke.IBOSS.PRD.WCF.DataModels;
using Dongke.IBOSS.PRD.WCF.Proxys;
using Dongke.IBOSS.PRD.WCF.Proxys.PMModuleService;
using Dongke.IBOSS.PRD.WCF.Proxys.SystemModuleService;
namespace Dongke.IBOSS.PRD.Client.PMModule
{
///
/// 入窑、出窑、卸车计件新建
///
public partial class F_PM_0602 : FormBase
{
#region 成员变量
// 工序ID
private int _procedureID;
//窗体名称
private string _fromTitle;
// 工序实体类
ProcedureEntity _procedureDataEntity;
// 生产数据实体类
List _productionDataEntity = new List();
// 数据源Table
private DataTable _dataSourceTable = null;
// 添加行数据源
private DataTable _collectType = null;
// 当前操作实体
ProductionDataEntity _productionEntity = new ProductionDataEntity();
//窑车实体类
CheckKilnCarResultEntity _kilnCarEntity = null;
// 配置文件的全路径
private string _iniFilePath = LocalPath.RootPath + Constant.INI_FILE_NAME;
#endregion
#region 构造函数
///
/// 构造函数
///
public F_PM_0602()
{
InitializeComponent();
}
///
/// 构造函数
///
/// 工序编号
/// 窗体名称
public F_PM_0602(int procedureID, string fromTitle)
{
InitializeComponent();
this._procedureID = procedureID;
this._fromTitle = fromTitle;
this.SetFromTitleInfo();
}
#endregion
#region 属性
///
/// 绑定GridView数据源
///
public DataTable DataSourceTable
{
set
{
_dataSourceTable = value;
}
get
{
if (_dataSourceTable == null)
{
_dataSourceTable = new DataTable("Table1");
_dataSourceTable.Columns.Add("BarCode");
_dataSourceTable.Columns.Add("GoodsID");
_dataSourceTable.Columns.Add("GoodsCode");
_dataSourceTable.Columns.Add("GoodsName");
_dataSourceTable.Columns.Add("UserID");
_dataSourceTable.Columns.Add("UserCode");
_dataSourceTable.Columns.Add("UserName");
_dataSourceTable.Columns.Add("KilnID");
_dataSourceTable.Columns.Add("KilnCode");
_dataSourceTable.Columns.Add("KilnName");
_dataSourceTable.Columns.Add("KilnCarID");
_dataSourceTable.Columns.Add("KilnCarCode");
_dataSourceTable.Columns.Add("KilnCarName");
_dataSourceTable.Columns.Add("KilnCarPosition", typeof(decimal));
_dataSourceTable.Columns.Add("Remarks");
_dataSourceTable.Columns.Add("IsPublicBody");
_dataSourceTable.Columns.Add("MouldCode");
_dataSourceTable.Columns.Add("GroutingUserCode");
_dataSourceTable.Columns.Add("GroutingNum");
_dataSourceTable.Columns.Add("GroutingDate", typeof(DateTime));
_dataSourceTable.Columns.Add("LogoCodeName");
return _dataSourceTable;
}
else
{
return _dataSourceTable;
}
}
}
///
/// 添加行数据源
///
public DataTable DataSourceCollectTypeTable
{
set
{
_collectType = value;
}
get
{
if (_collectType == null)
{
_collectType = new DataTable("Table2");
_collectType.Columns.Add("BarCode");
_collectType.Columns.Add("GoodsID");
_collectType.Columns.Add("GoodsCode");
_collectType.Columns.Add("GoodsName");
_collectType.Columns.Add("UserID");
_collectType.Columns.Add("UserCode");
_collectType.Columns.Add("UserName");
_collectType.Columns.Add("KilnID");
_collectType.Columns.Add("KilnCode");
_collectType.Columns.Add("KilnName");
_collectType.Columns.Add("KilnCarID");
_collectType.Columns.Add("KilnCarCode");
_collectType.Columns.Add("KilnCarName");
_collectType.Columns.Add("KilnCarPosition", typeof(decimal));
_collectType.Columns.Add("Remarks");
return _collectType;
}
else
{
return _collectType;
}
}
}
#endregion
#region 事件
///
/// 窗体加载事件
///
///
///
private void F_PM_0602_Load(object sender, EventArgs e)
{
try
{
//string getKiln = Utility.ReadIniFile(Constant.INI_SECTION_SETTINGS,
// Constant.INI_KEY_KILN_CODE, this._iniFilePath);
string getKiln = Utility.ReadIniFile(Constant.INI_SECTION_SETTINGS,
Constant.INI_KEY_KILN_CODE, LocalPath.LocalINIFilePath);
if (getKiln != string.Empty)
{
this.txtKiln.Text = getKiln;
this.txtKilnCarCode.Focus();
}
else
{
this.txtKiln.Focus();
}
// 加载权限
FormPermissionManager.FormPermissionControl(this.Name, this,
Dongke.IBOSS.PRD.Client.DataModels.LogInUserInfo.CurrentUser.CurrentUserEntity.UserRightData,
Dongke.IBOSS.PRD.Client.DataModels.LogInUserInfo.CurrentUser.CurrentUserEntity.FunctionData);
this._productionEntity.UserID = Constant.INT_IS_NEGATIE_ONE;
this._productionEntity.UserCode = string.Empty;
this._productionEntity.UserName = string.Empty;
this._productionEntity.KilnCarID = Constant.INT_IS_NEGATIE_ONE;
this._productionEntity.KilnCarCode = string.Empty;
this._productionEntity.KilnCarName = string.Empty;
this.dgvProduction.DataSource = DataSourceTable;
this.KilnCarPosition.DisplayMember = "DictionaryValue";
this.KilnCarPosition.ValueMember = "DictionaryID";
this.KilnCarPosition.DataSource = GetMSTKilnCarPositionInfo();
// 获取工序明细数据
ProcedureEntity procedureDataEntity = (ProcedureEntity)DoAsync(new BaseAsyncMethod(() =>
{
return PMModuleProxy.Service.GetProcedureDataEntityByID(this._procedureID);
}));
this._procedureDataEntity = procedureDataEntity;
// 设置控件禁用或启用
SetControlEnable();
//this.txtKiln.Focus();
}
catch (Exception ex)
{
// 对异常进行共通处理
ExceptionManager.HandleEventException(this.ToString(),
System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
}
}
///
/// 窗体关闭事件
///
///
///
private void tsbtnClose_Click(object sender, EventArgs e)
{
this.Close();
}
///
/// 窗体关闭事件
///
///
///
private void btnCancel_Click(object sender, EventArgs e)
{
this.Close();
}
///
/// 自动适应列宽
///
///
///
private void tsbtnAdaptive_Click(object sender, EventArgs e)
{
this.dgvProduction.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells);
}
///
/// 删除按钮事件
///
///
///
private void tsbtnDelete_Click(object sender, EventArgs e)
{
if (this.dgvProduction.CurrentCell != null)
{
this.DataSourceTable.Rows[this.dgvProduction.CurrentCell.RowIndex].Delete();
}
}
///
/// 控件数据校验时发生
///
///
///
private void txtUserCode_Validating(object sender, System.ComponentModel.CancelEventArgs e)
{
try
{
if (txtUserCode.Text.Trim() == string.Empty) // 如果未添加数据,则此项获取焦点
{
this.txtUserCode.IsMustInput = true;
this.txtUserCode.SelectAll();
e.Cancel = true;
return;
}
else if (!this.txtUserCode.ReadOnly)
{
SUserEntity userEntity = new SUserEntity();
userEntity.UserCode = this.txtUserCode.Text.Trim();
// 是否存在此用户编码的生产工号
CheckProcedureUserResult MsgCheckProcedureUser = (CheckProcedureUserResult)DoAsync(new BaseAsyncMethod(() =>
{
return PMModuleProxy.Service.CheckProcedureUser(this._procedureID, this.txtUserCode.Text.Trim());
}));
if (MsgCheckProcedureUser != null)
{
if (!string.IsNullOrEmpty(MsgCheckProcedureUser.ErrMsg))
{
MessageBox.Show(MsgCheckProcedureUser.ErrMsg,
this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
this.txtUserCode.SelectAll();
e.Cancel = true;
return;
}
// 有此生产工号
if (this._productionEntity.UserID != Constant.INT_IS_NEGATIE_ONE)
{
if (MsgCheckProcedureUser.UserID != this._productionEntity.UserID)
{
btnSave_Click(sender, e);
}
}
this._productionEntity.UserID = MsgCheckProcedureUser.UserID;
this._productionEntity.UserCode = MsgCheckProcedureUser.UserCode;
this._productionEntity.UserName = MsgCheckProcedureUser.UserName;
this.txtUserCode.ReadOnly = true;
}
}
}
catch (Exception ex)
{
// 对异常进行共通处理
ExceptionManager.HandleEventException(this.ToString(),
System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
}
}
///
/// 窑车号按键事件
///
///
///
private void txtKilnCarCode_KeyPress(object sender, KeyPressEventArgs e)
{
try
{
if ((int)e.KeyChar == Constant.SYSTEM_KEYBOARD_ENTER_VALUE) // 按了回车键
{
if (this.txtUserCode.Text.Trim() == string.Empty)
{
this.txtUserCode.Focus();
this.txtKilnCarCode.Text = string.Empty;
return;
}
if (this.txtKilnCarCode.Text.Trim() == string.Empty)
{
this.txtKilnCarCode.SelectAll();
this.txtKilnCarCode.Focus();
return;
}
// 是否存在此窑车号
_kilnCarEntity = (CheckKilnCarResultEntity)DoAsync(new BaseAsyncMethod(() =>
{
return PMModuleProxy.Service.CheckKilnCar(this._procedureID, this.txtKilnCarCode.Text.Trim(), this._procedureDataEntity.ModelType);
}));
if (!string.IsNullOrEmpty(_kilnCarEntity.ErrMsg))
{
MessageBox.Show(_kilnCarEntity.ErrMsg,
this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
this.txtKilnCarCode.SelectAll();
this.txtKilnCarCode.Focus();
return;
}
////////////////// 有此生产工号
////////////////if (this._productionEntity.KilnCarID != Constant.INT_IS_NEGATIE_ONE)
////////////////{
//////////////// if (kilnCarEntity.KilnCarInfos[0].KilnCarID != this._productionEntity.KilnCarID)
//////////////// {
//////////////// if (this._procedureDataEntity.CollectType == (int)Constant.ProcedureCollectType.Togather) // 集中采集 直接保存
//////////////// {
//////////////// this.SaveDataInfo(false);
//////////////// }
//////////////// else
//////////////// {
//////////////// this.DataSourceTable.Rows.Clear();
//////////////// }
//////////////// }
////////////////}
if (_kilnCarEntity != null)
{
this._productionEntity.KilnCarID = _kilnCarEntity.KilnCarInfos[0].KilnCarID;
this._productionEntity.KilnCarCode = _kilnCarEntity.KilnCarInfos[0].KilnCarCode;
this._productionEntity.KilnCarName = _kilnCarEntity.KilnCarInfos[0].KilnCarName;
}
foreach (KilnCarInfo kilnCarInfo in _kilnCarEntity.KilnCarInfos)
{
// 生产数据实体
ProductionDataEntity procedureDataEntity = new ProductionDataEntity();
procedureDataEntity.Barcode = kilnCarInfo.BarCode; // 产品条码
procedureDataEntity.GoodsID = kilnCarInfo.GoodsID;
procedureDataEntity.GoodsCode = kilnCarInfo.GoodsCode;
procedureDataEntity.GoodsName = kilnCarInfo.GoodsName;
procedureDataEntity.UserID = this._productionEntity.UserID;
procedureDataEntity.UserCode = this._productionEntity.UserCode;
procedureDataEntity.UserName = this._productionEntity.UserName;
procedureDataEntity.KilnID = kilnCarInfo.KilnID;
procedureDataEntity.KilnCode = kilnCarInfo.KilnCode;
procedureDataEntity.KilnName = kilnCarInfo.KilnName;
procedureDataEntity.KilnCarID = this._productionEntity.KilnCarID;
procedureDataEntity.KilnCarCode = this._productionEntity.KilnCarCode;
procedureDataEntity.KilnCarName = this._productionEntity.KilnCarName;
procedureDataEntity.KilnCarPosition = kilnCarInfo.KilnCarPosition;
procedureDataEntity.ValueFlag = Constant.ValueFlag.Effective.GetHashCode();
procedureDataEntity.Remarks = txtRemarks.Text.Trim();// 备注信息
procedureDataEntity.IsPublicBody = Convert.ToInt32(kilnCarInfo.Ispublicbody);
procedureDataEntity.MouldCode = kilnCarInfo.MouldCode;
procedureDataEntity.GroutingNum = kilnCarInfo.GroutingNum;
procedureDataEntity.GroutingUserCode = kilnCarInfo.GroutingUserCode;
procedureDataEntity.LogoID = kilnCarInfo.LogoID;
//if (this._procedureDataEntity.CollectType == (int)Constant.ProcedureCollectType.Point) // 单点采集 直接保存
//{
// this.CollectTypeTwo(procedureDataEntity);
//}
//else
//{
this.CollectTypeOne(procedureDataEntity, kilnCarInfo.LogoName + "[" + kilnCarInfo.LogoCode + "]"); // 集中采集
//}
}
//if (this._procedureDataEntity.CollectType == (int)Constant.ProcedureCollectType.Point) // 单点采集 直接保存
//{
// SaveCollectTypeTwo();//单点采集,全部table一起写入
//}
this.txtKilnCarCode.Text = string.Empty;
this.txtKilnCarCode.Focus();
}
}
catch (Exception ex)
{
// 对异常进行共通处理
ExceptionManager.HandleEventException(this.ToString(),
System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
}
}
///
/// 窑车验证事件
///
///
///
private void txtKilnCarCode_Validating(object sender, System.ComponentModel.CancelEventArgs e)
{
//if (this.txtUserCode.Text.Trim() == string.Empty)
//{
// this.txtUserCode.Focus();
// this.txtKilnCarCode.Text = string.Empty;
// return;
//}
//if (this.txtKilnCarCode.Text.Trim() == string.Empty)
//{
// this._kilnCarEntity = null;
// //this.txtKilnCarCode.SelectAll();
// //this.txtKilnCarCode.Focus();
// return;
//}
//if (this.txtKilnCarCode.Text.Trim() != "")
//{
// // 是否存在此窑车号
// _kilnCarEntity = (CheckKilnCarResultEntity)DoAsync(new BaseAsyncMethod(() =>
// {
// return PMModuleProxy.Service.CheckKilnCar(this._procedureID,
// this.txtKiln.Text.Trim() + this.txtKilnCarCode.Text.Trim(), this._procedureDataEntity.ModelType);
// }));
// if (!string.IsNullOrEmpty(_kilnCarEntity.ErrMsg))
// {
// MessageBox.Show(_kilnCarEntity.ErrMsg,
// this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
// this.txtKilnCarCode.SelectAll();
// this.txtKilnCarCode.Focus();
// this.txtKiln.Enabled = true;
// this.txtKilnCarCode.Enabled = true;
// return;
// }
// if (_kilnCarEntity != null)
// {
// this._productionEntity.KilnCarID = _kilnCarEntity.KilnCarInfos[0].KilnCarID;
// this._productionEntity.KilnCarCode = _kilnCarEntity.KilnCarInfos[0].KilnCarCode;
// this._productionEntity.KilnCarName = _kilnCarEntity.KilnCarInfos[0].KilnCarName;
// }
//}
}
///
/// 确定按钮事件
///
///
///
private void btnOk_Click(object sender, EventArgs e)
{
try
{
//this.txtRemarks.Focus();
if (this.txtUserCode.Text.Trim() == string.Empty)
{
this.txtUserCode.Focus();
this.txtKilnCarCode.Text = string.Empty;
return;
}
if (this.txtKilnCarCode.Text.Trim() == string.Empty)
{
this._kilnCarEntity = null;
//this.txtKilnCarCode.SelectAll();
//this.txtKilnCarCode.Focus();
return;
}
if (this.txtKilnCarCode.Text.Trim() != "")
{
// 是否存在此窑车号
_kilnCarEntity = (CheckKilnCarResultEntity)DoAsync(new BaseAsyncMethod(() =>
{
return PMModuleProxy.Service.CheckKilnCar(this._procedureID,
this.txtKiln.Text.Trim() + this.txtKilnCarCode.Text.Trim(), this._procedureDataEntity.ModelType);
}));
if (!string.IsNullOrEmpty(_kilnCarEntity.ErrMsg))
{
MessageBox.Show(_kilnCarEntity.ErrMsg,
this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
this.txtKilnCarCode.SelectAll();
this.txtKilnCarCode.Focus();
//this.txtKiln.Enabled = true;
//this.txtKilnCarCode.Enabled = true;
this.txtKiln.ReadOnly = false;
this.txtKilnCarCode.ReadOnly = false;
return;
}
if (_kilnCarEntity != null)
{
this._productionEntity.KilnCarID = _kilnCarEntity.KilnCarInfos[0].KilnCarID;
this._productionEntity.KilnCarCode = _kilnCarEntity.KilnCarInfos[0].KilnCarCode;
this._productionEntity.KilnCarName = _kilnCarEntity.KilnCarInfos[0].KilnCarName;
//this.txtKilnCarCode.Enabled = true; ;
this.txtKilnCarCode.ReadOnly = false; ;
}
}
if (_kilnCarEntity != null)
{
foreach (KilnCarInfo kilnCarInfo in _kilnCarEntity.KilnCarInfos)
{
// 生产数据实体
ProductionDataEntity procedureDataEntity = new ProductionDataEntity();
procedureDataEntity.Barcode = kilnCarInfo.BarCode; // 产品条码
procedureDataEntity.GoodsID = kilnCarInfo.GoodsID;
procedureDataEntity.GoodsCode = kilnCarInfo.GoodsCode;
procedureDataEntity.GoodsName = kilnCarInfo.GoodsName;
procedureDataEntity.UserID = this._productionEntity.UserID;
procedureDataEntity.UserCode = this._productionEntity.UserCode;
procedureDataEntity.UserName = this._productionEntity.UserName;
procedureDataEntity.KilnID = kilnCarInfo.KilnID;
procedureDataEntity.KilnCode = kilnCarInfo.KilnCode;
procedureDataEntity.KilnName = kilnCarInfo.KilnName;
procedureDataEntity.KilnCarID = this._productionEntity.KilnCarID;
procedureDataEntity.KilnCarCode = this._productionEntity.KilnCarCode;
procedureDataEntity.KilnCarName = this._productionEntity.KilnCarName;
procedureDataEntity.KilnCarPosition = kilnCarInfo.KilnCarPosition;
procedureDataEntity.ValueFlag = Constant.ValueFlag.Effective.GetHashCode();
procedureDataEntity.Remarks = txtRemarks.Text.Trim();// 备注信息
procedureDataEntity.IsPublicBody = Convert.ToInt32(kilnCarInfo.Ispublicbody);
procedureDataEntity.MouldCode = kilnCarInfo.MouldCode;
procedureDataEntity.GroutingNum = kilnCarInfo.GroutingNum;
procedureDataEntity.GroutingUserCode = kilnCarInfo.GroutingUserCode;
procedureDataEntity.CreateTime = kilnCarInfo.GroutingDate;
procedureDataEntity.LogoID = kilnCarInfo.LogoID;
this.CollectTypeOne(procedureDataEntity, kilnCarInfo.LogoName + "[" + kilnCarInfo.LogoCode + "]"); // 集中采集
}
//this.txtKilnCarCode.Text = string.Empty;
this.txtKilnCarCode.SelectAll();
this.txtKilnCarCode.Focus();
this._kilnCarEntity = null;
//this.txtKiln.Enabled = false;
//this.txtKilnCarCode.Enabled = false;
this.txtKiln.ReadOnly = true;
this.txtKilnCarCode.ReadOnly = true;
}
}
catch (Exception ex)
{
// 对异常进行共通处理
ExceptionManager.HandleEventException(this.ToString(),
System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
}
}
///
/// 保存按钮事件
///
///
///
private void btnSave_Click(object sender, EventArgs e)
{
try
{
this.SaveDataInfo(true);
}
catch (Exception ex)
{
// 对异常进行共通处理
ExceptionManager.HandleEventException(this.ToString(),
System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
}
}
///
/// 窗体关闭时事件
///
///
///
private void F_PM_0602_FormClosing(object sender, FormClosingEventArgs e)
{
if (this.btnSave.Visible)
{
try
{
this.DataSourceTable.AcceptChanges();
this.DataSourceCollectTypeTable.Clear();
if (this.DataSourceTable.Rows.Count > Constant.INT_IS_ZERO)
{
DialogResult result = MessageBox.Show(Messages.MSG_CMN_Q001, this.Text,
MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question);
if (result == DialogResult.Yes)
{
// 保存数据
btnSave_Click(sender, e);
}
else if (result == DialogResult.Cancel)
{
e.Cancel = true;
}
}
}
catch (Exception ex)
{
// 对异常进行共通处理
ExceptionManager.HandleEventException(this.ToString(),
System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
}
}
}
///
/// 鼠标单击事件
///
///
///
private void txtUserCode_MouseClick(object sender, MouseEventArgs e)
{
if (this.txtUserCode.Text.Trim() != string.Empty)
{
this.txtUserCode.SelectAll();
}
}
///
/// 生产工号回车事件
///
///
///
private void txtUserCode_KeyPress(object sender, KeyPressEventArgs e)
{
if ((int)e.KeyChar == 13) // 按了回车键
{
this.txtKilnCarCode.Focus();
}
}
#endregion
#region 私有方法
///
/// 设置窗体按钮的文本信息
///
private void SetFromTitleInfo()
{
this.Text = this._fromTitle;
this.tsbtnDelete.Text = ButtonText.TSBTN_DELETE;
//自动适应列宽
this.tsbtnAdaptive.Text = ButtonText.TSBTN_ADAPTIVE;
//关闭
this.tsbtnClose.Text = ButtonText.TSBTN_CLOSE;
this.btnSave.Text = ButtonText.BTN_SAVE;
this.btnCancel.Text = ButtonText.BTN_CLOSE;
}
///
/// 获取窑车位置字典表数据
///
///
public DataTable GetMSTKilnCarPositionInfo()
{
DataTable dtDicInfo = (DataTable)DoAsync(new BaseAsyncMethod(() =>
{
return CommonModuleProxy.Service.GetDataDictionaryByType(Constant.TPC_TPC003);
}));
return dtDicInfo;
}
///
/// 设置控件禁用或启用
///
private void SetControlEnable()
{
if (this._procedureDataEntity != null)
{
if (this._procedureDataEntity.CollectType == (int)Constant.ProcedureCollectType.Togather)
{
this.txtUserCode.Enabled = true;
this.tsbtnDelete.Visible = true;
this.tsbtnDelete.Enabled = true;
this.btnSave.Visible = true;
}
else
{
this.txtUserCode.Enabled = true;
this.txtUserCode.ReadOnly = true;
this._productionEntity.UserID = Dongke.IBOSS.PRD.Client.DataModels.LogInUserInfo.CurrentUser.CurrentUserEntity.UserID;
this._productionEntity.UserCode = Dongke.IBOSS.PRD.Client.DataModels.LogInUserInfo.CurrentUser.CurrentUserEntity.UserCode;
this._productionEntity.UserName = Dongke.IBOSS.PRD.Client.DataModels.LogInUserInfo.CurrentUser.CurrentUserEntity.UserName;
this.txtUserCode.Text = this._productionEntity.UserCode;
// 此工号是否能生产工序
CheckProcedureUserResult checkProcedureUser = (CheckProcedureUserResult)DoAsync(new BaseAsyncMethod(() =>
{
return PMModuleProxy.Service.CheckProcedureUser(this._procedureID,
Dongke.IBOSS.PRD.Client.DataModels.LogInUserInfo.CurrentUser.CurrentUserEntity.UserCode);
}));
if (checkProcedureUser != null)
{
if (!string.IsNullOrEmpty(checkProcedureUser.ErrMsg))
{
// 此工号不允许生产工序
MessageBox.Show(checkProcedureUser.ErrMsg,
this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
this.Close();
return;
}
}
this.btnSave.Visible = true;//单点采集时,也是统一保存,所以显示出来
}
}
}
///
/// 保存方法
///
private void SaveCollectTypeTwo()
{
this.DataSourceTable.AcceptChanges();
this.DataSourceCollectTypeTable.Clear();
foreach (DataRow drproductionData in this.DataSourceTable.Rows)
{
DataRow drCollectType = DataSourceCollectTypeTable.NewRow();
drCollectType["BarCode"] = drproductionData["BarCode"];
drCollectType["GoodsID"] = drproductionData["GoodsID"];
drCollectType["GoodsCode"] = drproductionData["GoodsCode"];
drCollectType["GoodsName"] = drproductionData["GoodsName"];
drCollectType["UserID"] = drproductionData["UserID"];
drCollectType["UserCode"] = drproductionData["UserCode"];
drCollectType["UserName"] = drproductionData["UserName"];
drCollectType["KilnID"] = drproductionData["KilnID"];
drCollectType["KilnCode"] = drproductionData["KilnCode"];
drCollectType["KilnName"] = drproductionData["KilnName"];
drCollectType["KilnCarID"] = drproductionData["KilnCarID"];
drCollectType["KilnCarCode"] = drproductionData["KilnCarCode"];
drCollectType["KilnCarName"] = drproductionData["KilnCarName"];
drCollectType["KilnCarPosition"] = drproductionData["KilnCarPosition"];
DataSourceCollectTypeTable.Rows.Add(drCollectType);
}
DataTable returnString = (DataTable)DoAsync(new BaseAsyncMethod(() =>
{
return PMModuleProxy.Service.AddWorkPiece(this._procedureID, DataSourceCollectTypeTable);
}
));
}
///
/// 单点采集模式
///
///
private void CollectTypeTwo(ProductionDataEntity procedureDataEntity)
{
try
{
#region 单点采集
// 添加行就可以 并保存
// 保存到数据库
DataSourceCollectTypeTable.Rows.Clear();
DataRow drCollectType = DataSourceCollectTypeTable.NewRow();
drCollectType["BarCode"] = procedureDataEntity.Barcode;
drCollectType["GoodsID"] = procedureDataEntity.GoodsID;
drCollectType["GoodsCode"] = procedureDataEntity.GoodsCode;
drCollectType["GoodsName"] = procedureDataEntity.GoodsName;
drCollectType["UserID"] = procedureDataEntity.UserID;
drCollectType["UserCode"] = procedureDataEntity.UserCode;
drCollectType["UserName"] = procedureDataEntity.UserName;
drCollectType["KilnID"] = procedureDataEntity.KilnID;
drCollectType["KilnCode"] = procedureDataEntity.KilnCode;
drCollectType["KilnName"] = procedureDataEntity.KilnName;
drCollectType["KilnCarID"] = procedureDataEntity.KilnCarID;
drCollectType["KilnCarCode"] = procedureDataEntity.KilnCarCode;
drCollectType["KilnCarName"] = procedureDataEntity.KilnCarName;
drCollectType["KilnCarPosition"] = procedureDataEntity.KilnCarPosition;
drCollectType["Remarks"] = procedureDataEntity.Remarks;
DataSourceCollectTypeTable.Rows.Add(drCollectType);
//DataTable returnString = (DataTable)DoAsync(new BaseAsyncMethod(() =>
//{
// return PMModuleProxy.Service.AddWorkPiece(this._procedureID, DataSourceCollectTypeTable);
//}
//));
DataRow dr = this.DataSourceTable.NewRow();
dr["BarCode"] = procedureDataEntity.Barcode;
dr["GoodsID"] = procedureDataEntity.GoodsID;
dr["GoodsCode"] = procedureDataEntity.GoodsCode;
dr["GoodsName"] = procedureDataEntity.GoodsName;
dr["UserID"] = procedureDataEntity.UserID;
dr["UserCode"] = procedureDataEntity.UserCode;
dr["UserName"] = procedureDataEntity.UserName;
dr["KilnID"] = procedureDataEntity.KilnID;
dr["KilnCode"] = procedureDataEntity.KilnCode;
dr["KilnName"] = procedureDataEntity.KilnName;
dr["KilnCarID"] = procedureDataEntity.KilnCarID;
dr["KilnCarCode"] = procedureDataEntity.KilnCarCode;
dr["KilnCarName"] = procedureDataEntity.KilnCarName;
dr["KilnCarPosition"] = procedureDataEntity.KilnCarPosition;
dr["Remarks"] = procedureDataEntity.Remarks;
this.DataSourceTable.Rows.Add(dr);
this.dgvProduction.CurrentCell = null;
this.dgvProduction.Rows[dgvProduction.RowCount - 1].Selected = true;
this.dgvProduction.CurrentCell = this.dgvProduction.Rows[dgvProduction.RowCount - 1].Cells[0];
#endregion
}
catch (Exception ex)
{
throw ex;
}
}
///
///集中采集模式
///
///
private void CollectTypeOne(ProductionDataEntity procedureDataEntity, string LogoCodeName)
{
try
{
#region 集中采集
DataRow[] drRows = this.DataSourceTable.Select("BarCode='" + procedureDataEntity.Barcode + "'");
if (drRows.Length > Constant.INT_IS_ZERO)
{
return;
}
//// 由产品条码获取注浆信息
//DataSet dsGroutingProduct = (DataSet)DoAsync(new BaseAsyncMethod(() =>
//{
// return PMModuleProxy.Service.GetGroutingProducttByBarCode(procedureDataEntity.Barcode);
//}));
DataRow dr = this.DataSourceTable.NewRow();
dr["BarCode"] = procedureDataEntity.Barcode;
dr["GoodsID"] = procedureDataEntity.GoodsID;
dr["GoodsCode"] = procedureDataEntity.GoodsCode;
dr["GoodsName"] = procedureDataEntity.GoodsName;
dr["UserID"] = procedureDataEntity.UserID;
dr["UserCode"] = procedureDataEntity.UserCode;
dr["UserName"] = procedureDataEntity.UserName;
dr["KilnID"] = procedureDataEntity.KilnID;
dr["KilnCode"] = procedureDataEntity.KilnCode;
dr["KilnName"] = procedureDataEntity.KilnName;
dr["KilnCarID"] = procedureDataEntity.KilnCarID;
dr["KilnCarCode"] = procedureDataEntity.KilnCarCode;
dr["KilnCarName"] = procedureDataEntity.KilnCarName;
dr["KilnCarPosition"] = procedureDataEntity.KilnCarPosition;
dr["Remarks"] = procedureDataEntity.Remarks;
dr["MouldCode"] = procedureDataEntity.MouldCode;
dr["GroutingUserCode"] = procedureDataEntity.GroutingUserCode;
dr["GroutingNum"] = procedureDataEntity.GroutingNum;
dr["GroutingDate"] = procedureDataEntity.CreateTime;
dr["IsPublicBody"] = procedureDataEntity.IsPublicBody;
dr["LogoCodeName"] = LogoCodeName;
this.DataSourceTable.Rows.Add(dr);
this.dgvProduction.CurrentCell = null;
this.dgvProduction.Rows[dgvProduction.RowCount - 1].Selected = true;
this.dgvProduction.CurrentCell = this.dgvProduction.Rows[dgvProduction.RowCount - 1].Cells[0];
#endregion
}
catch (Exception ex)
{
throw ex;
}
}
///
/// 保存数据到数据库
///
private void SaveDataInfo(bool isSave)
{
this.DataSourceTable.AcceptChanges();
this.DataSourceCollectTypeTable.Clear();
if (this.DataSourceTable.Rows.Count > Constant.INT_IS_ZERO)
{
foreach (DataRow drproductionData in this.DataSourceTable.Rows)
{
DataRow drCollectType = DataSourceCollectTypeTable.NewRow();
drCollectType["BarCode"] = drproductionData["BarCode"];
drCollectType["GoodsID"] = drproductionData["GoodsID"];
drCollectType["GoodsCode"] = drproductionData["GoodsCode"];
drCollectType["GoodsName"] = drproductionData["GoodsName"];
drCollectType["UserID"] = drproductionData["UserID"];
drCollectType["UserCode"] = drproductionData["UserCode"];
drCollectType["UserName"] = drproductionData["UserName"];
drCollectType["KilnID"] = drproductionData["KilnID"];
drCollectType["KilnCode"] = drproductionData["KilnCode"];
drCollectType["KilnName"] = drproductionData["KilnName"];
drCollectType["KilnCarID"] = drproductionData["KilnCarID"];
drCollectType["KilnCarCode"] = drproductionData["KilnCarCode"];
drCollectType["KilnCarName"] = drproductionData["KilnCarName"];
drCollectType["KilnCarPosition"] = drproductionData["KilnCarPosition"];
drCollectType["Remarks"] = drproductionData["Remarks"];
DataSourceCollectTypeTable.Rows.Add(drCollectType);
}
DataTable returnRow = (DataTable)DoAsync(new BaseAsyncMethod(() =>
{
return PMModuleProxy.Service.AddWorkPiece(this._procedureID, DataSourceCollectTypeTable);
}));
if (returnRow.Rows.Count <= Constant.INT_IS_ZERO)
{
// 提示信息
MessageBox.Show(Messages.MSG_PM_W012,
this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
}
else
{
if (string.IsNullOrEmpty(returnRow.Rows[0][Constant.BarCodeResultTableColumns.out_errMsg.ToString()].ToString()))//成功
{
// 提示信息
MessageBox.Show(string.Format(Messages.MSG_CMN_I001, "新增" + this.Text, "保存"),
this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
}
else
{
// 提示信息
MessageBox.Show(string.Format(returnRow.Rows[0][Constant.BarCodeResultTableColumns.out_errMsg.ToString()].ToString()),
this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
return;
}
}
this.txtKilnCarCode.Text = "";
this._productionDataEntity.Clear();
this.DataSourceTable.Rows.Clear();
this.txtRemarks.Text = string.Empty;
this.txtKiln.Enabled = true;
this.txtKilnCarCode.Enabled = true;
//this.txtKiln.Text = "";
if (this._procedureDataEntity.CollectType == (int)Constant.ProcedureCollectType.Togather)
{
if (isSave)
{
this.txtUserCode.Text = "";
this.txtUserCode.Focus();
}
this.txtUserCode.ReadOnly = false;
//this.txtKilnCarCode.Enabled = false;
this.txtKilnCarCode.ReadOnly = false;
}
else
{
this.txtKilnCarCode.Focus();
this.txtKiln.ReadOnly = false;
this.txtKilnCarCode.ReadOnly = false;
}
}
}
#endregion
private void txtKiln_KeyPress(object sender, KeyPressEventArgs e)
{
try
{
if ((int)e.KeyChar == Constant.SYSTEM_KEYBOARD_ENTER_VALUE) // 按了回车键
{
if (this.txtKiln.Text.Trim() == string.Empty)
{
this._kilnCarEntity = null;
return;
}
if (this.txtKiln.Text.Trim() != "")
{
DataSet dsResultAccount = (DataSet)DoAsync(new BaseAsyncMethod(() =>
{
return SystemModuleProxy.Service.GetAllKilntInfo();
}));
if (dsResultAccount != null && dsResultAccount.Tables[0].Rows.Count > 0)
{
DataView dv = dsResultAccount.Tables[0].DefaultView;
dv.RowFilter = "ValueFlag=1 and KilnCode='" + this.txtKiln.Text.Trim() + "'";
DataTable dt = dv.ToTable();
if (dt.Rows.Count == 0)
{
// 提示信息
MessageBox.Show("不存在此窑炉编号",
this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
this.txtKiln.SelectAll();
this.txtKiln.Focus();
return;
}
else
{
// 保存业务系统配置
Utility.WriteIniFile(Constant.INI_SECTION_SETTINGS, Constant.INI_KEY_KILN_CODE,
this.txtKiln.Text.Trim(), this._iniFilePath);
this.txtKilnCarCode.Focus();
}
}
}
}
}
catch (Exception ex)
{
// 对异常进行共通处理
ExceptionManager.HandleEventException(this.ToString(),
System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
}
}
private void txtKiln_Validating(object sender, System.ComponentModel.CancelEventArgs e)
{
try
{
if (this.txtKiln.Text.Trim() == string.Empty)
{
this._kilnCarEntity = null;
return;
}
if (this.txtKiln.Text.Trim() != "")
{
if (!this.txtKiln.ReadOnly)
{
DataSet dsResultAccount = (DataSet)DoAsync(new BaseAsyncMethod(() =>
{
return SystemModuleProxy.Service.GetAllKilntInfo();
}));
if (dsResultAccount != null && dsResultAccount.Tables[0].Rows.Count > 0)
{
DataView dv = dsResultAccount.Tables[0].DefaultView;
dv.RowFilter = "ValueFlag=1 and KilnCode='" + this.txtKiln.Text.Trim() + "'";
DataTable dt = dv.ToTable();
if (dt.Rows.Count == 0)
{
// 提示信息
MessageBox.Show("不存在此窑炉编号",
this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
this.txtKiln.SelectAll();
this.txtKiln.Focus();
return;
}
// 保存业务系统配置
Utility.WriteIniFile(Constant.INI_SECTION_SETTINGS, Constant.INI_KEY_KILN_CODE,
this.txtKiln.Text.Trim(), this._iniFilePath);
}
}
}
}
catch (Exception ex)
{
// 对异常进行共通处理
ExceptionManager.HandleEventException(this.ToString(),
System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
}
}
}
}