예제 #1
0
        /// <summary>
        /// 取得可使用機台清單
        /// </summary>
        /// <param name="lot"></param>
        public void GetEquipmentList(string operationName)
        {
            //清除機台清單
            ddlEquip.Items.Clear();
            ddlEquip.Enabled = false;

            //取得可用的所有機台
            var equipmentList = CustomizeFunction.GetEquipmentListByOperationName(operationName);

            //如果取得機台資料大於零,則將機台清單傳至下拉式元件
            if (equipmentList.Count > 0)
            {
                ddlEquip.Enabled        = true;
                ddlEquip.DataSource     = equipmentList;
                ddlEquip.DataTextField  = "EquipmentName";
                ddlEquip.DataValueField = "EquipmentSID";
                ddlEquip.DataBind();

                if (ddlEquip.Items.Count != 1)
                {
                    ddlEquip.Items.Insert(0, "");
                }
                else
                {
                    ddlEquip.SelectedIndex = 0;
                }
            }
        }
예제 #2
0
        /// <summary>
        /// 輸入機加批號
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void ttbLot_TextChanged(object sender, EventArgs e)
        {
            try
            {
                //取得 LOT / COMPONENTID / MATERIALLOT / INVLOT / WOLOT
                string lot = CustomizeFunction.ConvertDMCCode(ttbLot.Text.Trim());

                //清除資料
                ClearField();

                //是否取得批號資料旗標
                bool isFindLotData = false;

                //確認輸入資料是否為LOT
                isFindLotData = CheckLot(lot);

                if (isFindLotData == false)
                {
                    //確認輸入資料是否為COMPONENTID
                    isFindLotData = CheckComponentID(lot);
                }

                if (isFindLotData == false)
                {
                    //確認此批號是否為MATERIALLOT
                    isFindLotData = CheckMaterialLot(lot);
                }

                if (isFindLotData == false)
                {
                    //確認此批號是否為INVLOT
                    isFindLotData = CheckInvLot(lot);
                }

                if (isFindLotData == false)
                {
                    //確認此批號是否為WOLOT
                    isFindLotData = CheckWOLot(lot);
                }

                //如果五種搜尋方式都沒有找到批號資料的話,則顯示錯誤訊息
                if (isFindLotData == false)
                {
                    //[00030]{0}:{1}不存在!
                    throw new Exception(TextMessage.Error.T00030(lblLot.Text, ttbLot.Text));
                }
            }
            catch (Exception ex)
            {
                ttbLot.Text = "";

                ClearField();
                AjaxFocus(ttbLot);
                HandleError(ex);
            }
        }
예제 #3
0
        public static LotInfoEx GetLotByLot(string lot)
        {
            lot = CustomizeFunction.ConvertDMCCode(lot);

            string   sql = @"SELECT * FROM MES_WIP_LOT 
                            WHERE LOT = #[STRING]";
            SqlAgent sa  = SQLCenter.Parse(sql, lot);

            return(InfoCenter.GetBySQL <LotInfoEx>(sa));
        }
예제 #4
0
        public static List <LotInfoEx> GetLotByWorkOrderLotAndOperation(string lot, string operation)
        {
            lot = CustomizeFunction.ConvertDMCCode(lot);

            string   sql = @"SELECT * FROM MES_WIP_LOT 
                            WHERE WOLOT = #[STRING] AND OPERATION = #[STRING]";
            SqlAgent sa  = SQLCenter.Parse(sql, lot, operation);

            return(InfoCenter.GetList <LotInfoEx>(sa));
        }
예제 #5
0
        public static List <LotInfoEx> GetLotListByComponentLot(string componentLot)
        {
            componentLot = CustomizeFunction.ConvertDMCCode(componentLot);

            string   sql = @"SELECT * FROM MES_WIP_LOT 
                            WHERE COMPLOT = #[STRING]";
            SqlAgent sa  = SQLCenter.Parse(sql, componentLot);

            return(InfoCenter.GetList <LotInfoEx>(sa));
        }
예제 #6
0
        public static List <LotInfoEx> GetLotByMaterialLotAndWOLot(string materialLot, string woLot)
        {
            materialLot = CustomizeFunction.ConvertDMCCode(materialLot);
            woLot       = CustomizeFunction.ConvertDMCCode(woLot);

            string   sql = @"SELECT * FROM MES_WIP_LOT 
                            WHERE MATERIALLOT = #[STRING] AND WOLOT = #[STRING]";
            SqlAgent sa  = SQLCenter.Parse(sql, materialLot, woLot);

            return(InfoCenter.GetList <LotInfoEx>(sa));
        }
예제 #7
0
        public static ComponentInfoEx GetComponentByComponentID(string componentID)
        {
            componentID = CustomizeFunction.ConvertDMCCode(componentID);

            string   sql = @"SELECT *
                              FROM MES_WIP_COMP
                             WHERE COMPONENTID = #[STRING]";
            SqlAgent sa  = SQLCenter.Parse(sql, componentID);

            return(InfoCenter.GetBySQL <ComponentInfoEx>(sa));
        }
