/// <summary> /// 輸入工件序號 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void ttbCompLot_TextChanged(object sender, EventArgs e) { try { decimal haveMergeQty = 0; decimal mergeQty = 0; decimal notMergeQty = 0; //確認工件序號是否有輸入 ttbCompLot.Must(lblCompLot); //確認工件序號是否存在 var lotList = LotInfoEx.GetLotListByComponentLot(ttbCompLot.Text); if (lotList.Count == 0) { //工件序號:{0} 不存在!! throw new Exception(RuleMessage.Error.C10047(ttbCompLot.Text)); } var compLotData = lotList[0]; //確認狀態是否為WAIT if (compLotData.Status != LotDefaultStatus.Wait.ToString()) { //狀態為{0},不可執行 throw new Exception(RuleMessage.Error.C10003(compLotData.Status)); } //確認批號執行規則是否與程式相同 //if (compLotData.CurrentRuleName != _ProgramInformationBlock.ProgramRight) //{ // //該批號作業為XXXX,不為此功能,請遵循作業規範 // throw new Exception(RuleMessage.Error.C10004(compLotData.CurrentRuleName)); //} //取得小工單資料 var workOrderLot = CSTWorkOrderLotInfo.GetWorkOrderLotDataByWorkOrderLot(compLotData.WorkOrderLot); if (workOrderLot == null) { // [00030]{0}:{1}不存在! throw new Exception(TextMessage.Error.T00030(lblWOLot.Text, compLotData.WorkOrderLot)); } //取得相同小工單的工件序號清單資料 var sameWOLotList = LotInfoEx.GetLotListByWorkOrderLot(compLotData.WorkOrderLot); #region 取得相同工作站、UDC08等於Y及狀態為Wait的工件序號清單 var autoTypeLotList = sameWOLotList.FindAll(lot => lot.UserDefineColumn08 == "Y"); _MergeLotDataList = autoTypeLotList.FindAll(lot => lot.OperationName == compLotData.OperationName && lot.Status == LotDefaultStatus.Wait.ToString()); //計算可合併數量 _MergeLotDataList.ForEach(lot => { mergeQty += lot.Quantity; }); #endregion #region 取得不可合併的工件序號清單 var notMergeLotDataList = autoTypeLotList.FindAll(lot => (lot.OperationName == compLotData.OperationName && lot.Status == LotDefaultStatus.Wait.ToString()) == false); //計算不可合併數量 notMergeLotDataList.ForEach(lot => { notMergeQty += lot.Quantity; }); #endregion #region 取得已合併的工件序號清單 var haveMergeLotDataList = sameWOLotList.FindAll(lot => lot.UserDefineColumn08 == "N"); //計算已合併數量 haveMergeLotDataList.ForEach(lot => { haveMergeQty += lot.Quantity; }); #endregion //取得流程清單 GetRoute(compLotData); //顯示介面資料 ttbOperation.Text = compLotData.OperationName; ttbWOLot.Text = compLotData.WorkOrderLot; ttbWOQty.Text = workOrderLot.Quantity.ToString(); ttbMergeQty.Text = mergeQty.ToString(); ttbNotMergeQty.Text = notMergeQty.ToString(); ttbHaveMergeQty.Text = haveMergeQty.ToString(); gvMergeCompLot.SetDataSource(_MergeLotDataList, true); gvNotMergeCompLot.SetDataSource(notMergeLotDataList, true); btnOK.Enabled = true; } catch (Exception ex) { ClearField(); AjaxFocus(ttbCompLot); HandleError(ex); } }
private DataTable GetLotTitle() { DataTable dt = _LotData.CopyDataToTable("MES_WIP_LOT"); dt.Columns.Add("DeviceCode");//料號的2,3碼 dt.Columns.Add("LotTypeDescr"); dt.Columns.Add("WOQuantity"); dt.Columns.Add("DeviceDescr"); dt.Columns.Add("DeviceBPNo"); dt.Columns.Add("DeviceBPRev"); dt.Columns.Add("ProductionDate"); //預計生產日期 dt.Columns.Add("ScheduleDate"); //預計完成日期 dt.Columns.Add("BOM_MATNR"); //投入料號 dt.Columns.Add("Device_PLMNO"); //PLM 編號 dt.Columns.Add("Device_PLMVR"); //PLM 版本 if (cbxWO.Checked) { var woLot = CSTWorkOrderLotInfo.GetWorkOrderLotDataByWorkOrderLot(ttbWOLot.Text.Trim()); dt.Rows[0]["WOLOT"] = woLot.WOLOT; dt.Rows[0]["INVLOT"] = woLot.INVLOT; dt.Rows[0]["MATERIALLOT"] = woLot.MATERIALLOT; dt.Rows[0]["Quantity"] = woLot.Quantity; dt.Rows[0]["LOT"] = woLot.WOLOT; var cstWOBOMInfo = CSTWPCWorkOrderBOMInfo.GetDataByWorkOrder(woLot.WorkOrder).Find(p => p["SORTF"].ToString() == "1"); if (cstWOBOMInfo != null) { dt.Rows[0]["BOM_MATNR"] = cstWOBOMInfo["MATNR"].ToString(); } dt.Rows[0]["DeviceCode"] = _LotData.DeviceName.Substring(1, 2); var lsLotType = WpcExClassItemInfo.GetExClassItemInfo("LotType", _LotData.LotType); dt.Rows[0]["LotTypeDescr"] = lsLotType.Count > 0 ? lsLotType[0].Remark02 : ""; var WOData = WorkOrderInfo.GetWorkOrderByWorkOrder(woLot.WorkOrder); dt.Rows[0]["WOQuantity"] = WOData.Quantity; dt.Rows[0]["ProductionDate"] = WOData["ProductionDate"].ToCimesString(); dt.Rows[0]["ScheduleDate"] = WOData.ScheduleDate; var DeviceData = DeviceVersionInfoEx.GetActiveDeviceVersion(_LotData.DeviceName).ChangeTo <DeviceVersionInfoEx>(); dt.Rows[0]["DeviceDescr"] = DeviceData.Description; dt.Rows[0]["DeviceBPNo"] = DeviceData["BPNO"].ToString(); dt.Rows[0]["DeviceBPRev"] = DeviceData["BPREV"].ToString(); dt.Rows[0]["Device_PLMVR"] = DeviceData["PLMVR"].ToString(); dt.Rows[0]["Device_PLMNO"] = DeviceData["PLMNO"].ToString(); } if (cbxSN.Checked || cbxLot.Checked) { dt.Rows[0]["WOLOT"] = _LotData.WorkOrderLot; dt.Rows[0]["INVLOT"] = _LotData.InventoryLot; dt.Rows[0]["MATERIALLOT"] = _LotData.MaterialLot; dt.Rows[0]["Quantity"] = _LotData.Quantity; dt.Rows[0]["LOT"] = _LotData.Lot; dt.Rows[0]["DeviceCode"] = _LotData.DeviceName.Substring(1, 2); var lsLotType = WpcExClassItemInfo.GetExClassItemInfo("LotType", _LotData.LotType); dt.Rows[0]["LotTypeDescr"] = lsLotType.Count > 0 ? lsLotType[0].Remark02 : ""; var WOData = WorkOrderInfo.GetWorkOrderByWorkOrder(_LotData.WorkOrder); dt.Rows[0]["WOQuantity"] = WOData.Quantity; dt.Rows[0]["ProductionDate"] = WOData["ProductionDate"].ToCimesString(); dt.Rows[0]["ScheduleDate"] = WOData.ScheduleDate; var DeviceData = DeviceVersionInfoEx.GetActiveDeviceVersion(_LotData.DeviceName).ChangeTo <DeviceVersionInfoEx>(); dt.Rows[0]["DeviceDescr"] = DeviceData.Description; dt.Rows[0]["DeviceBPNo"] = DeviceData["BPNO"].ToString(); dt.Rows[0]["DeviceBPRev"] = DeviceData["BPREV"].ToString(); dt.Rows[0]["Device_PLMVR"] = DeviceData["PLMVR"].ToString(); dt.Rows[0]["Device_PLMNO"] = DeviceData["PLMNO"].ToString(); var cstWOBOMInfo = CSTWPCWorkOrderBOMInfo.GetDataByWorkOrder(WOData.WorkOrder).Find(p => p["SORTF"].ToString() == "1"); if (cstWOBOMInfo != null) { dt.Rows[0]["BOM_MATNR"] = cstWOBOMInfo["MATNR"].ToString(); } } return(dt); }