private void btnSua_Click(object sender, EventArgs e) { EKHACHHANG ek = new EKHACHHANG(); ek.MAKH = txtsdt.Text.Trim(); ek.TENK = txttenk.Text.Trim(); ek.GIOITINH = rdNam.Checked ? "Nam" : "Nữ"; ek.SDT = txtsdt.Text.Trim(); ek.DIACHI = txtdc.Text.Trim(); BKHACHHANG.Update(ek); FormKhachhang_Load(sender, e); }
private void button1_Click(object sender, EventArgs e) { EKHACHHANG ek = new EKHACHHANG(); ek.MAKH = txtsdt.Text.Trim(); ek.TENK = txttenk.Text.Trim(); ek.GIOITINH = rdNam.Checked ? "Nam" : "Nữ"; ek.SDT = txtsdt.Text.Trim(); ek.DIACHI = txtdc.Text.Trim(); DataTable dt = BKHACHHANG.SelectAll(txtsdt.Text.Trim()); if (dt == null || dt.Rows.Count == 0) { BKHACHHANG.Insert(ek); } else { BKHACHHANG.Update(ek); } //hoa don EHOADON ehd = new EHOADON(); ehd.SOHOADON = txtshd.Text.Trim(); ehd.NGAYHOADON = dtngay.Value.Day.ToString() + "/" + dtngay.Value.Month.ToString() + "/" + dtngay.Value.Year.ToString(); ehd.MAKH = txtsdt.Text.Trim(); ehd.NHANVIEN = txtnv.Text.Trim(); ehd.GHICHU = txtghichu.Text.Trim(); if (!isHD) { BHOADON.Insert(ehd); isHD = true; } else { BHOADON.Update(ehd); } button1.Text = "Sửa hóa đơn"; grbcthd.Enabled = true; }