Ejemplo n.º 1
0
        protected void SaveBtn_Click(object sender, EventArgs e)
        {
            _salaryRepo = RepositoryFactory.CreateSalaryLimitRepo();
            //取得頁面資料
            model = WebUtils.ViewModelMapping <SalaryLimitViewModel>(this.Page);

            var validator   = new Validator();
            var validResult = validator.ValidateModel(model);

            if (!validResult.IsValid)
            {
                Response.Write(validResult.ErrorMessage.ToString().ToAlertFormat());
                return;
            }

            //btn處理
            ViewUtils.ButtonOff(SaveBtn, CoverBtn);

            //存檔
            string result = "存檔成功!";

            try
            {
                _salaryRepo.SaveData(model);
                ViewUtils.ButtonOn(SaveBtn, CoverBtn);
                Response.ShowMessageAndRefresh(result.ToAlertFormat());
            }
            catch (Exception ex)
            {
                result = String.Concat("存檔失敗!\r\n錯誤訊息: ", ex.Message);
                Response.Write(result.ToAlertFormat());
                ViewUtils.ShowRefreshBtn(CoverBtn, RefreshBtn);
            }
        }
        protected void SaveBtn_Click(object sender, EventArgs e)
        {
            _typeRepo = RepositoryFactory.CreateTypeRepo();
            //取得頁面資料
            model = WebUtils.ViewModelMapping <TypeViewModel>(this.Page);

            var validator   = new Validator();
            var validResult = validator.ValidateModel(model);

            if (!validResult.IsValid)
            {
                Response.Write(validResult.ErrorMessage.ToString().ToAlertFormat());
                return;
            }

            //btn處理
            ViewUtils.ButtonOff(SaveBtn, CoverBtn);


            //存檔
            var responseMessage = "";
            var successRdUrl    = String.Empty;

            try
            {
                if (String.IsNullOrWhiteSpace(Request["FormID"]))
                {
                    _typeRepo.CreateData(model);
                    successRdUrl    = @"TypeDataList.aspx?orderField=CreateDate&descending=True";
                    responseMessage = "新增成功!";
                }
                else
                {
                    //編輯資料
                    _typeRepo.EditData(model);
                    successRdUrl    = @"TypeDataList.aspx?orderField=ModifyDate&descending=True";
                    responseMessage = "編輯成功!";
                }

                //btn處理
                ViewUtils.ButtonOn(SaveBtn, CoverBtn);
                responseMessage = responseMessage.ToAlertAndRedirect(successRdUrl);
            }
            catch (Exception ex)
            {
                responseMessage = String.Concat("存檔失敗!\r\n錯誤訊息: ", ex.Message).ToAlertFormat();
                ViewUtils.ShowRefreshBtn(CoverBtn, RefreshBtn);
            }
            finally
            {
                Response.Write(responseMessage);
            }
        }
