Ejemplo n.º 1
0
 protected void btnAdd_Click(object sender, EventArgs e)
 {
     try
     {
         CurrentToolData = InfoCenter.Create <ToolInfoEx>();
         ClearData();
         EnableTab();
         ddlState.ClearSelection();
         var li = ddlState.Items.FindByText("IDLE");
         if (li == null)
         {
             throw new CimesException(GetUIResource("ToolInitialStateUnSet"));
         }
         li.Selected = true;
         ToolAttributeSetup.BindData("ToolCutterAttribute", CurrentToolData.ID);
         PMCounterSetupInterface.BindUserControl(PMSType.ToolID, CurrentToolData.ID);
         //UserDefineColumnSet1.SetControl(BindType.Tool, null);
         btnSave.Visible   = true;
         btnCancel.Visible = true;
         Action            = "A";
     }
     catch (Exception ex)
     {
         HandleError(ex);
     }
 }
Ejemplo n.º 2
0
        private void InsertToolType(int rowIndex)
        {
            int         index     = gvQuery.Rows[rowIndex].DataItemIndex;
            ArrayList   SaveList  = new ArrayList();
            string      sToolType = ((TextBox)gvQuery.Rows[rowIndex].FindControl("ttbType")).Text;
            RadioButton rbtEnable = (RadioButton)gvQuery.Rows[rowIndex].FindControl("rbEnable");
            TextBox     ttbDescr  = (TextBox)gvQuery.Rows[rowIndex].FindControl("ttbDescription");

            //檢查是否有相同名稱存在的資料
            sql = "SELECT 1 FROM MES_TOOL_TYPE WHERE TYPE = #[STRING]";
            DataView dvCheck = DBCenter.GetDataTable(sql, sToolType).DefaultView;// Query.DoQuery(sql);

            if (dvCheck != null && dvCheck.Count > 0)
            {
                throw new Exception(TextMessage.Error.T00710(sToolType));
            }

            uscAttributeSetupGrid.ValidateCheck();
            //新增資料庫
            ToolTypeInfo toolTypeData = InfoCenter.Create <ToolTypeInfo>();

            toolTypeData.Type          = sToolType;
            toolTypeData.Description   = ttbDescr.Text;
            toolTypeData["TOOLCLASS"]  = "CUTTER";
            toolTypeData["UPDATETIME"] = DBCenter.GetSystemTime();
            toolTypeData["USERID"]     = this.User.Identity.Name;
            if (rbtEnable.Checked == true)
            {
                toolTypeData.Status     = "Enable";
                toolTypeData.ActiveFlag = "T";
            }
            else
            {
                toolTypeData.Status     = "Disable";
                toolTypeData.ActiveFlag = "F";
            }

            //儲存系統屬性
            _SystemAttribute.SaveSystemAttribute(toolTypeData);
            TransactionStamp txnStamp = new TransactionStamp(User.Identity.Name, ProgramRight, ProgramRight, this.ApplicationName);

            using (CimesTransactionScope cts = CimesTransactionScope.Create())
            {
                toolTypeData.InsertToDB();
                uscAttributeSetupGrid.ExcuteTransaction(toolTypeData.ID);

                //儲存刀壽
                SaveToolLife(sToolType, txnStamp.UserID, txnStamp.RecordTime);

                //儲存刀具圖檔
                SaveToolPicture(sToolType, txnStamp.UserID, txnStamp.RecordTime);

                cts.Complete();
            }

            _ProgramInformationBlock.ShowMessage(TextMessage.Hint.T00695(sToolType));
            ToolTypeList[index] = toolTypeData;
        }
Ejemplo n.º 3
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);
            }
        }
Ejemplo n.º 4
0
        protected void btnCopy_Click(object sender, EventArgs e)
        {
            try
            {
                //取得登入者資訊
                var recordTime = DBCenter.GetSystemTime();
                var userID     = User.Identity.Name;

                //確認目標料號及機台編號是否已經存在資料
                var toolDevices = CSTToolDeviceInfo.GetDataListByDeviceAndEquipmantName(ddlDevice.SelectedItem.Value, ddlEquipment.SelectedItem.Value);
                if (toolDevices.Count > 0)
                {
                    //料號({0})及機台({1}) 資料已存在,不可執行複製動作!
                    throw new Exception(RuleMessage.Error.C10117(ddlDevice.SelectedItem.Value, ddlEquipment.SelectedItem.Value));
                }

                using (var cts = CimesTransactionScope.Create())
                {
                    //新增一筆CST_TOOL_DEVICE資料
                    var toolDevice = InfoCenter.Create <CSTToolDeviceInfo>();
                    toolDevice.DeviceName    = ddlDevice.SelectedItem.Value;
                    toolDevice.EquipmentName = ddlEquipment.SelectedItem.Value;
                    toolDevice.Tag           = 1;

                    toolDevice.InsertToDB(userID, recordTime);
                    LogCenter.LogToDB(toolDevice, LogCenter.LogIndicator.Create(ActionType.Add, userID, recordTime));

                    //複製CST_TOOL_DEVICE_DETAIL資料
                    _ToolDeviceDetails.ForEach(toolDeviceDetail =>
                    {
                        var newToolDeviceDetail           = InfoCenter.Create <CSTToolDeviceDetailInfo>();
                        newToolDeviceDetail.EquipmentName = toolDevice.EquipmentName;
                        newToolDeviceDetail.Quantity      = toolDeviceDetail.Quantity;
                        newToolDeviceDetail.DeviceName    = toolDevice.DeviceName;
                        newToolDeviceDetail.ToolType      = toolDeviceDetail.ToolType;
                        newToolDeviceDetail.ToolDeviceSID = toolDevice.ToolDeviceSID;

                        newToolDeviceDetail.InsertToDB();

                        LogCenter.LogToDB(newToolDeviceDetail, LogCenter.LogIndicator.Create(ActionType.Add, userID, recordTime));
                    });

                    cts.Complete();
                }

                //INF-00002:{0}儲存成功!
                _ProgramInformationBlock.ShowMessage(TextMessage.Hint.T00083(""), MessageShowOptions.OnLabel);

                LoadControlDefault();
            }
            catch (Exception E)
            {
                HandleError(E);
            }
        }
Ejemplo n.º 5
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);
            }
        }
Ejemplo n.º 6
0
        protected void btnAdd_Click(object sender, EventArgs e)
        {
            try
            {
                //確認是否有選擇刀具類別
                ddlToolType.Must(lblToolType);
                ddlOperation.Must(lblOperation);

                //確認選擇刀具類別是否已新增
                _ModifyToolDeviceDetails.ForEach(toolDeviceDetail =>
                {
                    if (toolDeviceDetail.ToolType == ddlToolType.SelectedValue && toolDeviceDetail.OperationName == ddlOperation.SelectedValue)
                    {
                        //刀具類型:{0} 資料已存在!
                        throw new Exception(RuleMessage.Error.C10121(ddlToolType.SelectedValue));
                    }
                });

                //確認數量是否為整數
                ttbQuantity.MustInt(lblQuantity);

                //確數量是否大於零
                int value = Convert.ToInt32(ttbQuantity.Text);
                if (value <= 0)
                {
                    //[01397]數量必須大於零!
                    throw new Exception(TextMessage.Error.T01397());
                }

                //新增一筆資料
                var newToolDeviceDetail = InfoCenter.Create <CSTToolDeviceDetailInfo>();
                newToolDeviceDetail.EquipmentName = ttbEquipment.Text;
                newToolDeviceDetail.OperationName = ddlOperation.SelectedValue;
                newToolDeviceDetail.Quantity      = Convert.ToDecimal(ttbQuantity.Text);
                newToolDeviceDetail.DeviceName    = ttbDevice.Text;
                newToolDeviceDetail.ToolType      = ddlToolType.SelectedValue;

                //加入清單
                _ModifyToolDeviceDetails.Insert(0, newToolDeviceDetail);

                gvQuery.SetDataSource(_ModifyToolDeviceDetails, true);

                //清除資料
                ddlToolType.ClearSelection();
                ttbQuantity.Text = "";
            }
            catch (Exception E)
            {
                HandleError(E);
            }
        }
