//---------------------------------------------------------------- //THEM, XOA, SUA public bool themHD(ET_HoaDon eT_HoaDon) { try { openDB(); SqlCommand cmd = HandleCMD.proc("sp_ThemHoaDon", _con); cmd.Parameters.AddWithValue("@MaNV", eT_HoaDon.MaNV); cmd.Parameters.AddWithValue("@MaKH", eT_HoaDon.MaKH); cmd.Parameters.AddWithValue("@MaHD", eT_HoaDon.MaHD); cmd.Parameters.AddWithValue("@TongTien", eT_HoaDon.TongTien); cmd.Parameters.AddWithValue("@NgayXuatHoaDon", eT_HoaDon.NgayXuatHoaDon); cmd.Parameters.AddWithValue("@LoaiHoaDon", eT_HoaDon.LoaiHoaDon); if (this.cmdExecuted(cmd)) { return(true); } } catch (Exception ex) { Console.WriteLine("ERROR: " + ex.Message); return(false); } finally { closeDB(); } return(false); }
//---------------------------------------------------------------- //HAM PHU public void addParameter(SqlCommand cmd, ET_HoaDon hoaDon, String[] strNameParametor) { ArrayList list = hoaDon.getAllProperties(); foreach (string item in strNameParametor) { SqlParameter pt = new SqlParameter(item, list[Array.IndexOf(strNameParametor, item)]); cmd.Parameters.Add(pt); } }
public void CreateHoaDon() { string maNV = cbNhanVien.SelectedValue + ""; ET_HoaDon et = new ET_HoaDon(CreateNewID(), dtpNgayXuatHD.Value.ToString("yyyy-MM-dd"), int.Parse(txtTongTien.Text), cbLoaiHoaDon.SelectedItem.ToString(), maNV, cbKhachHang.SelectedItem.ToString()); if (bus_HoaDon.themHD(et)) { if (CreateChiTietHD()) { DialogResult r = MessageBox.Show("Thanh toán thành công!", "Thống báo", MessageBoxButtons.OK, MessageBoxIcon.Information); if (r == DialogResult.OK) { ResetControl(); } } } else { MessageBox.Show("Xin lỗi đã xảy ra lỗi trong quá trình thao tác!!!", "Thống báo", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public bool suaHD(ET_HoaDon eT_HoaDon) { try { openDB(); SqlCommand cmd = HandleCMD.proc("sp_CapNhapHoaDon", _con); addParameter(cmd, eT_HoaDon, strNameParametor); if (this.cmdExecuted(cmd)) { return(true); } } catch (Exception ex) { Console.WriteLine("ERROR: " + ex.Message); return(false); } finally { closeDB(); } return(false); }
public bool suaHD(ET_HoaDon et_HD) { return(dal_HD.suaHD(et_HD)); }
public bool themHD(ET_HoaDon et_HD) { return(dal_HD.themHD(et_HD)); }