/// <summary> /// 接班时更新状态并且插入一条接班记录期同时插入mat和wip的记录初数量为接班时数量的期末数量 /// </summary> public void UpdateAndInsertWipMatHandOverBySaveJieBan(HandOverTheWatchCtrl handOverTheWatchCtrl) { if (MessageBox.Show(StringParser.Parse("确定要接班吗?"), StringParser.Parse("${res:Global.SystemInfo}"), MessageBoxButtons.OKCancel) == DialogResult.OK) { DataSet dsGetShangYiBanHandOver = new DataSet(); OperationHandover _operationHandover = new OperationHandover(); //获取上一班的交接记录 dsGetShangYiBanHandOver = _operationHandover.GetShangYiBanHandOver(handOverTheWatchCtrl.Shift, handOverTheWatchCtrl.Operation, handOverTheWatchCtrl.FactRoom); string handOverKey = dsGetShangYiBanHandOver.Tables["ShiftHandover"].Rows[0][0].ToString(); Hashtable hashTable1 = new Hashtable(); hashTable1.Add("OPERATION_HANDOVER_KEY", handOverKey); hashTable1.Add("Receiveoperator", handOverTheWatchCtrl.Receiveoperator); hashTable1.Add("SHIFT", handOverTheWatchCtrl.Shift); hashTable1.Add("EDITOR", PropertyService.Get(PROPERTY_FIELDS.USER_NAME)); hashTable1.Add("EDIT_TIMEZONE", PropertyService.Get(PROPERTY_FIELDS.TIMEZONE)); DataTable tableParam1 = FanHai.Hemera.Share.Common.CommonUtils.ParseToDataTable(hashTable1); tableParam1.TableName = "HASH1"; DataSet dsSetIn1 = new DataSet(); dsSetIn1.Merge(tableParam1); _operationHandover.UpdateHandOver(dsSetIn1); //插入数据到工序交接班表 DataSet dsGetDangQianHandOver = _operationHandover.GetDangQianShiftHandover(handOverTheWatchCtrl.Shift, handOverTheWatchCtrl.Operation, handOverTheWatchCtrl.FactRoom); Hashtable hashTable = new Hashtable(); hashTable.Add("LOCATIOMKEY", handOverTheWatchCtrl.FactRoom); hashTable.Add("OPERATIONNAME", handOverTheWatchCtrl.Operation); hashTable.Add("SENDSHIFTVALUE", handOverTheWatchCtrl.Shift); hashTable.Add("DAY", dsGetDangQianHandOver.Tables["DAY"].Rows[0][0].ToString().Trim()); hashTable.Add("STATUS", "0"); hashTable.Add("SENDOPERATOR", handOverTheWatchCtrl.Sendoperator); hashTable.Add("CREATE_TIMEZONE", PropertyService.Get(PROPERTY_FIELDS.TIMEZONE)); hashTable.Add("CREATOR", PropertyService.Get(PROPERTY_FIELDS.USER_NAME)); DataTable tableParam = FanHai.Hemera.Share.Common.CommonUtils.ParseToDataTable(hashTable); tableParam.TableName = "HASH"; DataSet dsSetIn = new DataSet(); dsSetIn.Merge(tableParam); try { _operationHandover.InsertHandOver(dsSetIn); //插入数据到工序交接班表 DataSet dsGetDangQianHandOver1 = _operationHandover.GetDangQianShiftHandover(handOverTheWatchCtrl.Shift, handOverTheWatchCtrl.Operation, handOverTheWatchCtrl.FactRoom); string handDangqianOverKey = dsGetDangQianHandOver1.Tables["ShiftHandover"].Rows[0][0].ToString(); _operationHandover.InsertMatWipQiChu(handDangqianOverKey, handOverKey);//根据上一工序交接班主键获取上一工序交接班的期末数量插入到新生成的数据中的期初数量 MessageService.ShowMessage("保存成功", "系统提示"); } catch (Exception ex) { MessageService.ShowMessage(ex.Message, "系统提示"); } } }
/// <summary> /// 交班时更新wip和mat数据和交接班记录表的数据 /// </summary> public void UpdateWipMatHandOverBySaveJiaoban(HandOverTheWatchCtrl handOverTheWatchCtrl) { DataSet dsGetDangQianShiftHandover = new DataSet(); OperationHandover _operationHandover = new OperationHandover(); dsGetDangQianShiftHandover = _operationHandover.GetDangQianShiftHandover(handOverTheWatchCtrl.Shift, handOverTheWatchCtrl.Operation, handOverTheWatchCtrl.FactRoom); //获取当前班次的交班日期 DataTable dtHandOverTable = new DataTable(); DataView dv = gridView1.DataSource as DataView; if (dv != null) { dtHandOverTable = dv.Table; } string handOverKey = dsGetDangQianShiftHandover.Tables["ShiftHandover"].Rows[0][0].ToString(); Hashtable hashTable = new Hashtable(); hashTable.Add("OPERATION_HANDOVER_KEY", handOverKey); hashTable.Add("EDITOR", PropertyService.Get(PROPERTY_FIELDS.USER_NAME)); hashTable.Add("EDIT_TIMEZONE", PropertyService.Get(PROPERTY_FIELDS.TIMEZONE)); DataTable tableParam = FanHai.Hemera.Share.Common.CommonUtils.ParseToDataTable(hashTable);//02322 136669 tableParam.TableName = "HASH"; DataSet dsSetIn = new DataSet(); dtHandOverTable.TableName = "WST_OPERATION_HANDOVER_MAT"; dsSetIn.Merge(dtHandOverTable); dsSetIn.Merge(tableParam); if (dtHandOverTable == null) { MessageService.ShowMessage("没有可保存的物料信息!", "${res:Global.SystemInfo}"); } if (MessageBox.Show(StringParser.Parse("确定要交班吗?"), StringParser.Parse("${res:Global.SystemInfo}"), MessageBoxButtons.OKCancel) == DialogResult.OK) { if (_operationHandover.UpdateWipMatHandOverBySaveJiaoban(dsSetIn) != true)//保存数据到MAT和工序交接班表中 { MessageService.ShowMessage("交接信息保存失败!", "${res:Global.SystemInfo}"); } else { MessageService.ShowMessage("交接信息保存成功!", "${res:Global.SystemInfo}"); } } }
/// <summary> /// HandOverTheWatchCtrl上交接按钮Click事件绑定窗体控件值 /// </summary> /// <param name="handOverTheWatchCtrl"></param> public void BindContralByJiaoJieClick(HandOverTheWatchCtrl handOverTheWatchCtrl) { DataSet dsGetDangQianShiftHandover = new DataSet(); OperationHandover _operationHandover = new OperationHandover(); dsGetDangQianShiftHandover = _operationHandover.GetDangQianShiftHandover(handOverTheWatchCtrl.Shift, handOverTheWatchCtrl.Operation, handOverTheWatchCtrl.FactRoom); //获取当前班次的交班日期 if (dsGetDangQianShiftHandover.Tables["ShiftHandover"].Rows.Count > 0) { string handOverKey = dsGetDangQianShiftHandover.Tables["ShiftHandover"].Rows[0][0].ToString(); _operationHandover.UpdateHandOverMatAndWip(handOverKey); //通过工序交接班的主键然后获取WIP和物料的数量更新到表中 _operationHandover.UpdateHandOverMatAndWipQiMoShuLiang(handOverKey); //通过工序交接班的主键更新期末数据 this.txtFacRoom.Text = dsGetDangQianShiftHandover.Tables["ShiftHandover"].Rows[0][1].ToString(); this.txtGongXu.Text = dsGetDangQianShiftHandover.Tables["ShiftHandover"].Rows[0][2].ToString(); this.txtJiaoBanShift.Text = dsGetDangQianShiftHandover.Tables["ShiftHandover"].Rows[0][3].ToString(); this.txtJieBanShift.Text = dsGetDangQianShiftHandover.Tables["ShiftHandover"].Rows[0][4].ToString(); this.txtJiaoBaoTime.Text = Convert.ToDateTime(dsGetDangQianShiftHandover.Tables["ShiftHandover"].Rows[0][5].ToString()).ToString("yyyy-MM-dd"); this.txtZhuangTai.Text = dsGetDangQianShiftHandover.Tables["ShiftHandover"].Rows[0][6].ToString(); this.txtJiaoBanJobNumber.Text = dsGetDangQianShiftHandover.Tables["ShiftHandover"].Rows[0][7].ToString(); this.txtJieBanJobNumber.Text = dsGetDangQianShiftHandover.Tables["ShiftHandover"].Rows[0][8].ToString(); BindShuJuBiao(handOverKey); //绑定数据表通过工序交接班主键获取物料信息和WIP信息 } else { //没有查询出来的交接班记录 为交接班表插入一条记录 定义hash准备插入操作 Hashtable hashTable = new Hashtable(); hashTable.Add("LOCATIOMKEY", handOverTheWatchCtrl.FactRoom); hashTable.Add("OPERATIONNAME", handOverTheWatchCtrl.Operation); hashTable.Add("SENDSHIFTVALUE", handOverTheWatchCtrl.Shift); hashTable.Add("DAY", dsGetDangQianShiftHandover.Tables["DAY"].Rows[0][0].ToString()); hashTable.Add("STATUS", "0"); hashTable.Add("SENDOPERATOR", handOverTheWatchCtrl.Sendoperator); hashTable.Add("CREATE_TIMEZONE", PropertyService.Get(PROPERTY_FIELDS.TIMEZONE)); hashTable.Add("CREATOR", PropertyService.Get(PROPERTY_FIELDS.USER_NAME)); DataTable tableParam = FanHai.Hemera.Share.Common.CommonUtils.ParseToDataTable(hashTable); tableParam.TableName = "HASH"; DataSet dsSetIn = new DataSet(); dsSetIn.Merge(tableParam); _operationHandover.InsertHandOver(dsSetIn); //插入数据到工序交接班表 //获取插入后的工序交接班的详细信息 dsGetDangQianShiftHandover = _operationHandover.GetDangQianShiftHandover(handOverTheWatchCtrl.Shift, handOverTheWatchCtrl.Operation, handOverTheWatchCtrl.FactRoom); //先获取当前班次的交班日期然后获取工序交接班的信息记录 //获取插入记录的主键 string handOverKey = dsGetDangQianShiftHandover.Tables["ShiftHandover"].Rows[0][0].ToString(); //通过根据工序和工厂车间获取所有线上仓中的物料信息(WST_STORE,WST_STORE_MATERIAL)插入到WST_OPERATION_HANDOVER_MAT中 //(数量全部设置为0)。根据工序和工厂车间获取所有工单的在制品信息(POR_LOT,POR_WORK_ORDER,WIP_TRANSACTION)插入到 //WST_OPERATION_HANDOVER_WIP中(数量全部设置为0) _operationHandover.InsertHandOverMatAndWip(handOverKey, handOverTheWatchCtrl.FactRoom, handOverTheWatchCtrl.Operation); _operationHandover.UpdateHandOverMatAndWip(handOverKey); //通过工序交接班的主键然后获取WIP和物料的数量更新到表中 _operationHandover.UpdateHandOverMatAndWipQiMoShuLiang(handOverKey); //通过工序交接班的主键更新期末数据 this.txtFacRoom.Text = dsGetDangQianShiftHandover.Tables["ShiftHandover"].Rows[0][1].ToString(); this.txtGongXu.Text = dsGetDangQianShiftHandover.Tables["ShiftHandover"].Rows[0][2].ToString(); this.txtJiaoBanShift.Text = dsGetDangQianShiftHandover.Tables["ShiftHandover"].Rows[0][3].ToString(); this.txtJieBanShift.Text = dsGetDangQianShiftHandover.Tables["ShiftHandover"].Rows[0][4].ToString(); this.txtJiaoBaoTime.Text = Convert.ToDateTime(dsGetDangQianShiftHandover.Tables["ShiftHandover"].Rows[0][5].ToString()).ToString("yyyy-MM-dd"); this.txtZhuangTai.Text = dsGetDangQianShiftHandover.Tables["ShiftHandover"].Rows[0][6].ToString(); this.txtJiaoBanJobNumber.Text = dsGetDangQianShiftHandover.Tables["ShiftHandover"].Rows[0][7].ToString(); this.txtJieBanJobNumber.Text = dsGetDangQianShiftHandover.Tables["ShiftHandover"].Rows[0][8].ToString(); BindShuJuBiao(handOverKey); } }