Ejemplo n.º 7
0
        public static void SaveQCData(string InspectionNo, QCType qcType, LotNonActiveInfo lot, EquipmentInfo equipment, string batchID, QCStatus status, string objectType, TransactionStamp txnStamp)
        {
            QCInspectionInfoEx inspection = null;

            var lotNonActiveInfoEx = lot.ChangeTo <LotNonActiveInfoEx>();

            #region 產生檢驗單
            inspection = InfoCenter.Create <QCInspectionInfo>().ChangeTo <QCInspectionInfoEx>();
            inspection.InspectionNo  = InspectionNo;
            inspection.QCTYPE        = qcType.ToCimesString();
            inspection.OperationName = lotNonActiveInfoEx.OperationName;
            inspection.EquipmentName = equipment.EquipmentName;
            inspection.DeviceName    = lotNonActiveInfoEx.DeviceName;
            inspection.BatchID       = batchID;
            inspection.Status        = status.ToCimesString();
            inspection.CreateUser    = txnStamp.UserID;
            inspection.CreateTime    = txnStamp.RecordTime;
            inspection.InsertToDB(txnStamp.UserID, txnStamp.RecordTime);
            #endregion

            if (inspection == null)
            {
                //檢驗單主檔沒有資料
                throw new Exception(TextMessage.Error.T00060("QCData"));
            }
            #region 產生檢驗單對象
            //新增一筆資料到MES_QC_INSP_OBJ
            var inspectionObject = InfoCenter.Create <QCInspectionObjectInfo>();
            if (inspectionObject.InfoState == InfoState.NewCreate)
            {
                inspectionObject.QC_INSP_SID = inspection.QC_INSP_SID;
                inspectionObject.ObjectType  = objectType;
                inspectionObject.OBJECTSID   = lotNonActiveInfoEx.ID;
                inspectionObject.ObjectName  = lotNonActiveInfoEx.Lot;
                //COMPLOT
                inspectionObject.ItemName1 = lotNonActiveInfoEx.ComponentLot;
                //WOLOT
                inspectionObject.ItemName2 = lotNonActiveInfoEx.WorkOrderLot;
                //MATERIALLOT
                inspectionObject.ItemName3 = lotNonActiveInfoEx.MaterialLot;
                //OP1機台
                inspectionObject.ItemName5 = lotNonActiveInfoEx.ProcessEquipment;
                inspectionObject.Quantity  = 1;
                inspectionObject.Unit      = lotNonActiveInfoEx.Unit;
                inspectionObject.InsertToDB(txnStamp.UserID, txnStamp.RecordTime);
            }
            #endregion
        }
Ejemplo n.º 8
0
        /// <summary>
        /// 新增一筆刀壽設定資料
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnToolLifeAdd_Click(object sender, System.EventArgs e)
        {
            try
            {
                //確認供應商是否有選擇
                ddlSupplier.Must(lblSupplier);

                //確認刀壽是否為正整數
                ttbToolLifeCount.MustInt(lblToolLifeCount);
                int lifeCount = Convert.ToInt32(ttbToolLifeCount.Text);
                if (lifeCount <= 0)
                {
                    //[00916]輸入值必須為數字且必須大於等於0!!
                    throw new Exception(TextMessage.Error.T00916());
                }

                //確認供應商資料是否已經新增
                _ModifyToolTypeLifes.ForEach(toolTypeLife =>
                {
                    if (toolTypeLife.Supplier == ddlSupplier.SelectedItem.Text)
                    {
                        //供應商:{0} 資料已存在!
                        throw new Exception(RuleMessage.Error.C10120(ddlSupplier.SelectedItem.Text));
                    }
                });

                //新增一筆刀壽資料
                var newToolLife = InfoCenter.Create <CSTToolTypeLifeInfo>();
                newToolLife.Supplier = ddlSupplier.SelectedItem.Text;
                newToolLife.Life     = Convert.ToDecimal(ttbToolLifeCount.Text);
                newToolLife.ToolType = _ToolType;

                _ModifyToolTypeLifes.Insert(0, newToolLife);

                gvToolLife.SetDataSource(_ModifyToolTypeLifes, true);

                //清除資料
                ddlSupplier.ClearSelection();
                ttbToolLifeCount.Text = "";
            }
            catch (Exception ex)
            {
                HandleError(ex, CurrentUpdatePanel, string.Empty, MessageShowOptions.OnLabel);
            }
        }
Ejemplo n.º 9
0
        /// <summary>
        /// 檢查PPK是否完成,true: 表示完成、false: 表示未完成
        /// </summary>
        /// <param name="equipmentName"></param>
        /// <param name="deviceName"></param>
        /// <param name="deviceVersion"></param>
        /// <returns></returns>
        public static void UpdatePPK(string equipmentName, string deviceName, decimal deviceVersion, string resultFlag = null, string updateStatus = null)
        {
            //取得PPK資料
            var ppkData         = CSTWipPPKInfo.GetPPKDataByEqpAndDevice(equipmentName, deviceName);
            var deviceVerExData = DeviceVersionInfo.GetDeviceVersion(deviceName, deviceVersion).ChangeTo <DeviceVersionInfoEx>();

            if (ppkData == null)
            {
                #region 新增PPK資料
                var ppkItem = InfoCenter.Create <CSTWipPPKInfo>();
                ppkItem.EquipmentName = equipmentName;
                ppkItem.DeviceName    = deviceName;
                ppkItem.Status        = "NonActive";
                ppkItem.PPKCOUNT      = deviceVerExData.PPKCount - 1;
                ppkItem.InsertToDB();
                #endregion
            }
            else
            {
                //PPKCount不等於0,Count - 1
                if (ppkData.PPKCOUNT != 0)
                {
                    ppkData.PPKCOUNT = ppkData.PPKCOUNT - 1;
                }
                else
                {
                    if (resultFlag != null)
                    {
                        //檢驗結果
                        if (resultFlag.ToBool())
                        {
                            ppkData.Status = "Active";
                        }
                        else
                        {
                            //回壓PPKConut為初始化
                            ppkData.PPKCOUNT = deviceVerExData.PPKCount;
                        }
                    }
                }

                ppkData.UpdateToDB();
            }
        }
Ejemplo n.º 10
0
        protected void btnAdd_Click(object sender, System.EventArgs e)
        {
            try
            {
                if (ToolTypeList == null)
                {
                    ToolTypeList = new List <ToolTypeInfo>();
                }
                //若第一筆資料模式仍是新增,則不再新增空白列
                if (ToolTypeList.Count > 0)
                {
                    if (ToolTypeList[0].InfoState == InfoState.NewCreate)
                    {
                        return;
                    }
                }

                //取得路徑對應清單
                _SavePicturedData = GetExtendItemListByClass("SAIToolTypeImage");

                //新增一筆空白在第一列
                gvQuery.CurrentPageIndex = 0;

                ToolTypeList.Insert(0, InfoCenter.Create <ToolTypeInfo>());
                gvQuery.SetDataSource(ToolTypeList, true);
                gvQuery.EditItemIndex = 0;
                gvQuery.DataBind();

                uscAttributeSetupGrid.BindData("ToolTypeAttribute", "");

                //顯示系統屬性
                _SystemAttribute.LoadSystemAttribute(ToolTypeList[0], "ToolCutterTypeSystemAttribute");

                EnableSubControl();

                //初始化刀壽及圖檔設定資料
                LoadControlDefaultToolLifeAndPicture("");
            }
            catch (Exception ex)
            {
                HandleError(ex, CurrentUpdatePanel, string.Empty, MessageShowOptions.OnLabel);
            }
        }
Ejemplo n.º 11
0
        /// <summary>
        /// 依據傳入批號資料及工作站來更新預約資料
        /// </summary>
        /// <param name="txnLotData"></param>
        /// <param name="operationName"></param>
        /// <param name="txnStamp"></param>
        public void UpdateReserveCheckInData(LotInfoEx txnLotData, string operationName, TransactionStamp txnStamp)
        {
            //取得預約資料
            var WIPReserveList = CSTWIPReserveCheckInInfo.GetDataByLotAndOper(txnLotData.Lot, operationName);

            WIPReserveList.ForEach(reserveData =>
            {
                //記錄出站時間
                reserveData.OutTime = DBCenter.GetSystemTime();

                //記錄LOG
                CSTWIPReserveCheckInLogInfo reserveDataLog = InfoCenter.Create <CSTWIPReserveCheckInLogInfo>();
                reserveDataLog         = reserveData.Fill <CSTWIPReserveCheckInLogInfo>();
                reserveDataLog.LinkSID = txnStamp.LinkSID;

                reserveData.DeleteFromDB();
                reserveDataLog.InsertToDB();
            });
        }
Ejemplo n.º 12
0
        /// <summary>
        /// 系統事件 : btnPrint Click時觸發
        /// 將產生的ReportDocument 匯出成為PDF格式的檔案
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnPrint_Click(object sender, EventArgs e)
        {
            try
            {
                if (toolData == null)
                {
                    throw new Exception(TextMessage.Error.T00060(""));
                }
                _dsReport.Tables.Clear();

                // 取得Report資料
                _dsReport = GetRunCardDataSource(toolData);
                _dsReport.AcceptChanges();

                TransactionStamp txnStamp = new TransactionStamp(User.Identity.Name, ProgramRight, ProgramRight, ApplicationName);
                using (var cts = CimesTransactionScope.Create())
                {
                    var printLotInfo = InfoCenter.Create <CSTToolLabelPrintLogInfo>();
                    printLotInfo.ToolName = toolData.ToolName;
                    printLotInfo.RuleName = ProgramRight;
                    printLotInfo.InsertToDB(txnStamp.UserID, txnStamp.RecordTime);
                    cts.Complete();
                }

                if (_dsReport.Tables.Count > 0)
                {
                    string sPrintProgram    = "/CustomizeRule/ToolRule/T022View.aspx";
                    string sHost            = Request.Url.Host;
                    string sApplicationPath = Request.ApplicationPath;
                    string ReportPath       = "http://" + sHost + sApplicationPath + sPrintProgram;
                    Session["T022View"] = _dsReport;
                    //開啟查詢工單頁面
                    string openPrintWindow = "window.open('" + ReportPath + "','pop','resizable: yes; status: no; scrollbars:no; menubar:no;toolbar:no;location:no;dialogLeft:10px;dialogTop:10px;dialogHeight:10px;dialogWidth:10px',false);";
                    ScriptManager.RegisterStartupScript(UpdatePanel1, UpdatePanel1.GetType(), Guid.NewGuid().ToString(), openPrintWindow, true);
                }
            }
            catch (Exception E)
            {
                HandleError(E);
            }
        }
