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(), null)) { 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(), null)) { vtxtEmpCode.Text = "รหัสพนักงานธนาคารนี้มีอยู่แล้วในระบบแล้ว"; i += 1; } else { vtxtEmpCode.Text = ""; } } //************************************รหัสเจ้าหน้าที่การตลาด******************************************** if (txtMarketingCode.Text.Trim() == "") { //vtxtMarketingCode.Text = "กรุณาระบุรหัสเจ้าหน้าที่การตลาด"; //i += 1; } else { vtxtMarketingCode.Text = ""; if (SlmScr019Biz.CheckMarketingCodeExist(txtMarketingCode.Text.Trim(), null)) { 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 { vcmbBranchCode.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); } }