예제 #8
0
        /// <summary>
        /// 依照輸入LotID取得相關欄位資料及相關Button設定
        /// </summary>
        /// <param name="LotID">批號名稱</param>
        private void LoadControlByLot(string LotID)
        {
            // 清除欄位資訊
            ClearField();
            if (cbxWO.Checked)
            {
                _LotData = LotInfoEx.GetLotByWorkOrderLot(LotID);
            }

            if (cbxLot.Checked)
            {
                _LotData = LotInfoEx.GetLotByLot(LotID);
            }

            if (cbxSN.Checked)
            {
                var lot = CustomizeFunction.ConvertDMCCode(LotID);

                var compInfo = ComponentInfoEx.GetComponentByComponentID(lot);
                if (compInfo == null)
                {
                    var compList = ComponentInfoEx.GetComponentByDMCCode(lot);
                    if (compList.Count != 0)
                    {
                        compInfo = compList[0];
                    }
                }

                if (compInfo != null)
                {
                    _LotData = LotInfo.GetLotByLot(compInfo.CurrentLot).ChangeTo <LotInfoEx>();
                }
            }

            // 若該批號無資料可顯示,離開程式並顯示訊息
            if (_LotData == null)
            {
                btnPrint.Enabled = false;
                AjaxFocus(ttbWOLot);
                throw new Exception(TextMessage.Error.T00060(LotID));
            }

            btnPrint.Enabled = true;
        }
예제 #9
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));
                }
            }
        }
예제 #10
0
        protected void ttbWorkpiece_TextChanged(object sender, EventArgs e)
        {
            try
            {
                btnOK.Enabled = false;

                if (ttbWorkpiece.Text.Trim().IsNullOrEmpty())
                {
                    if (_ProdType == CustomizeFunction.ProdType.B.ToCimesString())
                    {
                        ddlOperation.Enabled = true;
                        ddlOperation.ClearSelection();
                    }
                    return;
                }

                string componentid = CustomizeFunction.ConvertDMCCode(ttbWorkpiece.Text.Trim());

                //僅有B跟S型態會刷DMC,故只需針對兩種CASE處理
                if (_ProdType == CustomizeFunction.ProdType.B.ToCimesString())
                {
                    _ComponentInfo = ComponentInfoEx.GetOneComponentByDMCCode(componentid);
                    if (_ComponentInfo == null)
                    {
                        throw new RuleCimesException(RuleMessage.Error.C00049(ttbWorkpiece.Text));
                    }
                }
                else if (_ProdType == CustomizeFunction.ProdType.S.ToCimesString())
                {
                    _ComponentInfo = ComponentInfoEx.GetComponentByComponentID(componentid);

                    if (_ComponentInfo == null)
                    {
                        throw new RuleCimesException(RuleMessage.Error.C10047(ttbWorkpiece.Text));
                    }
                }

                // 找不到工件
                if (_ComponentInfo == null)
                {
                    throw new RuleCimesException(RuleMessage.Error.C10047(ttbWorkpiece.Text));
                }

                ddlOperation.Enabled = false;

                ProcessLotData = LotInfoEx.GetLotByLot(_ComponentInfo.CurrentLot);
                if (ProcessLotData == null)
                {
                    AjaxFocus(ttbWorkpiece);
                    throw new RuleCimesException(TextMessage.Error.T00030(lblWOLot.Text + "(" + ttbWOLot.Text.Trim() + ")" + lblttbWorkpiece.Text + "(" + componentid + ")", GetUIResource("Lot")), ttbWorkpiece);
                }

                if (ProcessLotData.OperationName == _JudgeOperationName)
                {
                    AjaxFocus(ttbWorkpiece);
                    throw new RuleCimesException(RuleMessage.Error.C10175(_JudgeOperationName), ttbWorkpiece);
                }

                var item = ddlOperation.Items.FindByValue(ProcessLotData.OperationName);
                if (item != null)
                {
                    ddlOperation.ClearSelection();
                    item.Selected = true;
                }

                btnOK.Enabled = true;
            }
            catch (Exception ex)
            {
                HandleError(ex);
                AjaxFocus(ttbWorkpiece);
            }
        }
