//---------------------------------------------------------------------------------------------------------// public static void Insert(EHOADON OHOADON) { SqlParameter[] pr = new SqlParameter[5]; pr[0] = new SqlParameter(@"SOHOADON", OHOADON.SOHOADON); pr[1] = new SqlParameter(@"NGAYHOADON", OHOADON.NGAYHOADON); pr[2] = new SqlParameter(@"MAKH", OHOADON.MAKH); pr[3] = new SqlParameter(@"NHANVIEN", OHOADON.NHANVIEN); pr[4] = new SqlParameter(@"GHICHU", OHOADON.GHICHU); DataAccseL.ExecuteNonQuery(CommandType.StoredProcedure, "HOADON_Insert", pr); }
public EHOADON(string vSOHOADON) { EHOADON OHOADON = BHOADON.SelectByID(vSOHOADON); this.SOHOADON = OHOADON.SOHOADON; this.NGAYHOADON = OHOADON.NGAYHOADON; this.MAKH = OHOADON.MAKH; this.NHANVIEN = OHOADON.NHANVIEN; this.GHICHU = OHOADON.GHICHU; }
//---------------------------------------------------------------------------------------------------------// private static EHOADON GetOneHOADON(IDataReader idr) { EHOADON OHOADON = new EHOADON(); if (idr["SOHOADON"] != DBNull.Value) OHOADON.SOHOADON = (string)idr["SOHOADON"]; if (idr["NGAYHOADON"] != DBNull.Value) OHOADON.NGAYHOADON = (string)idr["NGAYHOADON"]; if (idr["MAKH"] != DBNull.Value) OHOADON.MAKH = (string)idr["MAKH"]; if (idr["NHANVIEN"] != DBNull.Value) OHOADON.NHANVIEN = (string)idr["NHANVIEN"]; if (idr["GHICHU"] != DBNull.Value) OHOADON.GHICHU = (string)idr["GHICHU"]; return OHOADON; }
public static EHOADON SelectByID(string SOHOADON) { EHOADON OHOADON = new EHOADON(); SqlParameter[] pr = new SqlParameter[1]; pr[0] = new SqlParameter(@"SOHOADON", SOHOADON); IDataReader idr = DataAccseL.ExecuteReader(CommandType.StoredProcedure, "HOADON_SelectByID", pr); if (idr.Read()) OHOADON = GetOneHOADON(idr); idr.Close(); idr.Dispose(); return OHOADON; }
public static void Update(EHOADON OHOADON) { SqlParameter[] pr = new SqlParameter[5]; pr[0] = new SqlParameter(@"SOHOADON", OHOADON.SOHOADON); pr[1] = new SqlParameter(@"NGAYHOADON", OHOADON.NGAYHOADON); pr[2] = new SqlParameter(@"MAKH", OHOADON.MAKH); pr[3] = new SqlParameter(@"NHANVIEN", OHOADON.NHANVIEN); pr[4] = new SqlParameter(@"GHICHU", OHOADON.GHICHU); SqlHelper.ExecuteNonQuery(CommandType.StoredProcedure, "HOADON_Update", pr); }
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; }