public void Update(ChiTietHoaDon info) { string sqlQuery = "update ChiTietHoaDon" + " set MaSach='" + info.MaSach + "'," + "SoLuong=" + info.SoLuong + "where MaCTHD='" + info.MaCTHD + "'"; ExecuteNonQuery(sqlQuery); }
public void Insert(ChiTietHoaDon info) { string sqlQuery = "insert into ChiTietHoaDon values('" + info.MaHD + "', '" + info.MaSach + "' , '" + info.SoLuong + "','" + info.MaCTHD + "')"; ExecuteNonQuery(sqlQuery); }
private void btSua_Click(object sender, RoutedEventArgs e) { dsChiTietHoaDon = chiTietHoaDonBus.GetList(); Entity.ChiTietHoaDon chiTietHoaDon = new Entity.ChiTietHoaDon(); chiTietHoaDon.MaHD = maHD; chiTietHoaDon.SoLuong = int.Parse(tbSoLuong.Text); chiTietHoaDon.MaCTHD = tbMaCTHD.Text; foreach (Sach item in dsSach) { if (item.TenSach == tbTeSach.Text) { chiTietHoaDon.MaSach = item.MaSach; break; } } chiTietHoaDonBus.Update(chiTietHoaDon); }
public List<ChiTietHoaDon> GetList() { List<ChiTietHoaDon> list = new List<ChiTietHoaDon>(); string sqlQuery = "select * from ChiTietHoaDon"; reader = ExecuteReader(sqlQuery); while(reader.Read()) { ChiTietHoaDon chiTietHoaDon = new ChiTietHoaDon(); chiTietHoaDon.MaHD = reader["MaHD"].ToString(); chiTietHoaDon.MaSach = reader["MaSach"].ToString(); chiTietHoaDon.SoLuong = (int) reader["SoLuong"]; chiTietHoaDon.MaCTHD = reader["MaCTHD"].ToString(); list.Add(chiTietHoaDon); } return list; }
private void btThem_Click(object sender, RoutedEventArgs e) { dsChiTietHoaDon = chiTietHoaDonBus.GetList(); Entity.ChiTietHoaDon chiTietHoaDon = new Entity.ChiTietHoaDon(); chiTietHoaDon.MaHD = maHD; chiTietHoaDon.SoLuong = int.Parse(tbSoLuong.Text); ThongTinChiTietHoaDon info = new ThongTinChiTietHoaDon(); int id = int.Parse(dsChiTietHoaDon[dsChiTietHoaDon.Count - 1].MaCTHD); chiTietHoaDon.MaCTHD = (++id).ToString(); info.MaCTHD = id.ToString(); info.TenSach = tbTeSach.Text; info.SoLuong = tbSoLuong.Text.ToString(); foreach (Sach item in dsSach) { if(item.TenSach==tbTeSach.Text) { chiTietHoaDon.MaSach = item.MaSach; info.DonGia = item.GiaBan.ToString(); foreach (TheLoai theloai in dsTheLoai) { if(item.TheLoai==theloai.MaTheLoai) { info.TheLoai = theloai.TenTheLoai; break; } } break; } } chiTietHoaDonBus.Insert(chiTietHoaDon); dataGrid.Items.Add(info); }
private void btThem_Click(object sender, RoutedEventArgs e) { dsChiTietHoaDon = chiTietHoaDonBus.GetList(); Entity.ChiTietHoaDon chiTietHoaDon = new Entity.ChiTietHoaDon(); chiTietHoaDon.MaHD = maHD; chiTietHoaDon.SoLuong = int.Parse(tbSoLuong.Text); ThongTinChiTietHoaDon info = new ThongTinChiTietHoaDon(); int id = int.Parse(dsChiTietHoaDon[dsChiTietHoaDon.Count - 1].MaCTHD); chiTietHoaDon.MaCTHD = (++id).ToString(); info.MaCTHD = id.ToString(); info.TenSach = tbTeSach.Text; info.SoLuong = tbSoLuong.Text.ToString(); foreach (Sach item in dsSach) { if (item.TenSach == tbTeSach.Text) { chiTietHoaDon.MaSach = item.MaSach; info.DonGia = item.GiaBan.ToString(); foreach (TheLoai theloai in dsTheLoai) { if (item.TheLoai == theloai.MaTheLoai) { info.TheLoai = theloai.TenTheLoai; break; } } break; } } chiTietHoaDonBus.Insert(chiTietHoaDon); dataGrid.Items.Add(info); }
public void Update(ChiTietHoaDon info) { data.Update(info); }
public void Insert(ChiTietHoaDon info) { data.Insert(info); }