Ejemplo n.º 13
0
        /// <summary>
        /// 取得預約工作站資料
        /// </summary>
        private void GetReserveCheckInData()
        {
            //如果批號狀態為Wait,表示第一次進站
            if (_LotData.Status == LotDefaultStatus.Wait.ToString())
            {
                //檢查批號目前規則是否與使用程式名稱一樣
                if (_LotData.CurrentRuleName != ProgramRight)
                {
                    //該批號作業為{0},不為此功能,請遵循作業規範
                    throw new Exception(RuleMessage.Error.C10004(_LotData.CurrentRuleName));
                }
            }
            else if (_LotData.Status == LotDefaultStatus.Run.ToString())
            {
                var reserveFlag = WpcExClassItemInfo.GetExtendItemListByClassAndRemarks("SAIReserve").Find(p => p.Remark01 == _LotData.Process);

                //如果批號狀態為Run,且有設定允許預約進站,則開始取得預約站點資訊
                if (reserveFlag != null)
                {
                    //取得預約工作站的序號
                    var nextOperationSequence = CustomizeFunction.GetAppointmentOperationSequence(_LotData.Lot, ProgramRight);

                    //取得預約工作站名稱
                    var operationName = CustomizeFunction.GetAppointmentOperationName(_LotData, nextOperationSequence);

                    //取得預約工作站的第一個RuleName
                    var firstRuleName = CustomizeFunction.GetFirstOperationTypeRuleByOperationName(_LotData, operationName, ProgramRight);

                    //新增一筆預約資料
                    _WIPReserveCheckInData               = InfoCenter.Create <CSTWIPReserveCheckInInfo>();
                    _WIPReserveCheckInData.Lot           = _LotData.Lot;
                    _WIPReserveCheckInData.OperationName = operationName;
                    _WIPReserveCheckInData.RuleName      = firstRuleName;
                }
                else
                {
                    throw new CimesException(TextMessage.Error.T00356(_LotData.Lot));
                }
            }
        }
Ejemplo n.º 14
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);
            }
        }
Ejemplo n.º 15
0
        protected void btnOK_Click(object sender, EventArgs e)
        {
            try
            {
                // 子單元不存在拋錯
                if (ComponentInfo == null)
                {
                    throw new RuleCimesException(TextMessage.Error.T00045(GetUIResource("Component")));
                }
                // 批號不存在拋錯
                if (ProcessLotData == null)
                {
                    throw new RuleCimesException(TextMessage.Error.T00045(GetUIResource("Lot")));
                }
                // 定義交易戳記
                var txnStamp = new TransactionStamp(User.Identity.Name, ProgramRight, ProgramRight, ApplicationName);
                using (var cts = CimesTransactionScope.Create())
                {
                    bool inSpec = true;
                    if (_CenterHoleFlag != "N")
                    {
                        gvComponentEDC.Rows.LoopDo <GridViewRow>((p, i) => {
                            // 取得TextBox Control
                            var ttbEDC = p.FindControl("ttbEDC") as TextBox;
                            if (ttbEDC.Text.IsNullOrEmpty())
                            {
                                throw new RuleCimesException(TextMessage.Error.T00043(GetUIResource("CenterHoleData")));
                            }
                            // 是否符合規格判斷
                            var measureVal = ttbEDC.Text.ToDecimal();
                            if (measureVal > SAICenterHole.Remark02.ToDecimal())
                            {
                                inSpec = false;
                            }

                            if (measureVal < SAICenterHole.Remark03.ToDecimal())
                            {
                                inSpec = false;
                            }
                            // 將量測資料記錄到客製表
                            var edcCompInfo              = InfoCenter.Create <CSTEDCComponentInfo>();
                            edcCompInfo.ComponentID      = ComponentInfo.ComponentID;
                            edcCompInfo.Data             = measureVal;
                            edcCompInfo.UpSpecification  = SAICenterHole.Remark02.ToDecimal();
                            edcCompInfo.LowSpecification = SAICenterHole.Remark03.ToDecimal();
                            edcCompInfo.INSPEC           = inSpec == true ? "OK" : "NG";
                            edcCompInfo.Lot              = ProcessLotData.Lot;
                            edcCompInfo["LINKSID"]       = txnStamp.LinkSID;
                            edcCompInfo["PARAMETER"]     = "SC" + (i + 1).ToString();
                            edcCompInfo.InsertToDB(txnStamp.UserID, txnStamp.RecordTime);
                        });
                    }

                    if (!ttbTemperature.Text.IsNullOrEmpty())
                    {
                        // 溫度必須是數值
                        ttbTemperature.MustDecimal(lblTemperature);
                        // 將量測資料記錄到客製表
                        var edcCompInfo = InfoCenter.Create <CSTEDCComponentInfo>();
                        edcCompInfo.ComponentID  = ComponentInfo.ComponentID;
                        edcCompInfo.Data         = ttbTemperature.Text.ToDecimal();
                        edcCompInfo.Lot          = ProcessLotData.Lot;
                        edcCompInfo["LINKSID"]   = txnStamp.LinkSID;
                        edcCompInfo["PARAMETER"] = "Temperature";
                        edcCompInfo.InsertToDB(txnStamp.UserID, txnStamp.RecordTime);
                    }

                    var lstCompAttr = new List <ModifyAttributeInfo>();
                    // 紀錄子單元量測時間
                    lstCompAttr.Add(ModifyAttributeInfo.CreateSystemAttributeInfo("CENTER_HOLE_TIME", txnStamp.RecordTime));
                    lstCompAttr.Add(ModifyAttributeInfo.CreateSystemAttributeInfo("DMC", ttbWorkpiece.Text.Trim()));
                    if (inSpec)
                    {
                        // 修改子單元系統屬性
                        lstCompAttr.Add(ModifyAttributeInfo.CreateSystemAttributeInfo("CENTER_HOLE_FLAG", "OK"));
                        WIPTransaction.ModifyLotComponentMultipleAttribute(ProcessLotData, ComponentInfo, lstCompAttr, txnStamp);
                    }
                    else
                    {
                        // 修改子單元系統屬性
                        lstCompAttr.Add(ModifyAttributeInfo.CreateSystemAttributeInfo("CENTER_HOLE_FLAG", "NG"));
                        WIPTransaction.ModifyLotComponentMultipleAttribute(ProcessLotData, ComponentInfo, lstCompAttr, txnStamp);

                        #region 若不在規格範圍內則拆批至待判站點
                        var                  lstSourceLot         = new List <LotInfo>();
                        List <SqlAgent>      splitLotArchiSQLList = new List <SqlAgent>();
                        List <ComponentInfo> lsComponentDatas     = new List <ComponentInfo>();
                        lsComponentDatas.Add(ComponentInfo);

                        var generator = NamingIDGenerator.GetRule("SplitLot");
                        if (generator == null)
                        {
                            //WRN-00411,找不到可產生的序號,請至命名規則維護設定,規則名稱:{0}!!!
                            throw new Exception(TextMessage.Error.T00437("SplitLot"));
                        }
                        var serialData = generator.GenerateNextIDs(1, ProcessLotData, new string[] { }, User.Identity.Name);
                        splitLotArchiSQLList = serialData.Second;
                        var splitLotID = serialData.First[0];

                        var          reasonCategoryInfo = ReasonCategoryInfo.GetReasonCategoryByCategoryNameAndReason("Common", "OTHER");
                        SplitLotInfo splitLotData       = SplitLotInfo.CreateSplitLotByLotAndQuantity(ProcessLotData.Lot, splitLotID, lsComponentDatas, reasonCategoryInfo, "EDC");

                        WIPTxn.SplitIndicator splitInd = WIPTxn.SplitIndicator.Create();
                        WIPTxn.Default.SplitLot(ProcessLotData, splitLotData, splitInd, txnStamp);

                        //若子單元為自動產生,更新序號至DB
                        if (splitLotArchiSQLList != null && splitLotArchiSQLList.Count > 0)
                        {
                            DBCenter.ExecuteSQL(splitLotArchiSQLList);
                        }
                        #endregion

                        var splitLotInfo = LotInfo.GetLotByLot(splitLotID);

                        // 新增Defect
                        List <ComponentDefectObject> lstCompDefectObj = new List <ComponentDefectObject>();
                        var reason = ReasonCategoryInfo.GetReasonCategoryByCategoryNameAndReason("CustomizeReason", "MeasureNG_MES");
                        lstCompDefectObj.Add(ComponentDefectObject.Create(ComponentInfo, 1, 0, reason, "CENTER_HOLE_FLAG:NG"));
                        WIPTransaction.DefectComponent(splitLotInfo, lstCompDefectObj, WIPTransaction.DefectIndicator.Create(), txnStamp);

                        #region ReassignOperation
                        // 取得待判站點設定
                        var saiJudgeOperation = WpcExClassItemInfo.GetExClassItemInfo("SAIJudgeOperation", splitLotInfo["PROCESS"].ToString());
                        if (saiJudgeOperation.Count == 0)
                        {
                            throw new RuleCimesException(TextMessage.Error.T00555("SAIJudgeOperation", splitLotInfo["PROCESS"].ToString()));
                        }
                        var reassignOperationInfo = RouteOperationInfo.GetLotAllRouteOperations(splitLotInfo).Find(oper => oper.OperationName == saiJudgeOperation[0].Remark02);
                        if (reassignOperationInfo == null)
                        {
                            throw new RuleCimesException(RuleMessage.Error.C10050());
                        }

                        var lstLotAttr = new List <ModifyLotAttributeInfo>();
                        // 修改批號系統屬性
                        lstLotAttr.Add(ModifyLotAttributeInfo.CreateLotSystemAttributeInfo("USERDEFINECOL01", "Y"));
                        lstLotAttr.Add(ModifyLotAttributeInfo.CreateLotSystemAttributeInfo("USERDEFINECOL02", splitLotInfo.OperationSequence));
                        lstLotAttr.Add(ModifyLotAttributeInfo.CreateLotSystemAttributeInfo("USERDEFINECOL03", splitLotInfo.OperationName));
                        WIPTransaction.ModifyLotMultipleAttribute(splitLotInfo, lstLotAttr, txnStamp);
                        WIPTransaction.ReassignOperation(splitLotInfo, reassignOperationInfo, reasonCategoryInfo, "EDCSplitReassignOperation", txnStamp);
                        WIPTransaction.ResetLotRule(splitLotInfo, txnStamp);
                        #endregion
                    }
                    cts.Complete();
                }

                ClearUI();
                AjaxFocus(ttbWorkpiece);
            }
            catch (Exception ex)
            {
                HandleError(ex);
            }
        }
