예제 #1
0
        private void InsertToolType(int rowIndex)
        {
            int         index     = gvQuery.Rows[rowIndex].DataItemIndex;
            ArrayList   SaveList  = new ArrayList();
            string      sToolType = ((TextBox)gvQuery.Rows[rowIndex].FindControl("ttbType")).Text;
            RadioButton rbtEnable = (RadioButton)gvQuery.Rows[rowIndex].FindControl("rbEnable");
            TextBox     ttbDescr  = (TextBox)gvQuery.Rows[rowIndex].FindControl("ttbDescription");

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

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

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

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

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

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

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

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

                cts.Complete();
            }

            _ProgramInformationBlock.ShowMessage(TextMessage.Hint.T00695(sToolType));
            ToolTypeList[index] = toolTypeData;
        }
예제 #2
0
        protected void btnCopy_Click(object sender, EventArgs e)
        {
            try
            {
                //取得登入者資訊
                var recordTime = DBCenter.GetSystemTime();
                var userID     = User.Identity.Name;

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

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

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

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

                        newToolDeviceDetail.InsertToDB();

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

                    cts.Complete();
                }

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

                LoadControlDefault();
            }
            catch (Exception E)
            {
                HandleError(E);
            }
        }
예제 #3
0
        /// <summary>
        /// 確定
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnOK_Click(object sender, EventArgs e)
        {
            try
            {
                TransactionStamp txnStamp = new TransactionStamp(User.Identity.Name, ProgramRight, ProgramRight, ApplicationName);

                //檢查機台是否有輸入
                ttbEquipOrCompLot.Must(lblEquipOrCompLot);

                using (var cts = CimesTransactionScope.Create())
                {
                    #region 更新機台狀態為FAI/PPK

                    //如果QCType參數為PPK,則不需更新機台狀態
                    if (_QCType != CustomizeFunction.QCType.PPK.ToCimesString())
                    {
                        //取得機台狀態資料
                        var newStateInfo = EquipmentStateInfo.GetEquipmentStateByState(_QCType);
                        if (newStateInfo == null)
                        {
                            //C00028 無機台狀態{0}的設定資料!
                            throw new CimesException(RuleMessage.Error.C00028(_QCType));
                        }

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

                    #region 更新單號狀態為FAI/PPK
                    foreach (DataRow dr in _QCTable.Rows)
                    {
                        var qcInspectionData = InfoCenter.GetBySID <QCInspectionInfo>(dr["QCINSPSID"].ToString()).ChangeTo <QCInspectionInfoEx>();

                        qcInspectionData.Status    = _QCType;
                        qcInspectionData.StartTime = DBCenter.GetSystemTime();
                        qcInspectionData.StartUser = txnStamp.UserID;
                        qcInspectionData.UpdateToDB(txnStamp.UserID, txnStamp.RecordTime);
                    }
                    #endregion

                    cts.Complete();
                }

                ClearField();
                AjaxFocus(ttbEquipOrCompLot);

                _ProgramInformationBlock.ShowMessage(TextMessage.Hint.T00614(""));
            }
            catch (Exception ex)
            {
                HandleError(ex);
            }
        }
예제 #4
0
        /// <summary>
        /// 確定
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnOK_Click(object sender, EventArgs e)
        {
            try
            {
                TransactionStamp txnStamp = new TransactionStamp(User.Identity.Name, ProgramRight, ProgramRight, ApplicationName);

                //檢查機台是否有輸入
                ttbEquipOrCompLot.Must(lblEquipOrCompLot);

                //確認是否有勾選資料
                if (SelectedData() == false)
                {
                    // [00816]請至少選取一個{0}!
                    throw new Exception(TextMessage.Error.T00816(GetUIResource("SN")));
                }

                using (var cts = CimesTransactionScope.Create())
                {
                    #region 更新單號狀態為PPK

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

                        //只有勾選的資料才要更新單號狀態
                        if (thisCheckBox.Checked)
                        {
                            DataRow dr = _QCTable.Rows[i];
                            var     qcInspectionData = InfoCenter.GetBySID <QCInspectionInfo>(dr["QCINSPSID"].ToString()).ChangeTo <QCInspectionInfoEx>();

                            qcInspectionData.Status    = _QCType;
                            qcInspectionData.StartTime = DBCenter.GetSystemTime();
                            qcInspectionData.StartUser = txnStamp.UserID;
                            qcInspectionData.UpdateToDB(txnStamp.UserID, txnStamp.RecordTime);
                        }
                    }

                    #endregion

                    cts.Complete();
                }

                ClearField();
                AjaxFocus(ttbEquipOrCompLot);

                _ProgramInformationBlock.ShowMessage(TextMessage.Hint.T00614(""));
            }
            catch (Exception ex)
            {
                HandleError(ex);
            }
        }
