예제 #1
0
        /// <summary>
        /// 更新FAI,檢驗完成回壓FAICount,第一次首件回壓FAIDevice
        /// </summary>
        /// <param name="equipmentName"></param>
        /// <param name="lot"></param>
        public static void UpdateFAI(string equipmentName, string lot, bool initFlag, TransactionStamp txs)
        {
            //取得批號資料
            var lotData = LotInfo.GetLotByLot(lot);

            var faiData = CSTEquipmentFAIInfo.GetDataByEquipmentAndDevice(equipmentName, lotData.DeviceName);

            if (faiData == null)
            {
                return;
            }

            if (faiData.INSPTYPE == FAIType.CN.ToCimesString())
            {
                #region 連N測試,只要一支NG,就要reset檢驗次數,重新送件

                //判定NG的時候回壓初始化FAICount,判定OK則WAITFAICOUNT減1
                if (initFlag) //NG
                {
                    //取得料號版本的資料
                    var deviceVerExData = DeviceVersionInfo.GetDeviceVersion(lotData.DeviceName, lotData.DeviceVersion).ChangeTo <DeviceVersionInfoEx>();

                    //檢查料號的FAICount有無設定
                    if (deviceVerExData.FAICount.ToString().IsNullOrTrimEmpty())
                    {
                        //T00541
                        //料號:xxx的系統屬性:xxx 未設定,請洽IT人員!) error code:T00031
                        throw new Exception(TextMessage.Error.T00541(deviceVerExData.DeviceName, "FAICount"));
                    }

                    faiData.WAITFAICOUNT = deviceVerExData.FAICount;
                }
                else //OK
                {
                    faiData.WAITFAICOUNT = faiData.WAITFAICOUNT - 1;
                }
                #endregion
            }
            else
            {
                //首N測試,判定OK將WAITFAICOUNT減1就好,判定NG不須動作
                if (!initFlag)
                {
                    faiData.WAITFAICOUNT = faiData.WAITFAICOUNT - 1;
                }
            }

            faiData.UpdateToDB(txs.UserID, txs.RecordTime);
            LogCenter.LogToDB(faiData, LogCenter.LogIndicator.Create(ActionType.Set, txs.UserID, txs.RecordTime));
        }
예제 #2
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();
            }
        }
예제 #3
0
        private void LoadDeviceControl()
        {
            ttbDeviceFilter.Text = ttbDeviceFilter.Text.Trim();
            ddlDevice.Items.Clear();
            DeviceVersionInfo device = null;

            if (ttbDeviceFilter.Text.IsNullOrTrimEmpty() == false)
            {
                device = DeviceVersionInfo.GetActiveDeviceVersion(ttbDeviceFilter.Text);
            }

            if (device != null)
            {
                ddlProduct.Items.Clear();
                ddlProduct.Items.Insert(0, new ListItem(device.ProductName, device.ProductName));
                ddlDevice.Items.Add(new ListItem(device.DeviceName, device.DeviceName));
                ddlDevice_SelectedIndexChanged(ddlDevice, EventArgs.Empty);
            }
            else
            {
                if (ddlProduct.SelectedItem.Text.IsNullOrTrimEmpty() == true)
                {
                    return;
                }

                List <string> paras = new List <string>();
                sql = @"SELECT {0} FROM MES_PRC_DEVICE_VER V WHERE V.REVSTATE = 'ACTIVE' AND V.PRODUCT = #[STRING] ";
                paras.Add(ddlProduct.SelectedItem.Value);

                if (ttbDeviceFilter.Text.IsNullOrTrimEmpty() == false)
                {
                    sql += " AND V.DEVICE LIKE #[STRING] ";
                    paras.Add(ttbDeviceFilter.Text + "%");
                }

                //sql += " ORDER BY V.DEVICE";

                if (DBCenter.GetSingleResult <int>(string.Format(sql, "COUNT(V.DEVICE)"), paras.ToArray()) > maxReturnQty)
                {
                    ddlDevice.Items.Add(new ListItem(GetUIResource("InputRequired", lblDevice.Text), string.Empty));
                }
                else
                {
                    List <DeviceVersionInfo> DeviceList = InfoCenter.GetList <DeviceVersionInfo>(string.Format(sql + " ORDER BY V.DEVICE", "V.DEVICE"), paras.ToArray());

                    ddlDevice.DataSource     = DeviceList;
                    ddlDevice.DataTextField  = "DeviceName";
                    ddlDevice.DataValueField = "DeviceName";
                    ddlDevice.DataBind();

                    if (DeviceList.Count == 0)
                    {
                        ddlDevice.Items.Add(new ListItem(TextMessage.Error.T00550(""), string.Empty));
                    }

                    if (DeviceList.Count == 1)
                    {
                        ddlDevice_SelectedIndexChanged(ddlDevice, EventArgs.Empty);
                    }

                    if (DeviceList.Count > 1)
                    {
                        ddlDevice.Items.Insert(0, "");
                    }
                }
            }
        }
