Пример #1
0
        protected void btnCheckUsername_Click(object sender, EventArgs e)
        {
            try
            {
                if (txtUserName.Text.Trim() != string.Empty)
                {
                    vtxtUserName.Text = "";

                    if (StaffBiz.CheckUsernameExist(txtUserName.Text.Trim(), null))
                    {
                        vtxtUserName.Text      = "Windows Username นี้มีอยู่แล้วในระบบแล้ว";
                        vtxtUserName.ForeColor = System.Drawing.Color.Red;
                    }
                    else
                    {
                        vtxtUserName.Text      = "Windows Username ใช้งานได้";
                        vtxtUserName.ForeColor = System.Drawing.Color.Green;
                    }
                }
                else
                {
                    vtxtUserName.Text = "";
                }
            }
            catch (Exception ex)
            {
                AppUtil.ClientAlert(Page, ex.InnerException != null ? ex.InnerException.Message : ex.Message);
            }
        }
Пример #2
0
        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 (StaffBiz.CheckUsernameExist(txtUserName.Text.Trim(), null))
                {
                    vtxtUserName.Text      = "Windows Username นี้มีอยู่แล้วในระบบแล้ว";
                    vtxtUserName.ForeColor = System.Drawing.Color.Red;
                    i += 1;
                }
                else
                {
                    vtxtUserName.Text = "";
                }
            }

            string desc;

            if (LeadBiz.CheckHeadStaff(txtEmpCode.Text, cmbHeadStaffId.SelectedValue.Trim(), out desc))
            {
                vcmbHeadStaffId.Text = "ไม่สามารถเปลี่ยนหัวหน้างานได้เนื่องจาก " + txtStaffNameTH.Text + "เป็นหัวหน้างาน" + cmbHeadStaffId.Text.Trim();
                i += 1;
            }

            //************************************รหัสพนักงานธนาคาร********************************************
            if (txtEmpCode.Text.Trim() == "")
            {
                vtxtEmpCode.Text = "กรุณาระบุรหัสพนักงานธนาคาร";
                i += 1;
            }
            else
            {
                vtxtEmpCode.Text = "";
                if (StaffBiz.CheckEmpCodeExist(txtEmpCode.Text.Trim(), null))
                {
                    vtxtEmpCode.Text = "รหัสพนักงานธนาคารนี้มีอยู่แล้วในระบบแล้ว";
                    i += 1;
                }
                else
                {
                    vtxtEmpCode.Text = "";
                }
            }

            //************************************รหัสเจ้าหน้าที่การตลาด********************************************
            if (txtMarketingCode.Text.Trim() == "")
            {
                //vtxtMarketingCode.Text = "กรุณาระบุรหัสเจ้าหน้าที่การตลาด";
                //i += 1;
            }
            else
            {
                vtxtMarketingCode.Text = "";
                if (StaffBiz.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 = "";
            }

            //************************************ COC Team ********************************************
            if (cmbStaffType.SelectedItem.Value == COCConstant.StaffType.Oper.ToString() || cmbStaffType.SelectedItem.Value == COCConstant.StaffType.SupervisorOper.ToString())
            {
                if (cmbCocTeam.SelectedItem.Value == "")
                {
                    vCocTeam.Text = "กรุณาระบุ COC Team";
                    i            += 1;
                }
                else
                {
                    vCocTeam.Text = "";
                }
            }
            else
            {
                vCocTeam.Text = "";
            }

            if (i > 0)
            {
                return(false);
            }
            else
            {
                return(true);
            }
        }