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 { Object.ObjCustomerDetail objCustoDetail = new Object.ObjCustomerDetail(); SetDataCustomerDetail(objCustoDetail); string Id_Customer = dgvDSChiTietNguoiDung.CurrentRow.Cells[0].Value.ToString(); 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) { if (cutomerDetailCtrl.Update(objCustoDetail) > 0) { MessageBox.Show("Lưu thành công", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); CustomerManage.HienThi(dgvDSChiTietNguoiDung); HienThiThongTin(); } else { MessageBox.Show("Id Customer hoặc Id Group không tồn tại, vui lòng thử lại", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } }
private void btnThemTaiKhoan_Click(object sender, EventArgs e) { Object.ObjCustomerDetail customerDetail = new Object.ObjCustomerDetail(); if (checkNullItem()) { GanDuLieu(customerDetail); { switch (customerDetailCtrl.Them(customerDetail)) { case 0: text = "Vui lòng chọn mã người dùng khác!"; 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 mã nhóm 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); } }
//Hàm xử lý lưu dữ liệu. private void GanDuLieu(Object.ObjCustomerDetail customerDetail) { customerDetail.Id_Customer = txtId_Customer.Text.Trim(); customerDetail.Name_Customer = txtName_Customer.Text.Trim(); customerDetail.Address_Customer = txtAddress_Customer.Text.Trim(); customerDetail.Grender_Customer = cbbGrender.Text.Trim(); customerDetail.Birthday_Customer = txtBirthday_Customer.Text.Trim(); customerDetail.Identity_Card = txtIdentity_Card.Text.Trim(); customerDetail.Id_Group = txtId_Group.Text.Trim(); }
private void SetDataCustomerDetail(Object.ObjCustomerDetail customerDetail) { customerDetail.Id_Customer = txtId_Customer.Text; customerDetail.Name_Customer = txtName_Customer.Text; customerDetail.Address_Customer = txtAddress_Customer.Text; customerDetail.Grender_Customer = cbbGioiTinh.Text; customerDetail.Birthday_Customer = txtBirthday_Customer.Text; customerDetail.Identity_Card = txtIdentity_Customer.Text; customerDetail.Id_Group = txtId_Group.Text; }
public int Them(Object.ObjCustomerDetail customerDetail) { if (!KTMaNguoiDung(Convert.ToInt32(customerDetail.Id_Customer))) { return(0); } if (!KTMaNhom(Convert.ToInt32(customerDetail.Id_Group))) { return(2); } return(customerDetailMng.Save(customerDetail)); }
public int Update(Object.ObjCustomerDetail customerDetail) { SqlCommand cmd = new SqlCommand(); cmd.CommandText = "UPDATE Customer_Detail SET Name_Customer = @name, Address_Customer = @address, Grender_Customer = @gt, Birthday_Customer = @birthday, Identity_Card = @identity, Id_Group = @idGroup WHERE Id_Customer = @idCustomer;"; cmd.Parameters.Add("name", SqlDbType.NVarChar).Value = customerDetail.Name_Customer; cmd.Parameters.Add("address", SqlDbType.NVarChar).Value = customerDetail.Address_Customer; cmd.Parameters.Add("gt", SqlDbType.NVarChar).Value = customerDetail.Grender_Customer; cmd.Parameters.Add("birthday", SqlDbType.DateTime).Value = customerDetail.Birthday_Customer; cmd.Parameters.Add("identity", SqlDbType.VarChar).Value = customerDetail.Identity_Card; cmd.Parameters.Add("idGroup", SqlDbType.Int).Value = customerDetail.Id_Group; cmd.Parameters.Add("idCustomer", SqlDbType.Int).Value = customerDetail.Id_Customer; return(cls.CapNhatDL(cmd)); }
public int Save(Object.ObjCustomerDetail cdt) { SqlCommand cmd = new SqlCommand(); cmd.CommandText = "INSERT INTO " + "Customer_Detail(Name_Customer, Address_Customer, Grender_Customer, Birthday_Customer, Identity_Card, Id_Group) " + "VALUES (@name_customer, @address_customer, @grender_customer, @birthday_customer, @identity_card, @id_group)"; cmd.Parameters.Add("name_customer", SqlDbType.NVarChar).Value = cdt.Name_Customer; cmd.Parameters.Add("address_customer", SqlDbType.NVarChar).Value = cdt.Address_Customer; cmd.Parameters.Add("grender_customer", SqlDbType.NVarChar).Value = cdt.Grender_Customer; cmd.Parameters.Add("birthday_customer", SqlDbType.DateTime).Value = cdt.Birthday_Customer; cmd.Parameters.Add("identity_card", SqlDbType.VarChar).Value = cdt.Identity_Card; cmd.Parameters.Add("id_group", SqlDbType.Int).Value = cdt.Id_Group; return(cls.CapNhatDL(cmd)); }
public int Update(Object.ObjCustomerDetail customerDetail) { return(customerDetailMng.Update(customerDetail)); }