예제 #4
0
        protected void ttbWOLot_TextChanged(object sender, EventArgs e)
        {
            try
            {
                /***************************************************************************************
                 * 依照PRODTYP不同,做不同畫面的處置:
                 * S:有序號,一律刷入DMC處理。
                 * G:僅有鍛造批,選擇要判定的工作站,系統找出該工作站所有的COMPONENT,順排取最後一個
                 * W:沒有刻字,選擇要判定的工作站,系統找出該工作站所有的COMPONENT,順排取最後一個
                 * B:有刻字,但序號無意義。
                 *    在刻字站前因為未刻字所以選擇要判定的工作站,系統找出該工作站所有的COMPONENT,順排取最後一個
                 *    刻字後,直接刷入DMC處理
                 **********************************************************/
                // 清除資料與使用者介面
                ClearField();

                LoadDefaultControl();

                string sWOLot = ttbWOLot.Text.Trim();
                if (sWOLot.IsNullOrEmpty())
                {
                    return;
                }

                #region 找出料號型態
                // 小工單號找批號,此處找批號只是為了找出料號,也順便可以確認線上還有批號可以做送待判這件事
                ProcessLotData = LotInfoEx.GetLotByWorkOrderLot(sWOLot);
                if (ProcessLotData == null)
                {
                    ProcessLotData = LotInfoEx.GetLotByLot(sWOLot);
                }

                if (ProcessLotData == null)
                {
                    ttbWOLot.Text = "";
                    AjaxFocus(ttbWOLot);
                    throw new RuleCimesException(TextMessage.Error.T00030(GetUIResource("WOLot"), sWOLot));
                }

                //取得小工單號的料號版本
                var deviceVersionInfo = DeviceVersionInfo.GetLotCurrentDeviceVersion(ProcessLotData).ChangeTo <DeviceVersionInfoEx>();
                if (deviceVersionInfo == null)
                {
                    throw new CimesException(TextMessage.Error.T00537(ProcessLotData.DeviceName));
                }

                if (deviceVersionInfo.ProdType.IsNullOrTrimEmpty())
                {
                    ttbWOLot.Text = "";
                    AjaxFocus(ttbWOLot);
                    throw new RuleCimesException(TextMessage.Error.T00031(GetUIResource("Device"), deviceVersionInfo.DeviceName, "PRODTYPE"));
                }
                _ProdType = deviceVersionInfo.ProdType;
                #endregion

                #region 取得工作站
                ddlOperation.Items.Clear();
                var lstLotRouteOperation = RouteOperationInfo.GetLotDefaultOperations(ProcessLotData).OrderBy(p => p.OperationSequence).ToList();
                lstLotRouteOperation.ForEach(oper => {
                    ddlOperation.Items.Add(new ListItem(oper.OperationName + "[" + oper.OperationSequence + "]", oper.OperationName));
                });
                ddlOperation.Items.Insert(0, "");
                #endregion

                #region 原因碼選項
                ddlDefectReason.Items.Clear();
                List <BusinessReason> reason = ReasonCategoryInfo.GetOperationRuleCategoryReasonsWithReasonDescr(ProgramRight, ProcessLotData.OperationName, "Default", ReasonMode.Category);
                if (reason.Count == 0)
                {
                    reason = ReasonCategoryInfo.GetOperationRuleCategoryReasonsWithReasonDescr(ProgramRight, "ALL", "Default", ReasonMode.Category);
                }

                if (reason.Count > 0)
                {
                    ddlDefectReason.DataSource     = reason;
                    ddlDefectReason.DataTextField  = "ReasonDescription";
                    ddlDefectReason.DataValueField = "ReasonCategorySID";
                    ddlDefectReason.DataBind();

                    if (ddlDefectReason.Items.Count != 1)
                    {
                        ddlDefectReason.Items.Insert(0, "");
                    }
                    else
                    {
                        ddlDefectReason.SelectedIndex = 0;
                    }
                }
                else
                {
                    //[00641]規則:{0} 工作站:{1} 使用的原因碼未設定,請洽IT人員!
                    throw new Exception(TextMessage.Error.T00641(ProgramRight, ProcessLotData.OperationName));
                }
                #endregion

                #region 依照PRODTYPE處理介面
                ttbDefectDesc.ReadOnly  = false;
                ddlDefectReason.Enabled = true;

                if (_ProdType == CustomizeFunction.ProdType.S.ToCimesString())
                {
                    ddlOperation.Enabled  = false;
                    ttbWorkpiece.ReadOnly = false;
                }

                if (_ProdType == CustomizeFunction.ProdType.W.ToCimesString() || _ProdType == CustomizeFunction.ProdType.G.ToCimesString())
                {
                    ttbWorkpiece.ReadOnly = true;
                    ddlOperation.Enabled  = true;
                }

                if (_ProdType == CustomizeFunction.ProdType.B.ToCimesString())
                {
                    ttbWorkpiece.ReadOnly = false;
                    ddlOperation.Enabled  = true;
                }
                #endregion

                #region 找出待判站
                //在系統資料維護裡,取得此批號對應製程(CPC/CPF)的待判工作站名稱
                List <WpcExClassItemInfo> operationList      = WpcExClassItemInfo.GetExtendItemListByClassAndRemarks("SAIJudgeOperation");
                WpcExClassItemInfo        judgeOperationData = operationList.Find(p => p.Remark01 == ProcessLotData.Process);
                if (judgeOperationData == null)
                {
                    //找不到待判站資訊,請至系統資料維護增加資訊,屬性:{0}
                    throw new Exception(RuleMessage.Error.C10014(ProcessLotData.Process));
                }

                //取得待判工作站名稱
                _JudgeOperationName = judgeOperationData.Remark02;

                #endregion

                if (ttbWorkpiece.Enabled)
                {
                    AjaxFocus(ttbWorkpiece);
                }
            }
            catch (Exception ex)
            {
                HandleError(ex);
            }
        }
