private bool ValidateData() { int i = 0; //************************************Windows Username******************************************** if (txtUsername.Text.Trim() == "") { vtxtUsername.Text = "กรุณาระบุ Windows Username"; vtxtUsername.ForeColor = System.Drawing.Color.Red; i += 1; } else { vtxtUsername.Text = ""; if (SlmScr019Biz.CheckUsernameExist(txtUsername.Text.Trim(), int.Parse(txtStaffId.Text.Trim()))) { vtxtUsername.Text = "Windows Username นี้มีอยู่แล้วในระบบแล้ว"; vtxtUsername.ForeColor = System.Drawing.Color.Red; i += 1; } else { vtxtUsername.Text = ""; } } //************************************ User Type ******************************************* if (!rbnUserTypeIndividual.Checked && !rbnUserTypeGroup.Checked) { vrbnUserType.Text = "กรุณาระบุประเภท User"; i += 1; } else { vrbnUserType.Text = ""; } //************************************รหัสพนักงานธนาคาร******************************************** if (txtEmpCode.Text.Trim() == "") { vtxtEmpCode.Text = "กรุณาระบุรหัสพนักงานธนาคาร"; i += 1; } else { vtxtEmpCode.Text = ""; if (SlmScr019Biz.CheckEmpCodeExist(txtEmpCode.Text.Trim(), int.Parse(txtStaffId.Text.Trim()))) { vtxtEmpCode.Text = "รหัสพนักงานธนาคารนี้มีอยู่แล้วในระบบแล้ว"; i += 1; } else { vtxtEmpCode.Text = ""; } } //************************************รหัสเจ้าหน้าที่การตลาด******************************************** if (txtMarketingCode.Text.Trim() == "") { //vtxtMarketingCode.Text = "กรุณาระบุรหัสเจ้าหน้าที่การตลาด"; //i += 1; } else { vtxtMarketingCode.Text = ""; if (SlmScr019Biz.CheckMarketingCodeExist(txtMarketingCode.Text.Trim(), int.Parse(txtStaffId.Text.Trim()))) { vtxtMarketingCode.Text = "รหัสเจ้าหน้าที่การตลาดนี้มีอยู่แล้วในระบบแล้ว"; i += 1; } else { vtxtMarketingCode.Text = ""; } } //************************************ชื่อ-นามสกุลพนักงาน******************************************** if (txtStaffNameTH.Text.Trim() == "") { vtxtStaffNameTH.Text = "กรุณาระบุชื่อ-นามสกุลพนักงาน"; i += 1; } else { vtxtStaffNameTH.Text = ""; } //************************************E-mail******************************************** if (txtStaffEmail.Text.Trim() == "") { vtxtStaffEmail.Text = "กรุณาระบุ E-mail"; i += 1; } else { if (!ValidateEmail()) { vtxtStaffEmail.Text = "กรุณาระบุ E-mail ให้ถูกต้อง"; i += 1; } else { vtxtStaffEmail.Text = ""; } } //************************************ตำแหน่ง******************************************** if (cmbPosition.SelectedItem.Value == "") { vtxtPositionName.Text = "กรุณาระบุ ตำแหน่ง"; i += 1; } else { vtxtPositionName.Text = ""; } //************************************Role Sale******************************************** if (cmbStaffType.SelectedItem.Value == "") { vcmbStaffType.Text = "กรุณาระบุ Role Sale"; i += 1; } else { vcmbStaffType.Text = ""; } //************************************Role Service**************************************** if (cmbRoleService.SelectedItem.Value == "") { vcmbRoleService.Text = "กรุณาระบุ Role Service"; i += 1; } else { vcmbRoleService.Text = ""; } //************************************ทีมการตลาด******************************************** //if (txtTeam.Text.Trim() == "") //{ // vtxtTeam.Text = "กรุณาระบุ ทีมการตลาด"; // i += 1; //} //else // vtxtTeam.Text = ""; //************************************สาขาพนักงาน******************************************** if (cmbBranchCode.SelectedItem.Value == "") { vcmbBranchCode.Text = "กรุณาระบุ สาขา"; i += 1; } else { if (cmbBranchCode.Items.Count > 0 && cmbBranchCode.SelectedItem.Value != "" && !BranchBiz.CheckBranchActive(cmbBranchCode.SelectedItem.Value)) { vcmbBranchCode.Text = "สาขานี้ถูกปิดแล้ว"; i += 1; } else { vcmbBranchCode.Text = ""; if (rbnUserTypeGroup.Checked && vrbnUserType.Text == "") { if (SlmScr019Biz.CheckExistGroupInBranch(cmbBranchCode.SelectedItem.Value, int.Parse(txtStaffId.Text.Trim()))) { vrbnUserType.Text = "ผู้ใช้คนนี้ไม่สามารถเป็นประเภท Group (Dummy) เพราะสาขานี้มี User ประเภท Group อยู่แล้ว"; i += 1; } else { vrbnUserType.Text = ""; } } } } //************************************สาขาหัวหน้างาน******************************************** if (cmbHeadBranchCode.Items.Count > 0 && cmbHeadBranchCode.SelectedItem.Value != "" && !BranchBiz.CheckBranchActive(cmbHeadBranchCode.SelectedItem.Value)) { vcmbHeadBranchCode.Text = "สาขานี้ถูกปิดแล้ว"; i += 1; } else { vcmbHeadBranchCode.Text = ""; } //************************************หัวหน้างาน******************************************** if (cmbHeadBranchCode.Items.Count > 0 && cmbHeadBranchCode.SelectedItem.Value != "") { if (cmbHeadStaffId.SelectedItem.Value == "") { vcmbHeadStaffId.Text = "กรุณาระบุ หัวหน้างาน"; i += 1; } else { var staffId = int.Parse(txtStaffId.Text); var headStaffId = int.Parse(cmbHeadStaffId.SelectedItem.Value); if (SlmScr018Biz.CheckIsLoopStructure(staffId, headStaffId)) { vcmbHeadStaffId.Text = "การบันทึกข้อมูลไม่สำเร็จเนื่องจากพบ Recursive หัวหน้างาน"; vcmbHeadStaffId.ForeColor = System.Drawing.Color.Red; i += 1; } else { vcmbHeadStaffId.Text = ""; } } } else { vcmbHeadStaffId.Text = ""; } if (i > 0) { return(false); } else { return(true); } }
private bool ValidateData() { int i = 0; //************************************Windows Username******************************************** if (txtUsername.Text.Trim() == "") { vtxtUsername.Text = "กรุณาระบุ Windows Username"; vtxtUsername.ForeColor = System.Drawing.Color.Red; i += 1; } else { vtxtUsername.Text = ""; if (SlmScr019Biz.CheckUsernameExist(txtUsername.Text.Trim(), int.Parse(txtStaffId.Text.Trim()))) { vtxtUsername.Text = "Windows Username นี้มีอยู่แล้วในระบบแล้ว"; vtxtUsername.ForeColor = System.Drawing.Color.Red; i += 1; } else { vtxtUsername.Text = ""; } } //************************************รหัสพนักงานธนาคาร******************************************** if (txtEmpCode.Text.Trim() == "") { vtxtEmpCode.Text = "กรุณาระบุรหัสพนักงานธนาคาร"; i += 1; } else { vtxtEmpCode.Text = ""; if (SlmScr019Biz.CheckEmpCodeExist(txtEmpCode.Text.Trim(), int.Parse(txtStaffId.Text.Trim()))) { vtxtEmpCode.Text = "รหัสพนักงานธนาคารนี้มีอยู่แล้วในระบบแล้ว"; i += 1; } else { vtxtEmpCode.Text = ""; } } //************************************รหัสเจ้าหน้าที่การตลาด******************************************** if (txtMarketingCode.Text.Trim() == "") { //vtxtMarketingCode.Text = "กรุณาระบุรหัสเจ้าหน้าที่การตลาด"; //i += 1; } else { vtxtMarketingCode.Text = ""; if (SlmScr019Biz.CheckMarketingCodeExist(txtMarketingCode.Text.Trim(), int.Parse(txtStaffId.Text.Trim()))) { vtxtMarketingCode.Text = "รหัสเจ้าหน้าที่การตลาดนี้มีอยู่แล้วในระบบแล้ว"; i += 1; } else { vtxtMarketingCode.Text = ""; } } //************************************ชื่อ-นามสกุลพนักงาน******************************************** if (txtStaffNameTH.Text.Trim() == "") { vtxtStaffNameTH.Text = "กรุณาระบุชื่อ-นามสกุลพนักงาน"; i += 1; } else { vtxtStaffNameTH.Text = ""; } //************************************E-mail******************************************** if (txtStaffEmail.Text.Trim() == "") { vtxtStaffEmail.Text = "กรุณาระบุ E-mail"; i += 1; } else { if (!ValidateEmail()) { vtxtStaffEmail.Text = "กรุณาระบุ E-mail ให้ถูกต้อง"; i += 1; } else { vtxtStaffEmail.Text = ""; } } //************************************ตำแหน่ง******************************************** if (cmbPosition.SelectedItem.Value == "") { vtxtPositionName.Text = "กรุณาระบุ ตำแหน่ง"; i += 1; } else { vtxtPositionName.Text = ""; } //************************************Role******************************************** if (cmbStaffType.SelectedItem.Value == "") { vcmbStaffType.Text = "กรุณาระบุ Role"; i += 1; } else { vcmbStaffType.Text = ""; } //************************************ทีมการตลาด******************************************** //if (txtTeam.Text.Trim() == "") //{ // vtxtTeam.Text = "กรุณาระบุ ทีมการตลาด"; // i += 1; //} //else // vtxtTeam.Text = ""; //************************************สาขาพนักงาน******************************************** if (cmbBranchCode.SelectedItem.Value == "") { vcmbBranchCode.Text = "กรุณาระบุ สาขา"; i += 1; } else { if (cmbBranchCode.Items.Count > 0 && cmbBranchCode.SelectedItem.Value != "" && !BranchBiz.CheckBranchActive(cmbBranchCode.SelectedItem.Value)) { vcmbBranchCode.Text = "สาขานี้ถูกปิดแล้ว"; i += 1; } else { vcmbBranchCode.Text = ""; } } //************************************สาขาหัวหน้างาน******************************************** if (cmbHeadBranchCode.Items.Count > 0 && cmbHeadBranchCode.SelectedItem.Value != "" && !BranchBiz.CheckBranchActive(cmbHeadBranchCode.SelectedItem.Value)) { vcmbHeadBranchCode.Text = "สาขานี้ถูกปิดแล้ว"; i += 1; } else { vcmbHeadBranchCode.Text = ""; } //************************************หัวหน้างาน******************************************** if (cmbHeadBranchCode.Items.Count > 0 && cmbHeadBranchCode.SelectedItem.Value != "" && cmbHeadStaffId.SelectedItem.Value == "") { vcmbHeadStaffId.Text = "กรุณาระบุ หัวหน้างาน"; i += 1; } else { vcmbHeadStaffId.Text = ""; } if (i > 0) { return(false); } else { return(true); } }
private bool ValidateData() { try { int i = 0; //เช็กสถานะ require cardId if (LeadInfoBiz.CheckRequireCardId(cmbLeadStatus.SelectedItem.Value)) { if (cmbCardType.SelectedItem.Value == "") { i += 1; vtxtCardType.Text = "กรุณาระบุประเภทบุคคล"; } if (txtCitizenId.Text.Trim() == "") { i += 1; vtxtCitizenId.Text = "กรุณาระบุเลขที่บัตร"; } if (cmbCardType.SelectedItem.Value != "" && txtCitizenId.Text.Trim() != "") { if (!AppUtil.ValidateCardId(cmbCardType, txtCitizenId, vtxtCitizenId)) { i += 1; } } } else { //Validate เลขที่บัตร if (cmbCardType.SelectedItem.Value != "") { if (txtCitizenId.Text.Trim() == "") { vtxtCitizenId.Text = "กรุณาระบุเลขที่บัตร"; i += 1; } else { if (!AppUtil.ValidateCardId(cmbCardType, txtCitizenId, vtxtCitizenId)) { i += 1; } } } else if (cmbCardType.SelectedItem.Value == "" && txtCitizenId.Text.Trim() != "") { vtxtCardType.Text = "กรุณาระบุประเภทบุคคล"; i += 1; } else { vtxtCardType.Text = ""; vtxtCitizenId.Text = ""; } } //OwnerBranch, Owner string clearOwnerBranchText = "Y"; if (cmbOwnerBranch.SelectedItem.Value != txtOldOwnerBranch.Text.Trim() || cmbOwner.SelectedItem.Value != txtOldOwner.Text.Trim()) { if (!AppUtil.ValidateOwner(_currentAssignedFlag, cmbOwnerBranch, vcmbOwnerBranch, cmbOwner, vcmbOwner, txtCampaignId.Text.Trim(), ref clearOwnerBranchText)) { i += 1; } //Branch ที่ถูกปิด if (cmbOwnerBranch.Items.Count > 0 && cmbOwnerBranch.SelectedItem.Value != "" && !BranchBiz.CheckBranchActive(cmbOwnerBranch.SelectedItem.Value)) { vcmbOwnerBranch.Text = "สาขานี้ถูกปิดแล้ว"; i += 1; } else { if (clearOwnerBranchText == "Y") { vcmbOwnerBranch.Text = ""; } } } else { vcmbOwnerBranch.Text = ""; vcmbOwner.Text = ""; } //DelegateBranch, Delegate if (cmbDelegateBranch.SelectedItem.Value != txtOldDelegateBranch.Text.Trim() || cmbDelegate.SelectedItem.Value != txtOldDelegate.Text.Trim()) { if (cmbDelegateBranch.SelectedItem.Value != string.Empty && cmbDelegate.SelectedItem.Value == string.Empty) { vcmbDelegate.Text = "กรุณาระบุ Delegate Lead"; i += 1; } else { vcmbDelegate.Text = ""; } if (cmbDelegateBranch.Items.Count > 0 && cmbDelegateBranch.SelectedItem.Value != "" && !BranchBiz.CheckBranchActive(cmbDelegateBranch.SelectedItem.Value)) { vcmbDelegateBranch.Text = "สาขานี้ถูกปิดแล้ว"; i += 1; } else { vcmbDelegateBranch.Text = ""; } } else { vcmbDelegateBranch.Text = ""; vcmbDelegate.Text = ""; } //รายละเอียดเพิ่มเติม if (txtContactDetail.Text.Trim() == "") { vtxtContactDetail.Text = "กรุณากรอกข้อมูลรายละเอียดก่อนทำการบันทึก"; i += 1; } else { vtxtContactDetail.Text = ""; } upPopup.Update(); return(i > 0 ? false : true); } catch (Exception ex) { throw ex; } }
public bool ValidateData(bool isValidateNewLead = true) { if (!isValidateNewLead) //หน้า Edit { if (!IsLastestOwnerDelegate()) { AppUtil.ClientAlertAndRedirect(Page, "ข้อมูลผู้มุ่งหวังนี้ถูกจ่ายงานให้พนักงานท่านอื่นแล้ว ระบบจะทำการ Refresh หน้าจอให้", "SLM_SCR_011.aspx?ticketid=" + txtslm_TicketId.Text.Trim()); return(false); } } int i = 0; if (txtName.Text.Trim() == string.Empty) { vtxtName.Text = "กรุณาระบุชื่อ"; i += 1; } else { vtxtName.Text = ""; } if (cmbCampaignId.SelectedItem.Value == string.Empty) { vcmbCampaignId.Text = "กรุณาระบุแคมเปญ"; i += 1; } else { vcmbCampaignId.Text = ""; } if (cmbChannelId.SelectedItem.Value == string.Empty) { vcmbChannelId.Text = "กรุณาระบุช่องทาง"; i += 1; } else { vcmbChannelId.Text = ""; } //****************************Owner********************************************************** if (isValidateNewLead) { if (cmbOwnerBranch.SelectedItem.Value != string.Empty && cmbOwner.Items.Count > 0 && cmbOwner.SelectedItem.Value == string.Empty) { vcmbOwner.Text = "กรุณาระบุ Owner Lead"; i += 1; } else { vcmbOwner.Text = ""; if (cmbCampaignId.SelectedItem.Value != string.Empty && cmbOwnerBranch.SelectedItem.Value != string.Empty && cmbOwner.Items.Count > 0 && cmbOwner.SelectedItem.Value != string.Empty) { if (!SlmScr010Biz.PassPrivilegeCampaign(SLMConstant.Branch.Active, cmbCampaignId.SelectedItem.Value, cmbOwner.SelectedItem.Value)) { vcmbOwner.Text = "Owner Lead ไม่มีสิทธิ์ในแคมเปญนี้"; i += 1; } else { vcmbOwner.Text = ""; } } } } else { //หน้า Edit //OwnerBranch, Owner string clearOwnerBranchText = "Y"; if (!AppUtil.ValidateOwner(newassignflag, cmbOwnerBranch, vcmbOwnerBranch, cmbOwner, vcmbOwner, cmbCampaignId.SelectedItem.Value, ref clearOwnerBranchText)) { i += 1; } //Branch ที่ถูกปิด if (cmbOwnerBranch.Items.Count > 0 && cmbOwnerBranch.SelectedItem.Value != "" && !BranchBiz.CheckBranchActive(cmbOwnerBranch.SelectedItem.Value)) { vcmbOwnerBranch.Text = "สาขานี้ถูกปิดแล้ว"; i += 1; } else { if (clearOwnerBranchText == "Y") { vcmbOwnerBranch.Text = ""; } } } //****************************Delegate********************************************************** //Delegate มีเฉพาะหน้า Edit if (!isValidateNewLead) { if (cmbDelegateBranch.Items.Count > 0 && cmbDelegateBranch.SelectedItem.Value != "" && !BranchBiz.CheckBranchActive(cmbDelegateBranch.SelectedItem.Value)) { vcmbDelegateBranch.Text = "สาขานี้ถูกปิดแล้ว"; i += 1; } else { vcmbDelegateBranch.Text = ""; } if (cmbDelegateBranch.SelectedItem.Value != string.Empty && cmbDelegateLead.SelectedItem.Value == string.Empty) { vcmbDelegateLead.Text = "กรุณาระบุ Delegate Lead"; i += 1; } else { vcmbDelegateLead.Text = ""; } } //****************************หมายเลขโทรศัพท์ 1******************************************** decimal result1; if (txtTelNo_1.Text.Trim() == string.Empty) { vtxtTelNo_1.Text = "กรุณาระบุหมายเลขโทรศัพท์ 1(มือถือ)ให้ถูกต้อง"; i += 1; } else if (txtTelNo_1.Text.Trim().Length < 9 || txtTelNo_1.Text.Trim().Length > 10) { vtxtTelNo_1.Text = "กรุณาระบุหมายเลขโทรศัพท์ 1(มือถือ)ให้ถูกต้อง"; i += 1; } else if (txtTelNo_1.Text.Trim() != string.Empty && !decimal.TryParse(txtTelNo_1.Text.Trim(), out result1)) { vtxtTelNo_1.Text = "หมายเลขโทรศัพท์ 1(มือถือ)ต้องเป็นตัวเลขเท่านั้น"; i += 1; } else if (txtTelNo_1.Text.Trim().StartsWith("0") == false) { vtxtTelNo_1.Text = "หมายเลขโทรศัพท์ 1(มือถือ)ต้องขึ้นต้นด้วยเลข 0 เท่านั้น"; i += 1; } else { vtxtTelNo_1.Text = ""; } //****************************หมายเลขโทรศัพท์ 2******************************************** decimal result2; if (txtTelNo2.Text.Trim() != string.Empty && txtTelNo2.Text.Trim().Length < 9) { vtxtTelNo2.Text = "หมายเลขโทรศัพท์ 2 ต้องมีอย่างน้อย 9 หลัก"; i += 1; } else if (txtTelNo2.Text.Trim() != string.Empty && !decimal.TryParse(txtTelNo2.Text.Trim(), out result2)) { vtxtTelNo2.Text = "หมายเลขโทรศัพท์ 2 ต้องเป็นตัวเลขเท่านั้น"; i += 1; } else if (txtTelNo2.Text.Trim() != string.Empty && txtTelNo2.Text.Trim().StartsWith("0") == false) { vtxtTelNo2.Text = "หมายเลขโทรศัพท์ 2 ต้องขึ้นต้นด้วยเลข 0 เท่านั้น"; i += 1; } else { vtxtTelNo2.Text = ""; } //****************************หมายเลขโทรศัพท์ 3******************************************** //****************************Ticket ID Refer******************************************** SlmScr003Biz biz = new SlmScr003Biz(); if (txtTicketIdRefer.Text.Trim() != string.Empty && txtslm_TicketId.Text == txtTicketIdRefer.Text.Trim()) { vtxtTicketIdRefer.Text = "Ticket ID Refer ต้องไม่เท่ากับ Ticket ID"; i += 1; } else if (SlmScr003Biz.ValidateTicketIDRefer(txtTicketIdRefer.Text.Trim())) { vtxtTicketIdRefer.Text = "ไม่พบ Ticket ID Refer ที่ระบุ"; i += 1; } //ValidateTicketIDRefer return(i == 0); }