예제 #1
0
        /// <summary>
        /// 產生PDF檔案
        /// </summary>
        private void RrintToPDF()
        {
            // 匯出檔名的設定
            string sReportFileName  = @"\rpt\T022_rpt.rpt";
            string sMapPath         = Server.MapPath("");
            string sHost            = Request.Url.Host;
            string sApplicationPath = Request.ApplicationPath;
            string reportID         = DBCenter.GetSystemID();

            string sExportFileName = Server.MapPath("../../") + @"PDF\T022_rpt" + reportID + ".pdf";
            string strPath         = sMapPath + sReportFileName;
            string ReportPath      = "http://" + sHost + sApplicationPath + "/PDF/T022_rpt" + reportID + ".pdf";

            DataSet dsLot = (DataSet)Session["T022View"];

            rptdoc = new CrystalDecisions.CrystalReports.Engine.ReportDocument();

            rptdoc.Load(strPath);
            rptdoc.SetDataSource(dsLot);

            // 設定匯出路徑及檔名
            DiskFileDestinationOptions df = new DiskFileDestinationOptions();

            df.DiskFileName = sExportFileName;
            rptdoc.ExportOptions.ExportDestinationType = CrystalDecisions.Shared.ExportDestinationType.DiskFile;
            rptdoc.ExportOptions.ExportFormatType      = CrystalDecisions.Shared.ExportFormatType.PortableDocFormat;
            rptdoc.ExportOptions.DestinationOptions    = df;
            rptdoc.Export();
            rptdoc.Dispose();

            //打開文件
            Response.Write("<script>window.open('" + ReportPath + "','_blank','resizable,scrollbars=no,menubar=no,toolbar=no,location=no,status=no',false);</script> ");

            Response.Write("<script>window.close();</script>");
        }
예제 #2
0
        protected void btnTempSave_Click(object sender, EventArgs e)
        {
            try
            {
                if (_DeviceName.IsNullOrEmpty())
                {
                    throw new RuleCimesException(TextMessage.Error.T00826(lblDeviceName.Text));
                }

                if (_PackingList.Count == 0 && _RelativePackingList.Count == 0)
                {
                    throw new RuleCimesException(TextMessage.Error.T00826(lblWorkpiece.Text));
                }

                var txnStamp = new TransactionStamp(User.Identity.Name, ProgramRight, ProgramRight, ApplicationName);
                using (var cts = CimesTransactionScope.Create())
                {
                    //刪除舊的資料
                    if (!_BatchID.IsNullOrEmpty())
                    {
                        DBCenter.ExecuteParse("DELETE CST_WIP_PACK_TEMP WHERE BATCHID = #[STRING]", _BatchID);
                    }
                    //產生新的批次ID
                    _BatchID = DBCenter.GetSystemID();
                    _PackingList.ForEach(p =>
                    {
                        var tempInfo         = InfoCenter.Create <CSTWIPPackTempInfo>();
                        tempInfo.DeviceName  = _DeviceName;
                        tempInfo.ComponentID = p.ComponentID;
                        tempInfo.SIDE        = "L";
                        tempInfo.BatchID     = _BatchID;
                        tempInfo.InsertToDB(txnStamp.UserID, txnStamp.RecordTime);
                    });
                    _RelativePackingList.ForEach(p =>
                    {
                        var tempInfo         = InfoCenter.Create <CSTWIPPackTempInfo>();
                        tempInfo.DeviceName  = _RelativeDeviceName;
                        tempInfo.ComponentID = p.ComponentID;
                        tempInfo.SIDE        = "R";
                        tempInfo.BatchID     = _BatchID;
                        tempInfo.InsertToDB(txnStamp.UserID, txnStamp.RecordTime);
                    });
                    //工時
                    _UserWorkTimeList.ForEach(p => {
                        p.InsertToDB(txnStamp.UserID, txnStamp.RecordTime);
                    });
                    _UserWorkTimeList.Clear();
                    cts.Complete();
                }

                ProgramInformationBlock1.ShowMessage(TextMessage.Hint.T00057(GetUIResource("TempSave")));
            }
            catch (Exception ex)
            {
                HandleError(ex);
            }
        }