Ejemplo n.º 16
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);
            }
        }
Ejemplo n.º 17
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);

                //確認是否有選擇送待判原因
                ddlJudgeDefect.Must(lblJudgeDefect);

                #region 檢查判定結果是否有選擇
                if (rdbGoods.Checked == false && rdbRepair.Checked == false && rdbDefectInv.Checked == false && rdbScrapInv.Checked == false)
                {
                    throw new Exception(TextMessage.Error.T00841(lblJudgeResult.Text));
                }
                #endregion

                //檢查判定原因是否有選擇
                ddlJudgeReason.Must(lblJudgeReason);

                using (var cts = CimesTransactionScope.Create())
                {
                    #region 依照選擇的判定結果,對批號進行不同的處置

                    //選取的判定結果
                    string result = "";

                    //選取的原因碼
                    var reasonCategory = InfoCenter.GetBySID <ReasonCategoryInfo>(ddlJudgeReason.SelectedValue);

                    #region 良品:依照批號的UDC02(工作站序號)+UDC03(工作站名稱)找出預設流程的下一站點,將批號跳站至該站
                    if (rdbGoods.Checked)
                    {
                        result = "Good";

                        //取得流程線上版本 取得目前Lot的所有流程(所有工作站)
                        RouteVersionInfo RouteVersion = RouteVersionInfo.GetRouteActiveVersion(_LotData.RouteName);

                        //取得設定包裝工作站名稱
                        var packingOperation = WpcExClassItemInfo.GetExtendItemListByClassAndRemarks("SAIPackingOperation");
                        if (packingOperation.Count == 0)
                        {
                            //T00555:查無資料,請至系統資料維護新增類別{0}、項目{1}!
                            throw new CimesException(TextMessage.Error.T00555("SAIPackingOperation", ""));
                        }

                        var reassignOperation = packingOperation[0];

                        //如果送待判站之前記錄的是包裝站,則直接跳至包裝站,反之,跳至下一站
                        if (reassignOperation.Remark01 == _LotData.UserDefineColumn03)
                        {
                            //取得包裝站名稱
                            string qcOperationName = reassignOperation.Remark01;

                            //取得包裝工作站資訊
                            var operation = OperationInfo.GetOperationByName(qcOperationName);
                            if (operation == null)
                            {
                                //T00171, 工作站:{0}不存在!!
                                throw new CimesException(TextMessage.Error.T00171(qcOperationName));
                            }
                            //根據指定的流程名稱、流程版本、工作站名稱, 找出第一個符合的流程工作站,新的站點包裝
                            var newOperation = RouteOperationInfo.GetRouteOperationByOperationName(_LotData.RouteName, _LotData.RouteVersion, qcOperationName);

                            //將批號的UDC02清空
                            WIPTransaction.ModifyLotSystemAttribute(_LotData, "USERDEFINECOL02", "", txnStamp);

                            //將批號的UDC03清空
                            WIPTransaction.ModifyLotSystemAttribute(_LotData, "USERDEFINECOL03", "", txnStamp);

                            //變更至指定工作站
                            WIPTransaction.ReassignOperation(_LotData, newOperation, reasonCategory, ttbJudgeDescr.Text, txnStamp);
                        }
                        else
                        {
                            //以此工作站名稱去查詢在流程中的序號
                            var routeOperation = RouteOperationInfo.GetRouteAllOperations(RouteVersion).Find(p => p.OperationName == _LotData.UserDefineColumn03);

                            var lastOperationSeq = string.Format("{0:000}", (Convert.ToDecimal(routeOperation.OperationSequence) + 1));

                            //下一個工作站 用LOT和流程中下一站的序號去查出下一個工作站資訊
                            var NextRouteOperation = RouteOperationInfo.GetRouteOperationByLotSequence(_LotData, lastOperationSeq);

                            if (NextRouteOperation == null)
                            {
                                //批號:{0}已無下個工作站點,請確認[流程設定]
                                throw new Exception(RuleMessage.Error.C10008(_LotData.Lot));
                            }

                            //將批號的UDC02清空
                            WIPTransaction.ModifyLotSystemAttribute(_LotData, "USERDEFINECOL02", "", txnStamp);

                            //將批號的UDC03清空
                            WIPTransaction.ModifyLotSystemAttribute(_LotData, "USERDEFINECOL03", "", txnStamp);

                            WIPTransaction.ReassignOperation(_LotData, NextRouteOperation, reasonCategory, ttbJudgeDescr.Text, txnStamp);
                        }
                    }
                    #endregion

                    #region 維修:紀錄維修及將批號派送至下一規則
                    if (rdbRepair.Checked)
                    {
                        result = "Repair";

                        List <WIPRepairInfo> repairDatas = new List <WIPRepairInfo>();

                        var componentData = ComponentInfoEx.GetDataByCurrentLot(_LotData.Lot)[0];
                        var repairData    = WIPRepairInfo.CreateInfo(_LotData, componentData, componentData.ComponentQuantity, reasonCategory, _LotData.OperationName, _LotData.ResourceName, string.Empty, string.Empty);
                        repairDatas.Add(repairData);

                        var issueOperation = OperationInfo.GetOperationByName(_LotData.OperationName);

                        WIPTransaction.RepairAdd(_LotData, repairDatas, issueOperation, txnStamp);
                        WIPTransaction.DispatchLot(_LotData, txnStamp);
                    }
                    #endregion

                    #region  良品入庫:將批號狀態變更為DefectInv
                    if (rdbDefectInv.Checked)
                    {
                        result = "DefectInv";
                        WIPTransaction.ModifyLotSystemAttribute(_LotData, "STATUS", "DefectInv", txnStamp);
                    }
                    #endregion

                    #region 報廢品入庫:將批號狀態變更為ScrapInv
                    if (rdbScrapInv.Checked)
                    {
                        result = "ScrapInv";
                        WIPTransaction.ModifyLotSystemAttribute(_LotData, "STATUS", "ScrapInv", txnStamp);
                    }
                    #endregion

                    #endregion

                    #region 將判定結果紀錄在CST_WIP_DEFECT_JUDGEMENT,Result:良品(Goods)、維修(Repair)、不良品入庫(DefectInv)、報廢入庫(ScrapInv)

                    var insertData = InfoCenter.Create <CSTWIPDefectJudgementInfo>();

                    insertData.WIPDefectSID      = _LotDefectData.DefectSID;
                    insertData["REASONCATEGORY"] = reasonCategory.Category;
                    insertData["LOT"]            = _LotData.Lot;
                    insertData.Reason            = reasonCategory.Reason;
                    insertData.Result            = result;
                    insertData.Description       = ttbJudgeDescr.Text;
                    insertData.LinkSID           = WIPHistoryInfo.GetLotFirstHistory(_LotData.Lot).LinkSID;

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

                    #endregion

                    cts.Complete();
                }

                ttbLot.Text = "";

                ClearField();
                AjaxFocus(ttbLot);

                _ProgramInformationBlock.ShowMessage(TextMessage.Hint.T00614(""));
            }
            catch (Exception ex)
            {
                HandleError(ex);
            }
        }
Ejemplo n.º 18
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);
            }
        }
