Esempio n. 1
0
 /// <summary>
 /// Takes input as User data of all types - Admin, Assistant, Doctor and Patient.
 /// Send the info from User to Database.
 /// </summary>
 /// <param name="user"></param>
 /// <param name="userObjects"></param>
 /// <returns>Flag as true if Added Successfully else false</returns>
 public bool AddUser(Users user, params object[] userObjects)
 {
     try
     {
         user.Password = encrypt.Encrypt(user.Password);
         return(userInformation.AddUser(user, userObjects));
     }
     catch (EmailAlreadyExistsEx ex)
     {
         throw ex;
     }
     catch (PhoneAlreadyExistsEx ex)
     {
         throw ex;
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Esempio n. 2
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            int _logInID = Convert.ToInt32(LogInID);
            int _userID  = Convert.ToInt32(UserID);

            userInformation.Username        = txtUserName.Text;
            userInformation.Userrole        = comboBoxRole.Text;
            userInformation.Employeename    = txtEmployeeName.Text;
            userInformation.Status          = comboBoxStatus.Text;
            userInformation.Region          = comboBoxRegion.Text;
            userInformation.Password        = txtPassword.Text;
            userInformation.ConfirmPassword = txtConfirmPassword.Text;

            if (string.IsNullOrEmpty(UserID))
            {
                if (!string.IsNullOrEmpty(userInformation.Username) && !string.IsNullOrEmpty(userInformation.Password) && !string.IsNullOrEmpty(userInformation.ConfirmPassword))
                {
                    if (txtPassword.Text == txtConfirmPassword.Text)
                    {
                        userInformation.AddUser();
                        if (userInformation.Check == true)
                        {
                            this.Close();
                        }
                    }
                    else
                    {
                        MetroFramework.MetroMessageBox.Show(this, "Password Doesn't matched", "Message", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
                else
                {
                    MetroFramework.MetroMessageBox.Show(this, "Input Information", "Message", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                comboBoxRegion.Items.Clear();
            }

            else
            {
                if (!string.IsNullOrEmpty(userInformation.Username))
                {
                    if (metroCheckBox.Checked == true)
                    {
                        if (!string.IsNullOrEmpty(userInformation.Password) && !string.IsNullOrEmpty(userInformation.ConfirmPassword))
                        {
                            if (txtPassword.Text == txtConfirmPassword.Text)
                            {
                                userInformation.EditUserWithPassword(_userID, _logInID);
                                if (userInformation.Check == true)
                                {
                                    this.Close();
                                }
                            }
                            else
                            {
                                MetroFramework.MetroMessageBox.Show(this, "Password Doesn't matched", "Message", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            }
                        }
                        else
                        {
                            MetroFramework.MetroMessageBox.Show(this, "Input Password", "Message", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                    }
                    else
                    {
                        userInformation.EditUser(_userID);
                        if (userInformation.Check == true)
                        {
                            this.Close();
                        }
                    }
                }

                else
                {
                    MetroFramework.MetroMessageBox.Show(this, "Input Information", "Message", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                comboBoxRegion.Items.Clear();
            }
        }