public void Call_Insert_User(DTO_Users u)
        {
            string hashpassword = Hash_Password(u.F_Password);

            u.F_Password = hashpassword;
            dal_user.Insert_Users_db(u);
        }
Example #2
0
        public void Insert_Users_db(DTO_Users u)
        {
            Open_connection();
            SqlCommand command = new SqlCommand();

            command.Connection  = conn;
            command.CommandType = CommandType.Text;
            command.CommandText = "INSERT INTO users(f_Username,f_Password,f_Name,f_Email,f_DOB) VALUES(@f_Username,@f_Password,@f_Name,@f_Email,@f_DOB)";
            command.Parameters.Add(new SqlParameter("@f_Username", u.F_Username));
            command.Parameters.Add(new SqlParameter("@f_Password", u.F_Password));
            command.Parameters.Add(new SqlParameter("@f_Name", u.F_Name));
            command.Parameters.Add(new SqlParameter("@f_Email", u.F_Email));
            command.Parameters.Add(new SqlParameter("@f_DOB", u.F_DOB));
            command.ExecuteNonQuery();
            Close_connection();
        }
Example #3
0
        private void btnDK_Click(object sender, EventArgs e)
        {
            DTO_Users dto_user    = new DTO_Users();
            BLL_Users bll_user    = new BLL_Users();
            BLL_Per   b_per       = new BLL_Per();
            string    temp_urname = bll_user.Call_Get_Username_User(txtUsername.Text);

            if (txtname.Text == "" || txtpassword.Text == "" || txtemail.Text == "" || txtUsername.Text == "")
            {
                MessageBox.Show("Không được để trống bất cứ ô nào", "Thông báo", MessageBoxButtons.OK);
            }
            else if (temp_urname == txtUsername.Text)
            {
                MessageBox.Show("Tên Đăng nhập đã tồn tại, vui lòng nhập vào tên đăng nhập khác", "Thông báo", MessageBoxButtons.OK);
                txtUsername.Focus();
            }
            else
            {
                try
                {
                    dto_user.F_Username = txtUsername.Text;
                    dto_user.F_Password = txtpassword.Text;
                    dto_user.F_Name     = txtname.Text;
                    dto_user.F_DOB      = DateTime.Parse(dtdbo.Text);
                    dto_user.F_Email    = txtemail.Text;
                    bll_user.Call_Insert_User(dto_user);
                    //
                    int id = bll_user.Call_Get_ID_User(txtUsername.Text);
                    b_per.Call_Insert_per(id);
                    MessageBox.Show("successful");
                    this.Close();
                }
                catch (Exception ee)
                {
                    MessageBox.Show(ee.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }