Exemplo n.º 1
0
        public bool InsertChiTietHoaDonNhaCungCap(string mahd, string masp, int soluong, decimal giamua, string ghichu, string tensp)
        {
            var c = from i in db.ChiTietHoaDonNhaCungCaps
                    where i.MaHoaDonNhaCungCap == mahd && i.MaSPNCC == masp
                    select i;

            if (c.Any())
            {
                throw new Exception("There Already Have");
            }
            else
            {
                ChiTietHoaDonNhaCungCap ct = new ChiTietHoaDonNhaCungCap();
                ct.MaHoaDonNhaCungCap  = mahd;
                ct.SoLuong             = soluong;
                ct.MaSPNCC             = masp;
                ct.TenSPNCC            = tensp;
                ct.GiaMuaBenNhaCungCap = giamua;
                ct.GhiChu = ghichu;
                decimal money = Convert.ToDecimal(soluong * giamua);
                UpdateTongTienHoaDonNhaCungCapI(mahd, money);
                db.ChiTietHoaDonNhaCungCaps.InsertOnSubmit(ct);
                db.SubmitChanges();
                InsertSanPhamNhaCungCap(masp);
                decimal n = giamua * (decimal)1.05;
                InsertOfUpdateBangGiaSi(masp, giamua.ToString());
                return(true);
            }
        }
Exemplo n.º 2
0
        private void DeleteChiTietHoaDonNhaCungCap(string MaHoaDonNhaCungCap, string MaSp)
        {
            ChiTietHoaDonNhaCungCap Chitiet = db.ChiTietHoaDonNhaCungCaps.Where(x => x.MaHoaDonNhaCungCap == MaHoaDonNhaCungCap && x.MaSPNCC == MaSp).FirstOrDefault();
            decimal Money = Convert.ToDecimal(Chitiet.GiaMuaBenNhaCungCap * Chitiet.SoLuong);

            db.ChiTietHoaDonNhaCungCaps.DeleteOnSubmit(Chitiet);
            db.SubmitChanges();
            UpdateTongTienHoaDonNhaCungCapD(MaHoaDonNhaCungCap, Money);
        }
Exemplo n.º 3
0
        public int GetSoLuongbyOneSanPham(string mahd, string masp)
        {
            ChiTietHoaDonNhaCungCap chitiet = db.ChiTietHoaDonNhaCungCaps.Where(x => x.MaSPNCC == masp && x.MaHoaDonNhaCungCap == mahd).FirstOrDefault();

            if (chitiet != null)
            {
                return(chitiet.SoLuong);
            }
            else
            {
                throw new Exception("Invalid ID or Null ID");
            }
        }
Exemplo n.º 4
0
        public bool DeleteChiTietHDNCC(string mahd, string masp)
        {
            ChiTietHoaDonNhaCungCap ct = db.ChiTietHoaDonNhaCungCaps.Where(x => x.MaSPNCC == masp && x.MaHoaDonNhaCungCap == mahd).FirstOrDefault();

            if (ct != null)
            {
                decimal money = ct.SoLuong * ct.GiaMuaBenNhaCungCap;
                UpdateTongTienHoaDonNhaCungCapD(mahd, money);
                db.ChiTietHoaDonNhaCungCaps.DeleteOnSubmit(ct);
                db.SubmitChanges();
                return(true);
            }
            else
            {
                throw new Exception("Invalid ID of Null ID");
            }
        }