Пример #1
0
        protected void btnOK_Click(object sender, EventArgs e)
        {
            try
            {
                if (_ProcessLot == null)
                {
                    throw new RuleCimesException(TextMessage.Error.T00826(lblUnPackingInventoryLot.Text));
                }

                // 定義交易戳記
                var txnStamp = new TransactionStamp(User.Identity.Name, ProgramRight, ProgramRight, ApplicationName);
                using (var cts = CimesTransactionScope.Create())
                {
                    // 將入庫批取消完工
                    WIPTransaction.UndoFinish(_ProcessLot, txnStamp);
                    var unPackingLot = LotInfo.GetLotByLot(ttbBoxNo.Text.Trim());
                    // 取得拆包Component
                    var lstUnPackingComp = unPackingLot.GetLotAllComponents();
                    // 將轉為子單元的批號還原,例如可使用於拆包
                    var txn = WIPTxn.Default.ConvertToLot(unPackingLot, lstUnPackingComp, txnStamp);
                    txn.LotList.ForEach(lot => {
                        //寫入WMSMaster & Detail
                        var wmsMaster = CSTWMSMastInfo.GetMaterialLotDataByMaterialLot(lot["INVLOT"].ToString());
                        if (wmsMaster == null)
                        {
                            wmsMaster            = InfoCenter.Create <CSTWMSMastInfo>();
                            wmsMaster.Lot        = lot["INVLOT"].ToString();
                            wmsMaster.DeviceName = lot.DeviceName;
                            wmsMaster.RuleName   = txnStamp.RuleName;
                            wmsMaster.InsertToDB(txnStamp.UserID, txnStamp.RecordTime);
                        }
                        //理論上只會有一個Comp
                        lot.GetLotAllComponents().ForEach(comp => {
                            var wmsDetail         = InfoCenter.Create <CSTWMSDetailInfo>();
                            wmsDetail.Lot         = lot["INVLOT"].ToString();
                            wmsDetail.ComponentID = comp.ComponentID;
                            wmsDetail.Quantity    = comp.ComponentQuantity;
                            wmsDetail.InsertToDB(txnStamp.UserID, txnStamp.RecordTime);
                        });
                        WIPTransaction.TerminateLot(lot, txnStamp);
                    });

                    cts.Complete();
                }
                // 返回定義的預設網頁
                ReturnToPortal();
            }
            catch (Exception ex)
            {
                HandleError(ex);
            }
        }