예제 #5
0
        protected void ttbWOLot_TextChanged(object sender, EventArgs e)
        {
            try
            {
                /****************************************************************
                * 1. 依照工作站點及料號的設定,判斷批號是否可執行中心孔資訊收集。
                * 2. 部分料號就算不收中心孔資訊,但需要收集DMC
                * 3. 若不須收集中心孔,且prodType = 'W',連DMC都不須執行
                ****************************************************************/
                ttbWorkpiece.ReadOnly   = true;
                ttbTemperature.ReadOnly = true;
                // 清除資料與使用者介面
                ClearField();

                string sWOLot = ttbWOLot.Text.Trim();
                if (sWOLot.IsNullOrEmpty())
                {
                    return;
                }

                // 小工單號找批號
                //var lotInfo = LotInfoEx.GetLotByWorkOrderLot(sWOLot);
                ProcessLotData = LotInfoEx.GetLotByLot(sWOLot);

                if (ProcessLotData == null)
                {
                    ttbWOLot.Text = "";
                    AjaxFocus(ttbWOLot);
                    throw new RuleCimesException(TextMessage.Error.T00030(lblWOLot.Text + "(" + sWOLot + ")", GetUIResource("Lot")));
                }

                _ComponentList = ComponentInfo.GetLotAllComponents(ProcessLotData);

                //取得小工單號的料號版本
                var deviceVersionInfo = DeviceVersionInfo.GetLotCurrentDeviceVersion(ProcessLotData).ChangeTo <DeviceVersionInfoEx>();
                if (deviceVersionInfo == null)
                {
                    throw new CimesException(TextMessage.Error.T00537(ProcessLotData.DeviceName));
                }

                if (deviceVersionInfo.ProdType.IsNullOrTrimEmpty())
                {
                    ttbWOLot.Text = "";
                    AjaxFocus(ttbWOLot);
                    throw new RuleCimesException(TextMessage.Error.T00031(GetUIResource("Device"), deviceVersionInfo.DeviceName, "PRODTYPE"));
                }
                _ProdType       = deviceVersionInfo.ProdType;
                _CenterHoleFlag = deviceVersionInfo.CenterHoleFlag;

                //確認執行的工作站是否需要收集中心孔
                var operData = OperationInfo.GetOperationByName(ProcessLotData.OperationName).ChangeTo <OperationInfoEx>();
                if (operData == null)
                {
                    throw new CimesException(TextMessage.Error.T00171(ProcessLotData.OperationName));
                }

                if (!operData.CenterHoleFlag.ToBool() && !operData.GetDMC.ToBool())
                {
                    AjaxFocus(ttbWOLot);
                    throw new CimesException(RuleMessage.Error.C00042(ProcessLotData.OperationName));
                }

                //若不須收集中心孔,且prodType = 'W',連DMC都不須執行
                if (!_CenterHoleFlag.ToBool() && deviceVersionInfo.ProdType == CustomizeFunction.ProdType.W.ToCimesString())
                {
                    AjaxFocus(ttbWOLot);
                    throw new CimesException(RuleMessage.Error.C00043(ProcessLotData.DeviceName));
                }

                if (_CenterHoleFlag.ToBool())
                {
                    gvComponentEDC.Visible = true;
                }
                else
                {
                    gvComponentEDC.Visible = false;
                }
                ttbWorkpiece.ReadOnly = false;
                AjaxFocus(ttbWorkpiece);
            }
            catch (Exception ex)
            {
                HandleError(ex);
            }
        }