Ejemplo n.º 19
0
        /// <summary>
        /// 確定
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnOK_Click(object sender, EventArgs e)
        {
            try
            {
                #region 確認選擇結果,如果是選擇NG,確認是否有選擇原因碼
                string result = "";
                if (rdbOK.Checked)
                {
                    result = "OK";
                }
                else if (rdbNG.Checked)
                {
                    result = "NG";

                    //確認是否有選擇原因碼
                    ddlPQCReasonCode.Must(lblPQCReasonCode);
                }
                #endregion

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

                using (var cts = CimesTransactionScope.Create())
                {
                    #region 更新檢驗主檔[MES_QC_INSP]
                    //取得檢驗主檔資料
                    var QCInsepctionData = InfoCenter.GetBySID <QCInspectionInfo>(_SelectedQCData.QCInspectionSID).ChangeTo <QCInspectionInfoEx>();

                    //有選擇原因碼才更新[NG_Category]及[NG_Reason]
                    if (string.IsNullOrEmpty(ddlPQCReasonCode.SelectedValue) == false)
                    {
                        var reason = InfoCenter.GetBySID <ReasonCategoryInfo>(ddlPQCReasonCode.SelectedValue);
                        QCInsepctionData.NG_Category = reason.Category;
                        QCInsepctionData.NG_Reason   = reason.Reason;
                    }

                    QCInsepctionData.NG_Description = ttbDescr.Text;
                    QCInsepctionData.Result         = result;
                    QCInsepctionData.Status         = "Finished";

                    QCInsepctionData.UpdateToDB(txnStamp.UserID, txnStamp.RecordTime);

                    #endregion

                    #region 更新自主檢數據內容[CST_EDC_COMP]
                    bool inSpec = true;

                    gvComponentEDC.Rows.LoopDo <GridViewRow>((p, i) => {
                        // 取得TextBox Control
                        var ttbEDC = p.FindControl("ttbEDC") as TextBox;
                        if (ttbEDC.Text.IsNullOrEmpty())
                        {
                            AjaxFocus(ttbEDC);
                            throw new Exception(TextMessage.Error.T00043(GetUIResource("CenterHoleData")));
                        }
                        // 是否符合規格判斷
                        var measureVal = ttbEDC.Text.ToDecimal();
                        if (measureVal > _SAICenterHole.Remark02.ToDecimal())
                        {
                            inSpec = false;
                        }

                        if (measureVal < _SAICenterHole.Remark03.ToDecimal())
                        {
                            inSpec = false;
                        }

                        var lotData = ComponentInfo.GetComponentByComponentID(_SelectedQCData.ComponentLot);

                        // 將量測資料記錄到客製表
                        var edcCompInfo              = InfoCenter.Create <CSTEDCComponentInfo>();
                        edcCompInfo.ComponentID      = _SelectedQCData.ComponentLot;
                        edcCompInfo.Data             = measureVal;
                        edcCompInfo.UpSpecification  = _SAICenterHole.Remark02.ToDecimal();
                        edcCompInfo.LowSpecification = _SAICenterHole.Remark03.ToDecimal();
                        edcCompInfo.INSPEC           = inSpec == true ? "OK" : "NG";
                        edcCompInfo.Lot              = (lotData == null) ? "" : lotData.CurrentLot;
                        edcCompInfo["LINKSID"]       = txnStamp.LinkSID;
                        edcCompInfo["PARAMETER"]     = "SC" + (i + 1).ToString();
                        edcCompInfo.InsertToDB(txnStamp.UserID, txnStamp.RecordTime);
                    });
                    #endregion

                    #region 更新機台狀態及更新檢驗單對應的批號資料

                    //如果選擇結果為NG時,則更新機台狀態及更新檢驗單對應的批號資料
                    if (rdbNG.Checked)
                    {
                        //取得機台狀態資料
                        var newStateInfo = EquipmentStateInfo.GetEquipmentStateByState("DOWN");

                        var equipData = EquipmentInfo.GetEquipmentByName(_SelectedQCData.EquipmentName);

                        //如果機台狀態為IDLE,則變更狀態為DOWN
                        if (equipData.CurrentState == "IDLE")
                        {
                            //更新機台狀態
                            EMSTransaction.ChangeState(equipData, newStateInfo, txnStamp);
                        }
                        else
                        {
                            //如果機台狀態不為IDLE,則註記機台[USERDEFINECOL01]為Y
                            EMSTransaction.ModifyEquipmentSystemAttribute(equipData, "USERDEFINECOL01", "Y", txnStamp);
                        }

                        //上一次的檢驗單號資料
                        QCInspectionInfoEx previousInspectionData = null;

                        //依據機台及料號查詢,然後用建立時間逆排序,找出所有FAI及MPQC的檢驗單號資料
                        var QCDataList = QCInspectionInfoEx.GetInspDataListByEquipmentAndDevice(QCInsepctionData.EquipmentName, QCInsepctionData.DeviceName);

                        //如果筆數大於1,則目前檢驗單號的索引值
                        if (QCDataList.Count > 1)
                        {
                            //找出目前檢驗單號的索引值
                            var NGIndex = QCDataList.FindIndex(p => p.InspectionNo == QCInsepctionData.InspectionNo);

                            //如果找到的索引值不是最後一筆的話,則找出上一次的檢驗單號資料
                            if (NGIndex != (QCDataList.Count - 1))
                            {
                                //找出上一次的檢驗單號資料
                                previousInspectionData = QCDataList[NGIndex + 1];
                            }
                        }

                        //取得目前檢驗單號的批號子單元資料
                        var componentList = ComponentInfoEx.GetDataByInspectionNo(QCInsepctionData.InspectionNo);
                        componentList.ForEach(component =>
                        {
                            //取得批號資料
                            var lotData = LotInfo.GetLotByLot(component.CurrentLot);

                            //更新欄位[PQCNGFLAG]
                            WIPTransaction.ModifyLotComponentSystemAttribute(lotData, component, "PQCNGFLAG", "Y", txnStamp);

                            //更新欄位[PQCNGNO]
                            WIPTransaction.ModifyLotComponentSystemAttribute(lotData, component, "PQCNGNO", QCInsepctionData.InspectionNo, txnStamp);
                        });

                        if (previousInspectionData != null)
                        {
                            //取得上一次檢驗單號的批號子單元資料
                            var previousComponentList = ComponentInfoEx.GetDataByInspectionNo(previousInspectionData.InspectionNo);

                            //取得不需要註記的ComponentID
                            var passInspectionDataList = QCInspectionObjectInfo.GetInspectionObjects(previousInspectionData);

                            previousComponentList.ForEach(component =>
                            {
                                //確認是否為不需要註記的ComponentID
                                if (passInspectionDataList.FindIndex(p => p.ItemName1 == component.ComponentID) == -1)
                                {
                                    //取得批號資料
                                    var lotData = LotInfo.GetLotByLot(component.CurrentLot);

                                    //更新欄位[PQCNGFLAG]
                                    WIPTransaction.ModifyLotComponentSystemAttribute(lotData, component, "PQCNGFLAG", "Y", txnStamp);

                                    //更新欄位[PQCNGNO]
                                    WIPTransaction.ModifyLotComponentSystemAttribute(lotData, component, "PQCNGNO", QCInsepctionData.InspectionNo, txnStamp);
                                }
                            });
                        }
                    }
                    #endregion

                    cts.Complete();
                }

                ClearField();
                AjaxFocus(ttbLot);

                _ProgramInformationBlock.ShowMessage(TextMessage.Hint.T00614(""));
            }
            catch (Exception ex)
            {
                HandleError(ex);
            }
        }
Ejemplo n.º 20
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                //取得登入者資訊
                var recordTime = DBCenter.GetSystemTime();
                var userID     = User.Identity.Name;

                //確認是否有資料
                if (_ModifyToolDeviceDetails.Count == 0)
                {
                    //請新增一筆刀具類型資料!
                    throw new Exception(RuleMessage.Error.C10122());
                }

                using (var cts = CimesTransactionScope.Create())
                {
                    CSTToolDeviceInfo toolDevice = null;

                    //如果傳入ToolDeviceSID為NULL,表示要新增一筆CST_TOOL_DEVICE資料
                    if (_CurrentToolDeviceSID.IsNullOrTrimEmpty())
                    {
                        toolDevice               = InfoCenter.Create <CSTToolDeviceInfo>();
                        toolDevice.DeviceName    = ttbDevice.Text;
                        toolDevice.EquipmentName = ttbEquipment.Text;
                        toolDevice.Tag           = 1;

                        toolDevice.InsertToDB(userID, recordTime);
                        LogCenter.LogToDB(toolDevice, LogCenter.LogIndicator.Create(ActionType.Add, userID, recordTime));
                    }
                    else
                    {
                        toolDevice = InfoCenter.GetBySID <CSTToolDeviceInfo>(_CurrentToolDeviceSID);
                    }

                    #region 更新資料清單
                    _ModifyToolDeviceDetails.ForEach(deviceDetail =>
                    {
                        //註記資料LOG的狀態
                        ActionType deviceDetailActionType = new ActionType();

                        if (deviceDetail.InfoState == InfoState.NewCreate)
                        {
                            deviceDetail.ToolDeviceSID = toolDevice.ToolDeviceSID;

                            //新增資料
                            deviceDetail.InsertToDB(userID, recordTime);
                            deviceDetailActionType = ActionType.Add;
                        }
                        else if (deviceDetail.InfoState == InfoState.Modified)
                        {
                            //更改資料
                            deviceDetail.UpdateToDB(userID, recordTime);
                            deviceDetailActionType = ActionType.Set;
                            _SourceToolDeviceDetails.Remove(deviceDetail);
                        }
                        else if (deviceDetail.InfoState == InfoState.Unchanged)
                        {
                            _SourceToolDeviceDetails.Remove(deviceDetail);
                        }

                        //紀錄歷史紀錄[CST_TOOL_DEVICE_DETAIL_LOG],有異動資料才更新
                        if (deviceDetailActionType != ActionType.None)
                        {
                            LogCenter.LogToDB(deviceDetail, LogCenter.LogIndicator.Create(deviceDetailActionType, userID, recordTime));
                        }
                    });
                    #endregion

                    #region 處理資料刪除的部份
                    _SourceToolDeviceDetails.ForEach(deviceDetail =>
                    {
                        deviceDetail.DeleteFromDB();

                        LogCenter.LogToDB(deviceDetail, LogCenter.LogIndicator.Create(ActionType.Remove, userID, recordTime));
                    });
                    #endregion

                    cts.Complete();
                }

                //INF-00002:{0}儲存成功!
                _ProgramInformationBlock.ShowMessage(TextMessage.Hint.T00083(""), MessageShowOptions.OnLabel);

                ClearData();

                LoadControlDefault();

                QueryData();

                btnExit_Click(null, EventArgs.Empty);
            }
            catch (Exception E)
            {
                HandleError(E);
            }
        }
