Exemple #1
0
    private void ValidateInputs()
    {
        SystemUser user = new SystemUser();

        user.Userid   = int.Parse(lblCode.Text.Trim());
        user.Fname    = TxtFname.Text.Trim();
        user.Sname    = txtLname.Text.Trim();
        user.Oname    = txtMiddleName.Text.Trim();
        user.Uname    = lblusername.Text.Trim();
        user.Phone    = txtphone.Text.Trim();
        user.Email    = txtemail.Text.Trim();
        user.Area     = int.Parse(cboAreas.SelectedValue.ToString());
        user.Branch   = cboBranches.SelectedValue.ToString();
        user.Title    = txtDesignation.Text.Trim();
        user.Role     = cboAccessLevel.SelectedValue.ToString();
        user.Active   = chkIsActive.Checked;
        user.LoggedOn = chkIsLoggedon.Checked;
        user.Reset    = chkResetPassword.Checked;
        user.UserName = txtUserName.Text.Trim();
        if (user.Fname.Equals(""))
        {
            ShowMessage("Please Enter User First Name", true);
            TxtFname.Focus();
        }
        else if (user.Sname.Equals(""))
        {
            ShowMessage("Please Enter User SurName", true);
            txtLname.Focus();
        }
        else if (!bll.IsValidEmailAddress(user.Email))
        {
            ShowMessage("Please Enter User Valid Email Address", true);
            txtemail.Focus();
        }
        else if (user.Area.Equals(0))
        {
            ShowMessage("Please Select Company Type", true);
        }
        else if (user.Role.Equals("0"))
        {
            ShowMessage("Please Select User System role", true);
        }
        else
        {
            if (user.Branch.Equals(0) && bll.AreaHasBranches(user.Area))
            {
                ShowMessage("Please Select Company", true);
            }
            else
            {
                string returned = Process.SaveSystemUser(user);
                if (returned.Contains("Successfully"))
                {
                    ShowMessage(returned, false);
                    MultiView2.ActiveViewIndex = -1;
                    ClearControls();
                }
                else if (returned.Contains("System generated username"))
                {
                    ShowMessage(returned, true);
                    MultiView2.ActiveViewIndex = 0;
                    txtUserName.Focus(); // USERNAME PROVIDED ALREADY EXISTS
                }
                else if (returned.Contains("UserName Provided already Exists"))
                {
                    ShowMessage(returned, true);
                    MultiView2.ActiveViewIndex = 0;
                    txtUserName.Focus(); // USERNAME PROVIDED ALREADY EXISTS
                }
                else
                {
                    ShowMessage(returned, true);
                    MultiView2.ActiveViewIndex = -1;
                }
            }
        }
    }