public void LoadHangHoa() { using (var db = new QUANLYCACDAILYEntities()) { HANGHOAS = db.HANGHOAs.ToList(); } }
private void LoadPhieuThu() { PHIEUTHUS = new List <ViewPhieuThu>(); using (var db = new QUANLYCACDAILYEntities()) { var query = from hd in db.HOADONs join pt in db.PHIEUTHUs on hd.MaHoaDon equals pt.MaHoaDon select new { pt.MaPhieuThu, hd.MaHoaDon, pt.NgayLapPhieu, hd.ThanhTien, pt.SoTienDaThu }; foreach (var item in query) { ViewPhieuThu viewPhieuThu = new ViewPhieuThu( item.MaPhieuThu, item.MaHoaDon, item.NgayLapPhieu.Value, item.ThanhTien.Value, item.SoTienDaThu.Value, item.ThanhTien.Value - item.SoTienDaThu.Value ); PHIEUTHUS.Add(viewPhieuThu); } } }
private void LoadUuDai() { using (var db = new QUANLYCACDAILYEntities()) { UUDAIS = db.UUDAIs.ToList(); } }
private void LoadDonHang() { using (var db = new QUANLYCACDAILYEntities()) { var query = (from dl in db.DAILies join dh in db.DONHANGs on dl.MaDaiLy equals dh.MaDaiLy join hd in db.HOADONs on dh.MaDonHang equals hd.MaDonHang join px in db.PHIEUXUATs on hd.MaPhieuXuat equals px.MaPhieuXuat join ct in db.CHITIETHANGHOAXUATs on px.MaPhieuXuat equals ct.MaPhieuXuat join hh in db.HANGHOAs on ct.MaHangHoa equals hh.MaHangHoa select new { dh.MaDonHang, dl.TenDaiLy, hh.TenMatHang, dh.NgayDangKy, ct.SoLuong, hh.DonGia }).ToList(); DONHANGS = new List <ViewDonHang>(); foreach (var item in query) { ViewDonHang viewDonHang = new ViewDonHang( item.MaDonHang, item.TenDaiLy, item.TenMatHang, item.NgayDangKy.Value, item.SoLuong.Value, item.DonGia.Value); DONHANGS.Add(viewDonHang); } } }
public void LoadDaiLy() { using (var db = new QUANLYCACDAILYEntities()) { DAILYS = db.DAILies.ToList(); } using (var db = new QUANLYCACDAILYEntities()) { DINHMUCS = db.DINHMUCs.ToList(); } }
private void OnDelete() { using (var db = new QUANLYCACDAILYEntities()) { db.DAILies.Remove( db.DAILies.Find( (from m in db.DAILies where m.MaDaiLy == SelectedDAILYS.MaDaiLy select m) )); } }
private void LoadHoaDon() { using (var db = new QUANLYCACDAILYEntities()) { HOADONS = new List <ViewHoaDon>(); var query1 = from ud in db.UUDAIs from dl in db.DAILies join dh in db.DONHANGs on dl.MaDaiLy equals dh.MaDaiLy join hd in db.HOADONs on dh.MaDonHang equals hd.MaDonHang join px in db.PHIEUXUATs on hd.MaPhieuXuat equals px.MaPhieuXuat join ct in db.CHITIETHANGHOAXUATs on px.MaPhieuXuat equals ct.MaPhieuXuat join hh in db.HANGHOAs on ct.MaHangHoa equals hh.MaHangHoa where dl.UUDAIs.Contains(ud) select new { dl.MaDaiLy, dl.TenDaiLy, hd.MaHoaDon, hh.TenMatHang, hd.NgayLap, ct.SoLuong, px.ThanhTien, hh.DonGia, ud.PhanTram }; foreach (var item in query1) { ViewHoaDon viewHoaDon = new ViewHoaDon( item.TenDaiLy, item.MaHoaDon, item.TenMatHang, item.NgayLap.Value, item.SoLuong.Value, item.DonGia.Value, item.SoLuong.Value * item.DonGia.Value, item.PhanTram.Value + "%", item.SoLuong.Value * item.DonGia.Value * ((100 - item.PhanTram.Value) / 100) ); HOADONS.Add(viewHoaDon); } } }
private void OnAdd() { try { Daily dl = new Daily(); using (var db = new QUANLYCACDAILYEntities()) { DAILY temp = new DAILY(); temp.MaDaiLy = dl.txt_madaily.ToString(); temp.MaDinhMuc = dl.cb_madinhmuc.SelectedItem.ToString(); temp.MaHopDong = dl.txt_mahopdong.ToString(); temp.NgayLap = DateTime.Parse(dl.dp_ngaylap.ToString()); temp.CMND = dl.txt_cmnd.ToString(); temp.HoTenChuDaiLy = dl.txt_hotenchudaily.ToString(); temp.NgaySinh = DateTime.Parse(dl.dp_ngaysinh.ToString()); temp.CapDaiLy = dl.txt_cap.ToString(); temp.TenDaiLy = dl.txt_tendaily.ToString(); temp.NoiDung = dl.txt_noidung.ToString(); db.DAILies.Add(temp); } } catch { } }