// Them chi tiet hoa don private void button5_Click(object sender, EventArgs e) { string m, ms; int sl, dg, tt; m = cbbMaHD.Text.Trim(); ms = cbbMaSP.Text.Trim(); sl = int.Parse(txtSoLuong.Text); dg = int.Parse(txtDonGia.Text); thanhTien(); tt = int.Parse(txtThanhTien.Text); DTOCTHoaDon cthd = new DTOCTHoaDon(m, ms, sl, dg, tt); try { int i = new BUSCTHoaDon().Add(cthd); loadLaiSanPham(); dgvChiTietHoaDon.DataSource = GetCTHD(); loadSanPham(); load(); } catch (SqlException ex) { MessageBox.Show(ex.Message); } }
public List <DTOCTHoaDon> GetCTHD(string sql) { dp.connect(); List <DTOCTHoaDon> list = new List <DTOCTHoaDon>(); { string m, ms; int sl, dg, tt; try { SqlDataReader dr = dp.ExecuteReader(sql); while (dr.Read()) { m = dr.GetString(0); ms = dr.GetString(1); sl = dr.GetInt32(2); dg = dr.GetInt32(3); tt = dr.GetInt32(4); DTOCTHoaDon cthd = new DTOCTHoaDon(m, ms, sl, dg, tt); list.Add(cthd); } dr.Close(); return(list); } catch (SqlException ex) { throw ex; } finally { dp.disconnect(); } } }
public int Add(DTOCTHoaDon cthd) { List <SqlParameter> paras = new List <SqlParameter>(); paras.Add(new SqlParameter("@m", cthd.MaHD)); paras.Add(new SqlParameter("@ms", cthd.MaSP)); paras.Add(new SqlParameter("@sl", cthd.SoLuong)); paras.Add(new SqlParameter("@dg", cthd.DonGia)); try { return(dp.ExcuteNonQuery("ThemCTHD", System.Data.CommandType.StoredProcedure, paras)); } catch (SqlException ex) { throw ex; } }
private void btThemCTHD_Click(object sender, EventArgs e) { string m, ms; int sl, dg; m = cbbMaHD.Text.Trim(); ms = cbbMaSP.Text.Trim(); sl = int.Parse(txtSoLuong.Text); dg = int.Parse(txtGia.Text); DTOCTHoaDon cthd = new DTOCTHoaDon(m, ms, sl, dg); try { int i = new BUSCTHoaDon().Add(cthd); dgvCTHoaDon.DataSource = GetCTHD(); load(); xoaCTHD(); } catch (SqlException ex) { MessageBox.Show(ex.Message); } }
public int Add(DTOCTHoaDon cthd) { return(new DAOCTHoaDon().Add(cthd)); }