private DTO.Users AddToDTO() { DTO.Users user = new DTO.Users(); user.Username1 = txtUsername.Text; user.Password1 = txtPassword.Text; user.Email1 = txtEmail.Text; return(user); }
private void btnUpdate_Click(object sender, EventArgs e) { if (demclick == 0) { int cr = dgvUsers.CurrentCell.RowIndex; txtUsername.Text = dgvUsers.Rows[cr].Cells[0].Value.ToString(); txtPassword.Text = dgvUsers.Rows[cr].Cells[1].Value.ToString(); txtEmail.Text = dgvUsers.Rows[cr].Cells[2].Value.ToString(); demclick = 1; btnUpdate.Text = "Lưu"; } else { DTO.Users user = AddToDTO(); DAO.DAO_Users.Instance.UpdateUser(user); LoadFromUser(); } }
private void btnAdd_Click(object sender, EventArgs e) { if (CheckEmpty() == true) { if (BUS_Users.Instance.CheckUser(txtUsername) != 0) { MessageBox.Show("Tên đăng nhập đã tồn tại"); } else { DTO.Users user = AddToDTO(); BUS.BUS_Users.Instance.Users_AddUser(user); if (cbxQLChuyen.Checked == true) { BUS_Users.Instance.Users_AddRole(txtUsername.Text, 2); } if (cbxQLTuyen.Checked == true) { BUS_Users.Instance.Users_AddRole(txtUsername.Text, 3); } if (cbxQLKhach.Checked == true) { BUS_Users.Instance.Users_AddRole(txtUsername.Text, 4); } if (cbxQLTaiXe.Checked == true) { BUS_Users.Instance.Users_AddRole(txtUsername.Text, 5); } if (cbxQLXe.Checked == true) { BUS_Users.Instance.Users_AddRole(txtUsername.Text, 6); } if (cbxQLDatBanVe.Checked == true) { BUS_Users.Instance.Users_AddRole(txtUsername.Text, 7); } MessageBox.Show("Thêm thành công!!!"); LoadFromUser(); ClearFrom(); } } }
protected void Unnamed1_Click(object sender, EventArgs e) { DTO.Users use = new DTO.Users(); use.name = txtTen.Text; use.email = txtemail.Text; use.phone = txtPhone.Text; use.password = txtpassword.Text; use.created_at = Convert.ToString(DateTime.Now); string repass = txtRePass.Text; if (use.password == repass) { obj.create(use); Response.Write("<script>alert('Đăng ký thành công!')</script>"); Response.Redirect("Login.aspx"); } else { Response.Write("<script>alert('Đăng ký không thành công!')</script>"); } }
public void create(DTO.Users c) { string sql = "insert tbl_User values(N'" + c.name + "' , N'" + c.email + "', '" + c.phone + "','" + c.password + "','" + c.created_at + "')"; obj.ExecuteNonQuery(sql); }