예제 #11
0
        protected void ttbWorkpiece_TextChanged(object sender, EventArgs e)
        {
            try
            {
                string inputObject = ttbWorkpiece.Text.Trim();
                if (inputObject.IsNullOrEmpty())
                {
                    ClearUI();
                    return;
                }
                //轉換字串最後"."的字串
                inputObject = CustomizeFunction.ConvertDMCCode(inputObject);
                //DMCCode有刻字有SN
                if (_ProdType == CustomizeFunction.ProdType.S.ToCimesString())
                {
                    ComponentInfo = _ComponentList.Find(p => p.ComponentID == inputObject);
                    if (ComponentInfo == null)
                    {
                        //工件{0}不屬於Runcard {1},請確認!!
                        throw new CimesException(RuleMessage.Error.C00030(inputObject, ttbWOLot.Text));
                    }
                    #region 以ComponentID找出ComponentInfo
                    //ComponentInfo = ComponentInfoEx.GetComponentByComponentID(inputObject);

                    //if (ComponentInfo != null)
                    //{
                    //    ProcessLotData = LotInfo.GetLotByLot(ComponentInfo.CurrentLot);
                    //}
                    #endregion
                }

                //DMCCode有刻字無SN
                if (_ProdType == CustomizeFunction.ProdType.G.ToCimesString())
                {
                    #region 以MLot,WOLot找出ComponentInfo
                    // 以物料批找出批號
                    var lstLots = LotInfoEx.GetLotByMaterialLotAndWOLot(inputObject, ProcessLotData.WorkOrderLot);
                    if (lstLots.Count > 1)
                    {
                        throw new RuleCimesException(RuleMessage.Error.C10040(inputObject));
                    }
                    // 若物料批找不到批號則以WOLot找出批號
                    if (lstLots.Count == 0)
                    {
                        //[00030]{0}:{1}不存在!
                        throw new RuleCimesException(TextMessage.Error.T00030(lblWOLot.Text + "(" + ttbWOLot.Text + ")," + lblMaterialLot.Text + "(" + inputObject + ")", GetUIResource("Lot")));
                    }

                    ProcessLotData = lstLots[0];

                    // 取得所有子單元,並取得沒有做過中心孔量測的批號,以ComponentID排序
                    var lstComponents = ComponentInfo.GetLotAllComponents(ProcessLotData).FindAll(p => p["CENTER_HOLE_FLAG"].ToString() == "N").OrderBy(p => p.ComponentID).ToList();
                    ComponentInfo = lstComponents.Count == 0 ? null : lstComponents[0];

                    if (ComponentInfo == null)
                    {
                        throw new CimesException(RuleMessage.Error.C00039(ProcessLotData.Lot));
                    }
                    #endregion
                }

                //DMCCode有刻字無意義,或是沒有刻DMCCODE,WOLOT是唯一所以可以直接找到批號
                if (_ProdType == CustomizeFunction.ProdType.B.ToCimesString() || _ProdType == CustomizeFunction.ProdType.W.ToCimesString())
                {
                    #region 以小工單號找出批號
                    // 以小工單號找出批號
                    //ProcessLotData = LotInfoEx.GetLotByWorkOrderLot(ttbWOLot.Text.Trim());
                    ProcessLotData = LotInfoEx.GetLotByLot(ttbWOLot.Text.Trim());
                    if (ProcessLotData == null)
                    {
                        throw new RuleCimesException(RuleMessage.Error.C10040(inputObject));
                    }

                    var lstComponents = ComponentInfo.GetLotAllComponents(ProcessLotData).ChangeTo <ComponentInfoEx>();

                    var lstComponentTemp = lstComponents.Find(p => p.DMC == inputObject);
                    if (lstComponentTemp != null)
                    {
                        throw new CimesException(RuleMessage.Error.C00052(inputObject));
                    }

                    // 取得所有子單元,並取得沒有做過中心孔量測的批號,以ComponentID排序
                    lstComponents = lstComponents.FindAll(p => p["CENTER_HOLE_FLAG"].ToString() == "N").OrderBy(p => p.ComponentID).ToList();

                    ComponentInfo = lstComponents.Count == 0 ? null : lstComponents[0];

                    if (ComponentInfo == null)
                    {
                        throw new CimesException(RuleMessage.Error.C00039(ProcessLotData.Lot));
                    }
                    #endregion
                }

                // 找不到工件
                if (ComponentInfo == null)
                {
                    throw new RuleCimesException(TextMessage.Error.T00045(GetUIResource("Workpiece")));
                }

                // 找不到批號
                if (ProcessLotData == null)
                {
                    throw new RuleCimesException(TextMessage.Error.T00045(GetUIResource("Lot")));
                }

                if (ComponentInfo["CENTER_HOLE_FLAG"].ToString() != "N")
                {
                    throw new RuleCimesException(RuleMessage.Error.C10049());
                }

                //批號檢查狀態
                if (ProcessLotData.Status != LotDefaultStatus.Run.ToCimesString())
                {
                    //[01203]批號狀態不正確, 應為 {0} !
                    throw new Exception(TextMessage.Error.T01203("Run"));
                }

                // 顯示機加批號資訊
                //ttbWOLot.Text = ProcessLotData["WOLOT"].ToString();
                // 顯示鍛造批號資訊
                ttbMaterialLot.Text = ProcessLotData["MATERIALLOT"].ToString();
                // 顯示工件序號資訊
                ttbWorkpieceSerialNumber.Text = ComponentInfo.ComponentID;
                // 顯示料號資訊
                ttbDeviceName.Text = ProcessLotData.DeviceName;

                var deviceInfo = DeviceInfo.GetDeviceByName(ProcessLotData.DeviceName);
                // 顯示機加批號資訊
                ttbDeviceDescr.Text = deviceInfo.Description;
                // 顯示工作站資訊
                ttbOperation.Text = ProcessLotData.OperationName;
                // 顯示流程名稱資訊
                ttbRouteName.Text = ProcessLotData.RouteName;

                if (_CenterHoleFlag.ToBool())
                {
                    // 取得中心孔量測設定值
                    var lstSAICenterHolde = WpcExClassItemInfo.GetExClassItemInfo("SAICenterHole", ProcessLotData.DeviceName);
                    if (lstSAICenterHolde.Count == 0)
                    {
                        lstSAICenterHolde = WpcExClassItemInfo.GetExClassItemInfo("SAICenterHole", "ALL");
                    }
                    // 若找不到中心孔量測需拋錯
                    if (lstSAICenterHolde.Count == 0)
                    {
                        throw new RuleCimesException(TextMessage.Error.T00555("SAICenterHole", ProcessLotData.DeviceName + "," + "ALL"));
                    }

                    SAICenterHole = lstSAICenterHolde[0];
                    // 設定中心孔量測的DataTable資料
                    DataTable dtEmpty = new DataTable();
                    dtEmpty.Columns.Add("ITEM", typeof(int));
                    dtEmpty.Columns.Add("EDC", typeof(String));

                    for (int i = 0; i < SAICenterHole.Remark04.ToDecimal(0); i++)
                    {
                        DataRow dr = dtEmpty.NewRow();
                        dr["ITEM"] = i + 1;
                        dtEmpty.Rows.Add(dr);
                    }
                    // 將產生的資料表顯示在畫面上
                    gvComponentEDC.DataSource = dtEmpty;
                    gvComponentEDC.DataBind();

                    ttbTemperature.ReadOnly = false;
                }
                else
                {
                    btnOK_Click(null, EventArgs.Empty);
                }
            }
            catch (Exception ex)
            {
                ttbWorkpiece.Text = "";
                ClearUI();
                HandleError(ex, ttbWorkpiece.ClientID);
            }
        }
