示例#1
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);
            }
        }
示例#2
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));
        }
示例#3
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));
        }
示例#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 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));
        }
示例#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
        /// <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;
        }
示例#8
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);
            }
        }
示例#9
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);
            }
        }
示例#10
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);
            }
        }
示例#11
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);
            }
        }
示例#12
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);
            }
        }