Ejemplo n.º 1
0
        private void btnThemTaiKhoan_Click(object sender, EventArgs e)
        {
            ObjAccount ac = new ObjAccount();

            if (checkNullItem())
            {
                GanDuLieu(ac);
                {
                    switch (AccCtrl.Them(ac))
                    {
                    case 0:
                        text = "Không tồn tại mã tài khoản!";
                        ThongBao(text);
                        break;

                    case 1:
                        MessageBox.Show("Thêm thành công", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        LamMoi();
                        break;

                    case 2:
                        text = "Vui lòng chọn tên đăng nhập khác!";
                        ThongBao(text);
                        break;
                    }
                }
            }
            else
            {
                MessageBox.Show("Vui lòng điền đầy đủ thông tin", "Cảnh báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Ejemplo n.º 2
0
        public int Save(ObjAccount acc)
        {
            SqlCommand cmd = new SqlCommand();

            cmd.CommandText = "INSERT INTO Account VALUES (@id, @user, @pass)";

            cmd.Parameters.Add("user", SqlDbType.NVarChar).Value = acc.UserName_Customer;
            cmd.Parameters.Add("pass", SqlDbType.VarChar).Value  = acc.PassWord_Customer;
            cmd.Parameters.Add("id", SqlDbType.Int).Value        = acc.Id_Customer;

            return(cls.CapNhatDL(cmd));
        }
Ejemplo n.º 3
0
        public int Update(ObjAccount acc)
        {
            SqlCommand cmd = new SqlCommand();

            cmd.CommandText = "UPDATE Account SET PassWord_Customer = @pass WHERE Id_Customer = @id AND User_Name_Customer = @ten; ";

            cmd.Parameters.Add("ten", SqlDbType.NVarChar).Value  = acc.UserName_Customer;
            cmd.Parameters.Add("pass", SqlDbType.NVarChar).Value = acc.PassWord_Customer;
            cmd.Parameters.Add("id", SqlDbType.Int).Value        = acc.Id_Customer;

            return(cls.CapNhatDL(cmd));
        }
Ejemplo n.º 4
0
 public int Them(ObjAccount acc)
 {
     if (KiemTraMatk(Convert.ToInt32(acc.Id_Customer)) == false)
     {
         return(0);
     }
     if (!KiemTraTenTK(acc.UserName_Customer))
     {
         return(2);
     }
     return(accMng.Save(acc));
 }
Ejemplo n.º 5
0
        private void btnCapNhat_Click(object sender, EventArgs e)
        {
            if (checkNullTextBox() == false)
            {
                MessageBox.Show("Xin mời nhập đầy đủ thông tin!", "Cảnh báo");
            }
            else
            {
                ObjAccount objAcc = new ObjAccount();
                SetDataAccount(objAcc);


                DialogResult dlg = MessageBox.Show("Bạn có chắc chắn muốn đổi dữ liệu này?", "Thông báo", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                if (dlg == DialogResult.Yes)
                {
                    try
                    {
                        if (accCtrl.Luu(objAcc) > 0)
                        {
                            MessageBox.Show("Lưu thành công", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            acc.HienThi(dgvDSTaiKhoan);
                            HienThiThongTin();
                        }
                        else
                        {
                            MessageBox.Show("Không tại mã người dùng này, vui lòng thử lại", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                    }
                    catch (Exception ce)
                    {
                        MessageBox.Show("Đã tồn tại tên tài khoản tương tự", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        MessageBox.Show(ce.Message);
                    }
                }
            }
        }
Ejemplo n.º 6
0
 //Hàm xử lý lưu dữ liệu.
 private void GanDuLieu(ObjAccount tk)
 {
     tk.Id_Customer       = txtId.Text.Trim();
     tk.UserName_Customer = txtUserName.Text.Trim();
     tk.PassWord_Customer = txtPassWord.Text.Trim();
 }
Ejemplo n.º 7
0
 //Hàm xử lý lưu dữ liệu.
 private void SetDataAccount(ObjAccount tk)
 {
     tk.Id_Customer       = txtId_Customer.Text;
     tk.UserName_Customer = txtUsername.Text;
     tk.PassWord_Customer = txtMaTK.Text;
 }
Ejemplo n.º 8
0
 public int Luu(ObjAccount ac)
 {
     return(accMng.Update(ac));
 }