Ejemplo n.º 21
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);
            }
        }
Ejemplo n.º 22
0
        /// <summary>
        /// 上傳檢驗報告
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnUpload_Click(object sender, EventArgs e)
        {
            try
            {
                string toolName = "";

                toolName = ttbToolName.Text;

                if (!FileUpload1.HasFile)
                {
                    //[00854]請選擇檔案!!
                    throw new CimesException(TextMessage.Error.T00854());
                }

                var    splitString = FileUpload1.PostedFile.FileName.Split('.');
                string fileName    = splitString[0] + "_" + DBCenter.GetSystemDateTime().ToString("HHmmss") + "." + splitString[1];

                WindowsImpersonationContext impersonationContext = null;

                //儲存資料夾
                string saveDirPath = _SaveInspectionData[0].Remark01;

                //使用者帳號
                string userName = _SaveInspectionData[0].Remark02;

                //使用者密碼
                string password = _SaveInspectionData[0].Remark03;

                //實際儲存檔案路徑
                string saveFilePath = saveDirPath + "\\" + toolName + "\\" + fileName;

                //如果使用者帳號不為空白才執行切換帳號功能
                if (userName.IsNullOrTrimEmpty() == false)
                {
                    //切換使用者
                    var             tokenHandle     = Impersonate(userName, password, "domain");
                    WindowsIdentity windowsIdentity = new WindowsIdentity(tokenHandle);
                    impersonationContext = windowsIdentity.Impersonate();
                }

                //判斷儲存路徑是否存在
                if (Directory.Exists(saveDirPath + "\\" + toolName) == false)
                {
                    //如果不存在,則新增一個資料夾路徑
                    Directory.CreateDirectory(saveDirPath + "\\" + toolName);
                }

                //儲存檔案
                FileUpload1.SaveAs(saveFilePath);

                if (impersonationContext != null)
                {
                    //切換回原身分
                    impersonationContext.Undo();
                }

                //新增一筆檢驗報告資料
                var toolReport = InfoCenter.Create <CSTToolReportInfo>();
                toolReport.ToolName = toolName;
                toolReport.FileName = saveFilePath;

                _ToolReports.Add(toolReport);

                //檔案名稱:{0}已上傳完成 !
                _ProgramInformationBlock.ShowMessage(RuleMessage.Hint.C10125(fileName));

                //依據檔案名稱,顯示檔案名稱的連結
                BindFileData(toolReport.FileName, fileName);
            }
            catch (Exception ex)
            {
                HandleError(ex);
            }
        }
Ejemplo n.º 23
0
        protected void ttbWorkpiece_TextChanged(object sender, EventArgs e)
        {
            try
            {
                // 若卡控需輸入料號
                if (ttbDeviceName.Text.Trim().IsNullOrEmpty() && !ckbNoControl.Checked)
                {
                    throw new RuleCimesException(TextMessage.Error.T00043(lblDeviceName.Text));
                }
                // 取得輸入工件
                string inputObject = ttbWorkpiece.Text.Trim();
                if (inputObject.IsNullOrEmpty())
                {
                    return;
                }

                ComponentInfo componentInfo = null;
                LotInfo       lotInfo       = null;

                var lstDMCComponent = ComponentInfoEx.GetComponentByDMCCode(inputObject).OrderBy(p => p.ComponentID).ToList();
                if (lstDMCComponent.Count == 0)
                {
                    var compID = CustomizeFunction.ConvertDMCCode(inputObject);
                    lstDMCComponent = ComponentInfoEx.GetComponentListByComponentID(compID).OrderBy(p => p.ComponentID).ToList();
                }

                lstDMCComponent.ForEach(comp =>
                {
                    // 若DMC是唯一值可以檢查是否已經重複
                    if (_ProdType == "S" || _ProdType == "B")
                    {
                        // 取得批號資料
                        lotInfo = LotInfo.GetLotByLot(comp.CurrentLot);

                        // 自動線沒有DMCCode
                        if (lotInfo.UserDefineColumn08 == "Y" && comp["DMC"].ToString().IsNullOrEmpty())
                        {
                            var txnStamp = new TransactionStamp(User.Identity.Name, ProgramRight, ProgramRight, ApplicationName);
                            using (var cts = CimesTransactionScope.Create())
                            {
                                WIPTransaction.ModifyLotComponentSystemAttribute(lotInfo, comp, "DMC", inputObject, txnStamp);
                                cts.Complete();
                            }
                        }

                        #region 檢查子單元資料是否重複
                        if (lotInfo.DeviceName == _DeviceName)
                        {
                            _PackingList.ForEach(p =>
                            {
                                if (p.ComponentID == comp.ComponentID)
                                {
                                    throw new RuleCimesException(TextMessage.Error.T00033(lblWorkpiece.Text, comp.ComponentID));
                                }
                            });
                        }
                        else if (lotInfo.DeviceName == _RelativeDeviceName)
                        {
                            _RelativePackingList.ForEach(p =>
                            {
                                if (p.ComponentID == comp.ComponentID)
                                {
                                    throw new RuleCimesException(TextMessage.Error.T00033(lblWorkpiece.Text, comp.ComponentID));
                                }
                            });
                        }
                        #endregion
                        componentInfo = comp;
                    }
                    else
                    {
                        if (_PackingList.Find(p => p.ComponentID == comp.ComponentID) == null && _RelativePackingList.Find(p => p.ComponentID == comp.ComponentID) == null && componentInfo == null)
                        {
                            componentInfo = comp;
                            // 取得批號資料
                            lotInfo = LotInfo.GetLotByLot(componentInfo.CurrentLot);
                        }
                    }
                });

                // 找不到子單元需拋錯
                if (componentInfo == null)
                {
                    throw new RuleCimesException(TextMessage.Error.T00045(GetUIResource("Workpiece")));
                }
                // 找不到批號需拋錯
                if (lotInfo == null)
                {
                    throw new RuleCimesException(TextMessage.Error.T00045(GetUIResource("Lot")));
                }
                // 檢查CurrentRule是否正確
                if (lotInfo.CurrentRuleName != ProgramInformationBlock1.ProgramRight)
                {
                    throw new RuleCimesException(TextMessage.Error.T00384(lotInfo.CurrentRuleName, ProgramInformationBlock1.ProgramRight));
                }
                // 若需卡控
                if (!ckbNoControl.Checked)
                {
                    // 檢查批號型號與輸入的型號是否相同
                    if (_PackType == "Standard" && lotInfo.DeviceName != _DeviceName)
                    {
                        throw new RuleCimesException(RuleMessage.Error.C10041(_DeviceName));
                    }
                    // 如果為包裝方式為Mix(左右手),則對應料號與對應料號須符合
                    if (_PackType == "Mix" && lotInfo.DeviceName != _DeviceName && lotInfo.DeviceName != _RelativeDeviceName)
                    {
                        throw new RuleCimesException(RuleMessage.Error.C10042(_DeviceName, _RelativeDeviceName));
                    }
                }

                var packTempInfo = CSTWIPPackTempInfo.GetPackTempByComponentID(componentInfo.ComponentID);
                if (packTempInfo != null)
                {
                    ttbWorkpiece.Text = "";
                    throw new RuleCimesException(RuleMessage.Error.C10093());
                }

                // 新增PackingInfo物件
                var newPackItem = new PackingInfo();
                newPackItem.ComponentID   = componentInfo.ComponentID;
                newPackItem.ComponentInfo = componentInfo;
                newPackItem.LotInfo       = lotInfo;
                newPackItem.DMC           = componentInfo["DMC"].ToString();

                // 將PackingInfo物件加入包裝清單全域變數
                if (_PackType == "Standard" || (_PackType == "Mix" && lotInfo.DeviceName == _DeviceName) || ckbNoControl.Checked)
                {
                    // 工件數量({0})達到滿箱數量({1}) !
                    if (!ckbNoControl.Checked && _PackingList.Count >= ttbMaxPackSize.Text.ToDecimal())
                    {
                        throw new RuleCimesException(RuleMessage.Error.C10092(_PackingList.Count.ToString(), ttbMaxPackSize.Text));
                    }

                    newPackItem.Device = lotInfo.DeviceName;
                    newPackItem.Item   = (_PackingList.Count + 1).ToString();
                    _PackingList.Add(newPackItem);
                }
                // 將PackingInfo物件加入對應料號包裝清單全域變數
                else
                {
                    // 工件數量({0})達到滿箱數量({1}) !
                    if (!ckbNoControl.Checked && _RelativePackingList.Count >= ttbMaxPackSize.Text.ToDecimal())
                    {
                        throw new RuleCimesException(RuleMessage.Error.C10092(_RelativePackingList.Count.ToString(), ttbMaxPackSize.Text));
                    }

                    newPackItem.Device = lotInfo.DeviceName;
                    newPackItem.Item   = (_RelativePackingList.Count + 1).ToString();
                    _RelativePackingList.Add(newPackItem);
                }
                // 將目前已經輸入的物件顯示至畫面上
                _PackingList           = _PackingList.OrderByDescending(p => p.Item.ToDecimal()).ToList();
                gvWorkpiece.DataSource = _PackingList;
                gvWorkpiece.DataBind();
                // 將目前已經輸入的物件顯示至畫面上
                _RelativePackingList           = _RelativePackingList.OrderByDescending(p => p.Item.ToDecimal()).ToList();
                gvRelativeWorkpiece.DataSource = _RelativePackingList;
                gvRelativeWorkpiece.DataBind();
                // 清除工件欄位
                ttbWorkpiece.Text = "";
                // 將指標焦點放工件欄位輸入框
                AjaxFocus(ttbWorkpiece);

                if (_PackingList.Count != 0 || _RelativePackingList.Count != 0)
                {
                    ttbTempWorkpiece.ReadOnly = true;
                }
                else
                {
                    ttbTempWorkpiece.ReadOnly = false;
                }
                // 取得BatchID
                if (_BatchID == "")
                {
                    var cstWIPPackTempInfo = InfoCenter.GetBySQL <CSTWIPPackTempInfo>("SELECT * FROM CST_WIP_PACK_TEMP WHERE COMPONENTID = #[STRING]", inputObject);
                    _BatchID = (cstWIPPackTempInfo == null) ? "" : cstWIPPackTempInfo.BatchID;
                }

                #region ProcessWorkTime
                string sysTime     = DBCenter.GetSystemTime();
                var    usrWorkTime = InfoCenter.Create <CSTUserWorkTimeInfo>();
                usrWorkTime.WorkOrder    = lotInfo.WorkOrder;
                usrWorkTime.WorkUserID   = User.Identity.Name;
                usrWorkTime.StartTime    = _StartTime;
                usrWorkTime.EndTime      = DateTime.Parse(sysTime).AddSeconds(-1).ToString("yyyy/MM/dd HH:mm:ss");
                usrWorkTime.EXECUTEFLAG  = "N";
                usrWorkTime.SHIFTDATE    = _ShiftDate;
                usrWorkTime.SHIFT        = _Shift;
                usrWorkTime.Lot          = lotInfo.Lot;
                usrWorkTime["OPERATION"] = lotInfo.OperationName;
                _StartTime = sysTime;
                _UserWorkTimeList.Add(usrWorkTime);
                #endregion
            }
            catch (Exception ex)
            {
                HandleError(ex, ttbWorkpiece.ClientID);
            }
        }