예제 #6
0
        /// <summary>
        /// 確定
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnOK_Click(object sender, EventArgs e)
        {
            try
            {
                //確認是否輸入工件序號
                ttbCompLot.Must(lblCompLot);

                //確認是否有選擇流程
                ddlRoute.Must(lblRoute);

                //確認是否有選擇流程工作站
                ddlRouteOperation.Must(lblRouteOperation);

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

                using (var cts = CimesTransactionScope.Create())
                {
                    //以第一個工件序號為拆批的母批
                    var txnLotData = _MergeLotDataList[0];

                    //取得原因碼資料
                    var reasonData = ReasonCategoryInfo.GetReasonCategoryByCategoryNameAndReason("Common", "OTHER");

                    #region 執行拆批
                    //批號子單元清單
                    var lsComponetData = ComponentInfoEx.GetDataByCurrentLot(txnLotData.Lot);

                    //取得併批批號名稱
                    var splitLotNaming = GetNamingRule("SplitLot", txnStamp.UserID, txnLotData);

                    //批號拆批
                    var splitLot = SplitLotInfo.CreateSplitLotByLotAndQuantity(txnLotData.Lot, splitLotNaming.First[0], lsComponetData, reasonData, reasonData.Description);
                    WIPTxn.Default.SplitLot(txnLotData, splitLot, WIPTxn.SplitIndicator.Create(null, null, null, TerminateBehavior.TerminateWithHistory), txnStamp);

                    //將批號的UDC08註記N
                    WIPTransaction.ModifyLotSystemAttribute(splitLot, "USERDEFINECOL08", "N", txnStamp);

                    if (splitLotNaming.Second != null && splitLotNaming.Second.Count != 0)
                    {
                        DBCenter.ExecuteSQL(splitLotNaming.Second);
                    }
                    #endregion

                    #region 執行併批
                    //移除第一個工件序號(因為拆批已處理過了)
                    _MergeLotDataList.RemoveAt(0);

                    List <MergeLotInfo> lsMergeLots = new List <MergeLotInfo>();

                    foreach (var mergeLot in _MergeLotDataList)
                    {
                        //批號子單元清單
                        var componetDataList = ComponentInfoEx.GetDataByCurrentLot(mergeLot.Lot);

                        //加入併批清單
                        lsMergeLots.Add(MergeLotInfo.GetMergeLotByLotAndQuantity(mergeLot.Lot, componetDataList, reasonData, reasonData.Description));
                    }

                    //將數量合併到在狀態為Run的批號上
                    if (lsMergeLots.Count > 0)
                    {
                        WIPTransaction.MergeLot(splitLot, lsMergeLots, txnStamp);
                    }
                    #endregion

                    #region 變更流程

                    //取得料號版本資料
                    var deviceVersionData = DeviceVersionInfo.GetDeviceVersion(splitLot.DeviceName, splitLot.DeviceVersion);

                    //取得所選擇的流程資料
                    var routeData = InfoCenter.GetBySID <RouteInfo>(ddlRoute.SelectedValue);

                    //取得所選擇流程目前線上版本資料
                    var routeVersionData = RouteVersionInfo.GetActiveRouteVersion(routeData);

                    //取得所選擇的流程工作站資料
                    var routeOpeartionData = InfoCenter.GetBySID <RouteOperationInfo>(ddlRouteOperation.SelectedValue);

                    WIPTransaction.ReassignRoute(splitLot, deviceVersionData, routeVersionData, routeOpeartionData, reasonData, reasonData.Description, txnStamp);

                    #endregion

                    cts.Complete();
                }

                ClearField();
                AjaxFocus(ttbCompLot);

                _ProgramInformationBlock.ShowMessage(TextMessage.Hint.T00614(""));
            }
            catch (Exception ex)
            {
                HandleError(ex);
            }
        }