예제 #3
0
        protected void btnOK_Click(object sender, EventArgs e)
        {
            try
            {
                ttbEquipmentName.Must(lblEquipment);
                ttbDevice1.Must(lblDevice1);

                //料號1一定要有資料
                if (_DeviceInfo1 == null)
                {
                    throw new RuleCimesException(TextMessage.Error.T00826(lblDevice1.Text));
                }

                //一定要輸入一種料號
                if (_dtVerifiy1 == null)
                {
                    throw new RuleCimesException(TextMessage.Error.T00826(lblDevice1.Text));
                }

                //若有輸入料號1則需驗證應領數量與領用數量是否相同
                if (_dtVerifiy1 != null)
                {
                    _dtVerifiy1.Rows.LoopDo <DataRow>((p, i) =>
                    {
                        if (p["NEEDQTY"].ToDecimal() != p["EQPTOOLCOUNT"].ToDecimal())
                        {
                            throw new RuleCimesException(RuleMessage.Error.C10141(_EquipmentInfo.EquipmentName, _DeviceInfo1.DeviceName, p["TOOLTYPE"].ToString(), p["NEEDQTY"].ToString()));
                        }
                    });
                }

                //若有輸入料號2則需驗證應領數量與領用數量是否相同
                if (_dtVerifiy2 != null)
                {
                    _dtVerifiy2.Rows.LoopDo <DataRow>((p, i) =>
                    {
                        if (p["NEEDQTY"].ToDecimal() != p["EQPTOOLCOUNT"].ToDecimal())
                        {
                            throw new RuleCimesException(RuleMessage.Error.C10141(_EquipmentInfo.EquipmentName, _DeviceInfo1.DeviceName, p["TOOLTYPE"].ToString(), p["NEEDQTY"].ToString()));
                        }
                    });
                }

                string           sReleaseID = DBCenter.GetSystemID();
                TransactionStamp txnStamp   = new TransactionStamp(User.Identity.Name, ProgramRight, ProgramRight, ApplicationName);
                using (var cts = CimesTransactionScope.Create())
                {
                    //先將舊的資料刪除
                    var lstEqpToolRelease = CSTEquipmentToolReleaseInfo.GetDataByEquipment(_EquipmentInfo.EquipmentName);
                    lstEqpToolRelease.ForEach(p => {
                        p.DeleteFromDB();
                        LogCenter.LogToDB(p, LogCenter.LogIndicator.Create(ActionType.Remove, txnStamp.UserID, txnStamp.RecordTime));
                    });

                    var lstEqpTool = EquipToolInfo.GetByEquipmentName(_EquipmentInfo.EquipmentName);
                    lstEqpTool.ForEach(p => {
                        //取得配件資訊
                        var toolInfo = ToolInfo.GetToolByName(p.ToolName);
                        //新增至CST_EQP_TOOL_RELEASE的Info物件
                        var eqpToolReleaseInfo           = InfoCenter.Create <CSTEquipmentToolReleaseInfo>();
                        eqpToolReleaseInfo.EquipmentName = _EquipmentInfo.EquipmentName;
                        eqpToolReleaseInfo.ToolName      = toolInfo.ToolName;
                        eqpToolReleaseInfo.HEAD          = toolInfo["HEAD"].ToString();
                        eqpToolReleaseInfo.RELEASEID     = sReleaseID;
                        eqpToolReleaseInfo["OPERATION"]  = toolInfo.UserDefineColumn08;
                        eqpToolReleaseInfo.InsertToDB(txnStamp.UserID, txnStamp.RecordTime);
                        LogCenter.LogToDB(eqpToolReleaseInfo, LogCenter.LogIndicator.Create(ActionType.Add, txnStamp.UserID, txnStamp.RecordTime));
                        //異動Tool的RELEASEID欄位
                        TMSTransaction.ModifyToolSystemAttribute(toolInfo, "RELEASEID", sReleaseID, txnStamp);
                    });

                    //先將舊的資料刪除
                    var lstEqpDeviceRelease = CSTEquipmentDeviceReleaseInfo.GetDataByEquipment(_EquipmentInfo.EquipmentName);
                    lstEqpDeviceRelease.ForEach(p => {
                        p.DeleteFromDB();
                        LogCenter.LogToDB(p, LogCenter.LogIndicator.Create(ActionType.Remove, txnStamp.UserID, txnStamp.RecordTime));
                    });

                    if (_dtVerifiy1 != null)
                    {
                        //新增至CST_EQP_DEVICE_RELEASE的Info物件
                        var eqpDeviceReleaseInfo = InfoCenter.Create <CSTEquipmentDeviceReleaseInfo>();
                        eqpDeviceReleaseInfo.EquipmentName = _EquipmentInfo.EquipmentName;
                        eqpDeviceReleaseInfo.DeviceName    = _DeviceInfo1.DeviceName;
                        eqpDeviceReleaseInfo.RELEASEID     = sReleaseID;
                        eqpDeviceReleaseInfo.InsertToDB(txnStamp.UserID, txnStamp.RecordTime);
                        LogCenter.LogToDB(eqpDeviceReleaseInfo, LogCenter.LogIndicator.Create(ActionType.Add, txnStamp.UserID, txnStamp.RecordTime));
                    }

                    if (_dtVerifiy2 != null)
                    {
                        //新增至CST_EQP_DEVICE_RELEASE的Info物件
                        var eqpDeviceReleaseInfo = InfoCenter.Create <CSTEquipmentDeviceReleaseInfo>();
                        eqpDeviceReleaseInfo.EquipmentName = _EquipmentInfo.EquipmentName;
                        eqpDeviceReleaseInfo.DeviceName    = _DeviceInfo2.DeviceName;
                        eqpDeviceReleaseInfo.RELEASEID     = sReleaseID;
                        eqpDeviceReleaseInfo.InsertToDB(txnStamp.UserID, txnStamp.RecordTime);
                        LogCenter.LogToDB(eqpDeviceReleaseInfo, LogCenter.LogIndicator.Create(ActionType.Add, txnStamp.UserID, txnStamp.RecordTime));
                    }
                    cts.Complete();
                }

                ((ProgramInformationBlock)ProgramInformationBlock1).ShowMessage(TextMessage.Hint.T00057(GetUIResource("ToolVerifiy")));
                ClearField();
                AjaxFocus(ttbEquipmentName);
            }
            catch (Exception ex)
            {
                HandleError(ex);
            }
        }