예제 #12
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";

                    //確認是否有選擇原因碼
                    ddlFAIReasonCode.Must(lblFAIReasonCode);
                }
                else if (rdbPASS.Checked)
                {
                    result = "PASS";
                }
                else if (rdbCLOSE.Checked)
                {
                    result = "CLOSE";

                    //確認是否有選擇原因碼
                    ddlFAIReasonCode.Must(lblFAIReasonCode);
                }
                #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>();

                    //原因碼
                    ReasonCategoryInfo reason = null;

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

                    //如果判定結果為結單的話,則必須把結單時間及人員資料寫回資料庫
                    if (result == "CLOSE")
                    {
                        QCInsepctionData.FINISHTIME = txnStamp.RecordTime;
                        QCInsepctionData.FINISHUSER = txnStamp.UserID;
                    }

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

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

                    #endregion

                    #region 更新機台檢驗主檔[CST_WIP_CMM]

                    if (_CSTWIPCMMList != null)
                    {
                        //更新檢驗主檔的QCInspectionSID欄位
                        _CSTWIPCMMList.ForEach(data =>
                        {
                            data.QCInspectionSID = QCInsepctionData.ID;
                            data.UpdateToDB();
                        });
                    }

                    #endregion

                    #region 更新機台資訊

                    //取得相同BatchID的檢驗資料
                    var QCDataList = QCInspectionInfoEx.GetDataListByBatchID(_SelectedQCData.BatchID);

                    //相同BatchID都已完成檢驗旗標
                    bool isAllFinish = true;

                    QCDataList.ForEach(p =>
                    {
                        if (!(p.Status == "Finished"))
                        {
                            isAllFinish = false;
                        }
                    });

                    //取得lot資料
                    var lot = InfoCenter.GetBySID <LotInfo>(_SelectedQCData.ObjectSID);

                    //更新機台屬性[FAICOUNT]
                    CustomizeFunction.UpdateFAI(_SelectedQCData.EquipmentName, lot.Lot, (rdbNG.Checked) ? true : false, txnStamp);

                    //如果相同的BatchID都檢驗完成或選擇結果為NG時,則更新狀態為IDLE及更新FAICOUNT
                    if (isAllFinish)
                    {
                        //取得機台狀態資料
                        var newStateInfo = EquipmentStateInfo.GetEquipmentStateByState("IDLE");

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

                        //更新機台狀態
                        EMSTransaction.ChangeState(equipData, newStateInfo, txnStamp);
                    }
                    #endregion

                    //如果判定結果選擇為NG,則必須拆批送待判
                    if (rdbNG.Checked)
                    {
                        //判定NG直接拆批及送待判工作站
                        CustomizeFunction.SplitDefectLot(_SelectedQCData.ComponentLot, ttbDescr.Text, reason, txnStamp);
                    }

                    cts.Complete();
                }

                ClearField();
                AjaxFocus(ttbLot);

                _ProgramInformationBlock.ShowMessage(TextMessage.Hint.T00614(""));
            }
            catch (Exception ex)
            {
                HandleError(ex);
            }
        }
