예제 #1
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);

                //確認是否輸入刀具零組件
                ttbToolName.Must(lblToolName);

                //確認是否有選擇變更回廠日
                var date = ttbDate.MustDate(lblDate);

                //取得系統時間
                var sysDate = Convert.ToDateTime(DBCenter.GetSystemDateTime().ToString("yyyy/MM/dd"));

                //確認預定回廠日是否大於等於當天日期
                if (date < sysDate)
                {
                    //變更回廠日必須大於等於{0} !
                    throw new Exception(RuleMessage.Error.C10170(sysDate.ToString("yyyy/MM/dd")));
                }

                using (var cts = CimesTransactionScope.Create())
                {
                    #region 更新[CST_TOOL_REPAIR]的預計回廠日
                    _ToolRepairData.EstimateDateOfReturn = ttbDate.Text;
                    _ToolRepairData.UpdateToDB(txnStamp.UserID, txnStamp.RecordTime);

                    //新增一筆[CST_TOOL_REPAIR_LOG]
                    LogCenter.LogToDB(_ToolRepairData, LogCenter.LogIndicator.Create(ActionType.Set, txnStamp.UserID, txnStamp.RecordTime));

                    #endregion

                    //預定回廠日
                    TMSTransaction.ModifyToolSystemAttribute(_ToolData, "USERDEFINECOL04", ttbDate.Text, txnStamp);

                    cts.Complete();
                }

                ClearField();

                AjaxFocus(ttbToolName);

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

                //確認是否輸入刀具零組件
                ttbToolName.Must(lblToolName);

                //確認是否選擇維修原因
                ddlReason.Must(lblReason);

                //確認是否有選擇預定回廠日
                var date = ttbDate.MustDate(lblDate);

                //取得系統時間
                var sysDate = Convert.ToDateTime(DBCenter.GetSystemDateTime().ToString("yyyy/MM/dd"));

                //確認預定回廠日是否大於等於當天日期
                if (date < sysDate)
                {
                    //預定回廠日必須大於等於{0} !
                    throw new Exception(RuleMessage.Error.C10159(sysDate.ToString("yyyy/MM/dd")));
                }

                using (var cts = CimesTransactionScope.Create())
                {
                    //取得原因碼資料
                    var reasonCategory = InfoCenter.GetBySID <ReasonCategoryInfo>(ddlReason.SelectedValue);

                    //取得刀面資料清單
                    var toolLifes = CSTToolLifeInfo.GetToolLifeByToolNmae(_ToolData.ToolName);
                    toolLifes.Sort(data => data.Head);

                    //新增一筆[CST_TOOL_REPAIR]
                    var newToolRePair = InfoCenter.Create <CSTToolRepairInfo>();
                    newToolRePair.EstimateDateOfReturn = ttbDate.Text;
                    newToolRePair.Parts          = ttbRepairPart.Text;
                    newToolRePair.Reason         = reasonCategory.Reason;
                    newToolRePair.ReasonCategory = reasonCategory.Category;
                    newToolRePair.RepairTime     = txnStamp.RecordTime;
                    newToolRePair.RepairUser     = txnStamp.UserID;
                    newToolRePair.ToolName       = _ToolData.ToolName;
                    newToolRePair.InsertToDB(txnStamp.UserID, txnStamp.RecordTime);

                    //新增一筆[CST_TOOL_REPAIR_LOG]
                    LogCenter.LogToDB(newToolRePair, LogCenter.LogIndicator.Create(ActionType.Add, txnStamp.UserID, txnStamp.RecordTime));

                    //新增[CST_TOOL_REPAIR_LIFE]
                    toolLifes.ForEach(toolLife =>
                    {
                        var newToolRePairLife           = InfoCenter.Create <CSTToolRepairLifeInfo>();
                        newToolRePairLife.Head          = toolLife.Head;
                        newToolRePairLife.Life          = toolLife.UseCount.ToString();
                        newToolRePairLife.ToolRepairSID = newToolRePair.ToolRepairSID;
                        newToolRePairLife.InsertToDB();
                    });

                    var newStateInfo = ToolStateInfo.GetToolStateByState("REPAIR");
                    if (newStateInfo == null)
                    {
                        //刀具零組件狀態: {0}不存在,請至配件狀態維護新增此狀態!!
                        throw new Exception(RuleMessage.Error.C10149("REPAIR"));
                    }

                    //因刀具報表需求,所以在送修時要將使用次數記錄在UDC07
                    var toolLifeData = toolLifes.Find(p => p.Head == _ToolData.Head);
                    TMSTransaction.ModifyToolSystemAttribute(_ToolData, "USERDEFINECOL07", toolLifeData.UseCount.ToCimesString(), txnStamp);

                    //變更狀態為REPAIR
                    TMSTransaction.ChangeToolState(_ToolData, newStateInfo, txnStamp);

                    int maintainCount = _ToolData.MaintainCount;

                    //維修次數+1
                    TMSTransaction.ModifyToolSystemAttribute(_ToolData, "MAINTAINCOUNT", (maintainCount + 1).ToString(), txnStamp);

                    //預定回廠日
                    TMSTransaction.ModifyToolSystemAttribute(_ToolData, "USERDEFINECOL04", ttbDate.Text, txnStamp);

                    //註記原因碼
                    txnStamp.CategoryReasonCode = reasonCategory;
                    txnStamp.Description        = "";

                    //備註
                    TMSTransaction.AddToolComment(_ToolData, txnStamp);

                    cts.Complete();
                }

                ClearField();

                AjaxFocus(ttbToolName);

                _ProgramInformationBlock.ShowMessage(TextMessage.Hint.T00614(""));
            }
            catch (Exception ex)
            {
                HandleError(ex);
            }
        }
