Exemple #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);
            }
        }
Exemple #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)
                    {
                        _SelectLotDatas.ForEach(lot =>
                        {
                            //將勾選的入庫資料塞到ERP TEMP表 To do...

                            //將入庫單號回寫到INVNO
                            WIPTransaction.ModifyLotSystemAttribute(lot, "INVNO", ttbScrapNo.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);
            }
        }
Exemple #3
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);
            }
        }