Ejemplo n.º 1
0
        private void btn_edit_user_Click(object sender, EventArgs e)
        {
            string user_name = tb_userName_user.Text.ToString().Trim();
            string name      = tb_name_user.Text.ToString().Trim();
            string sphone    = tb_phone_user.Text.ToString().Trim();
            string location  = tb_location_user.Text.ToString().Trim();
            string dob       = dtp_dob_user.Value.ToString("dd/MM/yyyy").Trim();
            string password  = tb_pass_user.Text.ToString().Trim();

            if (isValidString(user_name) && isValidString(name) && isValidString(location) && isValidString(password) && isValidString(sphone))
            {
                int          phone        = int.Parse(sphone);
                UserControls userControls = new UserControls();
                User         user         = userControls.SearchUser(user_name, "user");
                if (user != null)
                {
                    user         = new User(user_name, name, phone, location, dob, "user", password);
                    userControls = new UserControls(user);
                    bool isEdited = userControls.EditUser();
                    if (isEdited)
                    {
                        LoadUsers();
                        MessageBox.Show("User Edited.");
                    }
                    else
                    {
                        MessageBox.Show("User can not be Edited.");
                    }
                }
                else
                {
                    MessageBox.Show("User Doesn't Exist.");
                }
            }
            else
            {
                MessageBox.Show("Please Enter All Info.");
            }
        }