예제 #4
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);
            }
        }
예제 #5
0
        /// <summary>
        /// 確認
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnOK_Click(object sender, EventArgs e)
        {
            try
            {
                //確認是否輸入機台
                ttbEquipment.Must(lblEquipment);

                int checkedCount = 0;

                #region 確認是否有勾選資料
                for (int i = 0; i < gvQuery.Rows.Count; i++)
                {
                    var thisCheckBox = (CheckBox)gvQuery.Rows[i].FindControl("ckbSelect");
                    if (thisCheckBox.Checked)
                    {
                        checkedCount++;
                    }
                }

                if(checkedCount == 0)
                {
                    // [00816]請至少選取一個{0}!
                    throw new Exception(TextMessage.Error.T00816(GetUIResource("ToolName")));
                }
                #endregion

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

                using (var cts = CimesTransactionScope.Create())
                {
                    //新的群組ID
                    string newGroupID = DBCenter.GetSystemID();

                    for (int i = 0; i < gvQuery.Rows.Count; i++)
                    {
                        var thisCheckBox = (CheckBox)gvQuery.Rows[i].FindControl("ckbSelect");

                        //只有勾選的刀具才要下機
                        if (thisCheckBox.Checked)
                        {
                            //因刀具報表需求,所以在下機時要將當下的使用次數記錄在UDC07
                            var toolLifeList = CSTToolLifeInfo.GetToolLifeByToolNmae(_ToolList[i].ToolName);
                            var toolLife = toolLifeList.Find(p => p.Head == _ToolList[i].Head);
                            TMSTransaction.ModifyToolSystemAttribute(_ToolList[i], "USERDEFINECOL07", toolLife.UseCount.ToCimesString(), txnStamp);

                            //因為下機後在tool_hist會沒有機台資訊,所以在下機前把機台資訊記到remark(刀具報表需要用到)
                            txnStamp.Remark = _EquipData.EquipmentName;
                            //刀具下機台
                            TMSTxn.Default.RemoveToolFromEquipment(_ToolList[i], _EquipData, txnStamp);

                            //變更刀具 GROUPID
                            TMSTransaction.ModifyToolSystemAttribute(_ToolList[i], "GROUPID", newGroupID, txnStamp);

                            //變更儲位為Hub
                            TMSTransaction.ModifyToolSystemAttribute(_ToolList[i], "Location", "Hub", txnStamp);

                            //取得刀具狀態資料
                            var newStateInfo = ToolStateInfo.GetToolStateByState("IDLE");
                            if (newStateInfo == null)
                            {
                                //刀具零組件狀態: {0}不存在,請至配件狀態維護新增此狀態!!
                                throw new Exception(RuleMessage.Error.C10149("IDLE"));
                            }

                            //變更配件狀態為USED
                            TMSTransaction.ChangeToolState(_ToolList[i], newStateInfo, txnStamp);
                        }
                    }

                    //依據機台編號資料刪除[CST_EQP_TOOL_RELEASE]
                    var lstEqpToolRelease = CSTEquipmentToolReleaseInfo.GetDataByEquipment(_EquipData.EquipmentName);
                    lstEqpToolRelease.ForEach(p => {
                        p.DeleteFromDB();
                        LogCenter.LogToDB(p, LogCenter.LogIndicator.Create(ActionType.Remove, txnStamp.UserID, txnStamp.RecordTime));
                    });

                    //依據機台編號資料刪除[CST_EQP_DEVICE_RELEASE]
                    var lstEqpDeviceRelease = CSTEquipmentDeviceReleaseInfo.GetDataByEquipment(_EquipData.EquipmentName);
                    lstEqpDeviceRelease.ForEach(p => {
                        p.DeleteFromDB();
                        LogCenter.LogToDB(p, LogCenter.LogIndicator.Create(ActionType.Remove, txnStamp.UserID, txnStamp.RecordTime));
                    });

                    cts.Complete();
                }

                ClearField();

                AjaxFocus(ttbEquipment);

                _ProgramInformationBlock.ShowMessage(TextMessage.Hint.T00614(""));
            }
            catch (Exception ex)
            {
                HandleError(ex);
            }
        }
예제 #6
0
        protected void btnOK_Click(object sender, EventArgs e)
        {
            try
            {
                ttbEquipment.Must(lblEquipment);
                ddlOperation.Must(lblOperation);
                csReason.Must(lblTakeReason);

                if (_TakeToolLifeList.Count == 0)
                {
                    // [00824]請新增[刀頭]!
                    throw new RuleCimesException(TextMessage.Error.T00824(lblMillHeader.Text));
                }

                string groupid  = DBCenter.GetSystemID();
                var    txnStamp = new TransactionStamp(User.Identity.Name, ProgramRight, ProgramRight, ApplicationName);
                using (var cts = CimesTransactionScope.Create())
                {
                    _TakeToolLifeList.ForEach(tool =>
                    {
                        // 變更GROUPID與HEAD系統屬性
                        // HEAD紀錄目前刀具使用的刀頭
                        // GROUPID紀錄目前綁定的刀具
                        var toolInfo       = ToolInfo.GetToolByName(tool.ToolName);
                        var modifyAttrList = new List <ModifyAttributeInfo>();
                        modifyAttrList.Add(ModifyAttributeInfo.CreateSystemAttributeInfo("GROUPID", groupid));
                        modifyAttrList.Add(ModifyAttributeInfo.CreateSystemAttributeInfo("HEAD", tool.Head));
                        modifyAttrList.Add(ModifyAttributeInfo.CreateSystemAttributeInfo("LOCATION", "Hub"));
                        //因刀具報表需求,所以在領用時要AddComment,並將刀面及使用次數記錄在UDC06 & UDC07
                        modifyAttrList.Add(ModifyAttributeInfo.CreateSystemAttributeInfo("USERDEFINECOL06", tool.Head));
                        modifyAttrList.Add(ModifyAttributeInfo.CreateSystemAttributeInfo("USERDEFINECOL07", tool.UseCount));
                        modifyAttrList.Add(ModifyAttributeInfo.CreateSystemAttributeInfo("USERDEFINECOL08", tool.Operation));
                        TMSTransaction.ModifyToolMultipleAttribute(toolInfo, modifyAttrList, txnStamp);

                        txnStamp.Remark             = "刀具領用";
                        var reasonCategory          = InfoCenter.GetBySID <ReasonCategoryInfo>(csReason.SelectedValue);
                        txnStamp.CategoryReasonCode = reasonCategory;
                        txnStamp.Description        = "";
                        TMSTransaction.AddToolComment(toolInfo, txnStamp);
                    });

                    // 寫入CSTToolIssue客製表
                    var toolIssueInfo = InfoCenter.Create <CSTToolIssueInfo>();
                    toolIssueInfo.TOTALQTY      = _TakeToolLifeList.Count;
                    toolIssueInfo.Reason        = csReason.GetBusinessReason().ReasonCode;
                    toolIssueInfo.EquipmentName = _EquipmentInfo == null ? "" : _EquipmentInfo.EquipmentName;
                    toolIssueInfo.LinkSID       = txnStamp.LinkSID;
                    toolIssueInfo.Action        = "領用";
                    toolIssueInfo.InsertToDB(txnStamp.UserID, txnStamp.RecordTime);
                    cts.Complete();
                }

                ClearField();
                AjaxFocus(ttbMillName);

                ((ProgramInformationBlock)ProgramInformationBlock1).ShowMessage(TextMessage.Hint.T00057("領用"));
            }
            catch (Exception ex)
            {
                HandleError(ex);
            }
        }