Ejemplo n.º 3
0
        protected void SaveBtn_Click(object sender, EventArgs e)
        {
            _forgotRepo = RepositoryFactory.CreateForgotPunchRepo();
            //取得頁面資料
            model = PageDataBind();

            var validResult       = PunchDateTimeValidate();
            var duplicateResult   = IsDuplicateSubmit();
            var theSameDateResult = IsTheSameDate();

            if (!validResult.IsValid || !duplicateResult.IsValid || !theSameDateResult.IsValid)
            {
                var errorMessage = String.Concat(validResult.ErrorMessage, ",", duplicateResult.ErrorMessage, ",", theSameDateResult.ErrorMessage);
                Response.Write(String.Join("\r\n", errorMessage.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries)).ToAlertFormat());
                return;
            }

            //btn處理
            ViewUtils.ButtonOff(SaveBtn, CoverBtn);

            var responseMessage = String.Empty;

            try
            {
                var modelList = new List <RinnaiForms>();
                modelList.Add(model);
                //存檔
                if (String.IsNullOrEmpty(Request["SignDocID_FK"]))
                {
                    _forgotRepo.CreateData(modelList);
                    responseMessage = "新增成功!";
                }
                else
                {
                    _forgotRepo.EditData(modelList);
                    responseMessage = "編輯成功!";
                }
                #region #0022忘刷送出新增email通知
                //主管ADAccount
                string chiefID = _forgotRepo.FindChiefID(Request["SignDocID_FK"], User.Identity.Name);
                if (!string.IsNullOrEmpty(chiefID))
                {
                    MailerAPI.MailInfo mailInfo = new MailerAPI.MailInfo()
                    {
                        AddresseeTemp = System.Web.Configuration.WebConfigurationManager.AppSettings["MailTemplate"],
                        Subject       = String.Format("系統提醒!簽核單號 : {0} 已經送達!", model.SignDocID_FK),
                        //Subject = "系統部測試,請勿理會此郵件,謝謝!",
                        DomainPattern = ConfigUtils.ParsePageSetting("Pattern")["DomainPattern"],
                        CC            = new System.Collections.Generic.List <string>()
                        {
                            "*****@*****.**"
                        },
                        //To = string.Format("{0}@rinnai.com.tw", chiefID)
                        To = string.Format("{0}@rinnai.com.tw", chiefID)
                    };
                    var portalDomain = ConfigUtils.ParsePageSetting("Domain")["Portal"];

                    string body =
                        MailTools.BodyToTable(
                            String.Format(
                                @"系統提醒!簽核單號 : {0} 已經送達,請儘速檢視!<br /><a href='{1}/Area/Sign/ProcessWorkflowList.aspx?queryText={0}'>連結</a> <br />此件為系統發送,請勿回覆!",
                                //@"系統部測試,請勿理會此郵件,謝謝!",
                                model.SignDocID_FK, portalDomain));
                    mailInfo.Body.Append(body);
                    if (PublicRepository.CurrentWorkflowMode == Enums.WorkflowTypeEnum.RELEASE)
                    {
                        new Mailer(mailInfo).SendMail();
                    }
                }
                #endregion

                ViewUtils.ButtonOn(SaveBtn, CoverBtn);
                responseMessage = responseMessage.ToAlertAndRedirect(@"/Area/Sign/WorkflowQueryList.aspx?orderField=CreateDate&descending=True");
            }
            catch (Exception ex)
            {
                responseMessage = String.Concat("存檔失敗!\r\n錯誤訊息: ", ex.Message).ToAlertFormat();
                ViewUtils.ShowRefreshBtn(CoverBtn, RefreshBtn);
            }
            finally
            {
                Response.Write(responseMessage);
            }
        }
        /// <summary>
        /// 表單送出觸發事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void SaveBtn_Click(object sender, EventArgs e)
        {
            //送簽文件ID
            string signID = Request["SignDocID_FK"];

            //取得資料庫連線字串並建立DB模型
            _trainDetaiRepo = RepositoryFactory.CreateTrainDetailRepo();
            //欲作業的表格對象代碼
            string trainTableID = ((int)TrainingTableTypeEnum.TABLE02).ToString().PadLeft(2, '0');

            //取得頁面資料
            model = PageDataBind();

            #region #0015 取得登入者ID 擴充可幫他人填寫受訓心得表

            var empDc    = ConnectionFactory.GetPortalDC();
            var empRepos = new EmployeeRepository(empDc, new RootRepository(empDc));
            EmployeeViewModel empResult = empRepos.GetEmployeeDataByADAccount(User.Identity.Name);
            (model as RinnaiForms).ApplyID_FK = empResult.EmployeeID;

            #endregion #0015 取得登入者ID 擴充可幫他人填寫受訓心得表

            List <DataRow> QuestionDataList = _trainDetaiRepo.QueryQuestionDataByTableID(trainTableID);

            String chkString = "";
            String ansString = "";
            txterror.Text = "";

            #region 遍歷所有題目 判斷是否有填答案

            QuestionDataList.All(row =>
            {
                //如果題目填答型態為文字
                if (row["ANSTYPE"].ToString() == "C")
                {
                    TextBox tmpbox = PlaceHolder1.FindControl("textbox" + row["serial_no"].ToString()) as TextBox;
                    ansString      = tmpbox.Text;
                    if (ansString == "")
                    {
                        chkString += "第" + row["serial_no"].ToString() + "題 不可空白!";
                    }
                }
                //如果題目填答型態為數字
                else if (row["ANSTYPE"].ToString() == "N")
                {
                    RadioButtonList tmprbl = (RadioButtonList)PlaceHolder1.FindControl("rbl" + row["serial_no"].ToString());
                    ansString = tmprbl.SelectedValue;
                    if (ansString == "")
                    {
                        chkString += "第" + row["serial_no"].ToString() + "題 不可空白!";
                    }
                }
                return(true);
            });

            #endregion 遍歷所有題目 判斷是否有填答案

            //有沒填的就直接回要面並顯示警示訊息
            if (chkString != "")
            {
                txterror.Text = chkString;
                return;
            }

            //回傳至頁面的訊息
            var responseMessage = "";
            try
            {
                var modelList = new List <RinnaiForms>();
                modelList.Add(model);

                //新增畫面(即未傳入簽核ID)
                if (String.IsNullOrEmpty(signID))
                {
                    #region 建立簽核(送出簽核)

                    _trainDetaiRepo.CreateSignData(modelList);

                    #endregion 建立簽核(送出簽核)

                    string classID   = Request["CLID"];
                    string studentID = Request["SID"];

                    #region 先刪後增

                    #region 刪除答案

                    //刪除課程與簽核的關聯檔
                    _trainDetaiRepo.FromTableNameDeleteValue("FORM_SIGN", classID, studentID, trainTableID);
                    //===刪除全部原有答案===
                    //文字型態
                    _trainDetaiRepo.FromTableNameDeleteValue("CHARACTER_ANSWER", classID, studentID, trainTableID);
                    //數字型態
                    _trainDetaiRepo.FromTableNameDeleteValue("NUMERIC_ANSWER", classID, studentID, trainTableID);

                    #endregion 刪除答案

                    #region 新增答案

                    QuestionDataList.All(row =>
                    {
                        //文字類型
                        if (row["ANSTYPE"].ToString() == "C")
                        {
                            //新增
                            TextBox tmpbox = PlaceHolder1.FindControl("textbox" + row["serial_no"].ToString()) as TextBox;
                            _trainDetaiRepo.AddAnswer_C(Request["CLID"].ToString(), Request["SID"].ToString(), row["TABLE_ID"].ToString(), row["QNO"].ToString(), row["serial_no"].ToString(), tmpbox.Text, User.Identity.Name);
                        }
                        //數字類型
                        else if (row["ANSTYPE"].ToString() == "N")
                        {
                            //新增
                            RadioButtonList tmprbl = (RadioButtonList)PlaceHolder1.FindControl("rbl" + row["serial_no"].ToString());
                            _trainDetaiRepo.AddAnswer_N(Request["CLID"].ToString(), Request["SID"].ToString(), row["TABLE_ID"].ToString(), row["QNO"].ToString(), row["serial_no"].ToString(), tmprbl.SelectedValue, User.Identity.Name);
                        }
                        return(true);
                    });

                    #endregion 新增答案

                    #endregion 先刪後增

                    string EID = _trainDetaiRepo.Find_EDITIONID(trainTableID);
                    bool   hasEmptySignFormRecords = _trainDetaiRepo.CheckHasSignFormRecords(Request["CLID"].ToString(), trainTableID, EID);

                    //寫入空白單記錄
                    if (!hasEmptySignFormRecords)
                    {
                        _trainDetaiRepo.AddRECORDS(Request["CLID"].ToString(), trainTableID, EID);
                    }

                    #region 建立關聯簽核主檔

                    _trainDetaiRepo.AddFormSign(Request["CLID"].ToString(), Request["SID"].ToString(), trainTableID, false, modelList);

                    #endregion 建立關聯簽核主檔
                }

                //編輯畫面
                else
                {
                    //送出簽核
                    _trainDetaiRepo.EditData(modelList);

                    //刪除原有答案
                    string strCLID = _trainDetaiRepo.Find_CLID(Request["SignDocID_FK"]);
                    string strSID  = _trainDetaiRepo.Find_SID(Request["SignDocID_FK"]);

                    _trainDetaiRepo.FromTableNameDeleteValue("CHARACTER_ANSWER", strCLID, strSID, trainTableID);
                    _trainDetaiRepo.FromTableNameDeleteValue("NUMERIC_ANSWER", strCLID, strSID, trainTableID);

                    QuestionDataList.All(row =>
                    {
                        if (row["ANSTYPE"].ToString() == "C")//填文字
                        {
                            //新增
                            TextBox tmpbox = PlaceHolder1.FindControl("textbox" + row["serial_no"].ToString()) as TextBox;
                            _trainDetaiRepo.AddAnswer_C(strCLID, strSID, row["TABLE_ID"].ToString(), row["QNO"].ToString(), row["serial_no"].ToString(), tmpbox.Text, User.Identity.Name);
                        }
                        else if (row["ANSTYPE"].ToString() == "N")
                        {
                            //新增
                            RadioButtonList tmprbl = (RadioButtonList)PlaceHolder1.FindControl("rbl" + row["serial_no"].ToString());
                            _trainDetaiRepo.AddAnswer_N(strCLID, strSID, row["TABLE_ID"].ToString(), row["QNO"].ToString(), row["serial_no"].ToString(), tmprbl.SelectedValue, User.Identity.Name);
                        }
                        return(true);
                    });

                    String EID = _trainDetaiRepo.Find_EDITIONID(trainTableID);
                    bool   hasEmptySignFormRecords = _trainDetaiRepo.CheckHasSignFormRecords(strCLID, trainTableID, EID);
                    //寫入空白單記錄
                    if (!hasEmptySignFormRecords)
                    {
                        _trainDetaiRepo.AddRECORDS(strCLID, trainTableID, EID);
                    }
                }
                responseMessage = "送出成功!";

                #region 寄送email通知

                MailInfo mailInfo = new MailInfo()
                {
                    AddresseeTemp = System.Web.Configuration.WebConfigurationManager.AppSettings["MailTemplate"],
                    Subject       = String.Format("系統提醒!簽核單號 : {0} 已經送達!", model.SignDocID_FK),
                    DomainPattern = ConfigUtils.ParsePageSetting("Pattern")["DomainPattern"],
                };

                // 主管簽核 會簽 mail
                var deptData = _rootRepo.QueryForDepartmentByDeptID(model.DepartmentID_FK.ToString());
                var empData  = _rootRepo.QueryForEmployeeByEmpID(deptData["ChiefID_FK"].ToString());
                var chiefAD  = empData["ADAccount"].ToString();
                mailInfo.To += String.Format(mailInfo.AddresseeTemp, chiefAD) + ",";

                var portalDomain = ConfigUtils.ParsePageSetting("Domain")["Portal"];

                string body =
                    MailTools.BodyToTable(
                        String.Format(
                            @"系統提醒!簽核單號 : {0} 已經送達,請儘速檢視!<br /><a href='{1}/Area/Sign/ProcessWorkflowList.aspx?queryText={0}'>連結</a> <br />此件為系統發送,請勿回覆!",
                            model.SignDocID_FK, portalDomain));

                mailInfo.Body.Append(body);

                mailInfo.CC = new List <string>()
                {
                    String.Format(mailInfo.AddresseeTemp, User.Identity.Name)
                };
                mailInfo.To = mailInfo.To.TrimEnd(new char[] { ',' });
                if (PublicRepository.CurrentWorkflowMode == Enums.WorkflowTypeEnum.RELEASE)
                {
                    new Mailer(mailInfo).SendMail();
                }

                #endregion 寄送email通知

                _log.Trace(String.Format("MailTo : {0}\r\ncc : {1}\r\nTitle : {2}\r\nContent : {3}\r\n", mailInfo.To, String.Join(",", mailInfo.CC), mailInfo.Subject, mailInfo.Body));
                //btn處理
                ViewUtils.ButtonOn(SaveBtn, CoverBtn);
                responseMessage = responseMessage.ToAlertAndRedirect(@"/Area/Sign/WorkflowQueryList.aspx?orderField=CreateDate&descending=True");
            }
            catch (Exception ex)
            {
                responseMessage = String.Concat("送出失敗!\r\n錯誤訊息: ", ex.Message).ToAlertFormat();
                ViewUtils.ShowRefreshBtn(CoverBtn, RefreshBtn);
            }
            finally
            {
                Response.Write(responseMessage);
            }
        }
