Esempio n. 1
0
        private void SetBranchForEdit(string holidayDate)
        {
            try
            {
                var list = CalendarBranchBiz.SearchCalendarBranch(holidayDate, "", "");
                List <ControlListData> selectedList = list.Select(p => new ControlListData {
                    TextField = p.BranchName, ValueField = p.BranchCode
                }).OrderBy(p => p.TextField).ToList();
                BindListBox(lboxBranchSelected, selectedList);

                List <ControlListData> allBranchList = BranchBiz.GetBranchList(SLMConstant.Branch.All);
                foreach (ControlListData data in selectedList)
                {
                    ControlListData obj = allBranchList.Where(p => p.ValueField == data.ValueField).FirstOrDefault();
                    if (obj != null)
                    {
                        allBranchList.Remove(obj);
                    }
                }

                BindListBox(lboxBranchAll, allBranchList);

                lblBranchAllTotal.Text      = lboxBranchAll.Items.Count.ToString();
                lblBranchSelectedTotal.Text = lboxBranchSelected.Items.Count.ToString();
            }
            catch
            {
                throw;
            }
        }
        protected void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                if (ValidateInput())
                {
                    if (cbEdit.Checked)
                    {
                        CalendarBranchBiz.UpdateData(tdmHolidayDatePopup.DateValue, txtHolidayDescPopup.Text.Trim(), GetSelectedBranchCode(), HttpContext.Current.User.Identity.Name);
                    }
                    else
                    {
                        CalendarBranchBiz.InsertData(tdmHolidayDatePopup.DateValue, txtHolidayDescPopup.Text.Trim(), GetSelectedBranchCode(), HttpContext.Current.User.Identity.Name);
                    }

                    AppUtil.ClientAlert(Page, "บันทึกข้อมูลเรียบร้อย");

                    ClearPopupControl();
                    mpePopup.Hide();

                    DoSearchCalendarBranch(0);
                }
                else
                {
                    mpePopup.Show();
                }
            }
            catch (Exception ex)
            {
                string message = ex.InnerException != null ? ex.InnerException.Message : ex.Message;
                _log.Debug(message);
                AppUtil.ClientAlert(Page, message);
            }
        }
Esempio n. 3
0
        private void DoSearchCalendarBranch(int pageIndex)
        {
            try
            {
                string holidayDate = "";
                if (tdmHolidayDateSearch.DateValue.Year != 1)
                {
                    holidayDate = tdmHolidayDateSearch.DateValue.Year.ToString() + tdmHolidayDateSearch.DateValue.ToString("-MM-dd");
                }

                List <CalendarBranchData> list = CalendarBranchBiz.SearchCalendarBranch(holidayDate, txtHolidayDescSearch.Text.Trim(), cmbBranchSearch.SelectedItem.Value);
                BindGridview(pcTop, list.ToArray(), pageIndex);
            }
            catch
            {
                throw;
            }
        }