Ejemplo n.º 24
0
        /// <summary>
        /// 儲存刀具圖檔資料
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnUploadPicture_Click(object sender, System.EventArgs e)
        {
            try
            {
                if (!FileUpload1.HasFile)
                {
                    // [00854]請選擇檔案!!
                    throw new CimesException(TextMessage.Error.T00854());
                }

                string fileExt = System.IO.Path.GetExtension(FileUpload1.FileName).ToLower();
                //if (fileExt != ".jpeg" && fileExt != ".jpg" && fileExt != ".png" && fileExt != ".bmp")
                //{
                //    //僅接受格式為.jpg /.jpeg/.png/.bmp的檔案!
                //    throw new CimesException(RuleMessage.Error.C10182());
                //}

                string fileName = FileUpload1.PostedFile.FileName;

                WindowsImpersonationContext impersonationContext = null;

                //儲存資料夾
                string saveDirPath = _SavePicturedData[0].Remark01;

                //使用者帳號
                string userName = _SavePicturedData[0].Remark02;

                //使用者密碼
                string password = _SavePicturedData[0].Remark03;

                //實際儲存檔案路徑
                string saveFilePath = saveDirPath + "\\" + _ToolType + "\\" + fileName;

                //如果使用者帳號不為空白才執行切換帳號功能
                if (userName.IsNullOrTrimEmpty() == false)
                {
                    //切換使用者
                    var             tokenHandle     = Impersonate(userName, password, "domain");
                    WindowsIdentity windowsIdentity = new WindowsIdentity(tokenHandle);
                    impersonationContext = windowsIdentity.Impersonate();
                }

                //確認檔案在清單中是否已存在
                foreach (var toolTypePicture in _ModifyToolTypePictures)
                {
                    if (toolTypePicture.FileName == saveFilePath)
                    {
                        //檔案名稱:{0} 已存在!
                        throw new Exception(RuleMessage.Error.C10119(fileName));
                    }
                }

                //判斷儲存路徑是否存在
                if (Directory.Exists(saveDirPath + "\\" + _ToolType) == false)
                {
                    //如果不存在,則新增一個資料夾路徑
                    Directory.CreateDirectory(saveDirPath + "\\" + _ToolType);
                }

                //儲存檔案
                FileUpload1.SaveAs(saveFilePath);

                if (impersonationContext != null)
                {
                    //切換回原身分
                    impersonationContext.Undo();
                }

                //新增一筆刀壽資料
                var newToolPicture = InfoCenter.Create <CSTToolTypePictureInfo>();
                newToolPicture.ToolType = _ToolType;
                newToolPicture.FileName = saveFilePath;

                _ModifyToolTypePictures.Insert(0, newToolPicture);

                _HttpPostedFiles.Insert(0, FileUpload1.PostedFile);

                //顯示資料
                gvToolTypeImage.SetDataSource(_ModifyToolTypePictures, true);
            }
            catch (Exception ex)
            {
                HandleError(ex, CurrentUpdatePanel, string.Empty, MessageShowOptions.OnLabel);
            }
        }
Ejemplo n.º 25
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);

                //確認是否輸入刀具零組件
                ttbToolName.Must(lblToolName);

                //確認是否選擇維修原因
                ddlReason.Must(lblReason);

                //確認是否有選擇預定回廠日
                var date = ttbDate.MustDate(lblDate);

                //取得系統時間
                var sysDate = Convert.ToDateTime(DBCenter.GetSystemDateTime().ToString("yyyy/MM/dd"));

                //確認預定回廠日是否大於等於當天日期
                if (date < sysDate)
                {
                    //預定回廠日必須大於等於{0} !
                    throw new Exception(RuleMessage.Error.C10159(sysDate.ToString("yyyy/MM/dd")));
                }

                using (var cts = CimesTransactionScope.Create())
                {
                    //取得原因碼資料
                    var reasonCategory = InfoCenter.GetBySID <ReasonCategoryInfo>(ddlReason.SelectedValue);

                    //取得刀面資料清單
                    var toolLifes = CSTToolLifeInfo.GetToolLifeByToolNmae(_ToolData.ToolName);
                    toolLifes.Sort(data => data.Head);

                    //新增一筆[CST_TOOL_REPAIR]
                    var newToolRePair = InfoCenter.Create <CSTToolRepairInfo>();
                    newToolRePair.EstimateDateOfReturn = ttbDate.Text;
                    newToolRePair.Parts          = ttbRepairPart.Text;
                    newToolRePair.Reason         = reasonCategory.Reason;
                    newToolRePair.ReasonCategory = reasonCategory.Category;
                    newToolRePair.RepairTime     = txnStamp.RecordTime;
                    newToolRePair.RepairUser     = txnStamp.UserID;
                    newToolRePair.ToolName       = _ToolData.ToolName;
                    newToolRePair.InsertToDB(txnStamp.UserID, txnStamp.RecordTime);

                    //新增一筆[CST_TOOL_REPAIR_LOG]
                    LogCenter.LogToDB(newToolRePair, LogCenter.LogIndicator.Create(ActionType.Add, txnStamp.UserID, txnStamp.RecordTime));

                    //新增[CST_TOOL_REPAIR_LIFE]
                    toolLifes.ForEach(toolLife =>
                    {
                        var newToolRePairLife           = InfoCenter.Create <CSTToolRepairLifeInfo>();
                        newToolRePairLife.Head          = toolLife.Head;
                        newToolRePairLife.Life          = toolLife.UseCount.ToString();
                        newToolRePairLife.ToolRepairSID = newToolRePair.ToolRepairSID;
                        newToolRePairLife.InsertToDB();
                    });

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

                    //因刀具報表需求,所以在送修時要將使用次數記錄在UDC07
                    var toolLifeData = toolLifes.Find(p => p.Head == _ToolData.Head);
                    TMSTransaction.ModifyToolSystemAttribute(_ToolData, "USERDEFINECOL07", toolLifeData.UseCount.ToCimesString(), txnStamp);

                    //變更狀態為REPAIR
                    TMSTransaction.ChangeToolState(_ToolData, newStateInfo, txnStamp);

                    int maintainCount = _ToolData.MaintainCount;

                    //維修次數+1
                    TMSTransaction.ModifyToolSystemAttribute(_ToolData, "MAINTAINCOUNT", (maintainCount + 1).ToString(), txnStamp);

                    //預定回廠日
                    TMSTransaction.ModifyToolSystemAttribute(_ToolData, "USERDEFINECOL04", ttbDate.Text, txnStamp);

                    //註記原因碼
                    txnStamp.CategoryReasonCode = reasonCategory;
                    txnStamp.Description        = "";

                    //備註
                    TMSTransaction.AddToolComment(_ToolData, txnStamp);

                    cts.Complete();
                }

                ClearField();

                AjaxFocus(ttbToolName);

                _ProgramInformationBlock.ShowMessage(TextMessage.Hint.T00614(""));
            }
            catch (Exception ex)
            {
                HandleError(ex);
            }
        }