예제 #7
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);
            }
        }
예제 #8
0
        /// <summary>
        /// 確認預約工作站是否有開啟物料檢查功能
        /// </summary>
        private void CheckBom(string opeartoinName, EquipmentInfo equipData, LotInfo lotData)
        {
            //確認工作站是否有開啟物料檢查功能,如果機台資料為NULL,則直接跳過這個檢查機制
            var operationData = OperationInfo.GetOperationByName(opeartoinName).ChangeTo <OperationInfoEx>();

            if (operationData.CheckBOM == "Y" && equipData != null)
            {
                #region 先比對BOM表的料是否都有上機
                //取得客製表[CST_WPC_BOM]工單對應華司料(SORTF = 2)的資料
                var WOBomList = CSTWPCWorkOrderBOMInfo.GetDataByWorkOrderAndSORTF(_LotData.WorkOrder, "2");

                //取得目前選定的機台上所有的物料資料
                var eqpMLotList = EquipmentMaterialLotInfo.GetEquipmentMaterialLotByEquipment(equipData.EquipmentName);

                //確認目前選定的機台是否已經有上物料
                WOBomList.ForEach(WOBom =>
                {
                    bool isFind = false;

                    foreach (var eqpMLot in eqpMLotList)
                    {
                        //取得料編號資料
                        var materialLotData = MaterialLotInfo.GetMaterialLotByMaterialLot(eqpMLot.MaterialLot);
                        if (WOBom.MATNR == materialLotData.MaterialNO)
                        {
                            //註記有找到對應的物料編號
                            isFind = true;
                            break;
                        }
                    }

                    if (isFind == false)
                    {
                        //機台:{0} 沒有上物料編號{1}的資料!
                        throw new Exception(RuleMessage.Error.C10145(equipData.EquipmentName, WOBom.MATNR));
                    }
                });

                #endregion

                #region 依照料號的孔位設定,確認孔位都有華司資料
                var deviceVersion = DeviceVersionInfo.GetLotCurrentDeviceVersion(lotData).ChangeTo <DeviceVersionInfoEx>();

                if (deviceVersion.PushLocation.ToString().IsNullOrEmpty())
                {
                    //[00031]{0}:{1}的系統屬性:{2} 未設定,請洽IT人員!
                    throw new CimesException(TextMessage.Error.T00031(GetUIResource("Device"), deviceVersion.DeviceName, "PUSH_LOCATION"));
                }
                var lstPushLocation = deviceVersion["PUSH_LOCATION"].ToString().Split(',');

                //先取得機台上的物料批資訊
                List <MaterialLotInfo> eqpMaterialLotList = new List <MaterialLotInfo>();
                eqpMLotList.ForEach(p =>
                {
                    var mLot = MaterialLotInfo.GetMaterialLotByMaterialLot(p.MaterialLot);
                    eqpMaterialLotList.Add(mLot);
                });

                for (int i = 0; i < lstPushLocation.Length; i++)
                {
                    var mlotData = eqpMaterialLotList.Find(p => p.Location == lstPushLocation[i]);
                    if (mlotData == null)
                    {
                        throw new CimesException(RuleMessage.Error.C00041(equipData.EquipmentName, lstPushLocation[i]));
                    }
                }
                #endregion
            }
        }
