Exemplo n.º 1
0
        /// <summary>
        /// 取得配件工作站設定Tool資料
        /// </summary>
        private void QueryData()
        {
            string deviceName    = "";
            string equipmentName = "";

            if (ddlDevice.Items.Count != 0)
            {
                deviceName = ddlDevice.SelectedItem.Value;
            }

            if (ddlEquipment.Items.Count != 0)
            {
                equipmentName = ddlEquipment.SelectedItem.Value;
            }

            if (deviceName.IsNullOrTrimEmpty() && equipmentName.IsNullOrTrimEmpty())
            {
                _ToolDevices = new List <CSTToolDeviceInfo>();
            }
            else if (deviceName.IsNullOrTrimEmpty() && equipmentName.IsNullOrTrimEmpty() == false)
            {
                _ToolDevices = CSTToolDeviceInfo.GetDataListByEquipmentName(equipmentName);
            }
            else if (deviceName.IsNullOrTrimEmpty() == false && equipmentName.IsNullOrTrimEmpty())
            {
                _ToolDevices = CSTToolDeviceInfo.GetDataListByDeviceName(deviceName);
            }
            else if (deviceName.IsNullOrTrimEmpty() == false && equipmentName.IsNullOrTrimEmpty() == false)
            {
                _ToolDevices = CSTToolDeviceInfo.GetDataListByDeviceAndEquipmantName(deviceName, equipmentName);
            }

            gvQuery.SetDataSource(_ToolDevices, true);
        }
Exemplo n.º 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);
            }
        }
Exemplo n.º 3
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);
            }
        }