예제 #5
0
        private void LoadDefaultControl()
        {
            ttbTakeUserName.Text = UserProfileInfo.GetInfoByID(Page.User.Identity.Name).UserName;
            ttbTakeDate.Text     = DBCenter.GetSystemTime().Substring(0, 10);

            #region 取得Rule的Reason
            RuleReasonInfo ruleRsn = RuleReasonInfo.GetRuleReasonByOperationRuleControlName("ALL", this.ProgramRight, "Default");
            if (ruleRsn == null)
            {
                throw new RuleCimesException(TextMessage.Error.T00641(this.ProgramRight, "ALL"));
            }
            csReason.Setup(ruleRsn.RuleName, ruleRsn.OperationName, ruleRsn.ControlName, ReasonMode.Category);
            #endregion
        }
예제 #6
0
        private void UpdateToolType(int rowIndex)
        {
            int         index     = gvQuery.Rows[rowIndex].DataItemIndex;
            string      sToolType = ((TextBox)gvQuery.Rows[rowIndex].FindControl("ttbType")).Text;
            RadioButton rbtEnable = (RadioButton)gvQuery.Rows[rowIndex].FindControl("rbEnable");
            TextBox     ttbDescr  = (TextBox)gvQuery.Rows[rowIndex].FindControl("ttbDescription");

            uscAttributeSetupGrid.ValidateCheck();

            var toolTypeData = (ToolTypeInfo)ToolTypeList[index].DeepCopy();

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

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

            using (CimesTransactionScope cts = CimesTransactionScope.Create())
            {
                if (toolTypeData.UpdateToDB() == 0)
                {
                    throw new Exception(TextMessage.Error.T00747(""));
                }

                uscAttributeSetupGrid.ExcuteTransaction(toolTypeData.ID, toolTypeData.UserID, toolTypeData.UpdateTime);

                //處理刀壽
                SaveToolLife(sToolType, txnStamp.UserID, txnStamp.RecordTime);

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

                cts.Complete();
            }

            _ProgramInformationBlock.ShowMessage(TextMessage.Hint.T00083(sToolType));
            ToolTypeList[index] = toolTypeData;
        }
예제 #7
0
        /// <summary>
        /// 依據傳入批號資料及工作站來更新預約資料
        /// </summary>
        /// <param name="txnLotData"></param>
        /// <param name="operationName"></param>
        /// <param name="txnStamp"></param>
        public void UpdateReserveCheckInData(LotInfoEx txnLotData, string operationName, TransactionStamp txnStamp)
        {
            //取得預約資料
            var WIPReserveList = CSTWIPReserveCheckInInfo.GetDataByLotAndOper(txnLotData.Lot, operationName);

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

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

                reserveData.DeleteFromDB();
                reserveDataLog.InsertToDB();
            });
        }
예제 #8
0
        protected void gvQuery_RowDeleting(object sender, GridViewDeleteEventArgs e)
        {
            try
            {
                int dataIndex = gvQuery.Rows[e.RowIndex].DataItemIndex;

                //取得登入者資訊
                var recordTime = DBCenter.GetSystemTime();
                var userID     = User.Identity.Name;

                using (CimesTransactionScope cts = CimesTransactionScope.Create())
                {
                    //刪除主檔資料
                    _ToolDevices[dataIndex].DeleteFromDB();

                    LogCenter.LogToDB(_ToolDevices[dataIndex], LogCenter.LogIndicator.Create(ActionType.Remove, userID, recordTime));

                    //取得明細資料
                    var toolDeviceDetails = CSTToolDeviceDetailInfo.GetDataListByToolDeviceSID(_ToolDevices[dataIndex].ToolDeviceSID);
                    toolDeviceDetails.ForEach(toolDeviceDetail =>
                    {
                        //刪除明細資料
                        toolDeviceDetail.DeleteFromDB();

                        LogCenter.LogToDB(toolDeviceDetail, LogCenter.LogIndicator.Create(ActionType.Remove, userID, recordTime));
                    });

                    cts.Complete();
                }

                QueryData();
            }
            catch (Exception E)
            {
                HandleError(E);
            }
        }
