/*******************************************************************************
* Copyright(c) 2016 DongkeSoft All rights reserved. / Confidential
* 类的信息:
* 1.程序名称:F_PM_2202.cs
* 2.功能描述:半成品检验
* 编辑履历:
* 作者 日期 版本 修改内容
* 王鑫 2016/06/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.Client.CommonModule;
using Dongke.IBOSS.PRD.Client.DataModels;
using Dongke.IBOSS.PRD.WCF.DataModels;
using Dongke.IBOSS.PRD.WCF.Proxys;
namespace Dongke.IBOSS.PRD.Client.PMModule
{
///
/// 计检登记
///
public partial class F_PM_2202 : FormBase
{
#region 成员变量
// 新建,编辑返工,编辑不合格
private int _semiCheckEditType;
// 工序ID
private int _procedureID;
// 生产工号
private int _userID = -1;
// 生产编号
private string _userCode;
// 生产名称
private string _userName;
// 工序实体类
ProcedureEntity _procedureDataEntity;
// 产品数据表
DataTable _dtProductionData = null;
// 产品缺陷数据表
DataTable _dtProductionDefectData = null;
// 当前选择的行
private int _selectedRowIndex;
// ComBoxEditingControl
private DataGridViewComboBoxEditingControl _dataGridViewComboBox = null;
// 当前产品条码的产品ID,用来查询缺陷位置
private int _currentGoodsID = 0;
// 当前产品条码,用来切换筛选列表数据
private string _currentBarCode = "";
// 当前产品缺陷
private int _currentDefectFlag = 0;
// 返工工序搜索列表对象
C_DGV_Cell_ListBoxComboBox _C_DGV_Cell_ListBoxComboBox = null;
// 过滤结果集
private DataSet _ds = null;
// 过滤员工结果集
private DataSet _dsStaff = null;
// 过滤缺陷图片
private DataSet _dsImage = null;
// 过滤漏检员工结果集
private DataSet _dsMissdeStaff = null;
// 临时数,用来过滤责任员工数据源标识
private int _tempCount = 0;
// 当前临时标记
private string _currentTempSign = "";
// 图片字节集
private List _PicByte = new List();
// 缩略图片字节集
private List _smallByte = new List();
// 当前产品缺陷
private int _currentDefaultDefectFlag = 0;
// 当前默认产品分级ID
private int _currentGoodsLevelTypeID = 0;
// 返工工序数据源
private DataSet _dsRework = null;
// 产品等级数据源
private DataSet _dsGoodsLevel = null;
//编辑生产数据ID
private int _productiondataid = 0;
//编辑半成品数据ID
private int _semicheckid = 0;
// 是否查看
private bool _isView = false;
// 允许编辑
private int _AllowEdit = 0;
// 是否只读
private int _ReadOnly = 0;// 1为只读
// 时间戳
private DateTime _optimestamp;
// 默认责任工号数据源
private DataTable _dtDutyProcedureUser = null;
// 是否设置半检登记改判限制天数
private int _settingvaluedays = 0;
#endregion
#region 属性
///
/// 条码返工工序数据源
///
public DataSet DSREWORK
{
set
{
_dsRework = value;
}
get
{
if (_dsRework == null)
{
return _dsRework = new DataSet();
}
return _dsRework;
}
}
///
/// 生产工号
///
public int UserID
{
set
{
_userID = value;
}
get
{
return _userID;
}
}
///
/// 生产编号
///
public string UserCode
{
set
{
_userCode = value;
}
get
{
return _userCode;
}
}
///
/// 用户名称
///
public string UserName
{
set
{
_userName = value;
}
get
{
return _userName;
}
}
///
/// 时间戳
///
public DateTime PTimeStamp
{
get
{
return _optimestamp;
}
set
{
_optimestamp = value;
}
}
///
/// 产品数据表
///
public DataTable TableProductionData
{
set
{
_dtProductionData = value;
}
get
{
if (_dtProductionData == null)
{
_dtProductionData = new DataTable("ProductionData");
_dtProductionData.Columns.Add("ProductionDataID");
_dtProductionData.Columns.Add("BarCode");
_dtProductionData.Columns.Add("GoodsID");
_dtProductionData.Columns.Add("GoodsCode");
_dtProductionData.Columns.Add("GoodsName");
_dtProductionData.Columns.Add("DefectFlagID", typeof(decimal));
_dtProductionData.Columns.Add("ReworkProcedureID", typeof(decimal));
_dtProductionData.Columns.Add("Remarks");
_dtProductionData.Columns.Add("UserID");
_dtProductionData.Columns.Add("UserCode");
_dtProductionData.Columns.Add("UserName");
_dtProductionData.Columns.Add("GoodsLevelTypeID");
_dtProductionData.Columns.Add("OrgGoodsLevelTypeID");//原产品分级ID
_dtProductionData.Columns.Add("ReFine");//重烧标识
_dtProductionData.Columns.Add("SpecialRepairflag");//干补标识
_dtProductionData.Columns.Add("ReadOnly");//1 为 只读
_dtProductionData.Columns.Add("KilnCarCode");
_dtProductionData.Columns.Add("KilnCode");
_dtProductionData.Columns.Add("Dictionaryvalue");
_dtProductionData.Columns.Add("MouldCode");//模具编号
_dtProductionData.Columns.Add("GroutingDate", typeof(DateTime));//注浆日期
_dtProductionData.Columns.Add("GroutingUserCode");//成型工号
_dtProductionData.Columns.Add("IsPublicBody");//公坯标识
_dtProductionData.Columns.Add("GroutingNum");//注浆次数
_dtProductionData.Columns.Add("OPTimeStamp", typeof(DateTime));//时间戳 记录在产记录的时间戳
_dtProductionData.Columns.Add("LogoCodeName");//
_dtProductionData.Columns.Add("LogoID");//
return _dtProductionData;
}
else
{
return _dtProductionData;
}
}
}
///
/// 产品缺陷表
///
public DataTable TableProductionDefectData
{
set
{
_dtProductionDefectData = value;
}
get
{
if (_dtProductionDefectData == null)
{
_dtProductionDefectData = new DataTable("ProductionDefectData");
_dtProductionDefectData.Columns.Add("ProductionBarCode");
_dtProductionDefectData.Columns.Add("discarde");
_dtProductionDefectData.Columns.Add("DefectFlag", typeof(decimal));
_dtProductionDefectData.Columns.Add("DefectLocation", typeof(decimal));
_dtProductionDefectData.Columns.Add("DutyProcedureUserID", typeof(decimal));
_dtProductionDefectData.Columns.Add("DutyUserCode");
_dtProductionDefectData.Columns.Add("DefectRemarks");
return _dtProductionDefectData;
}
else
{
return _dtProductionDefectData;
}
}
}
///
/// 缺陷数据集
///
public DataSet DSTable
{
set
{
_ds = value;
}
get
{
if (_ds == null)
{
_ds = new DataSet();
return _ds;
}
else
{
return _ds;
}
}
}
///
/// 员工数据集
///
public DataSet DSTableStaff
{
set
{
_dsStaff = value;
}
get
{
if (_dsStaff == null)
{
_dsStaff = new DataSet();
return _dsStaff;
}
else
{
return _dsStaff;
}
}
}
////
//// 漏检员工数据集
////
////public DataSet DSTableMissedStaff
////{
//// set
//// {
//// _dsMissdeStaff = value;
//// }
//// get
//// {
//// if (_dsMissdeStaff == null)
//// {
//// _dsMissdeStaff = new DataSet();
//// return _dsMissdeStaff;
//// }
//// else
//// {
//// return _dsMissdeStaff;
//// }
//// }
////}
////
//// 缺陷图片
////
////public DataSet DSTableImage
////{
//// set
//// {
//// _dsImage = value;
//// }
//// get
//// {
//// if (_dsImage == null)
//// {
//// _dsImage = new DataSet();
//// return _dsImage;
//// }
//// else
//// {
//// return _dsImage;
//// }
//// }
////}
#endregion
#region 构造函数
public F_PM_2202()
{
InitializeComponent();
}
public F_PM_2202(int procedureID, string fromTitle)
{
InitializeComponent();
this._procedureID = procedureID;
this.Text = fromTitle;
this.tsbtnAdd.Text = ButtonText.TSBTN_ADD;
this.tsbtnEdit.Text = ButtonText.TSBTN_EDIT;
this.btnSave.Text = ButtonText.BTN_SAVE;
this.btnCancel.Text = ButtonText.BTN_CLOSE;
this.tsbtnClose.Text = ButtonText.TSBTN_TOOL_CLOSE;
}
public F_PM_2202(int procedureID, string fromTitle, int productiondataID, bool isView)
{
InitializeComponent();
this._AllowEdit = 1;//允许编辑
this._productiondataid = productiondataID;
this._procedureID = procedureID;
this.Text = fromTitle;
this._isView = isView;
this.tsbtnAdd.Text = ButtonText.TSBTN_ADD;
this.tsbtnEdit.Text = ButtonText.TSBTN_EDIT;
this.btnSave.Text = ButtonText.BTN_SAVE;
this.btnCancel.Text = ButtonText.BTN_CLOSE;
this.tsbtnClose.Text = ButtonText.TSBTN_TOOL_CLOSE;
}
#endregion
#region 事件
///
/// 窗体加载事件
///
///
///
private void F_PM_1202_Load(object sender, System.EventArgs e)
{
try
{
this.dgvProductionData.AutoGenerateColumns = false;
this.dgvProductionData.DataSource = null;
this.dgvProductionData.DataSource = TableProductionData;
this.dgvDefect.AutoGenerateColumns = false;
this.dgvDefectStaff.AutoGenerateColumns = false;
this.dropReworkProcedure.Enabled = false;
this.dropDutyUser.Enabled = false;
this.dkSemiCheckType.Enabled = false;
this.txtBarCode.Focus();
// 加载权限
FormPermissionManager.FormPermissionControl(this.Name, this,
Dongke.IBOSS.PRD.Client.DataModels.LogInUserInfo.CurrentUser.CurrentUserEntity.UserRightData,
Dongke.IBOSS.PRD.Client.DataModels.LogInUserInfo.CurrentUser.CurrentUserEntity.FunctionData);
//登陆工号是否有编辑半检权限 0 无 1 有
this._AllowEdit = PMModuleProxy.Service.GetSemiCheckStatusFuntion();
UserID = Convert.ToInt32(LogInUserInfo.CurrentUser.CurrentUserEntity.UserID);
UserName = LogInUserInfo.CurrentUser.CurrentUserEntity.UserName;
UserCode = LogInUserInfo.CurrentUser.CurrentUserEntity.UserCode;
this.txtUserCode.Text = UserCode;
// 返工工号
this.dropDutyUser.DisplayMember = "UserCode";
this.dropDutyUser.ValueMember = "UserID";
this.dropDutyUser.DataSource = GetDutyProcedureUser();
// 加载半检,复检状态数据源
DataSet dsGetSemiCheckType = SystemModuleProxy.Service.GetSemiCheckType();
if (dsGetSemiCheckType != null && dsGetSemiCheckType.Tables[0].Rows.Count > 0)
{
DataRow[] drSemiCheckType = dsGetSemiCheckType.Tables[0].Select("Semichecktype=1");
if (drSemiCheckType.Length > 0)
{
this.dkSemiCheckType.ValueMember = "Semichecktypeid";
this.dkSemiCheckType.DisplayMember = "Semichecktypename";
this.dkSemiCheckType.DataSource = drSemiCheckType.CopyToDataTable();
}
}
// 2016-10-10 是否启用过期未交坯限制 wangx
DataSet dsSetting = (DataSet)DoAsync(new BaseAsyncMethod(() =>
{
return SystemModuleProxy.Service.GetSystemSettingDataByCode(Constant.SettingType.S_PM_007.ToString());
}));
if (dsSetting != null && dsSetting.Tables[0].Rows.Count > 0)
{
_settingvaluedays = Convert.ToInt32(dsSetting.Tables[0].Rows[0]["SettingValue"]);
}
// end
}
catch (Exception ex)
{
// 对异常进行共通处理
ExceptionManager.HandleEventException(this.ToString(),
System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
}
}
///
/// 责任工号数据表 责任工序不选择时,默认数据源
///
///
private DataTable GetDutyProcedureUser()
{
SUserEntity userEntity = new SUserEntity();
userEntity.IsWorker = 1;//生产工号
DataSet dsDutyProcedureUser = (DataSet)DoAsync(new BaseAsyncMethod(() =>
{
return SystemModuleProxy.Service.SearchUserData(userEntity);
}));
DataRow dr = dsDutyProcedureUser.Tables[0].NewRow();
dr["UserID"] = -1;
dr["UserCode"] = "";
dr["UserName"] = "";
dsDutyProcedureUser.Tables[0].Rows.InsertAt(dr, 0);
dsDutyProcedureUser.Tables[0].AcceptChanges();
this._dtDutyProcedureUser = dsDutyProcedureUser.Tables[0];
return dsDutyProcedureUser.Tables[0];
}
///
/// 设置控件禁用或启用
///
private void SetControlEnable()
{
if (this._procedureDataEntity != null)
{
if (this._procedureDataEntity.CollectType == (int)Constant.ProcedureCollectType.Togather)
{
this.txtUserCode.Enabled = true;
this.btnSave.Visible = true;
}
else
{
this.txtUserCode.Enabled = true;
this.txtUserCode.ReadOnly = true;
// 此工号是否能生产工序
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;
}
}
UserID = checkProcedureUser.UserID;
UserCode = checkProcedureUser.UserCode;
UserName = checkProcedureUser.UserName;
}
this.txtUserCode.Text = UserCode;
}
}
///
/// 条形码按键事件
///
///
///
private void txtBarCode_KeyPress(object sender, KeyPressEventArgs e)
{
try
{
this._ReadOnly = 0;//防止输入前一个条码为只读时,在输入另一个条码永远是只读
if (this.txtBarCode.ReadOnly)
{
return;
}
if ((int)e.KeyChar == 13) // 按了回车键
{
if (this.txtUserCode.Text.Trim() == string.Empty)
{
this.txtUserCode.Focus();
this.txtBarCode.Text = string.Empty;
return;
}
if (this.txtBarCode.Text.Trim() == string.Empty)
{
this.txtBarCode.Focus();
return;
}
// 校验条码
ServiceResultEntity resultEntity = PMModuleProxy.Service.SemiCheckBarcode(this.txtBarCode.Text.Trim());
this._currentBarCode = this.txtBarCode.Text.Trim();
if (Convert.ToInt32(resultEntity.Result) < 0)
{
// 有错误
// 表示有错误
MessageBox.Show(resultEntity.Message,
this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
this._currentBarCode = string.Empty;
return;
}
else if (Convert.ToInt32(resultEntity.Result) == 0)
{
this._semiCheckEditType = 1;//新增
BindProductionData_New();//直接绑定产品信息
// 过滤掉半检状态为正常
DataView dv = this.dkSemiCheckType.DataSource.DefaultView;
dv.RowFilter = "Semichecktypeid<>0";
this.dkSemiCheckType.ValueMember = "Semichecktypeid";
this.dkSemiCheckType.DisplayMember = "Semichecktypename";
this.dkSemiCheckType.DataSource = dv.ToTable();
}
else if (Convert.ToInt32(resultEntity.Result) > 0)
{
this._semicheckid = Convert.ToInt32(resultEntity.Result);
if (resultEntity.Message == "返工")
{
this._semiCheckEditType = 2;//编辑返工
}
else
{
this._semiCheckEditType = 3;//编辑不合格
}
}
// 加载条码对应的返工工序
DataSet dsProcedure = (DataSet)DoAsync(new BaseAsyncMethod(() =>
{
return PMModuleProxy.Service.GetSemiCheckPassProcedure(txtBarCode.Text.Trim());
}));
if (dsProcedure != null && dsProcedure.Tables[0].Rows.Count > 0)
{
DataTable dtProcedure = dsProcedure.Tables[0];
DataRow dr = dtProcedure.NewRow();
dr["ProcedureName"] = "";
dr["ProcedureID"] = -1;
dtProcedure.Rows.InsertAt(dr, 0);
this.dropReworkProcedure.DataSource = dtProcedure;
this.dropReworkProcedure.DisplayMember = "ProcedureName";
this.dropReworkProcedure.ValueMember = "ProcedureID";
}
if (Convert.ToInt32(resultEntity.Result) > 0)
{
SetEditDataSource_Edit();//显示数据
}
this.txtBarCode.Text = string.Empty;
this.dropReworkProcedure.Enabled = true;
this.dropDutyUser.Enabled = true;
this.dkSemiCheckType.Enabled = true;
this.txtBarCode.Enabled = false;
}
}
catch (Exception ex)
{
// 对异常进行共通处理
ExceptionManager.HandleEventException(this.ToString(),
System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
}
}
///
/// 生产数据编辑控件显示事件
///
///
///
private void dgvProductionData_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e)
{
try
{
if (e.Control is DataGridViewComboBoxEditingControl
&& this.dgvProductionData.CurrentCell.ColumnIndex == Constant.INT_IS_THREE
&& this.dgvProductionData.CurrentCell.RowIndex != -Constant.INT_IS_ONE)
{
this._dataGridViewComboBox = (DataGridViewComboBoxEditingControl)e.Control;
//增加委托处理
this._dataGridViewComboBox.SelectionChangeCommitted += new EventHandler(this.dataGridViewComboBox_SelectionChangeCommitted);
}
if (e.Control is DKListBoxComboBox
&& this.dgvProductionData.CurrentCell.ColumnIndex == Constant.INT_IS_FOUR
&& this.dgvProductionData.CurrentCell.RowIndex != -Constant.INT_IS_ONE)
{
//_selectedRowIndex = TableProductionData.Rows.Count - 1;
_selectedRowIndex = this.dgvProductionData.CurrentCell.RowIndex;
DKListBoxComboBox dkListBoxComboBox = (DKListBoxComboBox)e.Control;
_currentGoodsID = Convert.ToInt32(this.dgvProductionData.Rows[_selectedRowIndex].Cells["GoodsID"].Value);
_currentBarCode = this.dgvProductionData.Rows[_selectedRowIndex].Cells["BarCode"].Value.ToString();
dkListBoxComboBox.DisplayMember = "ReworkProcedureName";
dkListBoxComboBox.ValueMember = "ReworkProcedureID";
dkListBoxComboBox.DataSource = DSREWORK.Tables[0];//
}
}
catch (Exception ex)
{
// 对异常进行共通处理
ExceptionManager.HandleEventException(this.ToString(),
System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
}
}
///
/// 生产数据下拉列表改变事件
///
///
///
private void dataGridViewComboBox_SelectionChangeCommitted(object sender, EventArgs e)
{
try
{
this._currentDefectFlag = Convert.ToInt32(((ComboBox)sender).SelectedValue.ToString());//当前缺陷类型
SetGridView(this._currentDefectFlag);
}
catch (Exception ex)
{
// 对异常进行共通处理
ExceptionManager.HandleEventException(this.ToString(),
System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
}
}
///
/// 产品数据单元格进入事件
///
///
///
private void dgvProductionData_CellEnter(object sender, DataGridViewCellEventArgs e)
{
try
{
if (this.dgvProductionData.CurrentCell != null)
{
// 记录最后选择行
if (e.ColumnIndex == Constant.INT_IS_FOUR && e.RowIndex != -Constant.INT_IS_ONE)
{
this._selectedRowIndex = this.dgvProductionData.CurrentCell.RowIndex;
this._currentBarCode = this.dgvProductionData.Rows[_selectedRowIndex].Cells["BarCode"].Value.ToString();
this._C_DGV_Cell_ListBoxComboBox = dgvProductionData.Rows[_selectedRowIndex].Cells[4] as C_DGV_Cell_ListBoxComboBox;
DataSet ds = (DataSet)DoAsync(new BaseAsyncMethod(() =>
{
return PMModuleProxy.Service.GetReworkProcedureByProcedureID(this._procedureID);
}));
this._currentGoodsID = Convert.ToInt32(this.dgvProductionData.Rows[_selectedRowIndex].Cells["GoodsID"].Value);
this._currentBarCode = this.dgvProductionData.Rows[_selectedRowIndex].Cells["BarCode"].Value.ToString();
this._C_DGV_Cell_ListBoxComboBox.DisplayMember = "ReworkProcedureName";
this._C_DGV_Cell_ListBoxComboBox.ValueMember = "ReworkProcedureID";
this._C_DGV_Cell_ListBoxComboBox.DataSource = ds.Tables[0];
}
}
}
catch (Exception ex)
{
// 对异常进行共通处理
ExceptionManager.HandleEventException(this.ToString(),
System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
}
}
///
/// 产品数据选定项改变事件
///
///
///
private void dgvProductionData_SelectionChanged(object sender, EventArgs e)
{
try
{
if (this.dgvProductionData.CurrentCell != null)
{
this._selectedRowIndex = this.dgvProductionData.CurrentCell.RowIndex;
// 有无缺陷 0无缺陷 1有缺陷
//this._currentDefectFlag = Convert.ToInt32(this.dgvProductionData.Rows[_selectedRowIndex].Cells["GoodsLevelTypeID"].Value.ToString());
this._currentGoodsID = Convert.ToInt32(this.dgvProductionData.Rows[_selectedRowIndex].Cells["GoodsID"].Value);
this._currentBarCode = this.dgvProductionData.Rows[_selectedRowIndex].Cells["BarCode"].Value.ToString();
this.dgvDefect.DataSource = DSTable.Tables[this._currentBarCode];
this.dgvDefectStaff.CurrentCell = null;
this.dgvDefectStaff.DataSource = null;
this._smallByte.Clear();//防止重复绑定图片
//设置只读数据,交不显示数据
string readonlyFlag = this.dgvProductionData.Rows[_selectedRowIndex].Cells["ReadOnly"].Value.ToString();
if (readonlyFlag == "1")
{
tsbtnAdd.Enabled = false;
tsbtnEdit.Enabled = false;
}
else
{
tsbtnAdd.Enabled = true;
tsbtnEdit.Enabled = true;
}
}
}
catch (Exception ex)
{
// 对异常进行共通处理
ExceptionManager.HandleEventException(this.ToString(),
System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
}
}
///
/// 缺陷数据源选定项改变事件
///
///
///
private void dgvDefect_SelectionChanged(object sender, EventArgs e)
{
try
{
if (this.dgvDefect.CurrentCell != null)
{
DataRow[] dr = this.TableProductionData.Select("barcode='" + this._currentBarCode + "'");
if (dr.Length > 0)
{
if (dr[0]["ReadOnly"].ToString() == "1")
{
this.tsbtnEdit.Enabled = false;
this.tsbtnAdd.Enabled = false;
}
else
{
this.tsbtnEdit.Enabled = true;
this.tsbtnAdd.Enabled = true;
}
}
else
{
//if (this._productiondataid > Constant.INT_IS_ZERO)
//{
if (this.btnSave.Enabled)
{
this.tsbtnEdit.Enabled = true;
this.tsbtnAdd.Enabled = true;
}
}
// }
if (this.dgvDefect.Rows[this.dgvDefect.CurrentCell.RowIndex].Cells["TempCount"].Value.ToString() != string.Empty)
{
int staffTempCount = Convert.ToInt32(this.dgvDefect.Rows[this.dgvDefect.CurrentCell.RowIndex].Cells["TempCount"].Value.ToString());
this.dgvDefectStaff.DataSource = DSTableStaff.Tables[string.Format("TempTable{0}", staffTempCount.ToString())];
this._currentTempSign = this.dgvDefect.Rows[this.dgvDefect.CurrentCell.RowIndex].Cells["TempCount"].Value.ToString(); //当前临时标记
this._smallByte.Clear();//防止重复绑定图片
}
else
{
this.dgvDefectStaff.DataSource = null;
this._smallByte.Clear();//防止重复绑定图片
}
}
}
catch (Exception ex)
{
// 对异常进行共通处理
ExceptionManager.HandleEventException(this.ToString(),
System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
}
}
///
/// 单元格CheckBox事件
///
///
///
private void dgvDefect_CellContentClick(object sender, DataGridViewCellEventArgs e)
{
try
{
if (e.ColumnIndex == Constant.INT_IS_ZERO && e.RowIndex != -Constant.INT_IS_ONE)
{
int checkValue = Convert.ToInt32(this.dgvDefect.Rows[e.RowIndex].Cells[0].EditedFormattedValue);
if (checkValue == Constant.INT_IS_ZERO)
{
SetCheckBoxSelected(checkValue, e.RowIndex);
}
else
{
this.dgvDefect.Rows[e.RowIndex].Cells[0].Value = 0;
}
}
}
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 dgvProductionData_UserDeletingRow(object sender, DataGridViewRowCancelEventArgs e)
{
try
{
string BarCode = this.dgvProductionData.Rows[e.Row.Index].Cells["BarCode"].Value.ToString();
DSTable.Tables[BarCode].Rows.Clear();//清空行
this.dgvDefectStaff.DataSource = null;//责任员工数据源
}
catch (Exception ex)
{
// 对异常进行共通处理
ExceptionManager.HandleEventException(this.ToString(),
System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
}
}
///
/// 产品缺陷删除行事件
///
///
///
private void dgvDefect_UserDeletingRow(object sender, DataGridViewRowCancelEventArgs e)
{
try
{
//if (e.Row.Index != -1)
//{
// //ProductionDataID
// if (this.dgvDefect.CurrentCell != null)
// {
// //是新增进来,加载条码是不允许删除的,只是编辑权限才能可以删除
// if (this.dgvDefect.Rows[e.Row.Index].Cells["ProductionDataID"].Value.ToString() != "" && Convert.ToInt32(this.dgvDefect.Rows[e.Row.Index].Cells["ProductionDataID"].Value) > 0 && this.dgvDefect.Rows[e.Row.Index].Cells["IsAllowEdit"].Value.ToString() == "0")
// {
// e.Cancel = true;
// return;
// }
// string TempCount = this.dgvDefect.Rows[e.Row.Index].Cells["TempCount"].Value.ToString();
// DSTableStaff.Tables[string.Format("TempTable{0}", TempCount.ToString())].Rows.Clear();//清空行
// this.dgvDefectStaff.DataSource = null;
// if (Convert.ToInt32(TempCount) > 0)
// {
// if (this.dgvDefect.CurrentCell != null)
// {
// DataRow[] dr = this.TableProductionData.Select("barcode='" + this._currentBarCode + "'");
// if (dr.Length > 0)
// {
// if (dr[0]["ReadOnly"].ToString() == "1")
// {
// this.tsbtnEdit.Enabled = false;
// this.tsbtnAdd.Enabled = false;
// }
// else
// {
// this.tsbtnEdit.Enabled = true;
// this.tsbtnAdd.Enabled = true;
// }
// }
// else
// {
// //if (this._productiondataid > Constant.INT_IS_ZERO)
// //{
// if (this.btnSave.Enabled)
// {
// this.tsbtnEdit.Enabled = true;
// this.tsbtnAdd.Enabled = true;
// }
// }
// // }
// if (this.dgvDefect.Rows[0].Cells["TempCount"].Value.ToString() != string.Empty)
// {
// int staffTempCount = Convert.ToInt32(this.dgvDefect.Rows[0].Cells["TempCount"].Value.ToString());
// this.dgvDefectStaff.DataSource = DSTableStaff.Tables[string.Format("TempTable{0}", staffTempCount.ToString())];
// this._currentTempSign = this.dgvDefect.Rows[0].Cells["TempCount"].Value.ToString(); //当前临时标记
// this._smallByte.Clear();//防止重复绑定图片
// }
// else
// {
// this.dgvDefectStaff.DataSource = null;
// this._smallByte.Clear();//防止重复绑定图片
// }
// }
// }
// }
//}
if (e.Row.Index != -1)
{
int selectedRow = 0;
if (this.dgvDefect.CurrentCell != null)
{
if (Convert.ToInt32(this.dgvDefect.Rows[this.dgvDefect.CurrentCell.RowIndex].Cells["IsAllowEdit"].Value.ToString()) == 0) //如果_AllowEdit=1,则是编辑状态,肯定允许编辑,因为分权限的时候就定义了
{
e.Cancel = true;
return;
}
string TempCount = this.dgvDefect.Rows[e.Row.Index].Cells["TempCount"].Value.ToString();
DSTableStaff.Tables[string.Format("TempTable{0}", TempCount.ToString())].Rows.Clear();//清空行
//dgvDefect_SelectionChanged(sender, e);
//this.dgvDefect.Rows[0].Cells["defectname"].Selected = true;
if (TempCount == "0")
{
selectedRow = this.dgvDefect.Rows.Count - 1;
}
this.dgvDefectStaff.DataSource = null;
}
if (this.dgvDefect.Rows[selectedRow].Cells["TempCount"].Value.ToString() != string.Empty)
{
int staffTempCount = Convert.ToInt32(this.dgvDefect.Rows[selectedRow].Cells["TempCount"].Value.ToString());
this.dgvDefectStaff.DataSource = DSTableStaff.Tables[string.Format("TempTable{0}", staffTempCount.ToString())];
this._currentTempSign = this.dgvDefect.Rows[selectedRow].Cells["TempCount"].Value.ToString(); //当前临时标记
}
else
{
this.dgvDefectStaff.DataSource = null;
}
}
}
catch (Exception ex)
{
// 对异常进行共通处理
ExceptionManager.HandleEventException(this.ToString(),
System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
}
}
///
/// 新建按钮事件
///
///
///
private void tsbtnAdd_Click(object sender, EventArgs e)
{
try
{
if (this.dgvProductionData.CurrentCell != null)
{
//int allow = Convert.ToInt32(this.dgvProductionData.Rows[_selectedRowIndex].Cells["GoodsLevelTypeID"].Value.ToString());
//if (allow != Constant.INT_IS_FOUR) // 有缺陷才能新建
//{
DSTable.Tables[this._currentBarCode].AcceptChanges(); // 添加这句为了删除后,未提交数据
if (DSTable.Tables[this._currentBarCode].Rows.Count == 0)
{
F_PM_2203 frm1203 = new F_PM_2203(
DSTable.Tables[this._currentBarCode], this._currentBarCode,
this._currentGoodsID, this._tempCount, this._procedureID, this.Text, false, this, this.DSTableStaff, null, null, this._PicByte, this._smallByte, -1, Convert.ToInt32(dropReworkProcedure.SelectedValue));
frm1203.ShowDialog();
}
// }
}
}
catch (Exception ex)
{
// 对异常进行共通处理
ExceptionManager.HandleEventException(this.ToString(),
System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
}
}
///
/// 编辑按钮事件
///
///
///
private void tsbtnEdit_Click(object sender, EventArgs e)
{
try
{
if (this.dgvDefect.CurrentCell != null)
{
//int isallowedit = Convert.ToInt32(this.dgvDefect.Rows[this.dgvDefect.CurrentCell.RowIndex].Cells["IsAllowEdit"].Value.ToString());
if (Convert.ToInt32(this.dgvDefect.Rows[this.dgvDefect.CurrentCell.RowIndex].Cells["IsAllowEdit"].Value.ToString()) == 1) //如果_AllowEdit=1,则是编辑状态,肯定允许编辑,因为分权限的时候就定义了
{
string barcode = this.dgvDefect.Rows[this.dgvDefect.CurrentCell.RowIndex].Cells["ProductionBarCode"].Value.ToString();
int tempcount = Convert.ToInt32(this.dgvDefect.Rows[this.dgvDefect.CurrentCell.RowIndex].Cells["TempCount"].Value.ToString());
int goodsID = 0;
DataRow[] dr = this.TableProductionData.Select("BarCode='" + barcode + "'");
if (dr.Length > Constant.INT_IS_ZERO)
{
goodsID = Convert.ToInt32(dr[0]["GoodsID"]);
}
F_PM_2203 frm1203 = new F_PM_2203(
DSTable.Tables[barcode], barcode,
goodsID, tempcount, this._procedureID, this.Text, true, this, this.DSTableStaff, null, null, this._PicByte, this._smallByte, this.dgvDefect.CurrentCell.RowIndex, null);
frm1203.ShowDialog();
}
}
}
catch (Exception ex)
{
// 对异常进行共通处理
ExceptionManager.HandleEventException(this.ToString(),
System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
}
}
///
/// 产品数据源值改变后
///
///
///
private void dgvProductionData_CellValueChanged(object sender, DataGridViewCellEventArgs e)
{
if (e.ColumnIndex == Constant.INT_IS_FOUR && e.RowIndex != -Constant.INT_IS_ONE)
{
}
}
///
/// 保存按钮事件
///
///
///
private void btnSave_Click(object sender, EventArgs e)
{
try
{
#region 保存画面验证 2016-06-29
if (this.dkSemiCheckType.SelectedValue.ToString() == "0")
{
// 半检状态-正常
if (this.dropReworkProcedure.SelectedValue != null && this.dropReworkProcedure.SelectedValue.ToString() != "-1")
{
// 提示信息
MessageBox.Show("半检状态正常时,返工工序必须为空",
this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
return;
}
if (this.dropDutyUser.SelectedValue != null && this.dropDutyUser.SelectedValue.ToString() != "-1")
{
// 提示信息
MessageBox.Show("半检状态正常时,返工工号必须为空",
this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
return;
}
DataTable dt = this.dgvDefect.DataSource as DataTable;
if (dt != null && dt.Rows.Count > 0)
{
// 提示信息
MessageBox.Show("半检状态正常时,缺陷记录必须为空",
this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
return;
}
}
else if (this.dkSemiCheckType.SelectedValue.ToString() == "1")
{
// 半检状态-返工
if (this.dropDutyUser.SelectedValue.ToString() == "-1")
{
// 提示信息
MessageBox.Show("半检状态返工时,返工工号必须填写",
this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
return;
}
DataTable dt = this.dgvDefect.DataSource as DataTable;
if (dt == null || dt.Rows.Count == 0)
{
// 提示信息
MessageBox.Show("半检状态返工时,缺陷记录必须填写",
this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
return;
}
}
else if (this.dkSemiCheckType.SelectedValue.ToString() == "2")
{
// 半检状态-不合格
if (this.dropReworkProcedure.SelectedValue != null && this.dropReworkProcedure.SelectedValue.ToString() != "-1")
{
// 提示信息
MessageBox.Show("半检状态不合格时,返工工序必须为空",
this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
return;
}
if (this.dropDutyUser.SelectedValue != null && this.dropDutyUser.SelectedValue.ToString() != "-1")
{
// 提示信息
MessageBox.Show("半检状态不合格时,返工工号必须为空",
this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
return;
}
DataTable dt = this.dgvDefect.DataSource as DataTable;
if (dt == null || dt.Rows.Count == 0)
{
// 提示信息
MessageBox.Show("半检状态不合格时,缺陷记录必须填写",
this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
return;
}
//else
//{
// // 必须有责任工序
// bool existProcedure = false;
// for (int i = 0; i < dt.Rows.Count; i++)
// {
// if (dt.Rows[i]["DefectProcedureID"].ToString() != "-1")
// {
// existProcedure = true;
// break;
// }
// }
// if (!existProcedure)
// {
// // 提示信息
// MessageBox.Show("半检状态不合格时,缺陷记录必须有责任工序",
// this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
// return;
// }
//}
}
#endregion 保存画面验证
if (this.TableProductionData.Select("ReadOnly<>1").Length > 0)
{
this.TableProductionData = this.TableProductionData.Select("ReadOnly<>1").CopyToDataTable();
}
SemiCheckEntity[] productionDataEntitys = new SemiCheckEntity[this.TableProductionData.Rows.Count];
bool isError = false; // 是否存在缺陷员工
int ErrorCount = -1;
//int CurrentRowIndex = -1;
for (int i = 0; i < this.TableProductionData.Rows.Count; i++)
{
//if (this.TableProductionData.Rows[i]["ReadOnly"].ToString() == "1") //只读数据不进行保存
//{
// continue;
//}
SemiCheckEntity productionDataEntity = new SemiCheckEntity();
productionDataEntity.SemiCheckCategory = 1;
productionDataEntity.SemiCheckType = this.dkSemiCheckType.SelectedValue.ToString();
productionDataEntity.SemiCheckEditType = this._semiCheckEditType;
if (this.dropReworkProcedure.SelectedValue != null && this.dropReworkProcedure.SelectedValue.ToString() != "-1")
{
string DutyProcedure = this.dropReworkProcedure.SelectedValue.ToString();
DataTable dtDutyProcedureCode = this.dropReworkProcedure.DataSource as DataTable;
if (dtDutyProcedureCode.Rows.Count > Constant.INT_IS_ZERO)
{
DataRow[] dr = dtDutyProcedureCode.Select("ProcedureID=" + DutyProcedure);
if (dr.Length > Constant.INT_IS_ZERO)
{
productionDataEntity.ReworkProcedureID = Convert.ToInt32(DutyProcedure);
productionDataEntity.ReworkProcedureCode = dr[0]["ProcedureCode"].ToString();
}
}
}
// 返工工号
if (this.dropDutyUser.SelectedValue != null && this.dropDutyUser.SelectedValue.ToString() != "-1")
{
string userid = this.dropDutyUser.SelectedValue.ToString();
DataTable dtUser = this.dropDutyUser.DataSource as DataTable;
if (dtUser.Rows.Count > Constant.INT_IS_ZERO)
{
DataRow[] dr = dtUser.Select("userid=" + userid);
if (dr.Length > Constant.INT_IS_ZERO)
{
productionDataEntity.ReworkUserID = Convert.ToInt32(userid);
productionDataEntity.ReworkUserCode = dr[0]["usercode"].ToString();
}
}
}
//if (this._productiondataid > 0)
//{
// productionDataEntity.ProductionDataID = this._productiondataid;
//}
if (this.TableProductionData.Rows[i]["ProductionDataID"].ToString() != "")
{
productionDataEntity.SemiCheckID = Convert.ToInt32(this.TableProductionData.Rows[i]["ProductionDataID"]);
}
productionDataEntity.BarCode = this.TableProductionData.Rows[i]["BarCode"].ToString();
productionDataEntity.SemiCheckUserID = UserID;// Convert.ToInt32(this.TableProductionData.Rows[i]["UserID"]);
productionDataEntity.SemiCheckUserCode = UserCode;// this.TableProductionData.Rows[i]["UserCode"].ToString();
//productionDataEntity.SemiCheckUserName = UserName;// this.TableProductionData.Rows[i]["UserName"].ToString(); ;
// productionDataEntity.DefectFlag = Convert.ToInt32(this.TableProductionData.Rows[i]["GoodsLevelTypeID"]) == 4 ? 1 : 2;
//productionDataEntity.GoodsLevelID = Convert.ToInt32(this.TableProductionData.Rows[i]["DefectFlagID"]);
//productionDataEntity.GoodsLevelTypeID = Convert.ToInt32(this.TableProductionData.Rows[i]["GoodsLevelTypeID"]);
productionDataEntity.Remarks = this.TableProductionData.Rows[i]["Remarks"].ToString();
productionDataEntitys[i] = productionDataEntity;
List productionDefectEntitys = new List();
SemiCheckDefectEntity productionDefectEntity = null;
for (int j = 0; j < this.DSTable.Tables[productionDataEntity.BarCode].Rows.Count; j++) //缺陷列表
{
productionDefectEntity = new SemiCheckDefectEntity();
//productionDefectEntity.SpecialDefect = this.DSTable.Tables[productionDataEntity.Barcode].Rows[j]["IsOtherDefect"].ToString();
//if (this.DSTable.Tables[productionDataEntity.BarCode].Rows[j]["DefectDeductionID"].ToString() != "-1"
// && this.DSTable.Tables[productionDataEntity.BarCode].Rows[j]["DefectDeductionID"].ToString() != string.Empty)
//{
// productionDefectEntity.DefectDeductionNum = Convert.ToDecimal(this.DSTable.Tables[productionDataEntity.Barcode].Rows[j]["DefectDeductionNum"]);
//}
productionDefectEntity.ScrapResponFlag = "0";
productionDefectEntity.DefectID =
Convert.ToInt32(this.DSTable.Tables[productionDataEntity.BarCode].Rows[j]["DefectID"]);
productionDefectEntity.DefectCode =
this.DSTable.Tables[productionDataEntity.BarCode].Rows[j]["DefectCode"].ToString();
productionDefectEntity.DefectName =
this.DSTable.Tables[productionDataEntity.BarCode].Rows[j]["DefectName"].ToString().Replace(productionDefectEntity.DefectCode + "->", "");
productionDefectEntity.DefectPositionID =
Convert.ToInt32(this.DSTable.Tables[productionDataEntity.BarCode].Rows[j]["DefectPositionID"]);
productionDefectEntity.DefectPositionCode =
this.DSTable.Tables[productionDataEntity.BarCode].Rows[j]["DefectPositionCode"].ToString();
productionDefectEntity.DefectPositionName =
this.DSTable.Tables[productionDataEntity.BarCode].Rows[j]["DefectPositionName"].ToString().Replace(productionDefectEntity.DefectPositionCode + "->", "");
productionDefectEntity.DefectProductionDataID =
Convert.ToInt32(this.DSTable.Tables[productionDataEntity.BarCode].Rows[j]["ProductionDataID"].ToString() == "" ? "0" :
this.DSTable.Tables[productionDataEntity.BarCode].Rows[j]["ProductionDataID"].ToString());
if (productionDefectEntity.DefectProductionDataID == 0)
{
productionDefectEntity.DefectProductionDataID = null;
}
if (this.DSTable.Tables[productionDataEntity.BarCode].Rows[j]["DefectProcedureID"].ToString() != string.Empty &&
Convert.ToInt32(this.DSTable.Tables[productionDataEntity.BarCode].Rows[j]["DefectProcedureID"]) > Constant.INT_IS_ZERO)
{
productionDefectEntity.DefectProcedureID =
Convert.ToInt32(this.DSTable.Tables[productionDataEntity.BarCode].Rows[j]["DefectProcedureID"]);
}
productionDefectEntity.DefectProcedureCode =
this.DSTable.Tables[productionDataEntity.BarCode].Rows[j]["DefectProcedureCode"].ToString();
productionDefectEntity.DefectProcedureName =
this.DSTable.Tables[productionDataEntity.BarCode].Rows[j]["DefectProcedureName"].ToString();
productionDefectEntity.DefectUserID =
Convert.ToInt32(this.DSTable.Tables[productionDataEntity.BarCode].Rows[j]["DefectUserID"]);
productionDefectEntity.DefectUserCode =
this.DSTable.Tables[productionDataEntity.BarCode].Rows[j]["DefectUserCode"].ToString();
productionDefectEntity.DefectUserName =
this.DSTable.Tables[productionDataEntity.BarCode].Rows[j]["DefectUserName"].ToString();
//productionDefectEntity.DefectJobs =
// Convert.ToInt32(this.DSTable.Tables[productionDataEntity.Barcode].Rows[j]["Jobs"].ToString());
productionDefectEntity.Remarks =
this.DSTable.Tables[productionDataEntity.BarCode].Rows[j]["DefectRemarks"].ToString();
// 遍历责任员工
List DefectResponsibles = new List();
if (this.DSTableStaff.Tables.Contains(string.Format("TempTable{0}",
this.DSTable.Tables[productionDataEntity.BarCode].Rows[j]["TempCount"].ToString())))
{
SemiCheckResponsibleEntity defectResponsibleEntity = null;
DataTable dtTemp = this.DSTableStaff.Tables[string.Format("TempTable{0}",
this.DSTable.Tables[productionDataEntity.BarCode].Rows[j]["TempCount"].ToString())];
foreach (DataRow drStaff in dtTemp.Rows)
{
if (Convert.ToInt32(drStaff["IsSelected"]) == Constant.INT_IS_ONE)
{
defectResponsibleEntity = new SemiCheckResponsibleEntity();
defectResponsibleEntity.StaffID = Convert.ToInt32(drStaff["StaffID"]);
defectResponsibleEntity.UserID = Convert.ToInt32(productionDefectEntity.DefectUserID);
defectResponsibleEntity.UserCode = productionDefectEntity.DefectUserCode;
defectResponsibleEntity.UJobsID = Convert.ToInt32(drStaff["UJobsID"]);
defectResponsibleEntity.SJobsID = Convert.ToInt32(drStaff["SJobsID"]);
defectResponsibleEntity.StaffStatus = Convert.ToInt32(drStaff["StaffStatus"]);
DefectResponsibles.Add(defectResponsibleEntity);
}
}
//productionDefectEntity.DefectResponsibles = DefectResponsibles.ToArray();//每个缺陷对应的责任员工
productionDefectEntity.DefectResponsibles = DefectResponsibles;//每个缺陷对应的责任员工
}
if (DefectResponsibles.Count == Constant.INT_IS_ZERO) // 并没有责任员工
{
isError = true;
this.dgvDefect.DataSource = this.DSTable.Tables[productionDataEntity.BarCode];
this.dgvDefect.CurrentCell = null;
this.dgvDefect.Rows[j].Selected = true;
if (this.DSTableStaff.Tables.Contains(string.Format("TempTable{0}",
this.DSTable.Tables[productionDataEntity.BarCode].Rows[j]["TempCount"].ToString())))
{
this.dgvDefectStaff.DataSource = this.DSTableStaff.Tables[string.Format("TempTable{0}",
this.DSTable.Tables[productionDataEntity.BarCode].Rows[j]["TempCount"].ToString())];
}
else
{
this.dgvDefectStaff.DataSource = null;
}
break;
}
productionDefectEntitys.Add(productionDefectEntity);
}
if (isError)
{
break;
}
//productionDataEntitys[i].ProductionDefects = productionDefectEntitys.ToArray();
productionDataEntitys[i].SemiCheckDefects = productionDefectEntitys;
}
// 有错误
if (isError)
{
if (ErrorCount == -Constant.INT_IS_ONE)
{
// 提示信息
MessageBox.Show(Messages.MSG_PM_W002,
this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
return;
}
else if (ErrorCount == -Constant.INT_IS_TWO)
{
// 提示信息
MessageBox.Show(Messages.MSG_PM_W004,
this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
return;
}
else
{
this.dgvProductionData.DataSource = TableProductionData;
// 提示信息
MessageBox.Show(Messages.MSG_PM_W003,
this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
return;
}
}
// 最外层For循环结束
if (productionDataEntitys.Length > Constant.INT_IS_ZERO)
{
string returnValue = "";
ServiceResultEntity entity = (ServiceResultEntity)DoAsync(new BaseAsyncMethod(() =>
{
return PMModuleProxy.Service.AddSemiCheck(productionDataEntitys);
}));
returnValue = entity.Message;
if (string.IsNullOrEmpty(returnValue))//成功
{
// 提示信息
MessageBox.Show(string.Format(Messages.MSG_CMN_I001, "新建" + this.Text, "保存"),
this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
this.TableProductionData.Rows.Clear();
this.dgvProductionData.DataSource = TableProductionData;
this.DSTable.Tables.Clear();
this.dgvDefect.DataSource = null;
this.DSTableStaff.Tables.Clear();
this.dgvDefectStaff.DataSource = null;
this.txtBarCode.Text = string.Empty;
//this.txtUserCode.Text = string.Empty;
//this.txtUserCode.ReadOnly = false;
this.dropReworkProcedure.SelectedValue = -1;
this.dropReworkProcedure.Enabled = false;
this.dropDutyUser.SelectedValue = -1;
this.dropDutyUser.Enabled = false;
this.dkSemiCheckType.SelectedIndex = -1;
this.dkSemiCheckType.Enabled = false;
this.txtBarCode.Enabled = true;
//this.DSREWORK.Tables.Clear();
}
else
{
// 提示信息
MessageBox.Show(returnValue,
this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
}
}
catch (Exception ex)
{
// 对异常进行共通处理
ExceptionManager.HandleEventException(this.ToString(),
System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
}
}
///
/// 关闭按钮事件
///
///
///
private void tsbCloseTop_Click(object sender, EventArgs e)
{
this.Close();
}
///
/// 单元格编辑开始时事件
///
///
///
private void dgvProductionData_CellBeginEdit(object sender, DataGridViewCellCancelEventArgs e)
{
try
{
if (e.ColumnIndex == Constant.INT_IS_FOUR && e.RowIndex != -Constant.INT_IS_ONE)
{
DataGridView dgv = (DataGridView)sender;
string value = this.dgvProductionData.Rows[this.dgvProductionData.CurrentCell.RowIndex].Cells["GoodsLevelTypeID"].Value.ToString();
if (value != Constant.GoodsLevelType.ReFire.GetHashCode().ToString())
{
e.Cancel = true;
}
}
if (e.ColumnIndex == Constant.INT_IS_THREE && e.RowIndex != -Constant.INT_IS_ONE)
{
if (this.dgvProductionData.Rows[this.dgvProductionData.CurrentCell.RowIndex].Cells["ReadOnly"].Value.ToString() == "1")
{
e.Cancel = true;
}
}
}
catch (Exception ex)
{
// 对异常进行共通处理
ExceptionManager.HandleEventException(this.ToString(),
System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
}
}
///
/// 用户编码验证事件
///
///
///
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)
{
DataTable dtUserWork = this.dropDutyUser.DataSource as DataTable; //判断输入工号是否是生产工号
if (dtUserWork != null)
{
DataRow[] dr = dtUserWork.Select("UserCode='" + this.txtUserCode.Text.Trim() + "'");
if (dr.Length == 0)
{
MessageBox.Show("无效" + this.txtUserCode.Text.Trim() + "生产工号",
this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
this.txtUserCode.SelectAll();
e.Cancel = true;
return;
}
UserID = Convert.ToInt32(dr[0]["UserID"]);
UserCode = dr[0]["UserCode"].ToString();
UserName = dr[0]["UserName"].ToString();
this.txtUserCode.ReadOnly = true;
}
}
}
catch (Exception ex)
{
// 对异常进行共通处理
ExceptionManager.HandleEventException(this.ToString(),
System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
}
}
///
/// 责任员工
///
///
///
private void dgvDefectStaff_UserDeletingRow(object sender, DataGridViewRowCancelEventArgs e)
{
try
{
if (e.Row.Index != -1)
{
if (this.dgvDefect.CurrentCell != null)
{
//是新增进来,加载条码是不允许删除的,只是编辑权限才能可以删除
if (this.dgvDefect.Rows[e.Row.Index].Cells["ProductionDataID"].Value.ToString() != "" && Convert.ToInt32(this.dgvDefect.Rows[e.Row.Index].Cells["ProductionDataID"].Value) > 0 && this.dgvDefect.Rows[e.Row.Index].Cells["IsAllowEdit"].Value.ToString() == "0")
{
e.Cancel = true;
return;
}
}
}
}
catch (Exception ex)
{
// 对异常进行共通处理
ExceptionManager.HandleEventException(this.ToString(),
System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
}
}
///
/// 漏扫责任员工
///
///
///
private void dgvMissStaff_UserDeletingRow(object sender, DataGridViewRowCancelEventArgs e)
{
try
{
if (e.Row.Index != -1)
{
if (this.dgvDefect.CurrentCell != null)
{
//是新增进来,加载条码是不允许删除的,只是编辑权限才能可以删除
if (this.dgvDefect.Rows[e.Row.Index].Cells["ProductionDataID"].Value.ToString() != "" && Convert.ToInt32(this.dgvDefect.Rows[e.Row.Index].Cells["ProductionDataID"].Value) > 0 && this.dgvDefect.Rows[e.Row.Index].Cells["IsAllowEdit"].Value.ToString() == "0")
{
e.Cancel = true;
return;
}
}
}
}
catch (Exception ex)
{
// 对异常进行共通处理
ExceptionManager.HandleEventException(this.ToString(),
System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
}
}
///
/// 返工工号验证事件
///
///
///
private void dropReworkProcedure_Validating(object sender, System.ComponentModel.CancelEventArgs e)
{
try
{
if (this.dropReworkProcedure.SelectedValue != null && this.dropReworkProcedure.SelectedValue.ToString() != "-1")
{
if (!this.txtBarCode.ReadOnly)
{
string DutyProcedure = this.dropReworkProcedure.SelectedValue.ToString();
DataTable dtDutyProcedureCode = this.dropReworkProcedure.DataSource as DataTable;
if (dtDutyProcedureCode.Rows.Count > Constant.INT_IS_ZERO)
{
DataRow[] dr = dtDutyProcedureCode.Select("ProcedureID=" + DutyProcedure);
if (dr.Length > Constant.INT_IS_ZERO)
{
this.dropDutyUser.SelectedValue = dr[0]["UserID"].ToString();
}
}
}
}
else
{
//默认加载全部生产工号
this.dropDutyUser.DisplayMember = "UserCode";
this.dropDutyUser.ValueMember = "UserID";
this.dropDutyUser.DataSource = this._dtDutyProcedureUser;
this.dropDutyUser.SelectedValue = -1;
}
}
catch (Exception ex)
{
// 对异常进行共通处理
ExceptionManager.HandleEventException(this.ToString(),
System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
}
}
#endregion
#region 私有方法
///
/// 绑定到第一个DataGriwView数据源
///
private void BindProductionData_New()
{
try
{
DataRow[] dr = TableProductionData.Select("BarCode='" + this.txtBarCode.Text.Trim() + "'");
if (dr.Length > Constant.INT_IS_ZERO)
{
// 不允许重复添加
return;
}
// 目前只能添加一个条码
this.TableProductionData.Rows.Clear();
this.dgvProductionData.DataSource = TableProductionData;
this.DSTable.Tables.Clear();
this.dgvDefect.DataSource = null;
this.DSTableStaff.Tables.Clear();
this.dgvDefectStaff.DataSource = null;
//this.txtBarCode.Text = string.Empty;
this.dropReworkProcedure.DataSource = null;
this.dropDutyUser.DisplayMember = "UserCode";
this.dropDutyUser.ValueMember = "UserID";
this.dropDutyUser.DataSource = this._dtDutyProcedureUser;
// 目前只能添加一个条码
int SpecialRepairflag = 0;
string KilnCarCode = string.Empty;
string KilnCode = string.Empty;
string Dictionaryvalue = string.Empty;
DataSet dsKilnCar = (DataSet)DoAsync(new BaseAsyncMethod(() =>
{
return PMModuleProxy.Service.GetKilnCarByBarCode(txtBarCode.Text.Trim());
}));
if (dsKilnCar != null && dsKilnCar.Tables[0].Rows.Count > Constant.INT_IS_ZERO)
{
KilnCarCode = dsKilnCar.Tables[0].Rows[0]["KilnCarCode"].ToString();
KilnCode = dsKilnCar.Tables[0].Rows[0]["KilnCode"].ToString();
Dictionaryvalue = dsKilnCar.Tables[0].Rows[0]["Dictionaryvalue"].ToString();
}
DataRow drNew = TableProductionData.NewRow();
drNew["BarCode"] = this.txtBarCode.Text.Trim();
DataSet ds = (DataSet)DoAsync(new BaseAsyncMethod(() =>
{
return PMModuleProxy.Service.GetGoodsInfoBybarcode(this.txtBarCode.Text.Trim());
}));
if (ds != null && ds.Tables[0].Rows.Count > 0)
{
drNew["GoodsID"] = ds.Tables[0].Rows[0]["GoodsID"];
drNew["GoodsCode"] = ds.Tables[0].Rows[0]["GoodsCode"];
drNew["GoodsName"] = ds.Tables[0].Rows[0]["GoodsName"];
SpecialRepairflag = Convert.ToInt32(ds.Tables[0].Rows[0]["SpecialRepairFlag"]);
}
drNew["UserID"] = UserID;
drNew["KilnCarCode"] = KilnCarCode;
drNew["KilnCode"] = KilnCode;
drNew["Dictionaryvalue"] = Dictionaryvalue;
// drNew["DefectFlagID"] = _dsGoodsLevel.Tables[0].Rows[0]["DefectFlagID"];
//drNew["ReworkProcedureID"] = DBNull.Value;
drNew["Remarks"] = "";
drNew["UserID"] = UserID;
drNew["UserCode"] = UserCode;
drNew["UserName"] = UserName;
//drNew["GoodsLevelTypeID"] = _dsGoodsLevel.Tables[0].Rows[0]["GoodsLevelTypeID"];
//drNew["OrgGoodsLevelTypeID"] = -1;
drNew["SpecialRepairflag"] = SpecialRepairflag == 1 ? 1 : 0;
drNew["LogoCodeName"] = ds.Tables[0].Rows[0]["logoname"]
+ "[" + ds.Tables[0].Rows[0]["logocode"] + "]";
drNew["LogoID"] = ds.Tables[0].Rows[0]["LogoID"];
// 校验条码是否重烧过
DataSet dsReFine = (DataSet)DoAsync(new BaseAsyncMethod(() =>
{
return PMModuleProxy.Service.GetReFine(this.txtBarCode.Text.Trim());
}));
if (dsReFine != null && dsReFine.Tables[0].Rows.Count > 0 && dsReFine.Tables[0].Rows[0]["IsReFire"].ToString() == "6")
{
drNew["ReFine"] = 1;
}
else
{
drNew["ReFine"] = 0;
}
// 由产品条码获取注浆信息
DataSet dsGroutingProduct = (DataSet)DoAsync(new BaseAsyncMethod(() =>
{
return PMModuleProxy.Service.GetGroutingProducttByBarCode(txtBarCode.Text.Trim());
}));
drNew["UserCode"] = this.txtUserCode.Text.Trim();
drNew["MouldCode"] = dsGroutingProduct.Tables[0].Rows[0]["MouldCode"];
drNew["GroutingUserCode"] = dsGroutingProduct.Tables[0].Rows[0]["GroutingUserCode"];
drNew["GroutingNum"] = dsGroutingProduct.Tables[0].Rows[0]["GroutingNum"];
drNew["IsPublicBody"] = dsGroutingProduct.Tables[0].Rows[0]["IsPublicBody"].ToString() != "1" ? 0 : 1;
drNew["GroutingDate"] = Convert.ToDateTime(dsGroutingProduct.Tables[0].Rows[0]["GroutingDate"]);
TableProductionData.Rows.Add(drNew);
if (DSTable.Tables.IndexOf(this.txtBarCode.Text.Trim()) == -Constant.INT_IS_ONE)
{
DataTable dtProductionDefectData = new DataTable(this.txtBarCode.Text.Trim());
dtProductionDefectData.Columns.Add("BarCode");
dtProductionDefectData.Columns.Add("DefectID", typeof(decimal));
dtProductionDefectData.Columns.Add("DefectName");
dtProductionDefectData.Columns.Add("DefectCode");
dtProductionDefectData.Columns.Add("DefectPositionID", typeof(decimal));
dtProductionDefectData.Columns.Add("DefectPositionName");
dtProductionDefectData.Columns.Add("DefectPositionCode");
dtProductionDefectData.Columns.Add("DefectProcedureID", typeof(decimal));
dtProductionDefectData.Columns.Add("DefectProcedureName");
dtProductionDefectData.Columns.Add("DefectProcedureCode");
dtProductionDefectData.Columns.Add("DefectUserID", typeof(decimal));//责任员工
dtProductionDefectData.Columns.Add("DefectUserName");//责任员工
dtProductionDefectData.Columns.Add("DefectUserCode");//
dtProductionDefectData.Columns.Add("Jobs", typeof(decimal));//工种
dtProductionDefectData.Columns.Add("JobsText");//工种
dtProductionDefectData.Columns.Add("DefectRemarks");
dtProductionDefectData.Columns.Add("TempCount");
dtProductionDefectData.Columns.Add("ProductionDataID"); //生产数据ID
dtProductionDefectData.Columns.Add("DefectFineID"); //缺席扣罚ID
dtProductionDefectData.Columns.Add("DefectFineValue"); //缺席扣罚
dtProductionDefectData.Columns.Add("MissedUserID"); //漏检工号ID
dtProductionDefectData.Columns.Add("MissedUserCode"); //漏检工号编码
dtProductionDefectData.Columns.Add("MissedUserName"); //漏检工号名称
dtProductionDefectData.Columns.Add("IsAllowEdit"); //允许编辑
//新添加的 wangx 2016/1/6
dtProductionDefectData.Columns.Add("DefectDeductionID"); //缺陷扣除数ID
dtProductionDefectData.Columns.Add("DefectDeductionNum"); //缺陷扣除数
dtProductionDefectData.Columns.Add("IsOtherDefect"); //特殊缺陷
DSTable.Tables.Add(dtProductionDefectData);
}
this.dgvDefect.DataSource = DSTable.Tables[this.txtBarCode.Text.Trim()];//根据条码产生不同数据源
//this.dgvProductionData.Rows[TableProductionData.Rows.Count - 1].Selected = true;
this.dgvDefect.DataSource = null;
this.dgvDefectStaff.DataSource = null;
// 添加一个产品条码时除了第一个显示在数据表中,其它的全部清空
this.tsbtnAdd.Enabled = true;//添加完条码后,可以新建其它信息
// 添加一个产品条码时除了第一个显示在数据表中,其它的全部清空
this.tsbtnAdd.Enabled = true;//添加完条码后,可以新建其它信息
// 添加一个产品条码时除了第一个显示在数据表中,其它的全部清空
this.tsbtnAdd.Enabled = true;//添加完条码后,可以新建其它信息
this._selectedRowIndex = TableProductionData.Rows.Count - 1;
}
catch (Exception ex)
{
throw ex;
}
}
///
/// 编辑后设置数据源
///
private void SetEditDataSource_Edit()
{
try
{
this.txtUserCode.Enabled = false;
this.txtBarCode.Enabled = false;
DataSet dsSemiCheckByID = (DataSet)DoAsync(new BaseAsyncMethod(() =>
{
return PMModuleProxy.Service.GetSemiCheckByID(this._semicheckid);
}));
if (dsSemiCheckByID != null && dsSemiCheckByID.Tables[0].Rows.Count > Constant.INT_IS_ZERO)
{
#region wangx 2016-10-10 校验是否可以半检登记改判限制天数
if (_settingvaluedays > 0)
{
ServiceResultEntity resultEntity = (ServiceResultEntity)DoAsync(new BaseAsyncMethod(() =>
{
return PMModuleProxy.Service.BarcodeAllowCancel(
Convert.ToDateTime(dsSemiCheckByID.Tables[0].Rows[0]["SemiCheckTime"]),
_settingvaluedays, Constant.SettingType.S_PM_007.ToString());
}));
if (Convert.ToInt32(resultEntity.Result) < 0)
{
MessageBox.Show(resultEntity.Message,
this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
this.txtBarCode.Text = "";
this.btnSave.Visible = false;//数据显示,但是保存按钮隐藏
}
}
#endregion wangx 2016-10-10 end
// 设置返工工序等信息
if (dsSemiCheckByID.Tables[0].Rows[0]["ReworkProcedureID"].ToString() != "")
{
this.dropReworkProcedure.SelectedValue = dsSemiCheckByID.Tables[0].Rows[0]["ReworkProcedureID"].ToString();
}
if (dsSemiCheckByID.Tables[0].Rows[0]["ReworkUserID"].ToString() != "")
{
this.dropDutyUser.SelectedValue = dsSemiCheckByID.Tables[0].Rows[0]["ReworkUserID"].ToString();
}
#region 如果无编辑权限半检状态只能往下调,过滤掉上级状态
if (this._AllowEdit == 0)
{
DataView dv = ((DataTable)this.dkSemiCheckType.DataSource).DefaultView;
dv.RowFilter = "Semichecktypeid>=" + dsSemiCheckByID.Tables[0].Rows[0]["SemiCheckType"].ToString();
this.dkSemiCheckType.ValueMember = "Semichecktypeid";
this.dkSemiCheckType.DisplayMember = "Semichecktypename";
this.dkSemiCheckType.DataSource = dv.ToTable();
}
#endregion 如果无编辑权限半检状态只能往下调,过滤掉上级状态 end
this.dkSemiCheckType.SelectedValue = dsSemiCheckByID.Tables[0].Rows[0]["SemiCheckType"].ToString();
// 设置返工工序等信息 end
// 产品数据
DataRow drNew = TableProductionData.NewRow();
drNew["ProductionDataID"] = this._semicheckid;
drNew["BarCode"] = dsSemiCheckByID.Tables[0].Rows[0]["BarCode"];
drNew["GoodsID"] = dsSemiCheckByID.Tables[0].Rows[0]["GoodsID"];
drNew["GoodsCode"] = dsSemiCheckByID.Tables[0].Rows[0]["GoodsCode"];
drNew["GoodsName"] = dsSemiCheckByID.Tables[0].Rows[0]["GoodsName"];
//drNew["DefectFlagID"] = dsSemiCheckByID.Tables[0].Rows[0]["DefectFlagID"];
//drNew["ReworkProcedureID"] = dsSemiCheckByID.Tables[0].Rows[0]["ReworkProcedureID"];
drNew["Remarks"] = dsSemiCheckByID.Tables[0].Rows[0]["Remarks"];
drNew["UserID"] = dsSemiCheckByID.Tables[0].Rows[0]["UserID"];
drNew["GoodsLevelTypeID"] = dsSemiCheckByID.Tables[0].Rows[0]["GoodsLevelTypeID"];
drNew["UserCode"] = dsSemiCheckByID.Tables[0].Rows[0]["UserCode"];
drNew["UserName"] = dsSemiCheckByID.Tables[0].Rows[0]["UserName"];
drNew["OrgGoodsLevelTypeID"] = dsSemiCheckByID.Tables[0].Rows[0]["GoodsLevelTypeID"];
drNew["ReadOnly"] = this._ReadOnly;
// drNew["KilnCarCode"] = dsSemiCheckByID.Tables[0].Rows[0]["KilnCarCode"];
// drNew["KilnCode"] = dsSemiCheckByID.Tables[0].Rows[0]["KilnCode"];
// drNew["Dictionaryvalue"] = dsSemiCheckByID.Tables[0].Rows[0]["Dictionaryvalue"];
drNew["UserCode"] = dsSemiCheckByID.Tables[0].Rows[0]["UserCode"];
drNew["MouldCode"] = dsSemiCheckByID.Tables[0].Rows[0]["MouldCode"];
drNew["GroutingUserCode"] = dsSemiCheckByID.Tables[0].Rows[0]["GroutingUserCode"];
drNew["GroutingNum"] = dsSemiCheckByID.Tables[0].Rows[0]["GroutingNum"];
drNew["IsPublicBody"] = dsSemiCheckByID.Tables[0].Rows[0]["IsPublicBody"].ToString() != "1" ? 0 : 1;
drNew["GroutingDate"] = Convert.ToDateTime(dsSemiCheckByID.Tables[0].Rows[0]["GroutingDate"]);
drNew["LogoCodeName"] = dsSemiCheckByID.Tables[0].Rows[0]["LogoName"] + "[" + dsSemiCheckByID.Tables[0].Rows[0]["LogoCode"] + "]";
drNew["LogoId"] = dsSemiCheckByID.Tables[0].Rows[0]["LogoId"];
//drNew["ReFine"] = dsSemiCheckByID.Tables[0].Rows[0]["Isrefire"];
drNew["SpecialRepairflag"] = dsSemiCheckByID.Tables[0].Rows[0]["SpecialRepairflag"];
TableProductionData.Rows.Add(drNew);
this.dgvProductionData.Rows[TableProductionData.Rows.Count - 1].Selected = true;
this._selectedRowIndex = TableProductionData.Rows.Count - 1;
this._currentBarCode = dsSemiCheckByID.Tables[0].Rows[0]["BarCode"].ToString();
this._currentGoodsID = Convert.ToInt32(dsSemiCheckByID.Tables[0].Rows[0]["GoodsID"]);
////////if (dsSemiCheckByID.Tables[0].Rows[0]["GoodsLevelTypeID"].ToString() == Constant.INT_IS_SEVEN.ToString())
////////{
//////// //次品设置只读的时候,原来默认不允许修改,目前注释掉
//////// //SetSubstandard();
//////// DataSet dsReturn = (DataSet)DoAsync(new BaseAsyncMethod(() =>
//////// {
//////// return PMModuleProxy.Service.GetSubstandardInfo(dsSemiCheckByID.Tables[0].Rows[0]["BarCode"].ToString());
//////// }));
//////// if (dsReturn != null && dsReturn.Tables[0].Rows.Count == 0) //防止回收站里没有此条码
//////// {
//////// // 提示信息
//////// MessageBox.Show("次品条码:" + dsSemiCheckByID.Tables[0].Rows[0]["BarCode"].ToString() + "不允许修改",
//////// this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
//////// return;
//////// }
//////// this.tsbtnAdd.Enabled = true;
////////}
////////else
////////{
//////// this.tsbtnAdd.Enabled = true;
//////// if (dsSemiCheckByID != null && dsSemiCheckByID.Tables[1].Rows.Count > Constant.INT_IS_ZERO)
//////// {
//////// this.tsbtnEdit.Enabled = true;
//////// }
////////}
}
if (DSTable.Tables.IndexOf(dsSemiCheckByID.Tables[0].Rows[0]["BarCode"].ToString()) == -Constant.INT_IS_ONE)
{
DataTable dtProductionDefectData = new DataTable(dsSemiCheckByID.Tables[0].Rows[0]["BarCode"].ToString());
dtProductionDefectData.Columns.Add("BarCode");
dtProductionDefectData.Columns.Add("DefectID", typeof(decimal));
dtProductionDefectData.Columns.Add("DefectName");
dtProductionDefectData.Columns.Add("DefectCode");
dtProductionDefectData.Columns.Add("DefectPositionID", typeof(decimal));
dtProductionDefectData.Columns.Add("DefectPositionName");
dtProductionDefectData.Columns.Add("DefectPositionCode");
dtProductionDefectData.Columns.Add("DefectProcedureID", typeof(decimal));
dtProductionDefectData.Columns.Add("DefectProcedureName");
dtProductionDefectData.Columns.Add("DefectProcedureCode");
dtProductionDefectData.Columns.Add("DefectUserID", typeof(decimal));//责任员工
dtProductionDefectData.Columns.Add("DefectUserName");//责任员工
dtProductionDefectData.Columns.Add("DefectUserCode");//
dtProductionDefectData.Columns.Add("Jobs", typeof(decimal));//工种
dtProductionDefectData.Columns.Add("JobsText");//工种
dtProductionDefectData.Columns.Add("DefectRemarks");
dtProductionDefectData.Columns.Add("TempCount");
dtProductionDefectData.Columns.Add("ProductionDataID"); //生产数据ID
dtProductionDefectData.Columns.Add("DefectFineID"); //缺陷扣罚ID
dtProductionDefectData.Columns.Add("DefectFineValue"); //缺陷扣罚
dtProductionDefectData.Columns.Add("MissedUserID"); //漏检工号ID
dtProductionDefectData.Columns.Add("MissedUserCode"); //漏检工号编码
dtProductionDefectData.Columns.Add("MissedUserName"); //漏检工号名称
dtProductionDefectData.Columns.Add("IsAllowEdit"); //是否允许编辑 0 不允许,1允许
//新添加的 wangx 2016/1/6
dtProductionDefectData.Columns.Add("DefectDeductionID"); //缺陷扣除数ID
dtProductionDefectData.Columns.Add("DefectDeductionNum"); //缺陷扣除数
dtProductionDefectData.Columns.Add("IsOtherDefect"); //特殊缺陷
//新添加的 wangx 2016/1/6 end
DSTable.Tables.Add(dtProductionDefectData);
}
if (dsSemiCheckByID != null && dsSemiCheckByID.Tables[1].Rows.Count > Constant.INT_IS_ZERO)
{
// 产品缺陷
if (DSTable.Tables.IndexOf(dsSemiCheckByID.Tables[0].Rows[0]["BarCode"].ToString()) == -Constant.INT_IS_ONE)
{
DataTable dtProductionDefectData = new DataTable(dsSemiCheckByID.Tables[0].Rows[0]["BarCode"].ToString());
dtProductionDefectData.Columns.Add("BarCode");
dtProductionDefectData.Columns.Add("DefectID", typeof(decimal));
dtProductionDefectData.Columns.Add("DefectName");
dtProductionDefectData.Columns.Add("DefectCode");
dtProductionDefectData.Columns.Add("DefectPositionID", typeof(decimal));
dtProductionDefectData.Columns.Add("DefectPositionName");
dtProductionDefectData.Columns.Add("DefectPositionCode");
dtProductionDefectData.Columns.Add("DefectProcedureID", typeof(decimal));
dtProductionDefectData.Columns.Add("DefectProcedureName");
dtProductionDefectData.Columns.Add("DefectProcedureCode");
dtProductionDefectData.Columns.Add("DefectUserID", typeof(decimal));//责任员工
dtProductionDefectData.Columns.Add("DefectUserName");//责任员工
dtProductionDefectData.Columns.Add("DefectUserCode");//
dtProductionDefectData.Columns.Add("Jobs", typeof(decimal));//工种
dtProductionDefectData.Columns.Add("JobsText");//工种
dtProductionDefectData.Columns.Add("DefectRemarks");
dtProductionDefectData.Columns.Add("TempCount");
dtProductionDefectData.Columns.Add("ProductionDataID"); //生产数据ID
dtProductionDefectData.Columns.Add("DefectFineID"); //缺席扣罚ID
dtProductionDefectData.Columns.Add("DefectFineValue"); //缺席扣罚
dtProductionDefectData.Columns.Add("MissedUserID"); //漏检工号ID
dtProductionDefectData.Columns.Add("MissedUserCode"); //漏检工号编码
dtProductionDefectData.Columns.Add("MissedUserName"); //漏检工号名称
dtProductionDefectData.Columns.Add("IsAllowEdit"); //是否允许编辑 0 不允许,1允许
//新添加的 wangx 2016/1/6
dtProductionDefectData.Columns.Add("DefectDeductionID"); //缺陷扣除数ID
dtProductionDefectData.Columns.Add("DefectDeductionNum"); //缺陷扣除数
dtProductionDefectData.Columns.Add("IsOtherDefect"); //特殊缺陷
//新添加的 wangx 2016/1/6 end
DSTable.Tables.Add(dtProductionDefectData);
}
this.dgvProductionData.Rows[TableProductionData.Rows.Count - 1].Selected = true;
this._selectedRowIndex = TableProductionData.Rows.Count - 1;
//this._currentDefectFlag = Convert.ToInt32(this.dgvProductionData.Rows[_selectedRowIndex].Cells["GoodsLevelTypeID"].Value.ToString());
this._currentGoodsID = Convert.ToInt32(this.dgvProductionData.Rows[_selectedRowIndex].Cells["GoodsID"].Value);
this._currentBarCode = this.dgvProductionData.Rows[_selectedRowIndex].Cells["BarCode"].Value.ToString();
//-----------------------
//DataSet ds = (DataSet)DoAsync(new BaseAsyncMethod(() =>
//{
// return PMModuleProxy.Service.GetReworkProcedureByProcedureID(this._procedureID);
//}));
//ds.Tables[0].TableName = dsProductionDataByID.Tables[0].Rows[0]["BarCode"].ToString();
//if (this.DSREWORK == null)
//{
// this.DSREWORK = new DataSet();
//}
//this.DSREWORK.Tables.Add(ds.Tables[0].Copy());
//C_DGV_Cell_ListBoxComboBox C_DGV_Cell_ListBoxComboBox = dgvProductionData.Rows[_selectedRowIndex].Cells[4] as C_DGV_Cell_ListBoxComboBox;
//C_DGV_Cell_ListBoxComboBox.DataSource = ds.Tables[0];
//C_DGV_Cell_ListBoxComboBox.DisplayMember = "ReworkProcedureName";
//C_DGV_Cell_ListBoxComboBox.ValueMember = "ReworkProcedureID";
for (int i = 0; i < dsSemiCheckByID.Tables[1].Rows.Count; i++)
{
DataRow dr = DSTable.Tables[dsSemiCheckByID.Tables[0].Rows[0]["BarCode"].ToString()].NewRow();
dr["BarCode"] = dsSemiCheckByID.Tables[0].Rows[0]["BarCode"];
dr["DefectID"] = dsSemiCheckByID.Tables[1].Rows[i]["DefectID"];
dr["DefectName"] = dsSemiCheckByID.Tables[1].Rows[i]["DefectName"];
dr["DefectCode"] = dsSemiCheckByID.Tables[1].Rows[i]["DefectCode"];
dr["DefectPositionID"] = dsSemiCheckByID.Tables[1].Rows[i]["DefectPositionID"];
dr["DefectPositionName"] = dsSemiCheckByID.Tables[1].Rows[i]["DefectPositionName"];
dr["DefectPositionCode"] = dsSemiCheckByID.Tables[1].Rows[i]["DefectPositionCode"];
dr["DefectProcedureID"] = dsSemiCheckByID.Tables[1].Rows[i]["DefectProcedureID"];
dr["DefectProcedureName"] = dsSemiCheckByID.Tables[1].Rows[i]["DefectProcedureName"];
dr["DefectProcedureCode"] = dsSemiCheckByID.Tables[1].Rows[i]["DefectProcedureCode"];
dr["DefectUserID"] = dsSemiCheckByID.Tables[1].Rows[i]["DefectUserID"];
dr["DefectUserName"] = dsSemiCheckByID.Tables[1].Rows[i]["DefectUserName"];
dr["DefectUserCode"] = dsSemiCheckByID.Tables[1].Rows[i]["DefectUserCode"];
//dr["Jobs"] = dsSemiCheckByID.Tables[1].Rows[i]["Jobs"];
//dr["JobsText"] = dsSemiCheckByID.Tables[1].Rows[i]["JobsText"];
dr["DefectRemarks"] = dsSemiCheckByID.Tables[1].Rows[i]["remarks"];
dr["TempCount"] = this._tempCount;
dr["ProductionDataID"] = dsSemiCheckByID.Tables[1].Rows[i]["DefectProductionDataID"];// dsProductionDataByID.Tables[1].Rows[i]["ProductionDataID"];
//dr["DefectFineID"] = dsSemiCheckByID.Tables[1].Rows[i]["DefectFineID"];
//dr["DefectFineValue"] = dsSemiCheckByID.Tables[1].Rows[i]["DefectFineValue"];
//dr["MissedUserID"] = dsSemiCheckByID.Tables[1].Rows[i]["MissedUserID"];
//dr["MissedUserCode"] = dsSemiCheckByID.Tables[1].Rows[i]["MissedUserCode"];
//dr["MissedUserName"] = dsSemiCheckByID.Tables[1].Rows[i]["MissedUserName"];
dr["IsAllowEdit"] = this._AllowEdit;
//dr["DefectDeductionID"] = dsProductionDataByID.Tables[1].Rows[i]["DefectDeductionID"];
//dr["DefectDeductionNum"] = dsSemiCheckByID.Tables[1].Rows[i]["DefectDeductionNum"];
//dr["IsOtherDefect"] = dsSemiCheckByID.Tables[1].Rows[i]["SpecialDefect"];
DSTable.Tables[dsSemiCheckByID.Tables[0].Rows[0]["BarCode"].ToString()].Rows.Add(dr);
// 防止工种不选择的话,直接New一个
if (!this.DSTableStaff.Tables.Contains(string.Format("TempTable{0}", this._tempCount)))
{
DataTable dtStaff = new DataTable(string.Format("TempTable{0}", this._tempCount));
dtStaff.Columns.Add("IsSelected");
dtStaff.Columns.Add("StaffID");
dtStaff.Columns.Add("StaffCode");
dtStaff.Columns.Add("StaffName");
dtStaff.Columns.Add("StaffTempCount");
dtStaff.Columns.Add("StaffStatus");
dtStaff.Columns.Add("UjobsID");
dtStaff.Columns.Add("SjobsID");
this.DSTableStaff.Tables.Add(dtStaff);
}
// 责任员工
DataRow[] drRow = dsSemiCheckByID.Tables[2].Select("SemiCheckDefectID=" + dsSemiCheckByID.Tables[1].Rows[i]["SemiCheckDefectID"]);
if (drRow.Length > Constant.INT_IS_ZERO)
{
foreach (DataRow r in drRow)
{
DataRow drStaff = this.DSTableStaff.Tables[string.Format("TempTable{0}", this._tempCount)].NewRow();
drStaff["IsSelected"] = 1;
drStaff["StaffID"] = r["StaffID"];
drStaff["StaffCode"] = r["StaffCode"];
drStaff["StaffName"] = r["StaffName"];
drStaff["StaffTempCount"] = this._tempCount;
drStaff["StaffStatus"] = r["StaffStatus"];
drStaff["UjobsID"] = r["UjobsID"];
drStaff["SjobsID"] = r["SjobsID"];
this.DSTableStaff.Tables[string.Format("TempTable{0}", this._tempCount)].Rows.Add(drStaff);
}
}
this._currentTempSign = i.ToString();
this._tempCount = this._tempCount + 1;
}
this.dgvDefect.DataSource = DSTable.Tables[dsSemiCheckByID.Tables[0].Rows[0]["BarCode"].ToString()];//根据条码产生不同数据源
}
if (!this.btnSave.Visible)
{
this.tsbtnAdd.Enabled = false;
this.tsbtnEdit.Enabled = false;
}
}
catch (Exception ex)
{
throw ex;
}
}
///
/// 设置数据源
///
///
public void SetDataSource(int tempCount)
{
this.dgvDefect.DataSource = DSTable.Tables[this._currentBarCode];
this.dgvDefectStaff.DataSource = DSTableStaff.Tables[string.Format("TempTable{0}", this._tempCount.ToString())];
this._tempCount = tempCount;
}
///
/// 设置编辑产品为时设置只读
///
private void SetSubstandard()
{
this.btnSave.Enabled = false;
this.dgvProductionData.ReadOnly = true;
this.tsbtnAdd.Enabled = false;
this.tsbtnEdit.Enabled = false;
this.dgvDefect.ReadOnly = true;
this.dgvDefectStaff.ReadOnly = true;
}
///
/// 编辑后设置数据源
///
private void SetEditDataSource()
{
try
{
this.txtUserCode.Enabled = false;
this.txtBarCode.Enabled = false;
DataSet dsProductionDataByID = (DataSet)DoAsync(new BaseAsyncMethod(() =>
{
return PMModuleProxy.Service.GetProductionDataByID(this._productiondataid);
}));
if (dsProductionDataByID != null && dsProductionDataByID.Tables[0].Rows.Count > Constant.INT_IS_ZERO)
{
int SpecialRepairflag = (int)DoAsync(new BaseAsyncMethod(() =>
{
return PMModuleProxy.Service.GetSpecialRepairflagByBarcode(dsProductionDataByID.Tables[0].Rows[0]["BarCode"].ToString());
}));
// 产品数据
DataRow drNew = TableProductionData.NewRow();
drNew["ProductionDataID"] = this._productiondataid;
drNew["BarCode"] = dsProductionDataByID.Tables[0].Rows[0]["BarCode"];
drNew["GoodsID"] = dsProductionDataByID.Tables[0].Rows[0]["GoodsID"];
drNew["GoodsCode"] = dsProductionDataByID.Tables[0].Rows[0]["GoodsCode"];
drNew["GoodsName"] = dsProductionDataByID.Tables[0].Rows[0]["GoodsName"];
drNew["DefectFlagID"] = dsProductionDataByID.Tables[0].Rows[0]["DefectFlagID"];
drNew["ReworkProcedureID"] = dsProductionDataByID.Tables[0].Rows[0]["ReworkProcedureID"];
drNew["Remarks"] = dsProductionDataByID.Tables[0].Rows[0]["Remarks"];
drNew["UserID"] = dsProductionDataByID.Tables[0].Rows[0]["UserID"];
drNew["GoodsLevelTypeID"] = dsProductionDataByID.Tables[0].Rows[0]["GoodsLevelTypeID"];
drNew["UserCode"] = dsProductionDataByID.Tables[0].Rows[0]["UserCode"];
drNew["UserName"] = dsProductionDataByID.Tables[0].Rows[0]["UserName"];
drNew["OrgGoodsLevelTypeID"] = dsProductionDataByID.Tables[0].Rows[0]["GoodsLevelTypeID"];
drNew["ReadOnly"] = this._ReadOnly;
drNew["KilnCarCode"] = dsProductionDataByID.Tables[0].Rows[0]["KilnCarCode"];
drNew["KilnCode"] = dsProductionDataByID.Tables[0].Rows[0]["KilnCode"];
drNew["Dictionaryvalue"] = dsProductionDataByID.Tables[0].Rows[0]["Dictionaryvalue"];
drNew["UserCode"] = dsProductionDataByID.Tables[0].Rows[0]["UserCode"];
drNew["MouldCode"] = dsProductionDataByID.Tables[0].Rows[0]["MouldCode"];
drNew["GroutingUserCode"] = dsProductionDataByID.Tables[0].Rows[0]["GroutingUserCode"];
drNew["GroutingNum"] = dsProductionDataByID.Tables[0].Rows[0]["GroutingNum"];
drNew["IsPublicBody"] = dsProductionDataByID.Tables[0].Rows[0]["IsPublicBody"].ToString() != "1" ? 0 : 1;
drNew["GroutingDate"] = Convert.ToDateTime(dsProductionDataByID.Tables[0].Rows[0]["GroutingDate"]);
drNew["LogoCodeName"] = dsProductionDataByID.Tables[0].Rows[0]["LogoName"] + "[" + dsProductionDataByID.Tables[0].Rows[0]["LogoCode"] + "]";
drNew["LogoId"] = dsProductionDataByID.Tables[0].Rows[0]["LogoId"];
DataSet dsOPTimeStamp = (DataSet)DoAsync(new BaseAsyncMethod(() =>
{
return PMModuleProxy.Service.GetCompleteProcedureIDPDA(dsProductionDataByID.Tables[0].Rows[0]["BarCode"].ToString());
}));
if (dsOPTimeStamp != null && dsOPTimeStamp.Tables[0].Rows.Count > 0)
{
drNew["OPTimeStamp"] = Convert.ToDateTime(dsOPTimeStamp.Tables[0].Rows[0]["OPTimeStamp"]);
}
//drNew["OPTimeStamp"]
// 校验条码是否重烧过,这个地方必须重新读取,因为防止编辑重烧以前的成检数据,如果直接取表里的就不准了
DataSet dsReFine = (DataSet)DoAsync(new BaseAsyncMethod(() =>
{
return PMModuleProxy.Service.GetReFine(dsProductionDataByID.Tables[0].Rows[0]["BarCode"].ToString());
}));
if (dsReFine != null && dsReFine.Tables[0].Rows.Count > 0 && dsReFine.Tables[0].Rows[0]["IsReFire"].ToString() == "6")
{
drNew["ReFine"] = 1;
}
else
{
drNew["ReFine"] = 0;
}
drNew["SpecialRepairflag"] = SpecialRepairflag.ToString() == "1" ? 1 : 0;
//原产品类别
//UserID = Convert.ToInt32(dsProductionDataByID.Tables[0].Rows[0]["UserID"]);
//UserCode = dsProductionDataByID.Tables[0].Rows[0]["UserCode"].ToString();
//UserName = dsProductionDataByID.Tables[0].Rows[0]["UserName"].ToString();
TableProductionData.Rows.Add(drNew);
this.dgvProductionData.Rows[TableProductionData.Rows.Count - 1].Selected = true;
this._selectedRowIndex = TableProductionData.Rows.Count - 1;
this._currentBarCode = dsProductionDataByID.Tables[0].Rows[0]["BarCode"].ToString();
this._currentGoodsID = Convert.ToInt32(dsProductionDataByID.Tables[0].Rows[0]["GoodsID"]);
if (dsProductionDataByID.Tables[0].Rows[0]["GoodsLevelTypeID"].ToString() == Constant.INT_IS_SEVEN.ToString())
{
//次品设置只读的时候,原来默认不允许修改,目前注释掉
//SetSubstandard();
DataSet dsReturn = (DataSet)DoAsync(new BaseAsyncMethod(() =>
{
return PMModuleProxy.Service.GetSubstandardInfo(dsProductionDataByID.Tables[0].Rows[0]["BarCode"].ToString());
}));
if (dsReturn != null && dsReturn.Tables[0].Rows.Count == 0) //防止回收站里没有此条码
{
// 提示信息
MessageBox.Show("次品条码:" + dsProductionDataByID.Tables[0].Rows[0]["BarCode"].ToString() + "不允许修改",
this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
return;
}
this.tsbtnAdd.Enabled = true;
}
else
{
this.tsbtnAdd.Enabled = true;
if (dsProductionDataByID != null && dsProductionDataByID.Tables[1].Rows.Count > Constant.INT_IS_ZERO)
{
this.tsbtnEdit.Enabled = true;
}
}
}
if (DSTable.Tables.IndexOf(dsProductionDataByID.Tables[0].Rows[0]["BarCode"].ToString()) == -Constant.INT_IS_ONE)
{
DataTable dtProductionDefectData = new DataTable(dsProductionDataByID.Tables[0].Rows[0]["BarCode"].ToString());
dtProductionDefectData.Columns.Add("BarCode");
dtProductionDefectData.Columns.Add("DefectID", typeof(decimal));
dtProductionDefectData.Columns.Add("DefectName");
dtProductionDefectData.Columns.Add("DefectCode");
dtProductionDefectData.Columns.Add("DefectPositionID", typeof(decimal));
dtProductionDefectData.Columns.Add("DefectPositionName");
dtProductionDefectData.Columns.Add("DefectPositionCode");
dtProductionDefectData.Columns.Add("DefectProcedureID", typeof(decimal));
dtProductionDefectData.Columns.Add("DefectProcedureName");
dtProductionDefectData.Columns.Add("DefectProcedureCode");
dtProductionDefectData.Columns.Add("DefectUserID", typeof(decimal));//责任员工
dtProductionDefectData.Columns.Add("DefectUserName");//责任员工
dtProductionDefectData.Columns.Add("DefectUserCode");//
dtProductionDefectData.Columns.Add("Jobs", typeof(decimal));//工种
dtProductionDefectData.Columns.Add("JobsText");//工种
dtProductionDefectData.Columns.Add("DefectRemarks");
dtProductionDefectData.Columns.Add("TempCount");
dtProductionDefectData.Columns.Add("ProductionDataID"); //生产数据ID
dtProductionDefectData.Columns.Add("DefectFineID"); //缺陷扣罚ID
dtProductionDefectData.Columns.Add("DefectFineValue"); //缺陷扣罚
dtProductionDefectData.Columns.Add("MissedUserID"); //漏检工号ID
dtProductionDefectData.Columns.Add("MissedUserCode"); //漏检工号编码
dtProductionDefectData.Columns.Add("MissedUserName"); //漏检工号名称
dtProductionDefectData.Columns.Add("IsAllowEdit"); //是否允许编辑 0 不允许,1允许
//新添加的 wangx 2016/1/6
dtProductionDefectData.Columns.Add("DefectDeductionID"); //缺陷扣除数ID
dtProductionDefectData.Columns.Add("DefectDeductionNum"); //缺陷扣除数
dtProductionDefectData.Columns.Add("IsOtherDefect"); //特殊缺陷
//新添加的 wangx 2016/1/6 end
DSTable.Tables.Add(dtProductionDefectData);
}
if (dsProductionDataByID != null && dsProductionDataByID.Tables[1].Rows.Count > Constant.INT_IS_ZERO)
{
// 产品缺陷
if (DSTable.Tables.IndexOf(dsProductionDataByID.Tables[0].Rows[0]["BarCode"].ToString()) == -Constant.INT_IS_ONE)
{
DataTable dtProductionDefectData = new DataTable(dsProductionDataByID.Tables[0].Rows[0]["BarCode"].ToString());
dtProductionDefectData.Columns.Add("BarCode");
dtProductionDefectData.Columns.Add("DefectID", typeof(decimal));
dtProductionDefectData.Columns.Add("DefectName");
dtProductionDefectData.Columns.Add("DefectCode");
dtProductionDefectData.Columns.Add("DefectPositionID", typeof(decimal));
dtProductionDefectData.Columns.Add("DefectPositionName");
dtProductionDefectData.Columns.Add("DefectPositionCode");
dtProductionDefectData.Columns.Add("DefectProcedureID", typeof(decimal));
dtProductionDefectData.Columns.Add("DefectProcedureName");
dtProductionDefectData.Columns.Add("DefectProcedureCode");
dtProductionDefectData.Columns.Add("DefectUserID", typeof(decimal));//责任员工
dtProductionDefectData.Columns.Add("DefectUserName");//责任员工
dtProductionDefectData.Columns.Add("DefectUserCode");//
dtProductionDefectData.Columns.Add("Jobs", typeof(decimal));//工种
dtProductionDefectData.Columns.Add("JobsText");//工种
dtProductionDefectData.Columns.Add("DefectRemarks");
dtProductionDefectData.Columns.Add("TempCount");
dtProductionDefectData.Columns.Add("ProductionDataID"); //生产数据ID
dtProductionDefectData.Columns.Add("DefectFineID"); //缺席扣罚ID
dtProductionDefectData.Columns.Add("DefectFineValue"); //缺席扣罚
dtProductionDefectData.Columns.Add("MissedUserID"); //漏检工号ID
dtProductionDefectData.Columns.Add("MissedUserCode"); //漏检工号编码
dtProductionDefectData.Columns.Add("MissedUserName"); //漏检工号名称
dtProductionDefectData.Columns.Add("IsAllowEdit"); //是否允许编辑 0 不允许,1允许
//新添加的 wangx 2016/1/6
dtProductionDefectData.Columns.Add("DefectDeductionID"); //缺陷扣除数ID
dtProductionDefectData.Columns.Add("DefectDeductionNum"); //缺陷扣除数
dtProductionDefectData.Columns.Add("IsOtherDefect"); //特殊缺陷
//新添加的 wangx 2016/1/6 end
DSTable.Tables.Add(dtProductionDefectData);
}
this.dgvProductionData.Rows[TableProductionData.Rows.Count - 1].Selected = true;
this._selectedRowIndex = TableProductionData.Rows.Count - 1;
this._currentDefectFlag = Convert.ToInt32(this.dgvProductionData.Rows[_selectedRowIndex].Cells["GoodsLevelTypeID"].Value.ToString());
this._currentGoodsID = Convert.ToInt32(this.dgvProductionData.Rows[_selectedRowIndex].Cells["GoodsID"].Value);
this._currentBarCode = this.dgvProductionData.Rows[_selectedRowIndex].Cells["BarCode"].Value.ToString();
//-----------------------
//DataSet ds = (DataSet)DoAsync(new BaseAsyncMethod(() =>
//{
// return PMModuleProxy.Service.GetReworkProcedureByProcedureID(this._procedureID);
//}));
//ds.Tables[0].TableName = dsProductionDataByID.Tables[0].Rows[0]["BarCode"].ToString();
//if (this.DSREWORK == null)
//{
// this.DSREWORK = new DataSet();
//}
//this.DSREWORK.Tables.Add(ds.Tables[0].Copy());
//C_DGV_Cell_ListBoxComboBox C_DGV_Cell_ListBoxComboBox = dgvProductionData.Rows[_selectedRowIndex].Cells[4] as C_DGV_Cell_ListBoxComboBox;
//C_DGV_Cell_ListBoxComboBox.DataSource = ds.Tables[0];
//C_DGV_Cell_ListBoxComboBox.DisplayMember = "ReworkProcedureName";
//C_DGV_Cell_ListBoxComboBox.ValueMember = "ReworkProcedureID";
for (int i = 0; i < dsProductionDataByID.Tables[1].Rows.Count; i++)
{
DataRow dr = DSTable.Tables[dsProductionDataByID.Tables[0].Rows[0]["BarCode"].ToString()].NewRow();
dr["BarCode"] = dsProductionDataByID.Tables[1].Rows[i]["BarCode"];
dr["DefectID"] = dsProductionDataByID.Tables[1].Rows[i]["DefectID"];
dr["DefectName"] = dsProductionDataByID.Tables[1].Rows[i]["DefectName"];
dr["DefectCode"] = dsProductionDataByID.Tables[1].Rows[i]["DefectCode"];
dr["DefectPositionID"] = dsProductionDataByID.Tables[1].Rows[i]["DefectPositionID"];
dr["DefectPositionName"] = dsProductionDataByID.Tables[1].Rows[i]["DefectPositionName"];
dr["DefectPositionCode"] = dsProductionDataByID.Tables[1].Rows[i]["DefectPositionCode"];
dr["DefectProcedureID"] = dsProductionDataByID.Tables[1].Rows[i]["DefectProcedureID"];
dr["DefectProcedureName"] = dsProductionDataByID.Tables[1].Rows[i]["DefectProcedureName"];
dr["DefectProcedureCode"] = dsProductionDataByID.Tables[1].Rows[i]["DefectProcedureCode"];
dr["DefectUserID"] = dsProductionDataByID.Tables[1].Rows[i]["DefectUserID"];
dr["DefectUserName"] = dsProductionDataByID.Tables[1].Rows[i]["DefectUserName"];
dr["DefectUserCode"] = dsProductionDataByID.Tables[1].Rows[i]["DefectUserCode"];
dr["Jobs"] = dsProductionDataByID.Tables[1].Rows[i]["Jobs"];
dr["JobsText"] = dsProductionDataByID.Tables[1].Rows[i]["JobsText"];
dr["DefectRemarks"] = dsProductionDataByID.Tables[1].Rows[i]["DefectRemarks"];
dr["TempCount"] = this._tempCount;
dr["ProductionDataID"] = dsProductionDataByID.Tables[1].Rows[i]["DefectProductionDataID"];// dsProductionDataByID.Tables[1].Rows[i]["ProductionDataID"];
dr["DefectFineID"] = dsProductionDataByID.Tables[1].Rows[i]["DefectFineID"];
dr["DefectFineValue"] = dsProductionDataByID.Tables[1].Rows[i]["DefectFineValue"];
dr["MissedUserID"] = dsProductionDataByID.Tables[1].Rows[i]["MissedUserID"];
dr["MissedUserCode"] = dsProductionDataByID.Tables[1].Rows[i]["MissedUserCode"];
dr["MissedUserName"] = dsProductionDataByID.Tables[1].Rows[i]["MissedUserName"];
dr["IsAllowEdit"] = this._AllowEdit;
//dr["DefectDeductionID"] = dsProductionDataByID.Tables[1].Rows[i]["DefectDeductionID"];
dr["DefectDeductionNum"] = dsProductionDataByID.Tables[1].Rows[i]["DefectDeductionNum"];
dr["IsOtherDefect"] = dsProductionDataByID.Tables[1].Rows[i]["SpecialDefect"];
DSTable.Tables[dsProductionDataByID.Tables[0].Rows[0]["BarCode"].ToString()].Rows.Add(dr);
// 防止工种不选择的话,直接New一个
if (!this.DSTableStaff.Tables.Contains(string.Format("TempTable{0}", this._tempCount)))
{
DataTable dtStaff = new DataTable(string.Format("TempTable{0}", this._tempCount));
dtStaff.Columns.Add("IsSelected");
dtStaff.Columns.Add("StaffID");
dtStaff.Columns.Add("StaffCode");
dtStaff.Columns.Add("StaffName");
dtStaff.Columns.Add("StaffTempCount");
dtStaff.Columns.Add("StaffStatus");
dtStaff.Columns.Add("UjobsID");
dtStaff.Columns.Add("SjobsID");
this.DSTableStaff.Tables.Add(dtStaff);
}
// 责任员工
DataRow[] drRow = dsProductionDataByID.Tables[2].Select("ProductionDefectID=" + dsProductionDataByID.Tables[1].Rows[i]["ProductionDefectID"]);
if (drRow.Length > Constant.INT_IS_ZERO)
{
foreach (DataRow r in drRow)
{
DataRow drStaff = this.DSTableStaff.Tables[string.Format("TempTable{0}", this._tempCount)].NewRow();
drStaff["IsSelected"] = 1;
drStaff["StaffID"] = r["StaffID"];
drStaff["StaffCode"] = r["StaffCode"];
drStaff["StaffName"] = r["StaffName"];
drStaff["StaffTempCount"] = this._tempCount;
drStaff["StaffStatus"] = r["StaffStatus"];
this.DSTableStaff.Tables[string.Format("TempTable{0}", this._tempCount)].Rows.Add(drStaff);
}
}
this._currentTempSign = i.ToString();
this._tempCount = this._tempCount + 1;
}
this.dgvDefect.DataSource = DSTable.Tables[dsProductionDataByID.Tables[0].Rows[0]["BarCode"].ToString()];//根据条码产生不同数据源
//控制产品等级,只有编辑权限的人才能随便改
if (this._AllowEdit == 0) //
{
for (int i = 0; i < this.dgvProductionData.Rows.Count; i++)
{
int goodsLevelTypeID = Convert.ToInt32(this.TableProductionData.Rows[i]["GoodsLevelTypeID"]);
if (this._dsGoodsLevel != null)
{
DataTable dt = this._dsGoodsLevel.Tables[0].Copy();
DataView dv = dt.DefaultView;
dv.RowFilter = "GoodsLevelTypeID>=" + goodsLevelTypeID;
DataGridViewComboBoxCell dgcbc = (DataGridViewComboBoxCell)dgvProductionData.Rows[i].Cells[3];
dgcbc.DisplayMember = "DefectFlagName";
dgcbc.ValueMember = "DefectFlagID";
dgcbc.DataSource = dv.ToTable();
}
}
}
}
}
catch (Exception ex)
{
throw ex;
}
}
///
/// 绑定到第一个DataGriwView数据源
///
private void BindProductionDataReFine(DataSet dsCheckBarcode)
{
try
{
DataRow[] dr = TableProductionData.Select("BarCode='" + this.txtBarCode.Text.Trim() + "'");
if (dr.Length > Constant.INT_IS_ZERO)
{
// 不允许重复添加
return;
}
int SpecialRepairflag = (int)DoAsync(new BaseAsyncMethod(() =>
{
return PMModuleProxy.Service.GetSpecialRepairflagByBarcode(this.txtBarCode.Text.Trim());
}));
string KilnCarCode = string.Empty;
string KilnCode = string.Empty;
string Dictionaryvalue = string.Empty;
DataSet dsKilnCar = (DataSet)DoAsync(new BaseAsyncMethod(() =>
{
return PMModuleProxy.Service.GetKilnCarByBarCode(txtBarCode.Text.Trim());
}));
if (dsKilnCar != null && dsKilnCar.Tables[0].Rows.Count > Constant.INT_IS_ZERO)
{
KilnCarCode = dsKilnCar.Tables[0].Rows[0]["KilnCarCode"].ToString();
KilnCode = dsKilnCar.Tables[0].Rows[0]["KilnCode"].ToString();
Dictionaryvalue = dsKilnCar.Tables[0].Rows[0]["Dictionaryvalue"].ToString();
}
DataRow drNew = TableProductionData.NewRow();
drNew["BarCode"] = this.txtBarCode.Text.Trim();
drNew["ProductionDataID"] = this._productiondataid;
drNew["GoodsID"] = dsCheckBarcode.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_goodsID.ToString()];
drNew["GoodsCode"] = dsCheckBarcode.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_goodsCode.ToString()];
drNew["GoodsName"] = dsCheckBarcode.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_goodsName.ToString()];
drNew["DefectFlagID"] = _dsGoodsLevel.Tables[0].Rows[0]["DefectFlagID"];
drNew["ReworkProcedureID"] = DBNull.Value;
drNew["Remarks"] = "";
drNew["UserID"] = UserID;
drNew["UserCode"] = UserCode;
drNew["UserName"] = UserName;
drNew["GoodsLevelTypeID"] = _dsGoodsLevel.Tables[0].Rows[0]["GoodsLevelTypeID"];
drNew["OrgGoodsLevelTypeID"] = -1;
drNew["SpecialRepairflag"] = SpecialRepairflag == 1 ? 1 : 0;
drNew["KilnCarCode"] = KilnCarCode;
drNew["KilnCode"] = KilnCode;
drNew["Dictionaryvalue"] = Dictionaryvalue;
// 校验条码是否重烧过
DataSet dsReFine = (DataSet)DoAsync(new BaseAsyncMethod(() =>
{
return PMModuleProxy.Service.GetReFine(this.txtBarCode.Text.Trim());
}));
if (dsReFine != null && dsReFine.Tables[0].Rows.Count > 0 && dsReFine.Tables[0].Rows[0]["IsReFire"].ToString() == "6")
{
drNew["ReFine"] = 1;
}
else
{
drNew["ReFine"] = 0;
}
drNew["UserCode"] = this.txtUserCode.Text.Trim();
// 由产品条码获取注浆信息
DataSet dsGroutingProduct = (DataSet)DoAsync(new BaseAsyncMethod(() =>
{
return PMModuleProxy.Service.GetGroutingProducttByBarCode(txtBarCode.Text.Trim());
}));
drNew["MouldCode"] = dsGroutingProduct.Tables[0].Rows[0]["MouldCode"];
drNew["GroutingUserCode"] = dsGroutingProduct.Tables[0].Rows[0]["GroutingUserCode"];
drNew["GroutingNum"] = dsGroutingProduct.Tables[0].Rows[0]["GroutingNum"];
drNew["IsPublicBody"] = dsGroutingProduct.Tables[0].Rows[0]["IsPublicBody"].ToString() != "1" ? 0 : 1;
drNew["GroutingDate"] = Convert.ToDateTime(dsGroutingProduct.Tables[0].Rows[0]["GroutingDate"]);
drNew["LogoCodeName"] = dsGroutingProduct.Tables[0].Rows[0]["LogoName"] + "[" + dsGroutingProduct.Tables[0].Rows[0]["LogoCode"] + "]";
drNew["LogoID"] = dsGroutingProduct.Tables[0].Rows[0]["LogoID"];
TableProductionData.Rows.Add(drNew);
if (DSTable.Tables.IndexOf(this.txtBarCode.Text.Trim()) == -Constant.INT_IS_ONE)
{
DataTable dtProductionDefectData = new DataTable(this.txtBarCode.Text.Trim());
dtProductionDefectData.Columns.Add("BarCode");
dtProductionDefectData.Columns.Add("DefectID", typeof(decimal));
dtProductionDefectData.Columns.Add("DefectName");
dtProductionDefectData.Columns.Add("DefectCode");
dtProductionDefectData.Columns.Add("DefectPositionID", typeof(decimal));
dtProductionDefectData.Columns.Add("DefectPositionName");
dtProductionDefectData.Columns.Add("DefectPositionCode");
dtProductionDefectData.Columns.Add("DefectProcedureID", typeof(decimal));
dtProductionDefectData.Columns.Add("DefectProcedureName");
dtProductionDefectData.Columns.Add("DefectProcedureCode");
dtProductionDefectData.Columns.Add("DefectUserID", typeof(decimal));//责任员工
dtProductionDefectData.Columns.Add("DefectUserName");//责任员工
dtProductionDefectData.Columns.Add("DefectUserCode");//
dtProductionDefectData.Columns.Add("Jobs", typeof(decimal));//工种
dtProductionDefectData.Columns.Add("JobsText");//工种
dtProductionDefectData.Columns.Add("DefectRemarks");
dtProductionDefectData.Columns.Add("TempCount");
dtProductionDefectData.Columns.Add("ProductionDataID"); //生产数据ID
dtProductionDefectData.Columns.Add("DefectFineID"); //缺席扣罚ID
dtProductionDefectData.Columns.Add("DefectFineValue"); //缺席扣罚
dtProductionDefectData.Columns.Add("MissedUserID"); //漏检工号ID
dtProductionDefectData.Columns.Add("MissedUserCode"); //漏检工号编码
dtProductionDefectData.Columns.Add("MissedUserName"); //漏检工号名称
dtProductionDefectData.Columns.Add("IsAllowEdit"); //漏检工号名称
//新添加的 wangx 2016/1/6
dtProductionDefectData.Columns.Add("DefectDeductionID"); //缺陷扣除数ID
dtProductionDefectData.Columns.Add("DefectDeductionNum"); //缺陷扣除数
dtProductionDefectData.Columns.Add("IsOtherDefect"); //特殊缺陷
DSTable.Tables.Add(dtProductionDefectData);
}
this.dgvDefect.DataSource = DSTable.Tables[this.txtBarCode.Text.Trim()];//根据条码产生不同数据源
this.dgvProductionData.Rows[TableProductionData.Rows.Count - 1].Selected = true;
this.dgvDefect.DataSource = null;
this.dgvDefectStaff.DataSource = null;
// 添加一个产品条码时除了第一个显示在数据表中,其它的全部清空
this.tsbtnAdd.Enabled = true;//添加完条码后,可以新建其它信息
// 添加一个产品条码时除了第一个显示在数据表中,其它的全部清空
this.tsbtnAdd.Enabled = true;//添加完条码后,可以新建其它信息
// 添加一个产品条码时除了第一个显示在数据表中,其它的全部清空
this.tsbtnAdd.Enabled = true;//添加完条码后,可以新建其它信息
this._selectedRowIndex = TableProductionData.Rows.Count - 1;
//DataSet ds = (DataSet)DoAsync(new BaseAsyncMethod(() =>
//{
// return PMModuleProxy.Service.GetReworkProcedureByProcedureID(this._procedureID);
//}));
//ds.Tables[0].TableName = this.txtBarCode.Text.Trim();
//if (this.DSREWORK == null)
//{
// this.DSREWORK = new DataSet();
//}
//this.DSREWORK.Tables.Add(ds.Tables[0].Copy());
//// 返工工序数据源
//C_DGV_Cell_ListBoxComboBox C_DGV_Cell_ListBoxComboBox = dgvProductionData.Rows[_selectedRowIndex].Cells[4] as C_DGV_Cell_ListBoxComboBox;
//C_DGV_Cell_ListBoxComboBox.DataSource = ds.Tables[0];
//C_DGV_Cell_ListBoxComboBox.DisplayMember = "ReworkProcedureName";
//C_DGV_Cell_ListBoxComboBox.ValueMember = "ReworkProcedureID";
}
catch (Exception ex)
{
throw ex;
}
}
///
/// 绑定到第一个DataGriwView数据源
///
private void BindProductionDataEdit(DataSet dsCheckBarcode)
{
try
{
DataRow[] dr = TableProductionData.Select("BarCode='" + this.txtBarCode.Text.Trim() + "'");
if (dr.Length > Constant.INT_IS_ZERO)
{
// 不允许重复添加
return;
}
int SpecialRepairflag = (int)DoAsync(new BaseAsyncMethod(() =>
{
return PMModuleProxy.Service.GetSpecialRepairflagByBarcode(this.txtBarCode.Text.Trim());
}));
string KilnCarCode = string.Empty;
string KilnCode = string.Empty;
string Dictionaryvalue = string.Empty;
DataSet dsKilnCar = (DataSet)DoAsync(new BaseAsyncMethod(() =>
{
return PMModuleProxy.Service.GetKilnCarByBarCode(txtBarCode.Text.Trim());
}));
if (dsKilnCar != null && dsKilnCar.Tables[0].Rows.Count > Constant.INT_IS_ZERO)
{
KilnCarCode = dsKilnCar.Tables[0].Rows[0]["KilnCarCode"].ToString();
KilnCode = dsKilnCar.Tables[0].Rows[0]["KilnCode"].ToString();
Dictionaryvalue = dsKilnCar.Tables[0].Rows[0]["Dictionaryvalue"].ToString();
}
DataRow drNew = TableProductionData.NewRow();
drNew["ProductionDataID"] = this._productiondataid;
drNew["BarCode"] = this.txtBarCode.Text.Trim();
DataSet ds = (DataSet)DoAsync(new BaseAsyncMethod(() =>
{
return PMModuleProxy.Service.GetGoodsInfoBybarcode(this.txtBarCode.Text.Trim());
}));
if (ds != null && ds.Tables[0].Rows.Count > 0)
{
drNew["GoodsID"] = ds.Tables[0].Rows[0]["GoodsID"];
drNew["GoodsCode"] = ds.Tables[0].Rows[0]["GoodsCode"];
drNew["GoodsName"] = ds.Tables[0].Rows[0]["GoodsName"];
}
drNew["DefectFlagID"] = _dsGoodsLevel.Tables[0].Rows[0]["DefectFlagID"];
drNew["ReworkProcedureID"] = DBNull.Value;
drNew["Remarks"] = "";
drNew["UserID"] = UserID;
drNew["UserCode"] = UserCode;
drNew["UserName"] = UserName;
drNew["GoodsLevelTypeID"] = _dsGoodsLevel.Tables[0].Rows[0]["GoodsLevelTypeID"];
drNew["OrgGoodsLevelTypeID"] = -1;
drNew["SpecialRepairflag"] = SpecialRepairflag == 1 ? 1 : 0;
drNew["KilnCarCode"] = KilnCarCode;
drNew["KilnCode"] = KilnCode;
drNew["Dictionaryvalue"] = Dictionaryvalue;
// 校验条码是否重烧过
DataSet dsReFine = (DataSet)DoAsync(new BaseAsyncMethod(() =>
{
return PMModuleProxy.Service.GetReFine(this.txtBarCode.Text.Trim());
}));
if (dsReFine != null && dsReFine.Tables[0].Rows.Count > 0 && dsReFine.Tables[0].Rows[0]["IsReFire"].ToString() == "6")
{
drNew["ReFine"] = 1;
}
else
{
drNew["ReFine"] = 0;
}
drNew["UserCode"] = this.txtUserCode.Text.Trim();
// 由产品条码获取注浆信息
DataSet dsGroutingProduct = (DataSet)DoAsync(new BaseAsyncMethod(() =>
{
return PMModuleProxy.Service.GetGroutingProducttByBarCode(txtBarCode.Text.Trim());
}));
drNew["MouldCode"] = dsGroutingProduct.Tables[0].Rows[0]["MouldCode"];
drNew["GroutingUserCode"] = dsGroutingProduct.Tables[0].Rows[0]["GroutingUserCode"];
drNew["GroutingNum"] = dsGroutingProduct.Tables[0].Rows[0]["GroutingNum"];
drNew["IsPublicBody"] = dsGroutingProduct.Tables[0].Rows[0]["IsPublicBody"].ToString() != "1" ? 0 : 1;
drNew["GroutingDate"] = Convert.ToDateTime(dsGroutingProduct.Tables[0].Rows[0]["GroutingDate"]);
drNew["LogoCodeName"] = dsGroutingProduct.Tables[0].Rows[0]["LogoName"] + "[" + dsGroutingProduct.Tables[0].Rows[0]["LogoCode"] + "]";
drNew["LogoId"] = dsGroutingProduct.Tables[0].Rows[0]["LogoId"];
TableProductionData.Rows.Add(drNew);
if (DSTable.Tables.IndexOf(this.txtBarCode.Text.Trim()) == -Constant.INT_IS_ONE)
{
DataTable dtProductionDefectData = new DataTable(this.txtBarCode.Text.Trim());
dtProductionDefectData.Columns.Add("BarCode");
dtProductionDefectData.Columns.Add("DefectID", typeof(decimal));
dtProductionDefectData.Columns.Add("DefectName");
dtProductionDefectData.Columns.Add("DefectCode");
dtProductionDefectData.Columns.Add("DefectPositionID", typeof(decimal));
dtProductionDefectData.Columns.Add("DefectPositionName");
dtProductionDefectData.Columns.Add("DefectPositionCode");
dtProductionDefectData.Columns.Add("DefectProcedureID", typeof(decimal));
dtProductionDefectData.Columns.Add("DefectProcedureName");
dtProductionDefectData.Columns.Add("DefectProcedureCode");
dtProductionDefectData.Columns.Add("DefectUserID", typeof(decimal));//责任员工
dtProductionDefectData.Columns.Add("DefectUserName");//责任员工
dtProductionDefectData.Columns.Add("DefectUserCode");//
dtProductionDefectData.Columns.Add("Jobs", typeof(decimal));//工种
dtProductionDefectData.Columns.Add("JobsText");//工种
dtProductionDefectData.Columns.Add("DefectRemarks");
dtProductionDefectData.Columns.Add("TempCount");
dtProductionDefectData.Columns.Add("ProductionDataID"); //生产数据ID
dtProductionDefectData.Columns.Add("DefectFineID"); //缺席扣罚ID
dtProductionDefectData.Columns.Add("DefectFineValue"); //缺席扣罚
dtProductionDefectData.Columns.Add("MissedUserID"); //漏检工号ID
dtProductionDefectData.Columns.Add("MissedUserCode"); //漏检工号编码
dtProductionDefectData.Columns.Add("MissedUserName"); //漏检工号名称
dtProductionDefectData.Columns.Add("IsAllowEdit"); //允许编辑
//新添加的 wangx 2016/1/6
dtProductionDefectData.Columns.Add("DefectDeductionID"); //缺陷扣除数ID
dtProductionDefectData.Columns.Add("DefectDeductionNum"); //缺陷扣除数
dtProductionDefectData.Columns.Add("IsOtherDefect"); //特殊缺陷
DSTable.Tables.Add(dtProductionDefectData);
}
this.dgvDefect.DataSource = DSTable.Tables[this.txtBarCode.Text.Trim()];//根据条码产生不同数据源
this.dgvProductionData.Rows[TableProductionData.Rows.Count - 1].Selected = true;
this.dgvDefect.DataSource = null;
this.dgvDefectStaff.DataSource = null;
// 添加一个产品条码时除了第一个显示在数据表中,其它的全部清空
this.tsbtnAdd.Enabled = true;//添加完条码后,可以新建其它信息
// 添加一个产品条码时除了第一个显示在数据表中,其它的全部清空
this.tsbtnAdd.Enabled = true;//添加完条码后,可以新建其它信息
// 添加一个产品条码时除了第一个显示在数据表中,其它的全部清空
this.tsbtnAdd.Enabled = true;//添加完条码后,可以新建其它信息
this._selectedRowIndex = TableProductionData.Rows.Count - 1;
}
catch (Exception ex)
{
throw ex;
}
}
///
/// 绑定到第一个DataGriwView数据源
///
private void BindProductionData(DataSet dsCheckBarcode)
{
try
{
DataRow[] dr = TableProductionData.Select("BarCode='" + this.txtBarCode.Text.Trim() + "'");
if (dr.Length > Constant.INT_IS_ZERO)
{
// 不允许重复添加
return;
}
int SpecialRepairflag = 0;
if (dsCheckBarcode == null || dsCheckBarcode.Tables[0].Rows.Count == 0)
{
SpecialRepairflag = (int)DoAsync(new BaseAsyncMethod(() =>
{
return PMModuleProxy.Service.GetSpecialRepairflagByBarcode(this.txtBarCode.Text.Trim());
}));
}
else
{
SpecialRepairflag = Convert.ToInt32(dsCheckBarcode.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_specialRepairFlag.ToString()]);
}
string KilnCarCode = string.Empty;
string KilnCode = string.Empty;
string Dictionaryvalue = string.Empty;
DataSet dsKilnCar = (DataSet)DoAsync(new BaseAsyncMethod(() =>
{
return PMModuleProxy.Service.GetKilnCarByBarCode(txtBarCode.Text.Trim());
}));
if (dsKilnCar != null && dsKilnCar.Tables[0].Rows.Count > Constant.INT_IS_ZERO)
{
KilnCarCode = dsKilnCar.Tables[0].Rows[0]["KilnCarCode"].ToString();
KilnCode = dsKilnCar.Tables[0].Rows[0]["KilnCode"].ToString();
Dictionaryvalue = dsKilnCar.Tables[0].Rows[0]["Dictionaryvalue"].ToString();
}
DataRow drNew = TableProductionData.NewRow();
drNew["BarCode"] = this.txtBarCode.Text.Trim();
if (dsCheckBarcode != null)
{
drNew["GoodsID"] = dsCheckBarcode.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_goodsID.ToString()];
drNew["GoodsCode"] = dsCheckBarcode.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_goodsCode.ToString()];
drNew["GoodsName"] = dsCheckBarcode.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_goodsName.ToString()];
}
else
{
DataSet ds = (DataSet)DoAsync(new BaseAsyncMethod(() =>
{
return PMModuleProxy.Service.GetGoodsInfoBybarcode(this.txtBarCode.Text.Trim());
}));
if (ds != null && ds.Tables[0].Rows.Count > 0)
{
drNew["GoodsID"] = ds.Tables[0].Rows[0]["GoodsID"];
drNew["GoodsCode"] = ds.Tables[0].Rows[0]["GoodsCode"];
drNew["GoodsName"] = ds.Tables[0].Rows[0]["GoodsName"];
}
}
drNew["UserID"] = UserID;
drNew["KilnCarCode"] = KilnCarCode;
drNew["KilnCode"] = KilnCode;
drNew["Dictionaryvalue"] = Dictionaryvalue;
drNew["DefectFlagID"] = _dsGoodsLevel.Tables[0].Rows[0]["DefectFlagID"];
drNew["ReworkProcedureID"] = DBNull.Value;
drNew["Remarks"] = "";
drNew["UserID"] = UserID;
drNew["UserCode"] = UserCode;
drNew["UserName"] = UserName;
drNew["GoodsLevelTypeID"] = _dsGoodsLevel.Tables[0].Rows[0]["GoodsLevelTypeID"];
drNew["OrgGoodsLevelTypeID"] = -1;
drNew["SpecialRepairflag"] = SpecialRepairflag == 1 ? 1 : 0;
drNew["LogoCodeName"] = dsCheckBarcode.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_logoName.ToString()]
+ "[" + dsCheckBarcode.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_logoCode.ToString()] + "]";
drNew["LogoID"] = dsCheckBarcode.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_logoID.ToString()];
// 校验条码是否重烧过
DataSet dsReFine = (DataSet)DoAsync(new BaseAsyncMethod(() =>
{
return PMModuleProxy.Service.GetReFine(this.txtBarCode.Text.Trim());
}));
if (dsReFine != null && dsReFine.Tables[0].Rows.Count > 0 && dsReFine.Tables[0].Rows[0]["IsReFire"].ToString() == "6")
{
drNew["ReFine"] = 1;
}
else
{
drNew["ReFine"] = 0;
}
if (dsCheckBarcode == null || dsCheckBarcode.Tables[0].Rows.Count == 0)
{
// 由产品条码获取注浆信息
DataSet dsGroutingProduct = (DataSet)DoAsync(new BaseAsyncMethod(() =>
{
return PMModuleProxy.Service.GetGroutingProducttByBarCode(txtBarCode.Text.Trim());
}));
drNew["UserCode"] = this.txtUserCode.Text.Trim();
drNew["MouldCode"] = dsGroutingProduct.Tables[0].Rows[0]["MouldCode"];
drNew["GroutingUserCode"] = dsGroutingProduct.Tables[0].Rows[0]["GroutingUserCode"];
drNew["GroutingNum"] = dsGroutingProduct.Tables[0].Rows[0]["GroutingNum"];
drNew["IsPublicBody"] = dsGroutingProduct.Tables[0].Rows[0]["IsPublicBody"].ToString() != "1" ? 0 : 1;
drNew["GroutingDate"] = Convert.ToDateTime(dsGroutingProduct.Tables[0].Rows[0]["GroutingDate"]);
}
else
{
drNew["UserCode"] = this.txtUserCode.Text.Trim();
drNew["MouldCode"] = dsCheckBarcode.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_mouldCode.ToString()];
drNew["GroutingUserCode"] = dsCheckBarcode.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_groutingUserCode.ToString()];
drNew["GroutingNum"] = dsCheckBarcode.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_groutingNum.ToString()];
drNew["IsPublicBody"] = dsCheckBarcode.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_ispublicbody.ToString()].ToString() != "1" ? 0 : 1;
drNew["GroutingDate"] = Convert.ToDateTime(dsCheckBarcode.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_groutingdate.ToString()]);
}
TableProductionData.Rows.Add(drNew);
if (DSTable.Tables.IndexOf(this.txtBarCode.Text.Trim()) == -Constant.INT_IS_ONE)
{
DataTable dtProductionDefectData = new DataTable(this.txtBarCode.Text.Trim());
dtProductionDefectData.Columns.Add("BarCode");
dtProductionDefectData.Columns.Add("DefectID", typeof(decimal));
dtProductionDefectData.Columns.Add("DefectName");
dtProductionDefectData.Columns.Add("DefectCode");
dtProductionDefectData.Columns.Add("DefectPositionID", typeof(decimal));
dtProductionDefectData.Columns.Add("DefectPositionName");
dtProductionDefectData.Columns.Add("DefectPositionCode");
dtProductionDefectData.Columns.Add("DefectProcedureID", typeof(decimal));
dtProductionDefectData.Columns.Add("DefectProcedureName");
dtProductionDefectData.Columns.Add("DefectProcedureCode");
dtProductionDefectData.Columns.Add("DefectUserID", typeof(decimal));//责任员工
dtProductionDefectData.Columns.Add("DefectUserName");//责任员工
dtProductionDefectData.Columns.Add("DefectUserCode");//
dtProductionDefectData.Columns.Add("Jobs", typeof(decimal));//工种
dtProductionDefectData.Columns.Add("JobsText");//工种
dtProductionDefectData.Columns.Add("DefectRemarks");
dtProductionDefectData.Columns.Add("TempCount");
dtProductionDefectData.Columns.Add("ProductionDataID"); //生产数据ID
dtProductionDefectData.Columns.Add("DefectFineID"); //缺席扣罚ID
dtProductionDefectData.Columns.Add("DefectFineValue"); //缺席扣罚
dtProductionDefectData.Columns.Add("MissedUserID"); //漏检工号ID
dtProductionDefectData.Columns.Add("MissedUserCode"); //漏检工号编码
dtProductionDefectData.Columns.Add("MissedUserName"); //漏检工号名称
dtProductionDefectData.Columns.Add("IsAllowEdit"); //允许编辑
//新添加的 wangx 2016/1/6
dtProductionDefectData.Columns.Add("DefectDeductionID"); //缺陷扣除数ID
dtProductionDefectData.Columns.Add("DefectDeductionNum"); //缺陷扣除数
dtProductionDefectData.Columns.Add("IsOtherDefect"); //特殊缺陷
DSTable.Tables.Add(dtProductionDefectData);
}
this.dgvDefect.DataSource = DSTable.Tables[this.txtBarCode.Text.Trim()];//根据条码产生不同数据源
this.dgvProductionData.Rows[TableProductionData.Rows.Count - 1].Selected = true;
this.dgvDefect.DataSource = null;
this.dgvDefectStaff.DataSource = null;
// 添加一个产品条码时除了第一个显示在数据表中,其它的全部清空
this.tsbtnAdd.Enabled = true;//添加完条码后,可以新建其它信息
// 添加一个产品条码时除了第一个显示在数据表中,其它的全部清空
this.tsbtnAdd.Enabled = true;//添加完条码后,可以新建其它信息
// 添加一个产品条码时除了第一个显示在数据表中,其它的全部清空
this.tsbtnAdd.Enabled = true;//添加完条码后,可以新建其它信息
this._selectedRowIndex = TableProductionData.Rows.Count - 1;
//DataTable dt = this._dsGoodsLevel.Tables[0];
//DataView dv = dt.DefaultView;
//dv.RowFilter = "GoodsLevelTypeID>=" + goodsLevelTypeID;
//DataSet ds = (DataSet)DoAsync(new BaseAsyncMethod(() =>
//{
// return PMModuleProxy.Service.GetReworkProcedureByProcedureID(this._procedureID);
//}));
//ds.Tables[0].TableName = this.txtBarCode.Text.Trim();
//if (this.DSREWORK == null)
//{
// this.DSREWORK = new DataSet();
//}
//this.DSREWORK.Tables.Add(ds.Tables[0].Copy());
//// 返工工序数据源
//C_DGV_Cell_ListBoxComboBox C_DGV_Cell_ListBoxComboBox = dgvProductionData.Rows[_selectedRowIndex].Cells[4] as C_DGV_Cell_ListBoxComboBox;
//C_DGV_Cell_ListBoxComboBox.DataSource = ds.Tables[0];
//C_DGV_Cell_ListBoxComboBox.DisplayMember = "ReworkProcedureName";
//C_DGV_Cell_ListBoxComboBox.ValueMember = "ReworkProcedureID";
}
catch (Exception ex)
{
throw ex;
}
}
///
/// 通过是否有缺陷来启用或禁用
///
///
private void SetGridView(int GoodsLevelID)
{
//DataTable dtDefectFlag = this.DefectFlag.DataSource as DataTable;//获取缺陷数据源
//int GoodsLevelTypeID = -1;
//DataRow[] dr = dtDefectFlag.Select("DefectFlagID=" + GoodsLevelID);
//if (dr.Length > Constant.INT_IS_ZERO)
//{
// GoodsLevelTypeID = Convert.ToInt32(dr[0]["GoodsLevelTypeID"]);
// this.dgvProductionData.Rows[this.dgvProductionData.CurrentCell.RowIndex].Cells["GoodsLevelTypeID"].Value = GoodsLevelTypeID;
//}
//if (GoodsLevelTypeID != -Constant.INT_IS_ONE)
//{
// this.dgvProductionData.Rows[this.dgvProductionData.CurrentCell.RowIndex].Cells["ReworkProcedureID"].Value = DBNull.Value;
// this.dgvProductionData.Rows[this.dgvProductionData.CurrentCell.RowIndex].Cells["ReworkProcedureCode"].Value = string.Empty;
// this.dgvProductionData.Rows[this.dgvProductionData.CurrentCell.RowIndex].Cells["ReworkProcedureName"].Value = string.Empty;
// if (GoodsLevelTypeID == (int)Constant.GoodsLevelType.Quality) //正品
// {
// this.dgvProductionData.Rows[this.dgvProductionData.CurrentCell.RowIndex].Cells["ReworkProcedureID"].ReadOnly = true;
// try
// {
// string BarCode = this.dgvProductionData.Rows[this.dgvProductionData.CurrentCell.RowIndex].Cells["BarCode"].Value.ToString();
// if (DSTable.Tables.Contains(BarCode))
// {
// DSTable.Tables[BarCode].Rows.Clear();//清空行
// }
// this.dgvDefectStaff.DataSource = null;
// }
// catch (Exception ex)
// {
// throw ex;
// }
// }
// else if (GoodsLevelTypeID == (int)Constant.GoodsLevelType.Quality) //次品 或者正品
// {
// this.dgvProductionData.Rows[this.dgvProductionData.CurrentCell.RowIndex].Cells["ReworkProcedureID"].ReadOnly = true;
// }
// else if (GoodsLevelTypeID == (int)Constant.GoodsLevelType.ReFire)//重烧
// {
// this.dgvProductionData.Rows[this.dgvProductionData.CurrentCell.RowIndex].Cells["ReworkProcedureID"].ReadOnly = false;
// }
// else if (GoodsLevelTypeID == (int)Constant.GoodsLevelType.Substandard)//重烧
// {
// // this.dgvProductionData.Rows[this.dgvProductionData.CurrentCell.RowIndex].Cells["GoodsLevelTypeID"].Value = GoodsLevelTypeID;
// this.dgvProductionData.Rows[this.dgvProductionData.CurrentCell.RowIndex].Cells["ReworkProcedureID"].ReadOnly = false;
// }
//}
}
///
/// 清空以前所选中的缺陷
///
///
private void SetCheckBoxSelected(int checkValue, int rowIndex)
{
DataTable dtOrgDataSource = this.dgvDefect.DataSource as DataTable;
for (int i = 0; i < DSTable.Tables[dtOrgDataSource.TableName].Rows.Count; i++)
{
if (i == rowIndex)
{
dtOrgDataSource.Rows[i]["discarde"] = 1;
}
else
{
dtOrgDataSource.Rows[i]["discarde"] = 0;
}
}
}
#endregion
}
}