/// <summary> /// 绑定批次信息。 /// </summary> private void BindLotInfo() { LotQueryEntity queryEntity = new LotQueryEntity(); this._dsLotInfo = queryEntity.GetLotInfo(this._model.LotNumber); if (!string.IsNullOrEmpty(queryEntity.ErrorMsg)) { MessageService.ShowError(queryEntity.ErrorMsg); this._dsLotInfo = null; return; } if (_dsLotInfo.Tables[0].Rows.Count < 1) { MessageService.ShowMessage(string.Format("获取【{0}】信息失败,请重试。", this._model.LotNumber)); this._dsLotInfo = null; return; } this.teLotNumber.Text = this._model.LotNumber; this.teLotNumber.Tag = Convert.ToString(_dsLotInfo.Tables[0].Rows[0][POR_LOT_FIELDS.FIELD_LOT_KEY]); this.teWorkorderNo.Text = Convert.ToString(_dsLotInfo.Tables[0].Rows[0][POR_LOT_FIELDS.FIELD_WORK_ORDER_NO]); this.teProId.Text = Convert.ToString(_dsLotInfo.Tables[0].Rows[0][POR_LOT_FIELDS.FIELD_PRO_ID]); this.teEnterpriseName.Text = Convert.ToString(_dsLotInfo.Tables[0].Rows[0][POR_ROUTE_ENTERPRISE_VER_FIELDS.FIELD_ENTERPRISE_NAME]); this.teRouteName.Text = Convert.ToString(_dsLotInfo.Tables[0].Rows[0][POR_ROUTE_ROUTE_VER_FIELDS.FIELD_ROUTE_NAME]); this.teStepName.Text = Convert.ToString(_dsLotInfo.Tables[0].Rows[0][POR_ROUTE_STEP_FIELDS.FIELD_ROUTE_STEP_NAME]); this.teEnterpriseName.Tag = Convert.ToString(_dsLotInfo.Tables[0].Rows[0][POR_LOT_FIELDS.FIELD_ROUTE_ENTERPRISE_VER_KEY]); string routeKey = Convert.ToString(_dsLotInfo.Tables[0].Rows[0][POR_LOT_FIELDS.FIELD_CUR_ROUTE_VER_KEY]); this.teRouteName.Tag = routeKey; this.teStepName.Tag = Convert.ToString(_dsLotInfo.Tables[0].Rows[0][POR_LOT_FIELDS.FIELD_CUR_STEP_VER_KEY]); this.teQty.Text = Convert.ToString(_dsLotInfo.Tables[0].Rows[0][POR_LOT_FIELDS.FIELD_QUANTITY]); this.teEfficiency.Text = Convert.ToString(_dsLotInfo.Tables[0].Rows[0][POR_LOT_FIELDS.FIELD_EFFICIENCY]); this._lotType = Convert.ToString(_dsLotInfo.Tables[0].Rows[0][POR_LOT_FIELDS.FIELD_LOT_TYPE]); BindTroubleStep(); }
/// <summary> /// 窗体载入事件。 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void TerminalLotDialog_Load(object sender, EventArgs e) { this.LotGroup.Text = StringParser.Parse("${res:FanHai.Hemera.Addins.WIP.LotGroup}"); this.lblRemark.Text = StringParser.Parse("${res:Global.Remark}"); this.btnCancel.Text = StringParser.Parse("${res:Global.Cancel}"); this.btnOK.Text = StringParser.Parse("${res:Global.OKButtonText}"); LotQueryEntity queryEntity = new LotQueryEntity(); dsLotInfo = queryEntity.GetLotInfo(this._model.LotNumber); if (!string.IsNullOrEmpty(queryEntity.ErrorMsg)) { MessageService.ShowError(queryEntity.ErrorMsg); dsLotInfo = null; return; } if (dsLotInfo.Tables[0].Rows.Count < 1) { MessageService.ShowMessage(string.Format("获取【{0}】信息失败,请重试。", this._model.LotNumber)); dsLotInfo = null; return; } this.lotInfoLayout.Controls.Add(lotBaseInfo); lotBaseInfo.SetValueToControl(dsLotInfo); }
/// <summary> /// 绑定批次信息。 /// </summary> private void BindLotInfo() { LotQueryEntity queryEntity = new LotQueryEntity(); DataSet dsReturn = queryEntity.GetLotInfo(this._model.LotNumber); if (!string.IsNullOrEmpty(queryEntity.ErrorMsg)) { MessageService.ShowError(queryEntity.ErrorMsg); dsReturn = null; return; } if (dsReturn.Tables[0].Rows.Count < 1) { MessageService.ShowMessage(string.Format("获取【{0}】信息失败,请重试。", this._model.LotNumber)); dsReturn = null; return; } dsReturn.Tables[0].TableName = POR_LOT_FIELDS.DATABASE_TABLE_NAME; this.gcList.MainView = this.gvList; this.gcList.DataSource = dsReturn.Tables[0]; this.txtLotNumber.Text = dsReturn.Tables[0].Rows[0]["LOT_NUMBER"].ToString(); this.txtWorkorderNo.Text = dsReturn.Tables[0].Rows[0]["WORK_ORDER_NO"].ToString(); this.txtProID.Text = dsReturn.Tables[0].Rows[0]["PRO_ID"].ToString(); this.txtEnterpriseName.Text = dsReturn.Tables[0].Rows[0]["ENTERPRISE_NAME"].ToString(); this.txtRouteName.Text = dsReturn.Tables[0].Rows[0]["ROUTE_NAME"].ToString(); this.txtStepName.Text = dsReturn.Tables[0].Rows[0]["ROUTE_STEP_NAME"].ToString(); this.txtQuantity.Text = dsReturn.Tables[0].Rows[0]["QUANTITY"].ToString(); this.txtEfficiency.Text = dsReturn.Tables[0].Rows[0]["EFFICIENCY"].ToString(); this.txtSILot.Text = dsReturn.Tables[0].Rows[0]["SI_LOT"].ToString(); }
/// <summary> /// 绑定批次的基础数据。 /// </summary> private void BindLotBaseInfoToControl() { string lotKey = Convert.ToString(_dsParams.Tables[0].Rows[0][WIP_FUTUREHOLD_FIELDS.FIELDS_LOT_KEY]); LotQueryEntity entity = new LotQueryEntity(); _dsLot = entity.GetLotInfo(lotKey); if (string.IsNullOrEmpty(entity.ErrorMsg)) { _lotInfoCtrl.SetValueToControl(_dsLot); } else { MessageService.ShowMessage(entity.ErrorMsg, "错误"); } }
/// <summary> /// 获取批次信息。 /// </summary> /// <returns>true:成功获取批次信息。false:获取批次信息失败。</returns> private bool GetLotInfomation() { string lotNo = this.txtLotNo.Text; this.txtMaterialLot.Text = string.Empty; this.txtWorkOrder.Text = string.Empty; this.txtPartNumber.Text = string.Empty; this.txtSupplier.Text = string.Empty; if (string.IsNullOrEmpty(lotNo)) { return(true); } LotQueryEntity entity = new LotQueryEntity(); DataSet ds = entity.GetLotInfo(lotNo); if (string.IsNullOrEmpty(entity.ErrorMsg)) { if (ds.Tables[0].Rows.Count == 0) { MessageService.ShowMessage("指定的批号不存在。"); return(false);//如果获取0行记录。 } string factoryRoomKey = ds.Tables[0].Rows[0]["FACTORYROOM_KEY"].ToString(); string equipmentKey = ds.Tables[0].Rows[0]["EQUIPMENT_KEY"].ToString(); string curRoomKey = this.lueFactoryRoom.EditValue.ToString(); string curEquipmentKey = this.lueEquipment.EditValue.ToString(); if (string.IsNullOrEmpty(factoryRoomKey) || factoryRoomKey != curRoomKey) { MessageService.ShowMessage("指定的批号在当前选中车间不存在。"); return(false); } this.txtMaterialLot.Text = ds.Tables[0].Rows[0]["MATERIAL_LOT"].ToString(); this.txtWorkOrder.Text = ds.Tables[0].Rows[0]["WORK_ORDER_NO"].ToString(); this.txtPartNumber.Text = ds.Tables[0].Rows[0]["PART_NUMBER"].ToString(); this.txtSupplier.Text = ds.Tables[0].Rows[0]["SUPPLIER_NAME"].ToString(); } else { MessageService.ShowMessage(entity.ErrorMsg); return(false); } return(true); }
/// <summary> /// 绑定批次信息。 /// </summary> private void BindLotInfo() { LotQueryEntity queryEntity = new LotQueryEntity(); DataSet dsReturn = queryEntity.GetLotInfo(this._model.LotNumber); if (!string.IsNullOrEmpty(queryEntity.ErrorMsg)) { MessageService.ShowError(queryEntity.ErrorMsg); dsReturn = null; return; } if (dsReturn.Tables[0].Rows.Count < 1) { MessageService.ShowMessage(string.Format("获取【{0}】信息失败,请重试。", this._model.LotNumber)); dsReturn = null; return; } dsReturn.Tables[0].TableName = POR_LOT_FIELDS.DATABASE_TABLE_NAME; this.gcLotList.MainView = this.gvList; this.gcLotList.DataSource = dsReturn.Tables[0]; }
/// <summary> /// 绑定批次基本信息。 /// </summary> private void BindLotBaseInfo() { DataSet dsLotInfo = _queryEntity.GetLotInfo(this._lotNumber); if (!string.IsNullOrEmpty(_queryEntity.ErrorMsg)) { MessageService.ShowError(_queryEntity.ErrorMsg); return; } if (null == dsLotInfo || dsLotInfo.Tables.Count < 1 || dsLotInfo.Tables[0].Rows.Count == 0) { MessageService.ShowMessage("没有获取到相应信息。", "提示"); return; } DataRow drLotInfo = dsLotInfo.Tables[0].Rows[0]; this.teLotNumber.Text = Convert.ToString(drLotInfo[POR_LOT_FIELDS.FIELD_LOT_NUMBER]); this.teLotNumber.Tag = Convert.ToString(drLotInfo[POR_LOT_FIELDS.FIELD_LOT_KEY]); this.teQuantityInit.Text = Convert.ToString(drLotInfo[POR_LOT_FIELDS.FIELD_QUANTITY_INITIAL]); this.teQuantity.Text = Convert.ToString(drLotInfo[POR_LOT_FIELDS.FIELD_QUANTITY]); string lotType = Convert.ToString(drLotInfo[POR_LOT_FIELDS.FIELD_LOT_TYPE]); this.teLotType.Text = this.GetBaseDataDisplayText(BASEDATA_CATEGORY_NAME.Lot_Type, "NAME", "CODE", lotType); string createType = Convert.ToString(drLotInfo[POR_LOT_FIELDS.FIELD_CREATE_TYPE]); this.teCreateType.Text = this.GetBaseDataDisplayText(BASEDATA_CATEGORY_NAME.Lot_CreateType, "NAME", "CODE", createType); this.teEfficiency.Text = Convert.ToString(drLotInfo[POR_LOT_FIELDS.FIELD_EFFICIENCY]); string priority = Convert.ToString(drLotInfo[POR_LOT_FIELDS.FIELD_PRIORITY]); this.tePriority.Text = this.GetBaseDataDisplayText(BASEDATA_CATEGORY_NAME.Lot_Priority, "NAME", "CODE", priority); int reworkFlag = Convert.ToInt32(drLotInfo[POR_LOT_FIELDS.FIELD_IS_REWORKED]); this.teReworkFlag.Text = reworkFlag == 0 ? "否" : Convert.ToString(reworkFlag); this.tePalletNo.Text = Convert.ToString(drLotInfo[POR_LOT_FIELDS.FIELD_PALLET_NO]); if (drLotInfo[POR_LOT_FIELDS.FIELD_PALLET_TIME] != null && drLotInfo[POR_LOT_FIELDS.FIELD_PALLET_TIME] != DBNull.Value) { DateTime dtPalletTime = Convert.ToDateTime(drLotInfo[POR_LOT_FIELDS.FIELD_PALLET_TIME]); this.tePalletTime.Text = dtPalletTime.ToString("yyyy-MM-dd HH:mm:ss"); } string proLevel = Convert.ToString(drLotInfo[POR_LOT_FIELDS.FIELD_PRO_LEVEL]); if (!string.IsNullOrEmpty(proLevel)) { this.teProductGrade.Text = GetProductGradeDisplayText(proLevel); } int holdFlag = Convert.ToInt32(drLotInfo[POR_LOT_FIELDS.FIELD_HOLD_FLAG]); this.teHoldFlag.Text = holdFlag == 0 ? "正常" : "暂停"; if (holdFlag == 1) { this.teHoldFlag.BackColor = System.Drawing.Color.Red; } LotStateFlag stateFlag = (LotStateFlag)Convert.ToInt32(drLotInfo[POR_LOT_FIELDS.FIELD_STATE_FLAG]); this.teStateFlag.Text = CommonUtils.GetEnumValueDescription(stateFlag); int deletedTermFlag = Convert.ToInt32(drLotInfo[POR_LOT_FIELDS.FIELD_DELETED_TERM_FLAG]); this.teDeletedTermFlag.Text = deletedTermFlag == 0 ? "正常" : (deletedTermFlag == 1 ? "已结束" : "已删除"); int shippedFlag = Convert.ToInt32(drLotInfo[POR_LOT_FIELDS.FIELD_SHIPPED_FLAG]); this.teShippedFlag.Text = shippedFlag == 0 ? "未出货" : "已出货"; this.teWorkOrderNumber.Text = Convert.ToString(drLotInfo[POR_LOT_FIELDS.FIELD_WORK_ORDER_NO]); this.teProId.Text = Convert.ToString(drLotInfo[POR_LOT_FIELDS.FIELD_PRO_ID]); this.tePartNumber.Text = Convert.ToString(drLotInfo[POR_LOT_FIELDS.FIELD_PART_NUMBER]); this.teSILot.Text = Convert.ToString(drLotInfo[POR_LOT_FIELDS.FIELD_SI_LOT]); this.teMaterialLot.Text = Convert.ToString(drLotInfo[POR_LOT_FIELDS.FIELD_MATERIAL_LOT]); this.teMaterialCode.Text = Convert.ToString(drLotInfo[POR_LOT_FIELDS.FIELD_MATERIAL_CODE]); this.teSupplier.Text = Convert.ToString(drLotInfo[POR_LOT_FIELDS.FIELD_SUPPLIER_NAME]); this.teEnterpriseName.Text = Convert.ToString(drLotInfo[POR_ROUTE_ENTERPRISE_VER_FIELDS.FIELD_ENTERPRISE_NAME]); this.teRouteName.Text = Convert.ToString(drLotInfo[POR_ROUTE_ROUTE_VER_FIELDS.FIELD_ROUTE_NAME]); this.teStepName.Text = Convert.ToString(drLotInfo[POR_ROUTE_STEP_FIELDS.FIELD_ROUTE_STEP_NAME]); this.teCreator.Text = Convert.ToString(drLotInfo[POR_LOT_FIELDS.FIELD_CREATOR]); DateTime dtCreateTime = Convert.ToDateTime(drLotInfo[POR_LOT_FIELDS.FIELD_CREATE_TIME]); this.teCreateTime.Text = dtCreateTime.ToString("yyyy-MM-dd HH:mm:ss"); this.teCreateOperation.Text = Convert.ToString(drLotInfo[POR_LOT_FIELDS.FIELD_CREATE_OPERTION_NAME]); this.teRoomName.Text = Convert.ToString(drLotInfo[POR_LOT_FIELDS.FIELD_FACTORYROOM_NAME]); this.teLineName.Text = Convert.ToString(drLotInfo[POR_LOT_FIELDS.FIELD_LINE_NAME]); this.teOperateLinePre.Text = Convert.ToString(drLotInfo[POR_LOT_FIELDS.FIELD_OPR_LINE_PRE]); this.teOperateComputer.Text = Convert.ToString(drLotInfo[POR_LOT_FIELDS.FIELD_OPR_COMPUTER]); this.teEditor.Text = Convert.ToString(drLotInfo[POR_LOT_FIELDS.FIELD_EDITOR]); DateTime dtEditTime = Convert.ToDateTime(drLotInfo[POR_LOT_FIELDS.FIELD_CREATE_TIME]); this.teEditTime.Text = dtEditTime.ToString("yyyy-MM-dd HH:mm:ss"); this.teDescription.Text = Convert.ToString(drLotInfo[POR_LOT_FIELDS.FIELD_DESCRIPTIONS]); }
/// <summary> /// 检查进行数据采集时是否对该批次号有权限。 /// </summary> /// <param name="lotNumber">批次号码。</param> /// <param name="actionName">NONE:离线数据采集。TRACKOUT:在线数据采集。</param> /// <returns>true或者false,true表示有权限,false表示没有权限。</returns> /// comment by peter 2012-2-23 private bool CheckLotNo(string lotNumber, string actionName) { LotQueryEntity entity = new LotQueryEntity(); DataSet ds = entity.GetLotInfo(lotNumber); if (string.IsNullOrEmpty(entity.ErrorMsg)) { if (ds.Tables[0].Rows.Count == 0) { MessageService.ShowMessage("指定的批号不存在。", "提示"); return(false);//如果获取0行记录。 } string factoryRoomKey = ds.Tables[0].Rows[0]["FACTORYROOM_KEY"].ToString(); string equipmentKey = ds.Tables[0].Rows[0]["EQUIPMENT_KEY"].ToString(); string stepName = ds.Tables[0].Rows[0]["ROUTE_STEP_NAME"].ToString(); int state = Convert.ToInt32(ds.Tables[0].Rows[0]["STATE_FLAG"]); string orderNumber = Convert.ToString(ds.Tables[0].Rows[0]["WORK_ORDER_NO"]); string materialLot = Convert.ToString(ds.Tables[0].Rows[0]["MATERIAL_LOT"]); string partNumber = Convert.ToString(ds.Tables[0].Rows[0]["PART_NUMBER"]); string partType = Convert.ToString(ds.Tables[0].Rows[0]["LOT_TYPE"]); string edcInsKey = Convert.ToString(ds.Tables[0].Rows[0]["EDC_INS_KEY"]); string routeKey = Convert.ToString(ds.Tables[0].Rows[0][POR_LOT_FIELDS.FIELD_CUR_ROUTE_VER_KEY]); string curRoomKey = this.lueFactoryRoom.EditValue.ToString(); string curEquipmentKey = this.lueEquipment.EditValue.ToString(); string operationName = this.cbOperation.Text; string curPartNumber = Convert.ToString(this.lueEDCItem.GetColumnValue(EDC_POINT_FIELDS.FIELD_TOPRODUCT)); string curPartType = Convert.ToString(this.lueEDCItem.GetColumnValue(EDC_POINT_FIELDS.FIELD_PART_TYPE)); string curRouteKey = Convert.ToString(this.lueEDCItem.GetColumnValue(EDC_POINT_FIELDS.FIELD_ROUTE_VER_KEY)); if (string.IsNullOrEmpty(factoryRoomKey) || factoryRoomKey != curRoomKey) { MessageService.ShowMessage("指定的批号在当前选中车间不存在。", "提示"); return(false); } //if (!string.IsNullOrEmpty(curRouteKey) && curRouteKey != routeKey) //{ // MessageService.ShowMessage("指定批号和指定数据采集项的工艺流程不一致。", "提示"); // return false; //} if (!string.IsNullOrEmpty(curPartNumber) && curPartNumber != partNumber) { MessageService.ShowMessage("指定批号的成品料号不能使用当前采集项目。", "提示"); return(false); } //else if (string.IsNullOrEmpty(curPartNumber) && !string.IsNullOrEmpty(curPartType) && curPartType != partType) //{ // MessageService.ShowMessage("指定批号的成品类型不能使用当前采集项目。", "提示"); // return false; //} //在线采集还需要继续判断。 //if (actionName != ACTIVITY_FIELD_VALUES.FIELD_ACTIVITY_NONE) //{ // if (stepName != operationName) // { // MessageService.ShowMessage("指定批号未在当前选中工序上进行加工。", "提示"); // return false; // } // if (curEquipmentKey != equipmentKey) // { // MessageService.ShowMessage("指定批号未在当前选中设备上进行加工。", "提示"); // return false; // } // if (string.IsNullOrEmpty(edcInsKey)) // { // MessageService.ShowMessage("指定批号不能进行数据采集。", "提示"); // return false; // } //} this.txtWorkOrder.Text = orderNumber; this.txtMaterialLot.Text = materialLot; } else { MessageService.ShowMessage(entity.ErrorMsg); return(false); } return(true); }
/// <summary> /// 确认按钮事件方法。 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void tsbOK_Click(object sender, EventArgs e) { if (this.gvList.State == GridState.Editing && this.gvList.IsEditorFocused && this.gvList.EditingValueModified) { this.gvList.SetFocusedRowCellValue(this.gvList.FocusedColumn, this.gvList.EditingValue); } this.gvList.UpdateCurrentRow(); //退料原因信息。 DataTable dtList = this.gcList.DataSource as DataTable; if (dtList == null || dtList.Rows.Count < 1) { MessageService.ShowMessage("退料原因列表中至少必须有一条记录。", "提示"); return; } //退料工序必须全部输入 List <DataRow> lst = (from item in dtList.AsEnumerable() where string.IsNullOrEmpty(Convert.ToString(item[WIP_RETURN_MAT_FIELDS.FIELD_STEP_KEY])) select item).ToList <DataRow>(); //如果不是组件补片批次且没有输入退料工序,则给出提示。 if (lst.Count() > 0 && this._lotType != "L") { MessageService.ShowMessage("非组件补片批次,退料原因列表中的【退料工序】必须输入。", "提示"); this.gvList.FocusedColumn = this.gclStep; this.gvList.FocusedRowHandle = dtList.Rows.IndexOf(lst[0]); this.gvList.ShowEditor(); return; } //退料原因必须全部输入 lst = (from item in dtList.AsEnumerable() where string.IsNullOrEmpty(Convert.ToString(item[WIP_RETURN_MAT_FIELDS.FIELD_REASON_CODE_KEY])) select item).ToList <DataRow>(); if (lst.Count() > 0) { MessageService.ShowMessage("退料原因列表中的【原因名称】必须输入。", "提示"); this.gvList.FocusedColumn = this.gclReasonCode; this.gvList.FocusedRowHandle = dtList.Rows.IndexOf(lst[0]); this.gvList.ShowEditor(); return; } //退料原因中的数量必须输入值且大于0 lst = (from item in dtList.AsEnumerable() where string.IsNullOrEmpty(Convert.ToString(item[WIP_RETURN_MAT_FIELDS.FIELD_RETURN_QUANTITY]).Trim()) || Convert.ToInt32(item[WIP_RETURN_MAT_FIELDS.FIELD_RETURN_QUANTITY]) <= 0 select item).ToList <DataRow>(); if (lst.Count() > 0) { MessageService.ShowMessage("数量必须输入且大于0。", "提示"); this.gvList.FocusedColumn = this.gclQty; this.gvList.FocusedRowHandle = dtList.Rows.IndexOf(lst[0]); this.gvList.ShowEditor(); return; } //获取当前操作的批次信息 if (_dsLotInfo == null) { LotQueryEntity queryEntity = new LotQueryEntity(); _dsLotInfo = queryEntity.GetLotInfo(this._model.LotNumber); if (!string.IsNullOrEmpty(queryEntity.ErrorMsg)) { MessageService.ShowError(queryEntity.ErrorMsg); _dsLotInfo = null; return; } } if (_dsLotInfo.Tables[0].Rows.Count < 1) { MessageService.ShowMessage(string.Format("获取【{0}】信息失败,请重试。", this._model.LotNumber), "提示"); _dsLotInfo = null; return; } DataRow drLotInfo = _dsLotInfo.Tables[0].Rows[0]; string lotKey = Convert.ToString(drLotInfo[POR_LOT_FIELDS.FIELD_LOT_KEY]); double qty = Convert.ToDouble(this.teQty.Text); //退料数量总和不能超过当前电池片数量 double returnQty = dtList.AsEnumerable().Sum(dr => dr[WIP_RETURN_MAT_FIELDS.FIELD_RETURN_QUANTITY] == DBNull.Value ? 0: Convert.ToDouble(dr[WIP_RETURN_MAT_FIELDS.FIELD_RETURN_QUANTITY])); double leftQty = qty - returnQty; if (leftQty < 0) { MessageService.ShowMessage("电池片退料数量不能超过当前电池片数量。", "提示"); return; } string lineKey = Convert.ToString(drLotInfo[POR_LOT_FIELDS.FIELD_CUR_PRODUCTION_LINE_KEY]); string lineName = Convert.ToString(drLotInfo[POR_LOT_FIELDS.FIELD_LINE_NAME]); string workOrderKey = Convert.ToString(drLotInfo[POR_LOT_FIELDS.FIELD_WORK_ORDER_KEY]); string enterpriseKey = Convert.ToString(drLotInfo[POR_LOT_FIELDS.FIELD_ROUTE_ENTERPRISE_VER_KEY]); string enterpriseName = this.teEnterpriseName.Text; string routeKey = Convert.ToString(drLotInfo[POR_LOT_FIELDS.FIELD_CUR_ROUTE_VER_KEY]); string routeName = this.teRouteName.Text; string stepKey = Convert.ToString(drLotInfo[POR_LOT_FIELDS.FIELD_CUR_STEP_VER_KEY]); int stateFlag = Convert.ToInt32(drLotInfo[POR_LOT_FIELDS.FIELD_STATE_FLAG]); int reworkFlag = Convert.ToInt32(drLotInfo[POR_LOT_FIELDS.FIELD_IS_REWORKED]); string equipmentKey = Convert.ToString(drLotInfo[EMS_EQUIPMENTS_FIELDS.FIELD_EQUIPMENT_KEY]); string edcInsKey = Convert.ToString(drLotInfo[POR_LOT_FIELDS.FIELD_EDC_INS_KEY]); string stepName = this.teStepName.Text; string remark = this.teRemark.Text; string shiftName = this._model.ShiftName; string shiftKey = string.Empty; //Shift shiftEntity=new Shift(); //string shiftKey = shiftEntity.IsShiftValueExists(shiftName);//班次主键。 ////获取班次主键失败。 //if (!string.IsNullOrEmpty(shiftEntity.ErrorMsg)) //{ // MessageService.ShowError(shiftEntity.ErrorMsg); // return; //} ////没有排班。 //if (string.IsNullOrEmpty(shiftKey)) //{ // MessageService.ShowMessage("请先在系统中进行排班。", "提示"); // return; //} string oprComputer = PropertyService.Get(PROPERTY_FIELDS.COMPUTER_NAME); string timezone = PropertyService.Get(PROPERTY_FIELDS.TIMEZONE); DataSet dsParams = new DataSet(); //组织退料数据。 Hashtable htTransaction = new Hashtable(); htTransaction.Add(WIP_TRANSACTION_FIELDS.FIELD_PIECE_KEY, lotKey); htTransaction.Add(WIP_TRANSACTION_FIELDS.FIELD_ACTIVITY, this._activity); htTransaction.Add(WIP_TRANSACTION_FIELDS.FIELD_QUANTITY_IN, qty); htTransaction.Add(WIP_TRANSACTION_FIELDS.FIELD_QUANTITY_OUT, leftQty); htTransaction.Add(WIP_TRANSACTION_FIELDS.FIELD_ENTERPRISE_KEY, enterpriseKey); htTransaction.Add(WIP_TRANSACTION_FIELDS.FIELD_ENTERPRISE_NAME, enterpriseName); htTransaction.Add(WIP_TRANSACTION_FIELDS.FIELD_ROUTE_KEY, routeKey); htTransaction.Add(WIP_TRANSACTION_FIELDS.FIELD_ROUTE_NAME, routeName); htTransaction.Add(WIP_TRANSACTION_FIELDS.FIELD_STEP_KEY, stepKey); htTransaction.Add(WIP_TRANSACTION_FIELDS.FIELD_STEP_NAME, stepName); htTransaction.Add(WIP_TRANSACTION_FIELDS.FIELD_WORK_ORDER_KEY, workOrderKey); htTransaction.Add(WIP_TRANSACTION_FIELDS.FIELD_SHIFT_KEY, shiftKey); htTransaction.Add(WIP_TRANSACTION_FIELDS.FIELD_SHIFT_NAME, shiftName); htTransaction.Add(WIP_TRANSACTION_FIELDS.FIELD_STATE_FLAG, stateFlag); htTransaction.Add(WIP_TRANSACTION_FIELDS.FIELD_REWORK_FLAG, reworkFlag); htTransaction.Add(WIP_TRANSACTION_FIELDS.FIELD_OPERATOR, this._model.UserName); htTransaction.Add(WIP_TRANSACTION_FIELDS.FIELD_OPR_COMPUTER, oprComputer); htTransaction.Add(WIP_TRANSACTION_FIELDS.FIELD_LINE_KEY, lineKey); htTransaction.Add(WIP_TRANSACTION_FIELDS.FIELD_OPR_LINE, lineName); htTransaction.Add(WIP_TRANSACTION_FIELDS.FIELD_OPR_LINE_PRE, lineName); htTransaction.Add(WIP_TRANSACTION_FIELDS.FIELD_EDC_INS_KEY, edcInsKey); htTransaction.Add(WIP_TRANSACTION_FIELDS.FIELD_EQUIPMENT_KEY, equipmentKey); htTransaction.Add(WIP_TRANSACTION_FIELDS.FIELD_ACTIVITY_COMMENT, remark); htTransaction.Add(WIP_TRANSACTION_FIELDS.FIELD_EDITOR, this._model.UserName); htTransaction.Add(WIP_TRANSACTION_FIELDS.FIELD_EDIT_TIME, null); htTransaction.Add(WIP_TRANSACTION_FIELDS.FIELD_EDIT_TIMEZONE_KEY, timezone); htTransaction.Add(WIP_TRANSACTION_FIELDS.FIELD_TIME_STAMP, null); DataTable dtTransaction = CommonUtils.ParseToDataTable(htTransaction); dtTransaction.TableName = WIP_TRANSACTION_FIELDS.DATABASE_TABLE_NAME; dsParams.Tables.Add(dtTransaction); //组织退料原因数据 DataTable dtReturn = dtList.Copy(); dtReturn.TableName = WIP_RETURN_MAT_FIELDS.DATABASE_TABLE_NAME; foreach (DataRow dr in dtReturn.Rows) { dr[WIP_RETURN_MAT_FIELDS.FIELD_EDITOR] = this._model.UserName; dr[WIP_RETURN_MAT_FIELDS.FIELD_EDIT_TIME] = DBNull.Value; dr[WIP_RETURN_MAT_FIELDS.FIELD_EDIT_TIMEZONE] = timezone; } dsParams.Tables.Add(dtReturn); //组织其他附加参数数据 Hashtable htMaindata = new Hashtable(); htMaindata.Add(COMMON_FIELDS.FIELD_COMMON_EDIT_TIME, this._model.LotEditTime); DataTable dtParams = CommonUtils.ParseToDataTable(htMaindata); dtParams.TableName = TRANS_TABLES.TABLE_PARAM; dsParams.Tables.Add(dtParams); //执行退料。 this._entity.LotReturnMaterial(dsParams); if (!string.IsNullOrEmpty(this._entity.ErrorMsg)) { MessageService.ShowError(this._entity.ErrorMsg); } else { //this.tsbClose_Click(sender, e); MessageService.ShowMessage("保存成功"); WorkbenchSingleton.Workbench.ActiveWorkbenchWindow.CloseWindow(false); //重新打开批次创建视图。 LotOperationViewContent view = new LotOperationViewContent(this._model.OperationType); WorkbenchSingleton.Workbench.ShowView(view); } dsParams.Tables.Clear(); dtTransaction = null; dtReturn = null; dtParams = null; dsParams = null; }
/// <summary> /// 添加待返工的批次信息。 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnAdd_Click(object sender, EventArgs e) { DataTable dtList = this.gcLotList.DataSource as DataTable; string lotNumber = this.beLotNumber.Text.ToUpper().Trim(); if (string.IsNullOrEmpty(lotNumber)) { MessageService.ShowMessage("请输入序列号。", "提示"); this.beLotNumber.Select(); return; } if (dtList == null) { MessageService.ShowMessage(string.Format("【{0}】在列表中已存在,请确认。", lotNumber), "提示"); this.beLotNumber.SelectAll(); return; } int count = dtList.AsEnumerable() .Count(dr => Convert.ToString(dr[POR_LOT_FIELDS.FIELD_LOT_NUMBER]) == lotNumber); if (count > 0) { MessageService.ShowMessage(string.Format("【{0}】在列表中已存在,请确认。", lotNumber), "提示"); this.beLotNumber.SelectAll(); return; } LotQueryEntity queryEntity = new LotQueryEntity(); DataSet dsReturn = queryEntity.GetLotInfo(lotNumber); if (!string.IsNullOrEmpty(queryEntity.ErrorMsg)) { MessageService.ShowError(queryEntity.ErrorMsg); dsReturn = null; this.beLotNumber.SelectAll(); return; } if (dsReturn.Tables[0].Rows.Count < 1) { MessageService.ShowMessage(string.Format("获取【{0}】信息失败,请检查。", lotNumber)); dsReturn = null; this.beLotNumber.SelectAll(); return; } //判断批次号在指定车间中是否存在。 string currentRoomKey = Convert.ToString(dsReturn.Tables[0].Rows[0][POR_LOT_FIELDS.FIELD_FACTORYROOM_KEY]); if (this._model.RoomKey != currentRoomKey) { MessageService.ShowMessage(string.Format("【{0}】在当前车间中不存在,请确认。", lotNumber), "提示"); this.beLotNumber.SelectAll(); return; } //判断批次是否被锁定 int holdFlag = Convert.ToInt32(dsReturn.Tables[0].Rows[0][POR_LOT_FIELDS.FIELD_HOLD_FLAG]); if (holdFlag == 0) { MessageService.ShowMessage(string.Format("【{0}】未暂停,请确认。", lotNumber), "提示"); this.beLotNumber.SelectAll(); return; } //判断批次是否被删除 int deleteFlag = Convert.ToInt32(dsReturn.Tables[0].Rows[0][POR_LOT_FIELDS.FIELD_DELETED_TERM_FLAG]); if (deleteFlag == 1) { MessageService.ShowMessage(string.Format("【{0}】已结束,请确认。", lotNumber), "提示"); this.beLotNumber.SelectAll(); return; } //判断批次是否已结束 if (deleteFlag == 2) { MessageService.ShowMessage(string.Format("【{0}】已删除,请确认。", lotNumber), "提示"); this.beLotNumber.SelectAll(); return; } //已包装,出托后才能返修。 string palletNo = Convert.ToString(dsReturn.Tables[0].Rows[0][POR_LOT_FIELDS.FIELD_PALLET_NO]); if (!string.IsNullOrEmpty(palletNo)) { MessageService.ShowMessage(string.Format("【{0}】已包装,出托后才能返修。", lotNumber), "提示"); this.beLotNumber.SelectAll(); return; } dsReturn.Tables[0].TableName = POR_LOT_FIELDS.DATABASE_TABLE_NAME; //获取暂停信息。 DataSet dsHoldInfo = this._entity.GetLotHoldInfo(lotNumber); if (!string.IsNullOrEmpty(this._entity.ErrorMsg)) { MessageService.ShowError(this._entity.ErrorMsg); dsHoldInfo = null; return; } if (dsHoldInfo.Tables[0].Rows.Count < 1) { MessageService.ShowMessage(string.Format("获取【{0}】暂停信息失败,请重试。", lotNumber)); dsHoldInfo = null; return; } dsHoldInfo.Tables[0].TableName = WIP_HOLD_RELEASE_FIELDS.DATABASE_TABLE_NAME; //添加用于存储密码的临时列 dsHoldInfo.Tables[0].Columns.Add(TEMP_HOLD_LIST_RELEASE_PASSWORD); //添加批次信息。 dtList.Merge(dsReturn.Tables[0]); //添加暂停信息。 DataTable dtHoldList = this.gcHoldInfoList.DataSource as DataTable; dtHoldList.Merge(dsHoldInfo.Tables[0]); this.beLotNumber.SelectAll(); }
/// <summary> /// 新增按钮Click事件。 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnAdd_Click(object sender, EventArgs e) { string lotNo = this.lueLotNo.Text; if (string.IsNullOrEmpty(lotNo)) { this.lueLotNo.Select(); return; } if (dtLots != null && dtLots.Select(string.Format("LOT_NUMBER='{0}'", lotNo)).Length > 0) { MessageService.ShowMessage("该序列号已经存在于列表中。", "提示"); this.lueLotNo.SelectAll(); return; } if (dtLots != null && dtLots.Rows.Count >= 99) { MessageService.ShowMessage("预设暂停的数量不能超过99个。", "提示"); this.lueLotNo.SelectAll(); return; } LotQueryEntity entity = new LotQueryEntity(); DataSet ds = entity.GetLotInfo(lotNo); if (string.IsNullOrEmpty(entity.ErrorMsg)) { if (ds.Tables[0].Rows.Count <= 0) { MessageService.ShowMessage("该序列号不存在。", "提示"); this.lueLotNo.SelectAll(); return; } if (!string.IsNullOrEmpty(_factoryRoomKey)) { string curFactoryRoomKey = Convert.ToString(ds.Tables[0].Rows[0][POR_LOT_FIELDS.FIELD_FACTORYROOM_KEY]); if (_factoryRoomKey != curFactoryRoomKey) { MessageService.ShowMessage("该批号在当前车间中不存在。"); this.lueLotNo.SelectAll(); return; } } int stateFlag = Convert.ToInt32(ds.Tables[0].Rows[0][POR_LOT_FIELDS.FIELD_STATE_FLAG]); int deletedTermFlag = Convert.ToInt32(ds.Tables[0].Rows[0][POR_LOT_FIELDS.FIELD_DELETED_TERM_FLAG]); string routeKey = Convert.ToString(ds.Tables[0].Rows[0][POR_LOT_FIELDS.FIELD_CUR_ROUTE_VER_KEY]); string enterpriseKey = Convert.ToString(ds.Tables[0].Rows[0][POR_LOT_FIELDS.FIELD_ROUTE_ENTERPRISE_VER_KEY]); if (!string.IsNullOrEmpty(_routeKey) && _routeKey != routeKey) { MessageService.ShowMessage(string.Format("该批号不属于【{0}】工艺流程。", this.txtRoute.Text)); this.lueLotNo.SelectAll(); return; } if (!string.IsNullOrEmpty(_enterpriseKey) && _enterpriseKey != enterpriseKey) { MessageService.ShowMessage(string.Format("该批号不属于【{0}】工艺流程组。", this.txtEnterprise.Text)); this.lueLotNo.SelectAll(); return; } if (stateFlag >= 10) { MessageService.ShowMessage("该序列号已完成。", "提示"); this.lueLotNo.SelectAll(); return; } if (deletedTermFlag != 0) { MessageService.ShowMessage("该序列号已删除或已终止。", "提示"); this.lueLotNo.SelectAll(); return; } //第一次增加预设暂停的批次。 if (dtLots == null || dtLots.Rows.Count == 0) { dtLots = ds.Tables[0].Copy(); this._routeKey = routeKey; this._enterpriseKey = enterpriseKey; this.txtEnterprise.Text = Convert.ToString(dtLots.Rows[0][POR_ROUTE_ENTERPRISE_VER_FIELDS.FIELD_ENTERPRISE_NAME]); this.txtRoute.Text = Convert.ToString(dtLots.Rows[0][POR_ROUTE_ROUTE_VER_FIELDS.FIELD_ROUTE_NAME]); } else { dtLots.Merge(ds.Tables[0], true, MissingSchemaAction.Add); } this.gcLots.DataSource = dtLots; this.lueLotNo.EditValue = string.Empty; } else { MessageService.ShowMessage(entity.ErrorMsg, "提示"); this.lueLotNo.SelectAll(); } this.lueLotNo.Select(); }
/// <summary> /// 保存,调整批次。 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void tsbOK_Click(object sender, EventArgs e) { DataTable dtLotInfo = this.gcList.DataSource as DataTable; if (dtLotInfo.Rows.Count < 1) { MessageService.ShowMessage("待调整批次信息列表至少要有一条记录。", "提示"); return; } string newLotNumber = this.teLotNumber.Text.Trim().ToUpper(); string newProId = Convert.ToString(this.lueProId.EditValue); string newCreateType = Convert.ToString(this.lueCreateType.EditValue); string newLotType = Convert.ToString(this.lueLotType.EditValue); string newPriority = Convert.ToString(this.luePriority.EditValue); string newEfficiency = Convert.ToString(this.lueEfficiency.EditValue); string newSiLot = this.teSILot.Text.Trim(); string newEnterpriseName = this.beEnterpriseName.Text; string newEnterpriseKey = Convert.ToString(this.beEnterpriseName.Tag); string newRouteName = this.teRouteName.Text; string newRouteKey = Convert.ToString(this.teRouteName.Tag); string newStepName = this.teStepName.Text; string newStepKey = Convert.ToString(this.teStepName.Tag); string remark = this.teRemark.Text; //必须要输入一个调整项目。 if (string.IsNullOrEmpty(newLotNumber) && string.IsNullOrEmpty(newProId) && string.IsNullOrEmpty(newCreateType) && string.IsNullOrEmpty(newLotType) && string.IsNullOrEmpty(newPriority) && string.IsNullOrEmpty(newEfficiency) && string.IsNullOrEmpty(newSiLot) && string.IsNullOrEmpty(newStepKey)) { MessageService.ShowMessage("必须要输入一个调整项目。", "提示"); return; } //如果批次号不为空,则判断批次号是否存在。 if (!string.IsNullOrEmpty(newLotNumber)) { LotQueryEntity queryEntity = new LotQueryEntity(); DataSet dsReturn = queryEntity.GetLotInfo(newLotNumber); if (!string.IsNullOrEmpty(queryEntity.ErrorMsg)) { MessageService.ShowError(queryEntity.ErrorMsg); dsReturn = null; return; } if (dsReturn.Tables[0].Rows.Count > 0) { MessageService.ShowMessage(string.Format("【{0}】在数据库中已存在,请确认。", newLotNumber)); dsReturn = null; return; } } string shiftName = this._model.ShiftName; string shiftKey = string.Empty; //Shift shiftEntity = new Shift(); //string shiftKey = shiftEntity.IsShiftValueExists(shiftName);//班次主键。 ////获取班次主键失败。 //if (!string.IsNullOrEmpty(shiftEntity.ErrorMsg)) //{ // MessageService.ShowError(shiftEntity.ErrorMsg); // return; //} ////没有排班。 //if (string.IsNullOrEmpty(shiftKey)) //{ // MessageService.ShowMessage("请先在系统中进行排班。", "提示"); // return; //} string oprComputer = PropertyService.Get(PROPERTY_FIELDS.COMPUTER_NAME); string timezone = PropertyService.Get(PROPERTY_FIELDS.TIMEZONE); DataSet dsParams = new DataSet(); //存放新批次信息。 Hashtable htMaindata = new Hashtable(); //存放待调整的批次的操作数据 WIP_TRANSACTION_FIELDS transFields = new WIP_TRANSACTION_FIELDS(); DataTable dtTransaction = CommonUtils.CreateDataTable(transFields); //存放调整操作的明细记录。 WIP_COMMENT_FIELDS commentFileds = new WIP_COMMENT_FIELDS(); DataTable dtComment = CommonUtils.CreateDataTable(commentFileds); StringBuilder afterContent = new StringBuilder(); foreach (DataRow dr in dtLotInfo.Rows) { //组织待调整的批次的操作数据 DataRow drTransaction = dtTransaction.NewRow(); dtTransaction.Rows.Add(drTransaction); string transKey = CommonUtils.GenerateNewKey(0); drTransaction[WIP_TRANSACTION_FIELDS.FIELD_TRANSACTION_KEY] = transKey; drTransaction[WIP_TRANSACTION_FIELDS.FIELD_PIECE_KEY] = dr[POR_LOT_FIELDS.FIELD_LOT_KEY]; drTransaction[WIP_TRANSACTION_FIELDS.FIELD_ACTIVITY] = ACTIVITY_FIELD_VALUES.FIELD_ACTIVITY_ADJUST; drTransaction[WIP_TRANSACTION_FIELDS.FIELD_QUANTITY_IN] = dr[POR_LOT_FIELDS.FIELD_QUANTITY]; drTransaction[WIP_TRANSACTION_FIELDS.FIELD_QUANTITY_OUT] = dr[POR_LOT_FIELDS.FIELD_QUANTITY]; drTransaction[WIP_TRANSACTION_FIELDS.FIELD_ENTERPRISE_KEY] = dr[POR_LOT_FIELDS.FIELD_ROUTE_ENTERPRISE_VER_KEY]; drTransaction[WIP_TRANSACTION_FIELDS.FIELD_ENTERPRISE_NAME] = dr[POR_ROUTE_ENTERPRISE_VER_FIELDS.FIELD_ENTERPRISE_NAME]; drTransaction[WIP_TRANSACTION_FIELDS.FIELD_ROUTE_KEY] = dr[POR_LOT_FIELDS.FIELD_CUR_ROUTE_VER_KEY]; drTransaction[WIP_TRANSACTION_FIELDS.FIELD_ROUTE_NAME] = dr[POR_ROUTE_ROUTE_VER_FIELDS.FIELD_ROUTE_NAME]; drTransaction[WIP_TRANSACTION_FIELDS.FIELD_STEP_KEY] = dr[POR_LOT_FIELDS.FIELD_CUR_STEP_VER_KEY]; drTransaction[WIP_TRANSACTION_FIELDS.FIELD_STEP_NAME] = dr[POR_ROUTE_STEP_FIELDS.FIELD_ROUTE_STEP_NAME]; drTransaction[WIP_TRANSACTION_FIELDS.FIELD_WORK_ORDER_KEY] = dr[POR_LOT_FIELDS.FIELD_WORK_ORDER_KEY]; drTransaction[WIP_TRANSACTION_FIELDS.FIELD_SHIFT_KEY] = shiftKey; drTransaction[WIP_TRANSACTION_FIELDS.FIELD_SHIFT_NAME] = shiftName; drTransaction[WIP_TRANSACTION_FIELDS.FIELD_STATE_FLAG] = dr[POR_LOT_FIELDS.FIELD_STATE_FLAG]; drTransaction[WIP_TRANSACTION_FIELDS.FIELD_REWORK_FLAG] = dr[POR_LOT_FIELDS.FIELD_IS_REWORKED]; drTransaction[WIP_TRANSACTION_FIELDS.FIELD_OPERATOR] = this._model.UserName; drTransaction[WIP_TRANSACTION_FIELDS.FIELD_OPR_COMPUTER] = oprComputer; drTransaction[WIP_TRANSACTION_FIELDS.FIELD_LINE_KEY] = dr[POR_LOT_FIELDS.FIELD_CUR_PRODUCTION_LINE_KEY]; drTransaction[WIP_TRANSACTION_FIELDS.FIELD_OPR_LINE] = dr[POR_LOT_FIELDS.FIELD_OPR_LINE]; drTransaction[WIP_TRANSACTION_FIELDS.FIELD_OPR_LINE_PRE] = dr[POR_LOT_FIELDS.FIELD_OPR_LINE_PRE]; drTransaction[WIP_TRANSACTION_FIELDS.FIELD_EDC_INS_KEY] = dr[POR_LOT_FIELDS.FIELD_EDC_INS_KEY]; drTransaction[WIP_TRANSACTION_FIELDS.FIELD_EQUIPMENT_KEY] = dr[EMS_EQUIPMENTS_FIELDS.FIELD_EQUIPMENT_KEY]; drTransaction[WIP_TRANSACTION_FIELDS.FIELD_ACTIVITY_COMMENT] = remark; drTransaction[WIP_TRANSACTION_FIELDS.FIELD_EDITOR] = this._model.UserName; //用于暂存序列号批次信息最后的编辑时间,以便判断序列号信息是否过期。 drTransaction[WIP_TRANSACTION_FIELDS.FIELD_EDIT_TIME] = dr[POR_LOT_FIELDS.FIELD_EDIT_TIME]; drTransaction[WIP_TRANSACTION_FIELDS.FIELD_EDIT_TIMEZONE_KEY] = timezone; drTransaction[WIP_TRANSACTION_FIELDS.FIELD_TIME_STAMP] = DBNull.Value; //组织待调整的批次的明细操作数据 DataRow drComment = dtComment.NewRow(); dtComment.Rows.Add(drComment); drComment[WIP_COMMENT_FIELDS.FIELDS_TRANSACTION_KEY] = transKey; drComment[WIP_COMMENT_FIELDS.FIELDS_ENTERPRISE_KEY] = dr[POR_LOT_FIELDS.FIELD_ROUTE_ENTERPRISE_VER_KEY]; drComment[WIP_COMMENT_FIELDS.FIELDS_ROUTE_KEY] = dr[POR_LOT_FIELDS.FIELD_CUR_ROUTE_VER_KEY]; drComment[WIP_COMMENT_FIELDS.FIELDS_STEP_KEY] = dr[POR_LOT_FIELDS.FIELD_CUR_STEP_VER_KEY]; drComment[WIP_COMMENT_FIELDS.FIELDS_EDIT_TIMEZONE] = timezone; drComment[WIP_COMMENT_FIELDS.FIELDS_EDIT_TIME] = DBNull.Value; drComment[WIP_COMMENT_FIELDS.FIELDS_EDITOR] = this._model.UserName; StringBuilder beforeContent = new StringBuilder(); //新批次号不为空。 if (!string.IsNullOrEmpty(newLotNumber)) { if (!htMaindata.ContainsKey(POR_LOT_FIELDS.FIELD_LOT_NUMBER)) { htMaindata.Add(POR_LOT_FIELDS.FIELD_LOT_NUMBER, newLotNumber); afterContent.AppendFormat("批次号:{0};", newLotNumber); } beforeContent.AppendFormat("批次号:{0};", dr[POR_LOT_FIELDS.FIELD_LOT_NUMBER]); } //新产品ID号不为空 if (!string.IsNullOrEmpty(newProId)) { if (!htMaindata.ContainsKey(POR_LOT_FIELDS.FIELD_PRO_ID)) { htMaindata.Add(POR_LOT_FIELDS.FIELD_PRO_ID, newProId); afterContent.AppendFormat("产品ID号:{0};", newProId); } beforeContent.AppendFormat("产品ID号:{0};", dr[POR_LOT_FIELDS.FIELD_PRO_ID]); } //新的创建类别。 if (!string.IsNullOrEmpty(newCreateType)) { if (!htMaindata.ContainsKey(POR_LOT_FIELDS.FIELD_CREATE_TYPE)) { htMaindata.Add(POR_LOT_FIELDS.FIELD_CREATE_TYPE, newCreateType); afterContent.AppendFormat("创建类别:{0};", newCreateType); } beforeContent.AppendFormat("创建类别:{0};", dr[POR_LOT_FIELDS.FIELD_CREATE_TYPE]); } //新的批次类别。 if (!string.IsNullOrEmpty(newLotType)) { if (!htMaindata.ContainsKey(POR_LOT_FIELDS.FIELD_LOT_TYPE)) { htMaindata.Add(POR_LOT_FIELDS.FIELD_LOT_TYPE, newLotType); afterContent.AppendFormat("批次类别:{0};", newLotType); } beforeContent.AppendFormat("批次类别:{0};", dr[POR_LOT_FIELDS.FIELD_LOT_TYPE]); } //新的优先级。 if (!string.IsNullOrEmpty(newPriority)) { if (!htMaindata.ContainsKey(POR_LOT_FIELDS.FIELD_PRIORITY)) { htMaindata.Add(POR_LOT_FIELDS.FIELD_PRIORITY, newPriority); afterContent.AppendFormat("优先级:{0};", newPriority); } beforeContent.AppendFormat("优先级:{0};", dr[POR_LOT_FIELDS.FIELD_PRIORITY]); } //新的转换效率。 if (!string.IsNullOrEmpty(newEfficiency)) { if (!htMaindata.ContainsKey(POR_LOT_FIELDS.FIELD_EFFICIENCY)) { htMaindata.Add(POR_LOT_FIELDS.FIELD_EFFICIENCY, newEfficiency); afterContent.AppendFormat("转换效率:{0};", newEfficiency); } beforeContent.AppendFormat("转换效率:{0};", dr[POR_LOT_FIELDS.FIELD_EFFICIENCY]); } //新的硅片供应商。 if (!string.IsNullOrEmpty(newSiLot)) { if (!htMaindata.ContainsKey(POR_LOT_FIELDS.FIELD_SI_LOT)) { htMaindata.Add(POR_LOT_FIELDS.FIELD_SI_LOT, newSiLot); afterContent.AppendFormat("硅片供应商:{0};", newSiLot); } beforeContent.AppendFormat("硅片供应商:{0};", dr[POR_LOT_FIELDS.FIELD_SI_LOT]); } //新的工步主键。 if (!string.IsNullOrEmpty(newStepKey)) { if (!htMaindata.ContainsKey(POR_LOT_FIELDS.FIELD_ROUTE_ENTERPRISE_VER_KEY)) { htMaindata.Add(POR_LOT_FIELDS.FIELD_ROUTE_ENTERPRISE_VER_KEY, newEnterpriseKey); afterContent.AppendFormat("工艺流程组:{0};", newEnterpriseName); } if (!htMaindata.ContainsKey(POR_LOT_FIELDS.FIELD_CUR_ROUTE_VER_KEY)) { htMaindata.Add(POR_LOT_FIELDS.FIELD_CUR_ROUTE_VER_KEY, newRouteKey); afterContent.AppendFormat("工艺流程:{0};", newRouteName); } if (!htMaindata.ContainsKey(POR_LOT_FIELDS.FIELD_CUR_STEP_VER_KEY)) { htMaindata.Add(POR_LOT_FIELDS.FIELD_CUR_STEP_VER_KEY, newStepKey); afterContent.AppendFormat("工序:{0};", newStepName); } drComment[WIP_COMMENT_FIELDS.FIELDS_ENTERPRISE_KEY] = newEnterpriseKey; drComment[WIP_COMMENT_FIELDS.FIELDS_ROUTE_KEY] = newRouteKey; drComment[WIP_COMMENT_FIELDS.FIELDS_STEP_KEY] = newStepKey; beforeContent.AppendFormat("工艺流程组:{0};", dr[POR_ROUTE_ENTERPRISE_VER_FIELDS.FIELD_ENTERPRISE_NAME]); beforeContent.AppendFormat("工艺流程:{0};", dr[POR_ROUTE_ROUTE_VER_FIELDS.FIELD_ROUTE_NAME]); beforeContent.AppendFormat("工序:{0};", dr[POR_ROUTE_STEP_FIELDS.FIELD_ROUTE_STEP_NAME]); } drComment[WIP_COMMENT_FIELDS.FIELDS_BEFORE_CONTENT] = beforeContent; drComment[WIP_COMMENT_FIELDS.FIELDS_AFTER_CONTENT] = afterContent; } DataTable dtMaindata = CommonUtils.ParseToDataTable(htMaindata); dtMaindata.TableName = TRANS_TABLES.TABLE_MAIN_DATA; dsParams.Tables.Add(dtMaindata); dsParams.Tables.Add(dtTransaction); dsParams.Tables.Add(dtComment); //执行调整批次。 this._entity.LotAdjust(dsParams); if (!string.IsNullOrEmpty(this._entity.ErrorMsg)) { MessageService.ShowError(this._entity.ErrorMsg); } else { //this.tsbCancle_Click(sender, e); MessageService.ShowMessage("保存成功"); WorkbenchSingleton.Workbench.ActiveWorkbenchWindow.CloseWindow(false); //重新打开批次创建视图。 LotOperationViewContent view = new LotOperationViewContent(this._model.OperationType); WorkbenchSingleton.Workbench.ShowView(view); } dsParams.Tables.Clear(); dtTransaction = null; dtComment = null; dsParams = null; }
/// <summary> /// 添加待调整的批次信息。 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnAdd_Click(object sender, EventArgs e) { DataTable dtList = this.gcList.DataSource as DataTable; string lotNumber = this.beLotNumber.Text.ToUpper().Trim(); if (string.IsNullOrEmpty(lotNumber)) { MessageService.ShowMessage("请输入序列号。", "提示"); this.beLotNumber.Select(); return; } int count = dtList.AsEnumerable() .Count(dr => Convert.ToString(dr[POR_LOT_FIELDS.FIELD_LOT_NUMBER]) == lotNumber); if (count > 0) { MessageService.ShowMessage(string.Format("【{0}】在列表中已存在,请确认。", lotNumber), "提示"); this.beLotNumber.SelectAll(); return; } LotQueryEntity queryEntity = new LotQueryEntity(); DataSet dsReturn = queryEntity.GetLotInfo(lotNumber); if (!string.IsNullOrEmpty(queryEntity.ErrorMsg)) { MessageService.ShowError(queryEntity.ErrorMsg); dsReturn = null; this.beLotNumber.SelectAll(); return; } if (dsReturn.Tables[0].Rows.Count < 1) { MessageService.ShowMessage(string.Format("获取【{0}】信息失败,请检查。", lotNumber)); dsReturn = null; this.beLotNumber.SelectAll(); return; } //判断批次号在指定车间中是否存在。 string currentRoomKey = Convert.ToString(dsReturn.Tables[0].Rows[0][POR_LOT_FIELDS.FIELD_FACTORYROOM_KEY]); if (this._model.RoomKey != currentRoomKey) { MessageService.ShowMessage(string.Format("【{0}】在当前车间中不存在,请确认。", lotNumber), "提示"); this.beLotNumber.SelectAll(); return; } //判断批次是否被锁定 int holdFlag = Convert.ToInt32(dsReturn.Tables[0].Rows[0][POR_LOT_FIELDS.FIELD_HOLD_FLAG]); if (holdFlag == 1) { MessageService.ShowMessage(string.Format("【{0}】已被暂停,请确认。", lotNumber), "提示"); this.beLotNumber.SelectAll(); return; } //判断批次是否被删除 int deleteFlag = Convert.ToInt32(dsReturn.Tables[0].Rows[0][POR_LOT_FIELDS.FIELD_DELETED_TERM_FLAG]); if (deleteFlag == 1) { MessageService.ShowMessage(string.Format("【{0}】已结束,请确认。", lotNumber), "提示"); this.beLotNumber.SelectAll(); return; } //判断批次是否已结束 if (deleteFlag == 2) { MessageService.ShowMessage(string.Format("【{0}】已删除,请确认。", lotNumber), "提示"); this.beLotNumber.SelectAll(); return; } //已包装,出托后才能调整批次。 string palletNo = Convert.ToString(dsReturn.Tables[0].Rows[0][POR_LOT_FIELDS.FIELD_PALLET_NO]); if (!string.IsNullOrEmpty(palletNo)) { MessageService.ShowMessage(string.Format("【{0}】已包装,出托后才能调整。", lotNumber), "提示"); this.beLotNumber.SelectAll(); return; } dsReturn.Tables[0].TableName = POR_LOT_FIELDS.DATABASE_TABLE_NAME; dtList.Merge(dsReturn.Tables[0]); //如果要调整的批次中有多个批次信息,则不能调整批次号。 if (dtList.Rows.Count > 1) { this.teLotNumber.Text = string.Empty; this.lciLotNumber.Visibility = LayoutVisibility.Never; } this.beLotNumber.SelectAll(); }
private string MESSAGEBOX_CAPTION = StringParser.Parse("${res:Global.SystemInfo}"); //提示 /// <summary> /// 新增批次操作记录。 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnAdd_Click(object sender, EventArgs e) { try { DataTable dtList = this.gcExchangeLine.DataSource as DataTable; string lotNumber = this.teLotNumber.Text.ToUpper().Trim(); if (string.IsNullOrEmpty(lotNumber)) { MessageService.ShowMessage(StringParser.Parse("${res:FanHai.Hemera.Addins.WIP.LotUndoCtrl.Msg001}"), MESSAGEBOX_CAPTION);//请输入序列号 //MessageService.ShowMessage("请输入序列号。", "提示"); this.teLotNumber.Select(); return; } int count = dtList.AsEnumerable() .Count(dr => Convert.ToString(dr[POR_LOT_FIELDS.FIELD_LOT_NUMBER]) == lotNumber); if (count > 0) { MessageService.ShowMessage(string.Format("【{0}】在列表中已存在,请确认。", lotNumber), "提示"); this.teLotNumber.SelectAll(); return; } LotQueryEntity queryEntity = new LotQueryEntity(); DataSet dsReturn = queryEntity.GetLotInfo(lotNumber); if (!string.IsNullOrEmpty(queryEntity.ErrorMsg)) { MessageService.ShowError(queryEntity.ErrorMsg); dsReturn = null; this.teLotNumber.SelectAll(); return; } if (dsReturn.Tables[0].Rows.Count < 1) { MessageService.ShowMessage(string.Format("获取【{0}】信息失败,请检查。", lotNumber)); dsReturn = null; this.teLotNumber.SelectAll(); return; } //判断批次号在指定车间中是否存在。 string currentRoomKey = Convert.ToString(dsReturn.Tables[0].Rows[0][POR_LOT_FIELDS.FIELD_FACTORYROOM_KEY]); string roomKey = lueFactoryRoom.EditValue.ToString(); if (roomKey != currentRoomKey) { MessageService.ShowMessage(string.Format("【{0}】在当前车间中不存在,请确认。", lotNumber), "提示"); this.teLotNumber.SelectAll(); return; } //判断批次是否被锁定 int holdFlag = Convert.ToInt32(dsReturn.Tables[0].Rows[0][POR_LOT_FIELDS.FIELD_HOLD_FLAG]); if (holdFlag == 1) { MessageService.ShowMessage(string.Format("【{0}】已被暂停,请确认。", lotNumber), "提示"); this.teLotNumber.SelectAll(); return; } //判断批次是否被删除 int deleteFlag = Convert.ToInt32(dsReturn.Tables[0].Rows[0][POR_LOT_FIELDS.FIELD_DELETED_TERM_FLAG]); if (deleteFlag == 1) { MessageService.ShowMessage(string.Format("【{0}】已结束,请确认。", lotNumber), "提示"); this.teLotNumber.SelectAll(); return; } //判断批次是否已结束 if (deleteFlag == 2) { MessageService.ShowMessage(string.Format("【{0}】已删除,请确认。", lotNumber), "提示"); this.teLotNumber.SelectAll(); return; } //判断组件状态 int curState = int.Parse(dsReturn.Tables[0].Rows[0][POR_LOT_FIELDS.FIELD_STATE_FLAG].ToString()); if (curState > 10) { MessageService.ShowMessage(string.Format("【{0}】已完工,请确认。", lotNumber), "提示"); return; } //判断用户是否有组件所在工序权限 string curOperationName = Convert.ToString(dsReturn.Tables[0].Rows[0][POR_ROUTE_STEP_FIELDS.FIELD_ROUTE_STEP_NAME]); string operations = PropertyService.Get(PROPERTY_FIELDS.OPERATIONS);//获取有权限的所有工序 if ((operations + ",").IndexOf(curOperationName + ",") == -1) { MessageService.ShowMessage(string.Format("您没有权限调整工序[{0}]组件线别的操作。", curOperationName), "提示"); return; } if (dtList == null) { this.gcExchangeLine.DataSource = dsReturn.Tables[0]; } else { if (dtList.Rows.Count >= 100) { MessageService.ShowMessage(StringParser.Parse("${res:FanHai.Hemera.Addins.WIP.LotOperationExchangeLine.Msg001}"), MESSAGEBOX_CAPTION);//一次调整录数不能超过100条 //MessageService.ShowMessage("一次调整录数不能超过100条。", "提示"); return; } dsReturn.Tables[0].TableName = POR_LOT_FIELDS.DATABASE_TABLE_NAME; dtList.Merge(dsReturn.Tables[0]); this.teLotNumber.SelectAll(); } } finally { this.teLotNumber.Select(); this.teLotNumber.SelectAll(); } }