Ejemplo n.º 5
0
        protected void SaveBtn_Click(object sender, EventArgs e)
        {
            _bbsRepo = RepositoryFactory.CreateBbsRepo();
            //取得頁面資料
            model = WebUtils.ViewModelMapping <BbsViewModel>(this.Page);
            var validator   = new Validator();
            var validResult = validator.ValidateModel(model);

            if (!validResult.IsValid)
            {
                Response.Write(validResult.ErrorMessage.ToString().ToAlertFormat());
                return;
            }
            //btn處理
            ViewUtils.ButtonOff(SaveBtn, CoverBtn);

            //存檔
            var responseMessage = "";
            var successRdUrl    = String.Empty;

            //if (!Check_Null())
            //{
            //    return;
            //}
            try
            {
                if (String.IsNullOrWhiteSpace(Request["BbsID"]))
                {
                    BatchFileUpload1(File_Photo);
                    BatchFileUpload2(File_Up1);
                    _bbsRepo.CreateData(model);
                    successRdUrl    = @"bbs_contentList.aspx?orderField=CreateDate&descending=True";
                    responseMessage = "新增成功!";
                }
                else
                {
                    string filepath1 = string.Empty;
                    if (File_Photo.Visible == false && Button_DelFILE1.Visible == true)
                    {
                        filepath1 = _bbsRepo.Find_Photo(model.bbs_id.ToString());
                    }
                    else if (!string.IsNullOrEmpty(File_Photo.PostedFile.FileName))
                    {
                        BatchFileUpload1(File_Photo);
                        filepath1 = File_Photo.FileName;
                    }
                    model.PhotoName = filepath1;

                    string filepath2 = string.Empty;
                    if (File_Up1.Visible == false && Button_DelFILE2.Visible == true)
                    {
                        filepath2 = _bbsRepo.Find_Url(model.bbs_id.ToString());
                    }
                    else if (!string.IsNullOrEmpty(File_Up1.PostedFile.FileName))
                    {
                        BatchFileUpload2(File_Up1);
                        filepath2 = File_Up1.FileName;
                    }
                    model.UpName = filepath2;

                    _bbsRepo.EditData(model);
                    successRdUrl    = @"bbs_contentList.aspx?orderField=ModifyDate&descending=True";
                    responseMessage = "編輯成功!";
                }
                //btn處理
                ViewUtils.ButtonOn(SaveBtn, CoverBtn);
                responseMessage = responseMessage.ToAlertAndRedirect(successRdUrl);
            }
            catch (Exception ex)
            {
                responseMessage = String.Concat("存檔失敗!\r\n錯誤訊息: ", ex.Message).ToAlertFormat();
                ViewUtils.ShowRefreshBtn(CoverBtn, RefreshBtn);
            }
            finally
            {
                Response.Write(responseMessage);
            }
        }
        protected void SaveBtn_Click(object sender, EventArgs e)
        {
            _trainDetaiRepo = RepositoryFactory.CreateTrainDetailRepo();
            var    QuestionDataList = _trainDetaiRepo.QueryQuestionDataByTableID("01");
            String chkString        = "";
            String ansString        = "";

            txterror.Text = "";
            if (!String.IsNullOrEmpty(Request["CLID"]) && !String.IsNullOrEmpty(Request["SID"]))
            {
                QuestionDataList.All(row =>
                {
                    if (row["ANSTYPE"].ToString() == "C")//填文字
                    {
                        TextBox tmpbox = PlaceHolder1.FindControl("textbox" + row["serial_no"].ToString()) as TextBox;
                        ansString      = tmpbox.Text;
                        if (ansString == "")
                        {
                            chkString += "第" + row["serial_no"].ToString() + "題 不可空白!";
                        }
                    }
                    else if (row["ANSTYPE"].ToString() == "N")
                    {
                        //RadioButtonList tmprbl = PlaceHolder1.FindControl("rbl" + row["serial_no"].ToString()) as RadioButtonList;
                        RadioButtonList tmprbl = (RadioButtonList)PlaceHolder1.FindControl("rbl" + row["serial_no"].ToString());
                        ansString = tmprbl.SelectedValue;
                        if (ansString == "")
                        {
                            chkString += "第" + row["serial_no"].ToString() + "題 不可空白!";
                        }
                    }

                    return(true);
                });
            }
            if (chkString != "")
            {
                txterror.Text = chkString;
            }
            else
            {
                var responseMessage = "";
                var successRdUrl    = String.Empty;
                try
                {
                    var modelList = new List <RinnaiForms>();
                    modelList.Add(model);
                    //刪除原有答案
                    _trainDetaiRepo.FromTableNameDeleteValue("CHARACTER_ANSWER", Request["CLID"], Request["SID"], "01");
                    _trainDetaiRepo.FromTableNameDeleteValue("NUMERIC_ANSWER", Request["CLID"], Request["SID"], "01");
                    QuestionDataList.All(row =>
                    {
                        if (row["ANSTYPE"].ToString() == "C")//填文字
                        {
                            //新增
                            TextBox tmpbox = PlaceHolder1.FindControl("textbox" + row["serial_no"].ToString()) as TextBox;
                            //ansString = tmpbox.Text;
                            _trainDetaiRepo.AddAnswer_C(Request["CLID"].ToString(), Request["SID"].ToString(), row["TABLE_ID"].ToString(), row["QNO"].ToString(), row["serial_no"].ToString(), tmpbox.Text, User.Identity.Name);
                        }
                        else if (row["ANSTYPE"].ToString() == "N")
                        {
                            //新增
                            RadioButtonList tmprbl = (RadioButtonList)PlaceHolder1.FindControl("rbl" + row["serial_no"].ToString());
                            //ansString = tmprbl.SelectedValue;
                            _trainDetaiRepo.AddAnswer_N(Request["CLID"].ToString(), Request["SID"].ToString(), row["TABLE_ID"].ToString(), row["QNO"].ToString(), row["serial_no"].ToString(), tmprbl.SelectedValue, User.Identity.Name);
                        }
                        return(true);
                    });
                    String EID = _trainDetaiRepo.Find_EDITIONID("01");
                    bool   hasEmptySignFormRecords = _trainDetaiRepo.CheckHasSignFormRecords(Request["CLID"].ToString(), "01", EID);
                    //寫入空白單記錄
                    if (!hasEmptySignFormRecords)
                    {
                        _trainDetaiRepo.AddRECORDS(Request["CLID"].ToString(), "01", EID);
                    }
                    //寫入記錄調查表的簽核狀態(只有02表有簽核單號)
                    _trainDetaiRepo.AddFormSign(Request["CLID"].ToString(), Request["SID"].ToString(), "01", true, modelList);
                    successRdUrl    = @"TrainList01.aspx?orderField=CLID&descending=True";
                    responseMessage = "送出成功!";

                    //btn處理
                    ViewUtils.ButtonOn(SaveBtn, CoverBtn);
                    responseMessage = responseMessage.ToAlertAndRedirect(successRdUrl);
                }
                catch (Exception ex)
                {
                    responseMessage = String.Concat("送出失敗!\r\n錯誤訊息: ", ex.Message).ToAlertFormat();
                    ViewUtils.ShowRefreshBtn(CoverBtn, RefreshBtn);
                }
                finally
                {
                    Response.Write(responseMessage);
                }
            }
        }