예제 #3
0
        /// <summary>
        /// 上傳檢驗報告
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnUpload_Click(object sender, EventArgs e)
        {
            try
            {
                string toolName = "";

                toolName = ttbToolName.Text;

                if (!FileUpload1.HasFile)
                {
                    //[00854]請選擇檔案!!
                    throw new CimesException(TextMessage.Error.T00854());
                }

                var    splitString = FileUpload1.PostedFile.FileName.Split('.');
                string fileName    = splitString[0] + "_" + DBCenter.GetSystemDateTime().ToString("HHmmss") + "." + splitString[1];

                WindowsImpersonationContext impersonationContext = null;

                //儲存資料夾
                string saveDirPath = _SaveInspectionData[0].Remark01;

                //使用者帳號
                string userName = _SaveInspectionData[0].Remark02;

                //使用者密碼
                string password = _SaveInspectionData[0].Remark03;

                //實際儲存檔案路徑
                string saveFilePath = saveDirPath + "\\" + toolName + "\\" + fileName;

                //如果使用者帳號不為空白才執行切換帳號功能
                if (userName.IsNullOrTrimEmpty() == false)
                {
                    //切換使用者
                    var             tokenHandle     = Impersonate(userName, password, "domain");
                    WindowsIdentity windowsIdentity = new WindowsIdentity(tokenHandle);
                    impersonationContext = windowsIdentity.Impersonate();
                }

                //判斷儲存路徑是否存在
                if (Directory.Exists(saveDirPath + "\\" + toolName) == false)
                {
                    //如果不存在,則新增一個資料夾路徑
                    Directory.CreateDirectory(saveDirPath + "\\" + toolName);
                }

                //儲存檔案
                FileUpload1.SaveAs(saveFilePath);

                if (impersonationContext != null)
                {
                    //切換回原身分
                    impersonationContext.Undo();
                }

                //新增一筆檢驗報告資料
                var toolReport = InfoCenter.Create <CSTToolReportInfo>();
                toolReport.ToolName = toolName;
                toolReport.FileName = saveFilePath;

                _ToolReports.Add(toolReport);

                //檔案名稱:{0}已上傳完成 !
                _ProgramInformationBlock.ShowMessage(RuleMessage.Hint.C10125(fileName));

                //依據檔案名稱,顯示檔案名稱的連結
                BindFileData(toolReport.FileName, fileName);
            }
            catch (Exception ex)
            {
                HandleError(ex);
            }
        }