예제 #13
0
        /// <summary>
        /// 輸入生產編號
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void ttbLot_TextChanged(object sender, EventArgs e)
        {
            try
            {
                //確認是否有輸入資料
                ttbLot.Must(lblLot);

                #region 取得檢驗資料(查詢機台、序號、機加批號及鍛造批號欄位是否有符合介面輸入的資料,資料狀態必須為FAI且判定結果為NULL)
                string sql = @"SELECT A.*, B.EQUIPMENT, B.PASSFLAG, B.BATCHID, B.DEVICE
                                  FROM MES_QC_INSP_OBJ A
                                       LEFT JOIN MES_QC_INSP B ON A.QC_INSP_SID = B.QC_INSP_SID
                                 WHERE (ITEM1 = #[STRING] OR ITEM2 = #[STRING] OR ITEM3 = #[STRING] OR EQUIPMENT = #[STRING]) 
                                    AND STATUS = 'FAI' 
                                    AND RESULT IS NULL";

                var lot = CustomizeFunction.ConvertDMCCode(ttbLot.Text.Trim());

                var table = DBCenter.GetDataTable(sql, lot, lot, lot, lot);

                if (table.Rows.Count == 0)
                {
                    //生產編號:{0} 查無檢驗資料!
                    throw new Exception(RuleMessage.Error.C10062(lot));
                }

                //清除檢驗清單資料
                _QCDataList.Clear();

                foreach (DataRow dr in table.Rows)
                {
                    _QCDataList.Add(new QCData()
                    {
                        ID                  = dr["QC_INSP_OBJ_SID"].ToString(),
                        EquipmentName       = dr["EQUIPMENT"].ToString(),
                        SecondEquipmentName = dr["ITEM5"].ToString(),
                        BatchID             = dr["BATCHID"].ToString(),
                        ComponentLot        = dr["ITEM1"].ToString(),
                        WorkOderLot         = dr["ITEM2"].ToString(),
                        MaterialLot         = dr["ITEM3"].ToString(),
                        ObjectSID           = dr["OBJECTSID"].ToString(),
                        PassFlag            = dr["PASSFLAG"].ToString(),
                        QCInspectionSID     = dr["QC_INSP_SID"].ToString(),
                        DeviceName          = dr["DEVICE"].ToString()
                    });
                }
                #endregion

                #region 清除介面資料

                ddlFAIReasonCode.Items.Clear();
                ddlSN.Items.Clear();
                ddlEquip.Items.Clear();

                ttbMaterialLot.Text  = "";
                ttbDescr.Text        = "";
                ttbWorkOrderLot.Text = "";

                btnOK.Enabled = false;

                rdbOK.Checked   = true;
                rdbNG.Checked   = false;
                rdbPASS.Checked = false;

                rdbOK.Enabled   = true;
                rdbNG.Enabled   = false;
                rdbPASS.Enabled = false;
                #endregion

                #region 設置機台資料

                //取得所有檢驗資料之不重複機台名稱
                foreach (var QCData in _QCDataList)
                {
                    ListItem newItem = new ListItem(QCData.EquipmentName, QCData.EquipmentName);

                    if (ddlEquip.Items.Contains(newItem) == false)
                    {
                        ddlEquip.Items.Add(newItem);
                    }
                }

                if (ddlEquip.Items.Count == 0)
                {
                    //生產編號:{0} 沒有機台可以選擇!
                    throw new Exception(RuleMessage.Error.C10063(lot));
                }

                if (ddlEquip.Items.Count != 1)
                {
                    ddlEquip.Items.Insert(0, "");
                }
                else
                {
                    ddlEquip.SelectedIndex = 0;
                    ddlEquip_SelectedIndexChanged(null, EventArgs.Empty);
                }
                #endregion
            }
            catch (Exception ex)
            {
                ClearField();
                AjaxFocus(ttbLot);
                HandleError(ex);
            }
        }
예제 #14
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);
                }
                else if (rdbCLOSE.Checked)
                {
                    result = "CLOSE";

                    //確認是否有選擇原因碼
                    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>();

                    //原因碼
                    ReasonCategoryInfo reason = null;

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

                    //如果判定結果為結單的話,則必須把結單時間及人員資料寫回資料庫
                    if (result == "CLOSE")
                    {
                        QCInsepctionData.FINISHTIME = txnStamp.RecordTime;
                        QCInsepctionData.FINISHUSER = txnStamp.UserID;
                    }

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

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

                    #endregion

                    #region 更新機台檢驗主檔[CST_WIP_CMM]

                    if (_CSTWIPCMMList != null)
                    {
                        //更新檢驗主檔的QCInspectionSID欄位
                        _CSTWIPCMMList.ForEach(data =>
                        {
                            data.QCInspectionSID = QCInsepctionData.ID;
                            data.UpdateToDB();
                        });
                    }

                    #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及PQC的檢驗單號資料
                        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

                    //如果判定結果選擇為NG,則必須拆批送待判
                    if (rdbNG.Checked)
                    {
                        //判定NG直接拆批及送待判工作站
                        CustomizeFunction.SplitDefectLot(_SelectedQCData.ComponentLot, ttbDescr.Text, reason, txnStamp);
                    }

                    cts.Complete();
                }

                ClearField();
                AjaxFocus(ttbLot);

                _ProgramInformationBlock.ShowMessage(TextMessage.Hint.T00614(""));
            }
            catch (Exception ex)
            {
                HandleError(ex);
            }
        }
예제 #15
0
        protected void ttbTempWorkpiece_TextChanged(object sender, EventArgs e)
        {
            try
            {
                //必須輸入Device
                if (_DeviceName.IsNullOrEmpty())
                {
                    ttbTempWorkpiece.Text = "";
                    AjaxFocus(ttbDeviceName);
                    throw new RuleCimesException(TextMessage.Error.T00826(lblDeviceName.Text));
                }

                if (ttbTempWorkpiece.Text.Trim().IsNullOrEmpty())
                {
                    return;
                }

                string sTempWorkpiece = CustomizeFunction.ConvertDMCCode(ttbTempWorkpiece.Text.Trim());

                //取得BatchID
                var cstWIPPackTempInfo = InfoCenter.GetBySQL <CSTWIPPackTempInfo>("SELECT * FROM CST_WIP_PACK_TEMP WHERE COMPONENTID = #[STRING]", sTempWorkpiece);

                if (cstWIPPackTempInfo == null)
                {
                    throw new CimesException(RuleMessage.Error.C00054(ttbTempWorkpiece.Text.Trim()));
                }

                if (cstWIPPackTempInfo.SIDE == "R" && _DeviceName == cstWIPPackTempInfo.DeviceName)
                {
                    throw new RuleCimesException(RuleMessage.Error.C10168());
                }

                _BatchID = (cstWIPPackTempInfo == null) ? "" : cstWIPPackTempInfo.BatchID;

                if (_BatchID == "")
                {
                    AjaxFocus(ttbTempWorkpiece);
                    throw new RuleCimesException(TextMessage.Error.T00045(lblTempWorkpiece.Text));
                }

                var lstCSTWIPPackTempInfo = InfoCenter.GetList <CSTWIPPackTempInfo>("SELECT * FROM CST_WIP_PACK_TEMP WHERE BATCHID = #[STRING]", _BatchID);

                int idx = 1;
                lstCSTWIPPackTempInfo.FindAll(p => p.SIDE == "L").ForEach(p =>
                {
                    var packingInfo             = new PackingInfo();
                    packingInfo.Item            = idx.ToString();
                    packingInfo.Device          = _DeviceName;
                    packingInfo.ComponentID     = p.ComponentID;
                    ComponentInfo componentInfo = ComponentInfo.GetComponentByComponentID(p.ComponentID);
                    packingInfo.ComponentInfo   = componentInfo;
                    packingInfo.DMC             = componentInfo["DMC"].ToString();
                    LotInfo lotInfo             = LotInfo.GetLotByLot(componentInfo.CurrentLot);
                    packingInfo.LotInfo         = lotInfo;
                    idx++;
                    _PackingList.Add(packingInfo);
                });

                idx = 1;
                lstCSTWIPPackTempInfo.FindAll(p => p.SIDE == "R").ForEach(p =>
                {
                    var packingInfo             = new PackingInfo();
                    packingInfo.Item            = idx.ToString();
                    packingInfo.Device          = _RelativeDeviceName;
                    packingInfo.ComponentID     = p.ComponentID;
                    ComponentInfo componentInfo = ComponentInfo.GetComponentByComponentID(p.ComponentID);
                    packingInfo.ComponentInfo   = componentInfo;
                    packingInfo.DMC             = componentInfo["DMC"].ToString();
                    LotInfo lotInfo             = LotInfo.GetLotByLot(componentInfo.CurrentLot);
                    packingInfo.LotInfo         = lotInfo;
                    idx++;
                    _RelativePackingList.Add(packingInfo);
                });

                gvWorkpiece.DataSource = _PackingList;
                gvWorkpiece.DataBind();

                gvRelativeWorkpiece.DataSource = _RelativePackingList;
                gvRelativeWorkpiece.DataBind();

                ttbTempWorkpiece.Text = "";
                if (_PackingList.Count != 0 || _RelativePackingList.Count != 0)
                {
                    ttbTempWorkpiece.ReadOnly = true;
                }
                else
                {
                    ttbTempWorkpiece.ReadOnly = false;
                }
                AjaxFocus(ttbWorkpiece);
            }
            catch (Exception ex)
            {
                HandleError(ex);
            }
        }