Esempio n. 4
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                if (ValidateInput())
                {
                    var isConnectWsSuccess = false;
                    if (AppConstant.CSMServiceEnableSyncCalendar)
                    {
                        try
                        {
                            //send data to webservice
                            var updateBranchCalendarRequest = new UpdateBranchCalendarRequest();
                            updateBranchCalendarRequest.Header = new WebServiceHeader();
                            updateBranchCalendarRequest.Header.service_name = "CSMBranchService";
                            updateBranchCalendarRequest.Header.user_name    = "SLM";
                            updateBranchCalendarRequest.Header.system_code  = "SLM";
                            updateBranchCalendarRequest.Header.password     = "******";
                            updateBranchCalendarRequest.Header.command      = "UpdateBranchCalendar";
                            updateBranchCalendarRequest.HolidayDate         = tdmHolidayDatePopup.DateValue;
                            updateBranchCalendarRequest.HolidayDesc         = txtHolidayDescPopup.Text.Trim();
                            updateBranchCalendarRequest.BranchCodeList      = GetSelectedNewBranchCode().ToArray();
                            updateBranchCalendarRequest.ActionUsername      = HttpContext.Current.User.Identity.Name;
                            updateBranchCalendarRequest.UpdateMode          = cbEdit.Checked ? 1 : 2;

                            //logging
                            _log.Info("===== [Start] Call WS Submit Staff Data to CSM: InsertOrUpdateBranchCalendar =====");
                            _log.Debug("===== [START] Request Parameter =====");
                            _log.Debug("HolidayDate=" + updateBranchCalendarRequest.HolidayDate);
                            _log.Debug("HolidayDesc=" + updateBranchCalendarRequest.HolidayDesc);
                            _log.Debug("BranchCodeList=" + updateBranchCalendarRequest.BranchCodeList);
                            _log.Debug("ActionUsername="******"UpdateMode=" + updateBranchCalendarRequest.UpdateMode);
                            _log.Debug("===== [END] Request Parameter =====");

                            var start = DateTime.Now;
                            _log.DebugFormat("Start Call InsertOrUpdateBranchCalendar at {0:dd/MM/yyyy HH:mm:ss}", start);

                            var csmBranchService = new CSMBranchServiceClient();
                            var response         = csmBranchService.UpdateBranchCalendar(updateBranchCalendarRequest);
                            isConnectWsSuccess = true;

                            var stop = DateTime.Now;
                            _log.DebugFormat("End Call InsertOrUpdateBranchCalendar at {0:dd/MM/yyyy HH:mm:ss} (Elapsed Time={1} seconds)", stop, stop.Subtract(start).TotalSeconds);

                            if (response.StatusResponse.Status == "SUCCESS")
                            {
                                _log.Info("===== [End] Call WS Submit Staff Data to CSM: InsertOrUpdateBranchCalendar (SUCCESS) =====");
                                _log.Debug("===== [START] Response Data =====");
                                _log.Debug("IsSuccess=" + response.StatusResponse.Status);
                                _log.Debug("ErrorCode=" + response.StatusResponse.ErrorCode);
                                _log.Debug("ErrorMessage=" + response.StatusResponse.Description);
                                _log.Debug("===== [END] Response Data =====");
                            }
                            else if (response.StatusResponse.Status == "FAILED")
                            {
                                _log.Error("===== [End] Call WS Submit Staff Data to CSM: InsertOrUpdateBranchCalendar (FAIL) =====");
                                _log.Error("===== [START] Response Data =====");
                                _log.Error("IsSuccess=" + response.StatusResponse.Status);
                                _log.Error("ErrorCode=" + response.StatusResponse.ErrorCode);
                                _log.Error("ErrorMessage=" + response.StatusResponse.Description);
                                _log.Error("===== [END] Response Data =====");
                            }

                            if (response.StatusResponse.Status == "FAILED")
                            {
                                if (response.StatusResponse.ErrorCode == "004") // ไม่พบ branch ที่ CSM แสดง error message branch code และ branch name
                                {
                                    var errorMessage = new StringBuilder();
                                    var count        = 0;
                                    foreach (var branchCode in response.StatusResponse.BranchCodeNotFoundList)
                                    {
                                        //displat last format
                                        if (count >= 0 && count <= 4)
                                        {
                                            errorMessage.AppendFormat("{0} :สาขา{1}\r\n", branchCode, BranchBiz.GetBranchNameNew(branchCode));
                                        }
                                        else if (count == 5)
                                        {
                                            errorMessage.Append("...\r\n");
                                        }

                                        count++;
                                    }

                                    throw new Exception(string.Format("การบันทึกข้อมูลไม่สำเร็จที่ระบบ CSM \r\n Error Message: ข้อมูลที่ไม่สามารถบันทึกรายการได้ เนื่องจากไม่พบ \r\n{0} ในฐานข้อมูล", errorMessage));
                                }

                                throw new Exception(string.Format("{0} \r\nError Message : {1}", "การบันทึกข้อมูลไม่สำเร็จที่ ระบบ CSM", !string.IsNullOrEmpty(response.StatusResponse.Description) ? response.StatusResponse.Description : string.Empty));
                            }
                        }
                        catch (Exception wsex)
                        {
                            _log.Error("===== [End] Call WS Submit Staff Data to CSM: InsertOrUpdateBranchCalendar (FAIL with Exception) =====", wsex);
                            _log.Error("===== [START] FAIL with Exception =====");
                            _log.Error("ErrorMessage=" + (!string.IsNullOrEmpty(wsex.ToString()) ? wsex.ToString() : "การบันทึกข้อมูลไม่สำเร็จเนื่องจากไม่สามารถเชื่อมต่อระบบ CSM"));
                            _log.Error("===== [END] FAIL with Exception =====");
                            if (!isConnectWsSuccess)
                            {
                                throw new Exception("การบันทึกข้อมูลไม่สำเร็จเนื่องจากไม่สามารถเชื่อมต่อระบบ CSM");
                            }
                            else
                            {
                                mpePopup.Show();
                                throw wsex;
                            }
                        }
                    }

                    if (cbEdit.Checked)
                    {
                        CalendarBranchBiz.UpdateData(tdmHolidayDatePopup.DateValue, txtHolidayDescPopup.Text.Trim(), GetSelectedBranchCode(), HttpContext.Current.User.Identity.Name);
                    }
                    else
                    {
                        CalendarBranchBiz.InsertData(tdmHolidayDatePopup.DateValue, txtHolidayDescPopup.Text.Trim(), GetSelectedBranchCode(), HttpContext.Current.User.Identity.Name);
                    }

                    AppUtil.ClientAlert(Page, "บันทึกข้อมูลเรียบร้อย");

                    ClearPopupControl();
                    mpePopup.Hide();

                    DoSearchCalendarBranch(0);
                }
                else
                {
                    mpePopup.Show();
                }
            }
            catch (Exception ex)
            {
                string message = ex.InnerException != null ? ex.InnerException.Message : ex.Message;
                _log.Error(message);
                AppUtil.ClientAlert(Page, message);
            }
        }