예제 #9
0
        protected void gvQuery_RowDeleting(object sender, GridViewDeleteEventArgs e)
        {
            try
            {
                int iIndex = gvQuery.Rows[e.RowIndex].DataItemIndex;


                //避免新增未按下儲存就按其他資料的編輯
                string SID, Tag;
                if (ToolTypeList[iIndex].ActiveFlag == "T")     //ActiveFlag的判斷,若曾經啟用過則不可刪除
                {
                    removeListAddandDeletRow();
                    gvQuery.SetDataSource(ToolTypeList);
                    gvQuery.DataBind();
                    throw new Exception(TextMessage.Error.T00714());
                }
                else
                {
                    //  Delete Data
                    SID = ToolTypeList[iIndex].ID;
                    //避免若新增模式時,按下刪除的button,不作動作
                    if (SID.Length == 0)
                    {
                        return;
                    }

                    using (CimesTransactionScope cts = CimesTransactionScope.Create())
                    {
                        if (ToolTypeList[iIndex].DeleteFromDB() == 0)
                        {
                            throw new Exception(TextMessage.Error.T00710(""));
                        }

                        AttributeAttributeInfo.DeleteByObjectSIDAndDataClass(SID, "ToolTypeAttribute", this.User.Identity.Name, DBCenter.GetSystemTime());

                        cts.Complete();
                    }
                    _ProgramInformationBlock.ShowMessage(TextMessage.Hint.T00349(ToolTypeList[iIndex].Type));

                    ToolTypeList.RemoveAt(iIndex);

                    removeListAddandDeletRow();
                    gvQuery.SetDataSource(ToolTypeList);

                    gvQuery.EditItemIndex = -1;
                    if (gvQuery.CurrentPageIndex > ((ToolTypeList.Count - 1) / gvQuery.PageSize))
                    {
                        gvQuery.CurrentPageIndex = (ToolTypeList.Count - 1) / gvQuery.PageSize;
                    }
                    gvQuery.DataBind();
                    DisableSubControl();
                    uscAttributeSetupGrid.ClearField();
                }
            }
            catch (Exception ex)
            {
                HandleError(ex, CurrentUpdatePanel, string.Empty, MessageShowOptions.OnLabel);
            }
        }
예제 #10
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);
            }
        }
예제 #11
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);
            }
        }
