protected void Page_Load(object sender, EventArgs e) { try { if (!IsPostBack) { ((Label)Page.Master.FindControl("lblTopic")).Text = "แก้ไขข้อมูล Lead (Edit)"; Page.Form.DefaultButton = btnSave.UniqueID; ctlCommon.SetControlMode(Lead_Detail_Master.CtlMode.Edit); if (Request["ticketid"] != null && Request["ticketid"].ToString().Trim() != string.Empty) { CheckTicketIdPrivilege(Request["ticketid"].ToString().Trim()); } else { AppUtil.ClientAlertAndRedirect(Page, "Ticket Id not found", "SLM_SCR_003.aspx"); return; } if (!string.IsNullOrEmpty(Request["ticketid"])) { var ticketid = Request["ticketid"]; LeadData lead = SlmScr010Biz.GetLeadData(ticketid); if (lead == null) { AppUtil.ClientAlertAndRedirect(Page, "ไม่พบ Ticket Id " + ticketid + " ในระบบ", "SLM_SCR_003.aspx"); return; } if (!CheckTicketCloseOrTicketCOC(lead)) { return; } CampaignId = lead.CampaignId; ctlCommon.SetLeadData(lead); LoadDetailControl(); ctlLead.LoadData(lead); //InitialControl(); //SetScript(); } else { AppUtil.ClientAlertAndRedirect(Page, "Ticket Id not found", "SLM_SCR_003.aspx"); return; } ScreenPrivilegeData priData = RoleBiz.GetScreenPrivilege(HttpContext.Current.User.Identity.Name, "SLM_SCR_011"); if (priData == null || priData.IsView != 1) { AppUtil.ClientAlertAndRedirect(Page, "คุณไม่มีสิทธิ์เข้าใช้หน้าจอนี้", "SLM_SCR_003.aspx"); return; } //Check สิทธิ์ภัทรในการเข้าใช้งาน StaffData staff = StaffBiz.GetStaff(HttpContext.Current.User.Identity.Name); ConfigBranchPrivilegeData data = ConfigBranchPrivilegeBiz.GetConfigBranchPrivilege(staff.BranchCode); if (data != null) { if (data.IsEdit != null && data.IsEdit.Value == false) { AppUtil.ClientAlertAndRedirect(Page, "คุณไม่มีสิทธิ์เข้าใช้หน้าจอนี้", "SLM_SCR_003.aspx"); return; } } //------------------------------------------------------------------------------------------------------ } } catch (Exception ex) { string message = ex.InnerException != null ? ex.InnerException.Message : ex.Message; _log.Error(message); AppUtil.ClientAlert(Page, message); } }
private void CreateCASActivityLog(string noteId) { SlmScr009Biz biz = new SlmScr009Biz(); string emailTo = ""; string emailSubject = ""; try { var data = CARServiceBiz.GetDataForCARLogService(txtTicketID.Text.Trim(), txtPreleadId.Text.Trim()); if (cbSendEmail.Checked) { emailSubject = txtEmailSubject.Text.Trim(); if (data != null) { emailSubject = "[" + data.StatusName + "]" + (string.IsNullOrEmpty(data.SubStatusName) ? "" : "-[" + data.SubStatusName + "]") + " " + emailSubject; if (!string.IsNullOrEmpty(data.Owner) && !string.IsNullOrEmpty(data.OwnerEmail)) { emailTo += (emailTo != "" ? ", " : "") + data.OwnerEmail; } if (!string.IsNullOrEmpty(data.Delegate) && !string.IsNullOrEmpty(data.DelegateEmail)) { emailTo += (emailTo != "" ? ", " : "") + data.DelegateEmail; } } if (txtEmailTo.Text.Trim() != "") { emailTo += (emailTo != "" ? ", " : "") + txtEmailTo.Text.Trim(); } } var staff = StaffBiz.GetStaff(HttpContext.Current.User.Identity.Name); //Activity Info List <Services.CARService.DataItem> actInfoList = new List <Services.CARService.DataItem>(); actInfoList.Add(new Services.CARService.DataItem() { SeqNo = 1, DataLabel = "ผู้สร้าง Note", DataValue = staff != null ? staff.StaffNameTH : HttpContext.Current.User.Identity.Name }); actInfoList.Add(new Services.CARService.DataItem() { SeqNo = 2, DataLabel = "ส่งอีเมล", DataValue = cbSendEmail.Checked ? "Y" : "N" }); actInfoList.Add(new Services.CARService.DataItem() { SeqNo = 3, DataLabel = "To", DataValue = emailTo }); actInfoList.Add(new Services.CARService.DataItem() { SeqNo = 4, DataLabel = "Subject", DataValue = emailSubject }); actInfoList.Add(new Services.CARService.DataItem() { SeqNo = 5, DataLabel = "บันทึก Note", DataValue = txtNoteDetail.Text.Trim() }); //Customer Info List <Services.CARService.DataItem> cusInfoList = new List <Services.CARService.DataItem>(); cusInfoList.Add(new Services.CARService.DataItem() { SeqNo = 1, DataLabel = "Subscription ID", DataValue = (data != null ? data.CitizenId : "") }); cusInfoList.Add(new Services.CARService.DataItem() { SeqNo = 2, DataLabel = "Subscription Type", DataValue = (data != null ? data.CardTypeName : "") }); cusInfoList.Add(new Services.CARService.DataItem() { SeqNo = 3, DataLabel = "ชื่อ-นามสกุลของลูกค้า", DataValue = data != null ? data.CustomerName : "" }); //Product Info List <Services.CARService.DataItem> prodInfoList = new List <Services.CARService.DataItem>(); prodInfoList.Add(new Services.CARService.DataItem() { SeqNo = 1, DataLabel = "Product Group", DataValue = (data != null ? data.ProductGroupName : "") }); prodInfoList.Add(new Services.CARService.DataItem() { SeqNo = 2, DataLabel = "Product", DataValue = (data != null ? data.ProductName : "") }); prodInfoList.Add(new Services.CARService.DataItem() { SeqNo = 3, DataLabel = "Campaign", DataValue = (data != null ? data.CampaignName : "") }); //Contract Info List <Services.CARService.DataItem> contInfoList = new List <Services.CARService.DataItem>(); contInfoList.Add(new Services.CARService.DataItem() { SeqNo = 1, DataLabel = "เลขที่สัญญา", DataValue = (data != null ? data.ContractNo : "") }); contInfoList.Add(new Services.CARService.DataItem() { SeqNo = 2, DataLabel = "ระบบที่บันทึกสัญญา", DataValue = txtPreleadId.Text.Trim() != "" ? "HP" : "" }); contInfoList.Add(new Services.CARService.DataItem() { SeqNo = 3, DataLabel = "ทะเบียนรถ", DataValue = (data != null ? data.LicenseNo : "") }); //Officer Info List <Services.CARService.DataItem> offInfoList = new List <Services.CARService.DataItem>(); offInfoList.Add(new Services.CARService.DataItem() { SeqNo = 1, DataLabel = "Officer", DataValue = (staff != null ? staff.StaffNameTH : HttpContext.Current.User.Identity.Name) }); Services.CARService.CARServiceData carData = new Services.CARService.CARServiceData() { ReferenceNo = noteId, SecurityKey = txtPreleadId.Text.Trim() != "" ? SLMConstant.CARLogService.OBTSecurityKey : SLMConstant.CARLogService.SLMSecurityKey, ServiceName = "CreateActivityLog", SystemCode = txtPreleadId.Text.Trim() != "" ? SLMConstant.CARLogService.CARLoginOBT : SLMConstant.CARLogService.CARLoginSLM, //ถ้ามี preleadid ให้ถือว่าเป็น OBT ทั้งหมด ถึงจะมี TicketId ก็ตาม TransactionDateTime = DateTime.Now, ActivityInfoList = actInfoList, CustomerInfoList = cusInfoList, ProductInfoList = prodInfoList, ContractInfoList = contInfoList, OfficerInfoList = offInfoList, ActivityDateTime = DateTime.Now, CampaignId = data != null ? data.CampaignId : "", ChannelId = data != null ? data.ChannelId : "", PreleadId = txtPreleadId.Text.Trim(), ProductGroupId = data != null ? data.ProductGroupId : "", ProductId = data != null ? data.ProductId : "", Status = data != null ? data.StatusName : "", SubStatus = data != null ? data.SubStatusName : "", TicketId = txtTicketID.Text.Trim(), SubscriptionId = data != null ? data.CitizenId : "", TypeId = SLMConstant.CARLogService.Data.TypeId, AreaId = SLMConstant.CARLogService.Data.AreaId, SubAreaId = SLMConstant.CARLogService.Data.SubAreaId, ActivityTypeId = SLMConstant.CARLogService.Data.ActivityType.FYIId, ContractNo = data != null ? data.ContractNo : "" }; if (data != null && !string.IsNullOrEmpty(data.CBSSubScriptionTypeId)) { carData.CIFSubscriptionTypeId = data.CBSSubScriptionTypeId; } bool ret = Services.CARService.CreateActivityLog(carData); biz.UpdateCasFlag(txtTicketID.Text.Trim(), txtPreleadId.Text.Trim(), noteId, ret ? "1" : "2"); } catch (Exception ex) { biz.UpdateCasFlag(txtTicketID.Text.Trim(), txtPreleadId.Text.Trim(), noteId, "2"); //Error ให้ลง Log ไว้ ไม่ต้อง Throw string message = ex.InnerException != null ? ex.InnerException.Message : ex.Message; _log.Error(message); } }
private void LoadStaffData() { try { StaffDataManagement staff = new StaffDataManagement(); if (txtStaffId.Text.Trim() != "") { staff = StaffBiz.GetStaff(int.Parse(txtStaffId.Text.Trim())); } if (staff != null) { txtUsername.Text = staff.Username; lblUsername.Text = staff.Username; txtEmpCode.Text = staff.EmpCode; txtMarketingCode.Text = staff.MarketingCode; txtStaffNameTH.Text = staff.StaffNameTH; txtTellNo.Text = staff.TelNo; txtStaffEmail.Text = staff.StaffEmail; cmbPosition.SelectedIndex = cmbPosition.Items.IndexOf(cmbPosition.Items.FindByValue(staff.PositionId)); if (staff.StaffTypeId != null) { cmbStaffType.SelectedIndex = cmbStaffType.Items.IndexOf(cmbStaffType.Items.FindByValue(staff.StaffTypeId.ToString())); } txtTeam.Text = staff.Team; cmbBranchCode.SelectedIndex = cmbBranchCode.Items.IndexOf(cmbBranchCode.Items.FindByValue(staff.BranchCode)); txtOldBranchCode.Text = staff.BranchCode; cmbBranchCode_SelectedIndexChanged(); if (staff.HeadStaffId != null) { cmbHeadStaffId.SelectedIndex = cmbHeadStaffId.Items.IndexOf(cmbHeadStaffId.Items.FindByValue(staff.HeadStaffId.ToString())); } if (staff.DepartmentId != null) { cmbDepartment.SelectedIndex = cmbDepartment.Items.IndexOf(cmbDepartment.Items.FindByValue(staff.DepartmentId.ToString())); } if (!string.IsNullOrEmpty(staff.CocTeam) && cmbCocTeam.Items.Count > 0) { cmbCocTeam.SelectedIndex = cmbCocTeam.Items.IndexOf(cmbCocTeam.Items.FindByValue(staff.CocTeam)); txtCurrentCocTeam.Text = staff.CocTeam; } else { txtCurrentCocTeam.Text = ""; } if (staff.Is_Deleted != null) { txtOldIsDeleted.Text = staff.Is_Deleted.ToString(); txtNewIsDeleted.Text = staff.Is_Deleted.ToString(); if (staff.Is_Deleted == 0) { rdNormal.Checked = true; } else if (staff.Is_Deleted == 1) { rdRetire.Checked = true; } else { rdNormal.Checked = false; rdRetire.Checked = false; } } } upInfo.Update(); } catch (Exception ex) { throw ex; } }
private bool DoImport(DataTable dt, decimal insComId, string fileName) { SlmProblemData data = new SlmProblemData(); try { data.ProblemDetails = SlmScr034Biz.ValidateProblemDetails(dt, cmbInsComImport.SelectedItem.Text); if (data.ProblemDetails.Count > 0 && data.ProblemDetails.Where(p => p.hasError) != null && data.ProblemDetails.Where(p => p.hasError).Count() > 0) { gvUploadError.DataSource = data.ProblemDetails.Where(p => p.hasError).ToList(); gvUploadError.DataBind(); //lblFilename.Text = fileName; lblFail.Text = data.ProblemDetails.Where(p => p.hasError).Count().ToString("#,##0"); lblSuccess.Text = "0"; lblTotal.Text = data.ProblemDetails.Count.ToString("#,##0");// lblFail.Text; tableUploadResult.Visible = true; gvUploadErrorHeader.Visible = true; gvUploadError.Visible = true; return(false); } else { data.Ins_Com_Id = insComId; data.FileName = fileName; data.Deleted = false; data.UpdatedBy = HttpContext.Current.User.Identity.Name; data.UpdatedDate = DateTime.Now; SlmScr034Biz.SaveProblemData(data); // บันทึกลง CAR System // CreateCASActivityLog(data); var staff = StaffBiz.GetStaff(HttpContext.Current.User.Identity.Name); data.ProblemDetails.Where(ticket => ticket.needCARprocess) .Select(t => new { TicketId = t.TicketId , RenewInsureId = t.RenewInsureId , IsPolicyPurchase = t.IsPolicyPurchase , IsActPurchase = t.IsActPurchase , PolicyRecAmt = t.PolicyRecAmt , ActRecAmt = t.ActRecAmt , PolicyLastRecAmt = (decimal?)null , ActLastRecAmt = (decimal?)null }) .Distinct() .ToList() .ForEach(ticket => { AppUtil.CreateCASActivityLog(this, ticket.TicketId, ticket.RenewInsureId, ticket.IsPolicyPurchase, ticket.IsActPurchase, ticket.PolicyLastRecAmt, ticket.ActLastRecAmt, ticket.PolicyRecAmt, ticket.ActRecAmt, staff); }); //lblFilename.Text = fileName; lblFail.Text = "0"; lblSuccess.Text = data.ProblemDetails.Count.ToString("#,##0"); lblTotal.Text = lblSuccess.Text; tableUploadResult.Visible = true; gvUploadErrorHeader.Visible = false; gvUploadError.Visible = true; gvUploadError.DataSource = null; gvUploadError.DataBind(); return(true); } } catch (Exception ex) { if (ex.Message.Contains("Ticket Id มากกว่า 1 รายการ ")) { _log.Error(ex.Message); AppUtil.ClientAlert(Page, ex.Message); } else { string message = ex.InnerException != null ? ex.InnerException.Message : ex.Message; _log.Error(message); AppUtil.ClientAlert(Page, message); } return(false); } }