예제 #9
0
        /// <summary>
        /// 切換料號
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void ddlDevice_SelectedIndexChanged(object sender, EventArgs e)
        {
            try
            {
                #region 清除資料
                ddlFileName.Items.Clear();
                ddlPPKReasonCode.Items.Clear();
                _CSTWIPCMMList = new List <CSTWIPCMMInfo>();

                _QCInspectionObjDataList.Clear();
                gvQC.SetDataSource(_QCInspectionObjDataList, true);

                _CSTWIPCMMDataList = new List <CSTWIPCMMDataInfo>();
                gvInspectionData.SetDataSource(_CSTWIPCMMDataList, true);

                btnOK.Enabled = false;
                #endregion

                //確認是否有選擇料號
                if (ddlDevice.SelectedItem.Text.IsNullOrTrimEmpty() == false)
                {
                    //取得料號名稱
                    string deviceName = ddlDevice.SelectedItem.Text;

                    //清除檢驗清單
                    _QCInspectionObjDataList.Clear();

                    List <QCInspectionObjectInfoEx> QCInspectionObjDataListTemp = new List <QCInspectionObjectInfoEx>();

                    _QCInspectionDataList.ForEach(QCData =>
                    {
                        //符合所選的料號才可以加入序號清單
                        if (QCData.DeviceName == deviceName)
                        {
                            var selectDataList = QCInspectionObjectInfoEx.GetDataListByQCInspectionSID(QCData.QC_INSP_SID);

                            QCInspectionObjDataListTemp.AddRange(selectDataList);
                        }
                    });

                    //以SID排序
                    _QCInspectionObjDataList = QCInspectionObjDataListTemp.OrderBy(p => p.ID).ToList();

                    #region 檢驗資料

                    //確認料號資料是否在在
                    _DeviceVersionData = DeviceVersionInfo.GetActiveDeviceVersion(deviceName).ChangeTo <DeviceVersionInfoEx>();
                    if (_DeviceVersionData == null)
                    {
                        //[00030]{0}:{1}不存在!
                        throw new Exception(TextMessage.Error.T00030(lblDevice.Text, deviceName));
                    }

                    //清除資料
                    _CSTWIPCMMList.Clear();

                    if (_DeviceVersionData.ProdType == CustomizeFunction.ProdType.S.ToCimesString())
                    {
                        _QCInspectionObjDataList.ForEach(data =>
                        {
                            //以機台名稱檢查是否有檢驗結果資料
                            var CSTWIPCMMListByEquipment = CSTWIPCMMInfo.GetDataListByEquipmantAndFileIDAndDevice(ttbEquip.Text, data.ItemName1, data.ItemName2,
                                                                                                                  data.ItemName3, deviceName);

                            //以OP1機台名稱檢查是否有檢驗結果資料
                            var CSTWIPCMMListBySEquipment = CSTWIPCMMInfo.GetDataListByEquipmantAndFileIDAndDevice(data.ItemName5, data.ItemName1, data.ItemName2,
                                                                                                                   data.ItemName3, deviceName);

                            //將二組資料合併,去除重覆資料
                            CSTWIPCMMListBySEquipment.ForEach(WIPCMMdata =>
                            {
                                if (CSTWIPCMMListByEquipment.Contains(WIPCMMdata) == false)
                                {
                                    CSTWIPCMMListByEquipment.Add(WIPCMMdata);
                                }
                            });

                            if (CSTWIPCMMListByEquipment.Count == 0)
                            {
                                //PPK 檢驗工件未到齊,無法執行 PPK 判定!
                                throw new Exception(RuleMessage.Error.C10118());
                            }

                            //再將找到的資料合併,去除重覆資料
                            CSTWIPCMMListByEquipment.ForEach(WIPCMMdata =>
                            {
                                //將[QC_INSP_SID]寫到每一筆檢驗機台資料
                                WIPCMMdata.QCInspectionSID = data.QC_INSP_SID;

                                if (_CSTWIPCMMList.Contains(WIPCMMdata) == false)
                                {
                                    _CSTWIPCMMList.Add(WIPCMMdata);
                                }
                            });
                        });
                    }
                    else
                    {
                        //以機台名稱檢查是否有檢驗結果資料
                        var CSTWIPCMMListByEquipment = CSTWIPCMMInfo.GetDataListByEquipmantAndDevice(ttbEquip.Text, deviceName);
                        if (CSTWIPCMMListByEquipment.Count == 0)
                        {
                            //PPK 檢驗工件未到齊,無法執行 PPK 判定!
                            throw new Exception(RuleMessage.Error.C10118());
                        }

                        _QCInspectionObjDataList.ForEach(data =>
                        {
                            //以OP1機台名稱檢查是否有檢驗結果資料
                            var CSTWIPCMMListBySEquipment = CSTWIPCMMInfo.GetDataListByEquipmantAndDevice(data.ItemName5, deviceName);

                            //將二組資料合併,去除重覆資料
                            CSTWIPCMMListBySEquipment.ForEach(WIPCMMdata =>
                            {
                                if (CSTWIPCMMListByEquipment.Contains(WIPCMMdata) == false)
                                {
                                    CSTWIPCMMListByEquipment.Add(WIPCMMdata);
                                }
                            });
                        });

                        //重新依據[FILEID], [SN], [SEQUENCE]執行排序
                        _CSTWIPCMMList = CSTWIPCMMListByEquipment.OrderBy(data => data.FileID).ThenBy(data => data["SN"]).ToList();

                        #region 確認檢驗結果主檔筆數是否與檢驗單明細筆數相同
                        List <NoSNData> NoSNDataList = new List <NoSNData>();

                        _CSTWIPCMMList.ForEach(data =>
                        {
                            NoSNData tempNoSNData = new NoSNData();
                            tempNoSNData.SN       = data["SN"].ToCimesString();
                            tempNoSNData.FileID   = data.FileID;

                            if (NoSNDataList.Contains(tempNoSNData) == false)
                            {
                                NoSNDataList.Add(tempNoSNData);
                            }
                        });

                        //比對檢驗結果主檔筆數是否與檢驗單明細筆數相同
                        if (NoSNDataList.Count != _QCInspectionObjDataList.Count)
                        {
                            //檢驗結果主檔筆數({0})與檢驗單明細筆數({1})不相同
                            throw new Exception(RuleMessage.Error.C10112(NoSNDataList.Count().ToString(), _QCInspectionObjDataList.Count.ToString()));
                        }
                        #endregion

                        for (int i = 0; i < NoSNDataList.Count; i++)
                        {
                            string QCInspectionSID = _QCInspectionObjDataList[i].QC_INSP_OBJ_SID;

                            _CSTWIPCMMList.ForEach(data =>
                            {
                                if (data.FileID == NoSNDataList[i].FileID && data["SN"].ToCimesString() == NoSNDataList[i].SN)
                                {
                                    //將[QC_INSP_SID]寫到每一筆檢驗機台資料
                                    data.QCInspectionSID = QCInspectionSID;
                                }
                            });
                        }
                    }

                    //加入機台檢驗檔名稱
                    _CSTWIPCMMList.ForEach(WIPCMMdata =>
                    {
                        ddlFileName.Items.Add(new ListItem(WIPCMMdata["FILENAME"].ToString(), WIPCMMdata.ID));
                    });

                    if (ddlFileName.Items.Count > 0)
                    {
                        ddlFileName.Items.Insert(0, "");
                    }

                    gvQC.SetDataSource(_QCInspectionObjDataList, true);
                    #endregion

                    #region 設置原因碼

                    //清除原因碼資料
                    ddlPPKReasonCode.Items.Clear();

                    rdbNG.Enabled = false;
                    rdbOK.Enabled = false;

                    rdbNG.Enabled = true;
                    rdbOK.Enabled = true;

                    //取得原因碼清單
                    List <BusinessReason> reason = ReasonCategoryInfo.GetOperationRuleCategoryReasonsWithReasonDescr(ProgramRight, "ALL", "Default", ReasonMode.Category);
                    if (reason.Count > 0)
                    {
                        ddlPPKReasonCode.DataSource     = reason;
                        ddlPPKReasonCode.DataTextField  = "ReasonDescription";
                        ddlPPKReasonCode.DataValueField = "ReasonCategorySID";
                        ddlPPKReasonCode.DataBind();

                        if (ddlPPKReasonCode.Items.Count != 1)
                        {
                            ddlPPKReasonCode.Items.Insert(0, "");
                        }
                        else
                        {
                            ddlPPKReasonCode.SelectedIndex = 0;
                        }
                    }
                    else
                    {
                        //[00641]規則:{0} 工作站:{1} 使用的原因碼未設定,請洽IT人員!
                        throw new Exception(TextMessage.Error.T00641(ProgramRight, "ALL"));
                    }

                    #endregion

                    btnOK.Enabled = true;
                }
            }
            catch (Exception ex)
            {
                //清除資料
                ddlFileName.Items.Clear();
                ddlPPKReasonCode.Items.Clear();
                _CSTWIPCMMList = new List <CSTWIPCMMInfo>();

                _QCInspectionObjDataList.Clear();
                gvQC.SetDataSource(_QCInspectionObjDataList, true);

                _CSTWIPCMMDataList = new List <CSTWIPCMMDataInfo>();
                gvInspectionData.SetDataSource(_CSTWIPCMMDataList, true);

                btnOK.Enabled = false;

                AjaxFocus(ddlDevice);
                HandleError(ex);
            }
        }