예제 #12
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                #region 檢查輸入資料
                ttbToolName.Must(lblToolName);
                ddlType.Must(lblType);

                if (!rbtDisable.Checked && !rbtEnable.Checked)
                {
                    throw new CimesException(TextMessage.Error.T00841(lblStates.Text));
                }


                CurrentToolData.ToolName = ttbToolName.Text.Trim();
                if (CurrentToolData.InfoState == InfoState.NewCreate)
                {
                    if (ToolInfo.GetToolByName(CurrentToolData.ToolName) != null)
                    {
                        throw new CimesException(TextMessage.Error.T00710(CurrentToolData.ToolName));
                    }
                }

                ToolAttributeSetup.ValidateCheck();
                #endregion

                //儲存系統屬性
                _SystemAttribute.SaveSystemAttribute(CurrentToolData);

                //預設ActiveFlag = "F"
                if (CurrentToolData.InfoState == InfoState.NewCreate)
                {
                    CurrentToolData.ActiveFlag = "F";
                    CurrentToolData.Location   = "Warehouse";
                    CurrentToolData.ToolClass  = "DIE";
                }

                CurrentToolData.UsingStatus = (rbtEnable.Checked ? UsingStatus.Enable : UsingStatus.Disable);
                CurrentToolData.ToolTypeSID = ddlType.SelectedItem.Value;
                CurrentToolData.ToolType    = ddlType.SelectedItem.Text;
                if (rbtEnable.Checked)
                {
                    //若啟用,則ActiveFlag=T
                    CurrentToolData.ActiveFlag = "T";
                }
                if (ddlState.SelectedItem != null && !ddlState.SelectedItem.Value.IsNullOrTrimEmpty())
                {
                    CurrentToolData.CurrentState = ddlState.SelectedItem.Text;
                    CurrentToolData.ToolStateSID = ddlState.SelectedItem.Value;
                }
                CurrentToolData.Description = ttbDescr.Text.Trim();

                #region 將使用次數寫至ToolMaster
                DropDownList ddlCountType = (DropDownList)FindControl("PMCounterSetup1$ddlCountType");
                if (ddlCountType != null)
                {
                    CurrentToolData.CountType = ddlCountType.Text;
                }

                TextBox ttbCountRatio = (TextBox)FindControl("PMCounterSetup1$ttbCountRatio");
                if (ttbCountRatio != null)
                {
                    CheckTextBox(ttbCountRatio, GetUIResource("CountRatio"), CheckDataType.GreaterEqualZeroDecimal);
                    CurrentToolData.CountRatio = ttbCountRatio.Text.ToDecimal();
                }

                TextBox ttbTotalCount = (TextBox)FindControl("PMCounterSetup1$ttbTotalCount");
                if (ttbTotalCount != null)
                {
                    CheckTextBox(ttbTotalCount, GetUIResource("TotalCount"), CheckDataType.GreaterEqualZeroDecimal);
                    CurrentToolData.TotalCount = ttbTotalCount.Text.ToDecimal();
                }

                TextBox ttbScrapCount = (TextBox)FindControl("PMCounterSetup1$ttbScrapCount");
                if (ttbScrapCount != null)
                {
                    CheckTextBox(ttbScrapCount, GetUIResource("ScrapCount"), CheckDataType.GreaterEqualZeroDecimal);
                    CurrentToolData.ScrapCount = ttbScrapCount.Text.ToDecimal();
                }
                #endregion

                ToolInfo         toolData       = (ToolInfo)CurrentToolData.DeepCopy();
                bool             bCheckPMSSetup = true;
                TransactionStamp txnStamp       = new TransactionStamp(User.Identity.Name, ProgramRight, ProgramRight, this.ApplicationName);
                using (CimesTransactionScope cts = CimesTransactionScope.Create())
                {
                    //UserDefineColumnSet1.ModifyInfoRecordWithoutUpdate(toolData);
                    if (toolData.InfoState == InfoState.NewCreate)
                    {
                        toolData.InsertImmediately(this.User.Identity.Name, DBCenter.GetSystemTime());
                        LogCenter.LogToDB(toolData, LogCenter.LogIndicator.Default);

                        if (PMSSetupInfo.GetSetupData("TOOL", "Type", toolData.ToolType).Count == 0)
                        {
                            bCheckPMSSetup = false;
                        }
                    }
                    else
                    {
                        if (toolData.UpdateImmediately(this.User.Identity.Name, DBCenter.GetSystemTime()) != 1)
                        {
                            throw new CimesException(TextMessage.Error.T00747(""));
                        }
                        LogCenter.LogToDB(toolData, LogCenter.LogIndicator.Create(ActionType.Set));

                        if (PMSSetupInfo.GetSetupData("TOOL", "Type", toolData.ToolType).Count == 0 && PMSSetupInfo.GetSetupData("TOOL", "ID", toolData.ToolName).Count == 0)
                        {
                            bCheckPMSSetup = false;
                        }
                    }

                    ToolAttributeSetup.ExcuteTransaction(toolData.ID);

                    if (bCheckPMSSetup == true)
                    {
                        PMCounterSetupInterface.SyncSettingToDB(toolData.ID, "ToolID", txnStamp);
                    }
                    cts.Complete();
                }

                CurrentToolData = (ToolInfoEx)toolData.DeepCopy();
                BindDataByCurrentToolData();
                gvToolList.ResetCloneDataSource();
                //QueryAllTool();
                //001
                AllTools = ToolInfoEx.GetToolByToolClass("DIE");

                int index = AllTools.FindIndex(p => p.ID == CurrentToolData.ID);

                //int pageIndex = index / gvToolList.PageSize;
                int selectedIndex = index % gvToolList.PageSize;

                //換頁要放在bind資料前
                //指定選擇行放在bind資料後
                gvToolList.PageIndex = gvToolList.CurrentPageIndex;
                gvToolList.SetDataSource(AllTools, true);
                gvToolList.SelectedIndex = selectedIndex;

                DisableTab();

                _ProgramInformationBlock.ShowMessage(TextMessage.Hint.T00083(""));
            }
            catch (Exception ex)
            {
                HandleError(ex);
            }
        }