Пример #2
0
        /// <summary>
        /// 確認
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnOK_Click(object sender, EventArgs e)
        {
            try
            {
                TransactionStamp txnStamp = new TransactionStamp(User.Identity.Name, ProgramRight, ProgramRight, ApplicationName);

                using (var cts = CimesTransactionScope.Create())
                {
                    if (_SelectLotDatas.Count > 0)
                    {
                        string sLotInString = "";
                        // 組出where in字串
                        _SelectLotDatas.ForEach(p =>
                        {
                            sLotInString += "'" + p.Lot + "',";
                        });
                        sLotInString = sLotInString.EndsWith(",") ? sLotInString.Substring(0, sLotInString.Length - 1) : sLotInString;

                        var    dtInvData = DBCenter.GetDataTable(@"SELECT WO,INVLOT,SUM(QUANTITY) QUANTITY,DEVICE,FACTORY FROM MES_WIP_LOT  WHERE LOT IN(" + sLotInString + ") GROUP BY WO,INVLOT,DEVICE,FACTORY ORDER BY WO");
                        string headerSID = "";
                        string date      = txnStamp.RecordTime.Substring(0, 10).Replace("/", "");
                        string time      = txnStamp.RecordTime.Substring(11).Replace(":", "");
                        string preWo     = string.Empty;
                        int    seq       = 1;
                        // SAI倉位對應表
                        var lstSAIWarehouse = WpcExClassItemInfo.GetInfoByClass("SAIWarehouse");

                        dtInvData.Rows.LoopDo <DataRow>((p, i) =>
                        {
                            string currentWO = p["WO"].ToString();
                            string device    = p["DEVICE"].ToString();
                            string factory   = p["FACTORY"].ToString();
                            string invLot    = p["INVLOT"].ToString();
                            string qty       = p["QUANTITY"].ToString();
                            if (preWo != currentWO)
                            {
                                seq       = 1;
                                headerSID = DBCenter.GetSystemID();
                                DBCenter.ExecuteParse(@"INSERT INTO PPFHK (SID, WDATE, WTIME, BUDAT, AUFNR, FLAG) 
                                    VALUES (#[STRING], #[STRING], #[STRING], #[STRING], #[STRING],'N')", headerSID, date, time, date, currentWO);
                            }
                            //寫入PPFHP
                            //WERKS:Factory
                            //LGORT:入庫倉位
                            //CHARG:INVLOT
                            //MATNR:Device
                            var lstDetail     = _SelectLotDatas.FindAll(select => select.InventoryLot == invLot);
                            var warehouseInfo = lstSAIWarehouse.Find(wpcItem => wpcItem.Remark01 == lstDetail[0].Process && wpcItem.Remark03 == "DEFECT");
                            if (warehouseInfo == null)
                            {
                                //T00555:查無資料,請至系統資料維護新增類別{0}、項目{1}!
                                throw new CimesException(TextMessage.Error.T00555("SAIWarehouse", lstDetail[0].Process + "Remark03:DEFECT"));
                            }
                            DBCenter.ExecuteParse(@"INSERT INTO PPFHP (SID, SEQNR, WDATE, WTIME, MATNR, WERKS, LGORT, CHARG, MENGE, MEINS, FLAG)
                                VALUES (#[STRING], #[DECIMAL], #[STRING], #[STRING], #[STRING], #[STRING], #[STRING], #[STRING], #[STRING], #[STRING], 'N')", headerSID, seq, date, time, device, factory, warehouseInfo.Remark02, invLot, qty, lstDetail[0].Unit);

                            int detailseq = 1;
                            lstDetail.ForEach(lot => {
                                var defectInfo      = CSTWIPDefectJudgementInfo.GetDataByLot(lot.Lot);
                                var reasonGroupInfo = WIPReasonGroupInfoEx.GetReasonGroupByCategory(defectInfo["REASONCATEGORY"].ToString());
                                var reasonGroup     = reasonGroupInfo == null ? "" : reasonGroupInfo.REASONGROUP;
                                //寫入PPBCH
                                DBCenter.ExecuteParse(@"INSERT INTO PPBCH (SID, MATNR, WERKS, CHARG, SEQNO, WDATE, WTIME, CLASS, ATINN, ATWRT, FLAG)
                                    Values (#[STRING], #[STRING], #[STRING], #[STRING], #[DECIMAL], #[STRING], #[STRING], #[STRING], #[STRING], #[STRING], 'N')", headerSID, device, factory, invLot, detailseq, date, time, reasonGroup, defectInfo["REASONCATEGORY"].ToString(), defectInfo.Reason);
                                detailseq += 1;
                            });

                            seq  += 1;
                            preWo = currentWO;
                        });

                        _SelectLotDatas.ForEach(lot =>
                        {
                            //寫入WMSMaster & Detail
                            var wmsMaster = CSTWMSMastInfo.GetMaterialLotDataByMaterialLot(lot.InventoryLot);
                            if (wmsMaster == null)
                            {
                                wmsMaster            = InfoCenter.Create <CSTWMSMastInfo>();
                                wmsMaster.Lot        = lot.InventoryLot;
                                wmsMaster.DeviceName = lot.DeviceName;
                                wmsMaster.RuleName   = txnStamp.RuleName;
                                wmsMaster.InsertToDB(txnStamp.UserID, txnStamp.RecordTime);
                            }
                            //理論上只會有一個Comp
                            lot.GetLotAllComponents().ForEach(comp => {
                                var wmsDetail         = InfoCenter.Create <CSTWMSDetailInfo>();
                                wmsDetail.Lot         = lot.InventoryLot;
                                wmsDetail.ComponentID = comp.ComponentID;
                                wmsDetail.Quantity    = comp.ComponentQuantity;
                                wmsDetail.InsertToDB(txnStamp.UserID, txnStamp.RecordTime);
                            });

                            //將入庫單號回寫到批號身上
                            WIPTransaction.ModifyLotSystemAttribute(lot, "INVNO", ttbDefectNo.Text, txnStamp);

                            //將勾選的批號結批
                            WIPTransaction.TerminateLot(lot, txnStamp);
                        });

                        #region 更新命名規則
                        if (_ExecuteNamingSQLList != null && _ExecuteNamingSQLList.Count > 0)
                        {
                            DBCenter.ExecuteSQL(_ExecuteNamingSQLList);
                        }
                        #endregion

                        cts.Complete();
                    }
                    else
                    {
                        //[00816]請至少選取一個{0}!
                        throw new Exception(TextMessage.Error.T00816(GetUIResource("WorkpieceLot")));
                    }
                }

                ClearField();

                _ProgramInformationBlock.ShowMessage(TextMessage.Hint.T00614(""));
            }
            catch (Exception ex)
            {
                HandleError(ex);
            }
        }
Пример #3
0
        /// <summary>
        /// 確定
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnOK_Click(object sender, EventArgs e)
        {
            try
            {
                //確認介面是否有輸入資料
                ttbLot.Must(lblLot);
                ttbDevice.Must(lblDevice);
                ttbQuantity.MustInt(lblQuantity);

                //號碼排除清單
                List <int> lossItemSNList = new List <int>();

                //取得輸入的號碼排除
                string lossItemSNString = ttbLossItemSN.Text.Trim();

                if (lossItemSNString.IsNullOrTrimEmpty() == false)
                {
                    //依據逗號分割字串
                    var arrLossItemSN = ttbLossItemSN.Text.Split(',');

                    //確認輸入的內容格式是否正確
                    for (int i = 0; i < arrLossItemSN.Length; i++)
                    {
                        int value = 0;

                        //如果轉換INT失敗,則顯示錯誤
                        if (int.TryParse(arrLossItemSN[i], out value) == false)
                        {
                            AjaxFocus(ttbLossItemSN);

                            //格式必須為正整數,且使用逗號隔開(例如:1,2,3)!!
                            throw new Exception(RuleMessage.Error.C10150());
                        }
                        else
                        {
                            //確認數值是否大於零,如果小於等於零,則顯示錯誤
                            if (value <= 0)
                            {
                                AjaxFocus(ttbLossItemSN);

                                //格式必須為正整數,且使用逗號隔開(例如:1,2,3)!!
                                throw new Exception(RuleMessage.Error.C10150());
                            }

                            //確認清單內是否已經加入
                            if (lossItemSNList.Contains(value) == false)
                            {
                                lossItemSNList.Add(value);
                            }
                        }
                    }

                    //排序
                    lossItemSNList.Sort();
                }

                var lotNo    = ttbLot.Text;
                var quantity = ttbQuantity.Text.ToCimesDecimal();

                #region 確認輸入的鍛造批號是否已建立資料
                var WMSMastBackData = CSTWMSMastBAKInfo.GetDataByLot(lotNo);
                if (WMSMastBackData != null)
                {
                    //鍛造批號:{0} 已存在,不可再執行入庫!
                    throw new Exception(RuleMessage.Error.C10095(lotNo));
                }

                var WMSMastData = CSTWMSMastInfo.GetMaterialLotDataByMaterialLot(lotNo);
                if (WMSMastData != null)
                {
                    //鍛造批號:{0} 已存在,不可再執行入庫!
                    throw new Exception(RuleMessage.Error.C10095(lotNo));
                }
                #endregion

                TransactionStamp txnStamp = new TransactionStamp(User.Identity.Name, ProgramRight, ProgramRight, ApplicationName);

                using (var cts = CimesTransactionScope.Create())
                {
                    var newMastData = InfoCenter.Create <CSTWMSMastInfo>();

                    //新增主檔
                    newMastData.Lot        = lotNo;
                    newMastData.DeviceName = ttbDevice.Text;
                    newMastData.RuleName   = _ProgramInformationBlock.ProgramRight;

                    newMastData.InsertToDB(txnStamp.UserID, txnStamp.RecordTime);

                    int itemSN = 1;

                    //新增明細檔
                    for (int i = 0; i < quantity; i++)
                    {
                        var newMastDetailData = InfoCenter.Create <CSTWMSDetailInfo>();

                        //確認必須排除的號碼
                        for (int j = 0; j < lossItemSNList.Count; j++)
                        {
                            if (lossItemSNList[j] == itemSN)
                            {
                                itemSN++;
                            }
                        }

                        newMastDetailData.Lot         = lotNo;
                        newMastDetailData.ComponentID = string.Format("{0}-{1:000}", lotNo, itemSN);
                        newMastDetailData.Quantity    = 1;

                        newMastDetailData.InsertToDB(txnStamp.UserID, txnStamp.RecordTime);

                        itemSN++;
                    }

                    cts.Complete();
                }

                ClearField();
                AjaxFocus(ttbLot);

                _ProgramInformationBlock.ShowMessage(TextMessage.Hint.T00614(""));
            }
            catch (Exception ex)
            {
                HandleError(ex);
            }
        }