예제 #16
0
        protected void ttbDeviceName_TextChanged(object sender, EventArgs e)
        {
            try
            {
                // 清除資料與使用者介面
                ClearField();
                // 取得輸入的料號
                string sDeviceName = ttbDeviceName.Text.Trim();

                #region 輸入料號客製屬性檢查
                var deviceVersionInfo = DeviceVersionInfo.GetActiveDeviceVersion(sDeviceName);
                if (deviceVersionInfo == null)
                {
                    throw new CimesException(TextMessage.Error.T00030(lblDeviceName.Text, sDeviceName));
                }
                // 檢查生產型態系統屬性是否有設定
                var prodTypeAttr = deviceVersionInfo["PRODTYPE"].ToString();
                if (prodTypeAttr.IsNullOrEmpty())
                {
                    throw new CimesException(TextMessage.Error.T00541(sDeviceName, "PRODTYPE"));
                }
                _ProdType = prodTypeAttr;
                // 檢查包裝方式系統屬性是否有設定
                var packTypeAttr = deviceVersionInfo["PACKTYPE"].ToString();
                if (packTypeAttr.IsNullOrEmpty())
                {
                    throw new CimesException(TextMessage.Error.T00541(sDeviceName, "PACKTYPE"));
                }
                _PackType = packTypeAttr;
                // 檢查包裝滿箱數量是否有設定
                var maxPackSizeAttr = deviceVersionInfo["MAX_PACK_SIZE"].ToString();
                if (maxPackSizeAttr.IsNullOrEmpty())
                {
                    throw new CimesException(TextMessage.Error.T00541(sDeviceName, "MAX_PACK_SIZE"));
                }
                #endregion

                string relativeDeviceAttr = "";
                // 包裝方式為Mix(左右手)須設定與檢查對應料號
                if (packTypeAttr == "Mix")
                {
                    // 若設定為混合,則滿箱數必須為雙數
                    //if (maxPackSizeAttr.ToDecimal() % 2 != 0)
                    //{
                    //    throw new CimesException(RuleMessage.Error.C10036(sDeviceName, maxPackSizeAttr.ToString()));
                    //}

                    // 檢查對應料號系統屬性是否有設定
                    relativeDeviceAttr = deviceVersionInfo["RELATIVE_DEVICE"].ToCimesString();
                    if (relativeDeviceAttr.IsNullOrEmpty())
                    {
                        throw new CimesException(TextMessage.Error.T00541(relativeDeviceAttr, "RELATIVE_DEVICE"));
                    }

                    #region  應檢查

                    string sRelativeDeviceName = relativeDeviceAttr;
                    _RelativeDeviceName = sRelativeDeviceName;
                    // 檢查對應的料號是否存在
                    var relativeDeviceIfno = DeviceVersionInfo.GetActiveDeviceVersion(sRelativeDeviceName);
                    if (relativeDeviceIfno == null)
                    {
                        throw new CimesException(RuleMessage.Error.C10037(sDeviceName, sRelativeDeviceName));
                    }
                    // 檢查對應的料號生產型態系統屬性是否有設定
                    var relativeProdTypeAttr = relativeDeviceIfno["PRODTYPE"].ToString();
                    if (relativeProdTypeAttr.IsNullOrEmpty())
                    {
                        throw new CimesException(TextMessage.Error.T00541(sRelativeDeviceName, "PRODTYPE"));
                    }
                    // 檢查對應的料號包裝方式系統屬性是否有設定
                    var relativePackTypeAttr = relativeDeviceIfno["PACKTYPE"].ToString();
                    if (relativePackTypeAttr.IsNullOrEmpty())
                    {
                        throw new CimesException(TextMessage.Error.T00541(sRelativeDeviceName, "PACKTYPE"));
                    }
                    // 檢查對應的料號包裝滿箱數量是否有設定
                    var relativeMaxPackSizeAttr = relativeDeviceIfno["MAX_PACK_SIZE"].ToString();
                    if (relativeMaxPackSizeAttr.IsNullOrEmpty())
                    {
                        throw new CimesException(TextMessage.Error.T00541(sRelativeDeviceName, "MAX_PACK_SIZE"));
                    }
                    // 檢查對應的料號對應料號系統屬性
                    var relativeRelativeDeviceAttr = relativeDeviceIfno["RELATIVE_DEVICE"].ToString();
                    if (relativeRelativeDeviceAttr.IsNullOrEmpty())
                    {
                        throw new CimesException(TextMessage.Error.T00541(sRelativeDeviceName, "RELATIVE_DEVICE"));
                    }
                    // 檢查輸入料號與對應料號生產型態是否相同
                    if (prodTypeAttr != relativeProdTypeAttr)
                    {
                        throw new CimesException(RuleMessage.Error.C10038(sDeviceName, "PRODTYPE", prodTypeAttr, sRelativeDeviceName, "PRODTYPE", relativeProdTypeAttr));
                    }
                    // 檢查輸入料號與對應料號包裝方式是否相同
                    if (packTypeAttr != relativePackTypeAttr)
                    {
                        throw new CimesException(RuleMessage.Error.C10038(sDeviceName, "PACKTYPE", packTypeAttr, sRelativeDeviceName, "PACKTYPE", relativePackTypeAttr));
                    }
                    // 檢查輸入料號與對應料號滿箱數量是否相同
                    if (maxPackSizeAttr != relativeMaxPackSizeAttr)
                    {
                        throw new CimesException(RuleMessage.Error.C10038(sDeviceName, "MAX_PACK_SIZE", maxPackSizeAttr, sRelativeDeviceName, "MAX_PACK_SIZE", relativeMaxPackSizeAttr));
                    }
                    // 檢查輸入料號與對應料號[對應料號]是否相同
                    if (relativeRelativeDeviceAttr != sDeviceName)
                    {
                        throw new CimesException(RuleMessage.Error.C10039(sRelativeDeviceName, "RELATIVE_DEVICE", relativeRelativeDeviceAttr, sDeviceName));
                    }

                    #endregion

                    // 只有在包裝方式為Mix(左右手)才顯示右邊表格
                    gvRelativeWorkpiece.Visible = true;
                }
                else
                {
                    // 包裝方式非Mix(左右手)不顯示右邊表格
                    gvRelativeWorkpiece.Visible = false;
                }

                // 顯示包裝方式
                ttbPackType.Text = GetUIResource(packTypeAttr);
                // 顯示滿箱數量
                ttbMaxPackSize.Text = maxPackSizeAttr.ToDecimal().ToString();
                // 顯示對應料號
                ttbRelativeDevice.Text = relativeDeviceAttr == null ? "" : relativeDeviceAttr;

                _DeviceName = sDeviceName;
                // 取得班別資料
                _StartTime = DBCenter.GetSystemTime();
                var shiftData = CustomizeFunction.GetUserShifeData(_StartTime, false);
                _ShiftDate = shiftData.First;
                _Shift     = shiftData.Second;

                AjaxFocus(ttbWorkpiece);
            }
            catch (Exception ex)
            {
                HandleError(ex, ttbDeviceName.ClientID);
            }
        }