Ejemplo n.º 26
0
        protected void btnOK_Click(object sender, EventArgs e)
        {
            try
            {
                // 包裝數量必須符合滿箱數量,否則須拋錯
                if (!ckbNoControl.Checked && _PackType == "Standard" && (_PackingList.Count + _RelativePackingList.Count) != ttbMaxPackSize.Text.ToDecimal())
                {
                    throw new RuleCimesException(RuleMessage.Error.C10043((_PackingList.Count + _RelativePackingList.Count).ToString(), ttbMaxPackSize.Text));
                }
                // 若包裝方式為左右手,則左右手的輸入數量需相同
                if (!ckbNoControl.Checked && _PackType == "Mix" && _PackingList.Count != _RelativePackingList.Count)
                {
                    throw new RuleCimesException(RuleMessage.Error.C10044(_DeviceName, _PackingList.Count.ToString(), _RelativeDeviceName, _RelativePackingList.Count.ToString()));
                }
                // 若包裝方式為左右手,則左右手的輸入數量需相同且需符合滿箱數量乘以二
                if (!ckbNoControl.Checked && _PackType == "Mix" && (_PackingList.Count + _RelativePackingList.Count) != (ttbMaxPackSize.Text.ToDecimal() * 2))
                {
                    throw new RuleCimesException(RuleMessage.Error.C10043((_PackingList.Count + _RelativePackingList.Count).ToString(), (ttbMaxPackSize.Text.ToDecimal() * 2).ToString()));
                }

                if (ddlInspector.SelectedValue.IsNullOrEmpty())
                {
                    //[00826] 請輸入{0}!
                    throw new RuleCimesException(TextMessage.Error.T00826(lblInspector.Text), ddlInspector);
                }


                var lstSourceLot = new List <LotInfo>();
                // 定義交易戳記
                var txnStamp = new TransactionStamp(User.Identity.Name, ProgramRight, ProgramRight, ApplicationName);
                using (var cts = CimesTransactionScope.Create())
                {
                    // 若有不同的批號需拆批
                    _PackingList.Distinct <PackingInfo>(new PackCompare()).ToList().ForEach(p =>
                    {
                        lstSourceLot.Add(SplitLot(p.LotInfo, false, txnStamp));
                    });
                    // 若有不同的批號需拆批
                    _RelativePackingList.Distinct <PackingInfo>(new PackCompare()).ToList().ForEach(p =>
                    {
                        lstSourceLot.Add(SplitLot(p.LotInfo, true, txnStamp));
                    });

                    #region SplitBoxLot
                    List <SqlAgent> splitLotArchiSQLList = new List <SqlAgent>();
                    var             generator            = NamingIDGenerator.GetRule("BoxNo");
                    if (generator == null)
                    {
                        //WRN-00411,找不到可產生的序號,請至命名規則維護設定,規則名稱:{0}!!!
                        throw new Exception(TextMessage.Error.T00437("BoxNo"));
                    }
                    var serialData = generator.GenerateNextIDs(1, lstSourceLot[0], new string[] { }, User.Identity.Name);
                    splitLotArchiSQLList = serialData.Second;
                    var boxNoLotID = serialData.First[0];

                    var reasonCategoryInfo = ReasonCategoryInfo.GetReasonCategoryByCategoryNameAndReason("Common", "OTHER");
                    var splitLotData       = SplitLotInfo.CreateSplitLotByLotAndQuantity(lstSourceLot[0].Lot, boxNoLotID, 0, 0, reasonCategoryInfo, "SplitBoxLot");

                    WIPTxn.SplitIndicator splitInd = WIPTxn.SplitIndicator.Create();
                    WIPTxn.Default.SplitLot(lstSourceLot[0], splitLotData, splitInd, txnStamp);

                    //若子單元為自動產生,更新序號至DB
                    if (splitLotArchiSQLList != null && splitLotArchiSQLList.Count > 0)
                    {
                        DBCenter.ExecuteSQL(splitLotArchiSQLList);
                    }
                    #endregion

                    var targetLot = LotInfo.GetLotByLot(boxNoLotID);
                    // 將批號轉換為另一個批號的子單元,轉換後批號結批,例如可使用於包裝
                    WIPTxn.Default.ConvertToComponent(targetLot, lstSourceLot, "Box", WIPTxn.ConvertToComponentIndicator.Default, txnStamp);
                    // 紀錄檢驗人員
                    //WIPTransaction.ModifyLotSystemAttribute(targetLot, "USERDEFINECOL12", ddlInspector.SelectedValue, txnStamp);
                    // 進行Dispatch
                    WIPTransaction.DispatchLot(targetLot, txnStamp);
                    // 刪除暫存檔案
                    if (_BatchID != "")
                    {
                        CSTWIPPackTempInfo.DeletePackTempByBatchID(_BatchID);
                    }

                    var packInfo = InfoCenter.Create <CSTWIPPackInfo>();
                    packInfo.BOXNO    = boxNoLotID;
                    packInfo.Quantity = _PackingList.Count + _RelativePackingList.Count;
                    packInfo.INSPUSER = ddlInspector.SelectedValue;
                    packInfo.InsertToDB(txnStamp.UserID, txnStamp.RecordTime);

                    _PackingList.ForEach(comp => {
                        var packDataInfo          = InfoCenter.Create <CSTWIPPackDataInfo>();
                        packDataInfo.WIP_PACK_SID = packInfo.ID;
                        packDataInfo.ComponentID  = comp.ComponentID;
                        packDataInfo.DMC          = comp.DMC;
                        packDataInfo.DeviceName   = comp.Device;
                        packDataInfo.Quantity     = 1;
                        packDataInfo.InsertToDB(txnStamp.UserID, txnStamp.RecordTime);
                    });

                    _RelativePackingList.ForEach(comp => {
                        var packDataInfo          = InfoCenter.Create <CSTWIPPackDataInfo>();
                        packDataInfo.WIP_PACK_SID = packInfo.ID;
                        packDataInfo.ComponentID  = comp.ComponentID;
                        packDataInfo.DMC          = comp.DMC;
                        packDataInfo.DeviceName   = comp.Device;
                        packDataInfo.Quantity     = 1;
                        packDataInfo.InsertToDB(txnStamp.UserID, txnStamp.RecordTime);
                    });

                    //工時
                    _UserWorkTimeList.ForEach(p => {
                        p.InsertToDB(txnStamp.UserID, txnStamp.RecordTime);
                    });
                    _UserWorkTimeList.Clear();

                    #region Print
                    _dsReport = new DataSet();
                    // 取得Report資料
                    _dsReport = GetRunCardDataSource(targetLot);
                    _dsReport.AcceptChanges();

                    if (_dsReport.Tables.Count > 0)
                    {
                        string sPrintProgram    = "/CustomizeRule/WIPRule/W035View.aspx";
                        string sHost            = Request.Url.Host;
                        string sApplicationPath = Request.ApplicationPath;
                        string ReportPath       = "http://" + sHost + sApplicationPath + sPrintProgram;
                        Session["W035View"] = _dsReport;
                        //開啟查詢工單頁面
                        string openPrintWindow = "window.open('" + ReportPath + "','pop','resizable: yes; status: no; scrollbars:no; menubar:no;toolbar:no;location:no;dialogLeft:10px;dialogTop:10px;dialogHeight:10px;dialogWidth:10px',false);";
                        ScriptManager.RegisterStartupScript(UpdatePanel1, UpdatePanel1.GetType(), Guid.NewGuid().ToString(), openPrintWindow, true);
                    }
                    #endregion
                    cts.Complete();
                }
                // ClearUI不會清除Device資料
                ttbDeviceName.Text = "";
                ClearField();
                //ReturnToPortal();
            }
            catch (Exception ex)
            {
                HandleError(ex);
            }
        }