예제 #13
0
        protected void gvToolList_RowDeleting(object sender, GridViewDeleteEventArgs e)
        {
            try
            {
                CurrentToolData = AllTools[gvToolList.Rows[e.RowIndex].DataItemIndex];

                if (CurrentToolData.ActiveFlag == "T")      //ActiveFlag的判斷,若曾經啟用過則不可刪除
                {
                    throw new Exception(TextMessage.Error.T00714());
                }

                using (CimesTransactionScope cts = CimesTransactionScope.Create())
                {
                    CurrentToolData.DeleteFromDB();
                    AttributeAttributeInfo.DeleteByObjectSIDAndDataClass(CurrentToolData.ID, "ToolAttribute", this.User.Identity.Name, DBCenter.GetSystemTime());
                    LogCenter.LogToDB(CurrentToolData, LogCenter.LogIndicator.Create(ActionType.Remove, User.Identity.Name, DBCenter.GetSystemTime()));
                    cts.Complete();
                }
                CurrentToolData = null;
                gvToolList.ResetCloneDataSource();
                QueryAllTool();
                //BindGridView();
            }
            catch (Exception ex)
            {
                HandleError(ex);
            }
        }
예제 #14
0
        /// <summary>
        /// 確定
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnOK_Click(object sender, EventArgs e)
        {
            try
            {
                /*  1.	檢查畫面上所有輸入欄位是否都已輸入。
                 *  2.	如為當站進站(批號狀態為Wait),則將批號進站併上機台。(EquipmentAddLot、CheckIn、Dispatch)。
                 *  3.	如為預約進站,則將預約資訊塞入客製表,做批號備註。(AddComment)
                 *  4.	清空畫面,游標停在機加批號。
                 */
                string           equipmentName = "";
                EquipmentInfo    equipData     = null;
                TransactionStamp txnStamp      = new TransactionStamp(User.Identity.Name, ProgramRight, ProgramRight, ApplicationName);

                //檢查機台是否有輸入
                if (ttbLot.Text.IsNullOrEmpty() || _LotData == null)
                {
                    AjaxFocus(ttbLot);
                    throw new Exception(TextMessage.Error.T00030(GetUIResource("LotCheckInLot"), ""));
                }

                //如果機台下拉式清單Enabled為TRUE,則必須檢查是否有選擇機台
                if (ddlEquip.Enabled)
                {
                    ddlEquip.Must(lblEquip);

                    //取得機台資訊
                    equipData = EquipmentInfo.GetEquipmentByID(ddlEquip.SelectedValue);

                    //註記機台名稱
                    equipmentName = equipData.EquipmentName;
                }

                using (var cts = CimesTransactionScope.Create())
                {
                    //批號狀態為Wait時,表示目前要執行進站
                    if (_LotData.Status == LotDefaultStatus.Wait.ToString())
                    {
                        CheckBom(_LotData.OperationName, equipData, _LotData);

                        if (equipData != null)
                        {
                            //批號上機台
                            EMSTxn.Default.AddLotToEquipment(_LotData, equipData, txnStamp);

                            //取得機台狀態資料
                            var newStateInfo = EquipmentStateInfo.GetEquipmentStateByState("RUN");

                            if (equipData.CurrentState != "RUN")
                            {
                                //更新機台狀態
                                EMSTransaction.ChangeState(equipData, newStateInfo, txnStamp);
                            }
                        }

                        //批號進站
                        WIPTransaction.CheckIn(_LotData, equipmentName, "", "", LotDefaultStatus.Run.ToString(), txnStamp);

                        //將批號Dispatch到下一規則
                        WIPTransaction.DispatchLot(_LotData, txnStamp);
                    }
                    else
                    {
                        CheckBom(_WIPReserveCheckInData.OperationName, equipData, _LotData);

                        //執行預約進站功能
                        _WIPReserveCheckInData.Equipment = equipmentName;
                        _WIPReserveCheckInData.InTime    = DBCenter.GetSystemTime();
                        _WIPReserveCheckInData.InsertToDB();

                        //做批號備註。(AddComment)
                        var reason  = ReasonCategoryInfo.GetReasonCategoryByCategoryNameAndReason("CustomizeReason", "ReserveLotCheckIn");
                        var massage = "";

                        WIPTransaction.AddLotComment(_LotData, reason, massage, txnStamp);
                    }
                    cts.Complete();
                }

                ClearField();
                AjaxFocus(ttbLot);

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

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

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

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

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

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

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

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

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

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

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

                    cts.Complete();
                }

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

                ClearData();

                LoadControlDefault();

                QueryData();

                btnExit_Click(null, EventArgs.Empty);
            }
            catch (Exception E)
            {
                HandleError(E);
            }
        }