예제 #17
0
        /// <summary>
        /// 確定
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnOK_Click(object sender, EventArgs e)
        {
            /*******************************************************************
             * PPK判定後須執行事項:
             * 1. 依照判定的BATCHID+料號,將所屬單號資料更新。
             * 2. 依照判定狀態更新CST_WIP_PPK結果。
             * 3. 如同一個BATCHID都判定完成,變更機台狀態,從PPK變IDLE。
             *    如一個BATCHID有兩個料號,需兩個料號都判定完成才可以變更機台狀態。
             ******************************************************************/
            try
            {
                //取得所選擇的料號名稱
                var deviceName = ddlDevice.SelectedValue;

                #region 確認選擇結果,如果是選擇NG,確認是否有選擇原因碼及選擇結果及檢驗清單的勾選是否符合
                string result = "";
                if (rdbOK.Checked)
                {
                    result = "OK";
                }
                else if (rdbNG.Checked)
                {
                    result = "NG";

                    //確認是否有選擇原因碼
                    ddlPPKReasonCode.Must(lblPPKReasonCode);

                    if (SelectedNGData() == false)
                    {
                        //PPK結果選擇NG,檢驗清單至少勾選一筆資料!
                        throw new Exception(RuleMessage.Error.C10070());
                    }
                }
                else if (rdbCLOSE.Checked)
                {
                    result = "CLOSE";

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

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

                using (var cts = CimesTransactionScope.Create())
                {
                    #region 更新檢驗主檔清單[MES_QC_INSP]
                    _QCInspectionDataList.ForEach(QCInspectionData =>
                    {
                        //符合選擇的料號才進行資料更新
                        if (QCInspectionData.DeviceName == deviceName)
                        {
                            //有選擇原因碼才更新[NG_Category]及[NG_Reason]
                            if (string.IsNullOrEmpty(ddlPPKReasonCode.SelectedValue) == false)
                            {
                                var reason = InfoCenter.GetBySID <ReasonCategoryInfo>(ddlPPKReasonCode.SelectedValue);
                                QCInspectionData.NG_Category = reason.Category;
                                QCInspectionData.NG_Reason   = reason.Reason;
                            }

                            //如果判定結果為結單的話,則必須把結單時間及人員資料寫回資料庫
                            if (result == "CLOSE")
                            {
                                QCInspectionData.FINISHTIME = txnStamp.RecordTime;
                                QCInspectionData.FINISHUSER = txnStamp.UserID;
                            }

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

                            QCInspectionData.UpdateToDB(txnStamp.UserID, txnStamp.RecordTime);
                        }
                    });
                    #endregion

                    #region 更新機台資訊及檢驗工件結果

                    //取某一支工件序號的資料來傳入UpdatePPK
                    var updateLot = InfoCenter.GetBySID <LotInfo>(_QCInspectionObjDataList[0].OBJECTSID).ChangeTo <LotInfoEx>();

                    //更新[CST_WIP_PPK.PPKCOUNT]
                    CustomizeFunction.UpdatePPK(_QCInspectionDataList[0].EquipmentName, updateLot.DeviceName, updateLot.DeviceVersion, (rdbNG.Checked) ? "false" : "true");

                    //將介面上所勾選/不勾選的資料對應到MES_QC_INSP_OBJ.ITEM4的欄位
                    for (int i = 0; i < gvQC.Rows.Count; i++)
                    {
                        var thisCheckBox = (CheckBox)gvQC.Rows[i].FindControl("ckbDefectSelect");

                        if (thisCheckBox.Checked)
                        {
                            _QCInspectionObjDataList[i].ItemName4 = "NG";
                        }
                        else
                        {
                            _QCInspectionObjDataList[i].ItemName4 = "OK";
                        }

                        _QCInspectionObjDataList[i].UpdateToDB(txnStamp.UserID, txnStamp.RecordTime);
                    }

                    //更新機台檢驗主檔
                    _CSTWIPCMMList.ForEach(data =>
                    {
                        data.UpdateToDB();
                    });

                    //取得相同BatchID的檢驗資料 (理論上應該都完成檢驗...)
                    //如果是雙料號,每次判定要分料號判定
                    var QCDataList = QCInspectionInfoEx.GetDataListByBatchIDAndDeviceName(_QCInspectionDataList[0].BatchID, deviceName);
                    //如果是雙料號,每次判定要分料號判定,但是機台的狀態要該batchID都判定通過,才算PPK完成
                    var QCDAllataList = QCInspectionInfoEx.GetDataListByBatchID(_QCInspectionDataList[0].BatchID);

                    #region 如果相同的BatchID都檢驗完成時,則更新機台狀態為IDLE
                    //相同BatchID都已完成檢驗旗標
                    //如果是雙料號,每次判定要分料號判定,但是機台的狀態要該batchID都判定通過,才算PPK完成
                    bool isAllFinish = true;

                    QCDAllataList.ForEach(p =>
                    {
                        if (p.Status != "Finished")
                        {
                            isAllFinish = false;
                        }
                    });

                    if (isAllFinish)
                    {
                        //取得機台狀態資料
                        var newStateInfo = EquipmentStateInfo.GetEquipmentStateByState("IDLE");

                        //檢查機台是否存在
                        var equipData = EquipmentInfo.GetEquipmentByName(_QCInspectionDataList[0].EquipmentName);
                        if (equipData == null)
                        {
                            //[00885]機台{0}不存在!
                            throw new Exception(TextMessage.Error.T00885(_QCInspectionDataList[0].EquipmentName));
                        }

                        //更新機台狀態
                        EMSTransaction.ChangeState(equipData, newStateInfo, txnStamp);
                    }
                    #endregion

                    #region 如果相同的BatchID都檢驗完成且結果都為OK時,則更新機台檢驗資料及更新COUNT
                    //相同BatchID都已完成檢驗及結果都為OK旗標
                    bool isAllFinishAndOK = true;
                    QCDataList.ForEach(p =>
                    {
                        if (!(p.Status == "Finished" && p.Result == "OK"))
                        {
                            isAllFinishAndOK = false;
                        }
                    });

                    if (isAllFinishAndOK)
                    {
                        //取得AutoMerge原因碼
                        var reasonCategory = ReasonCategoryInfo.GetReasonCategoryByCategoryNameAndReason("CustomizeReason", "AutoMerge");
                        if (reasonCategory == null)
                        {
                            //[00030]{0}:{1}不存在!
                            throw new Exception(TextMessage.Error.T00030("", "CustomizeReason- AutoMerge"));
                        }

                        _QCInspectionObjDataList.ForEach(Data =>
                        {
                            //更新機台檢驗資料
                            Data.UpdateToDB(txnStamp.UserID, txnStamp.RecordTime);
                        });

                        var mergeList = _QCInspectionObjDataList.Select(p => p.ItemName2).Distinct().ToList();

                        foreach (var lot in mergeList)
                        {
                            var lotData = LotInfoEx.GetLotByWorkOrderLot(lot);

                            //確認FAI是否已經檢驗完成
                            if (CustomizeFunction.CheckFAI(_QCInspectionDataList[0].EquipmentName, lotData.Lot))
                            {
                                //執行AutoMerge
                                CustomizeFunction.AutoMerge(lotData.InventoryLot, txnStamp, reasonCategory);
                            }
                        }
                    }
                    #endregion

                    #endregion

                    cts.Complete();
                }

                ClearField();
                AjaxFocus(ttbEquipOrCompLot);

                _ProgramInformationBlock.ShowMessage(TextMessage.Hint.T00614(""));
            }
            catch (Exception ex)
            {
                HandleError(ex);
            }
        }
예제 #18
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);
            }
        }