public void DeletePDNXKChiTiet(string SoPhieu, string MaSP)
        {
            ChiTietPhieuDNXK chitiet = db.ChiTietPhieuDNXKs.Where(x => x.MaPhieuDNXK == SoPhieu && x.MaSP == MaSP).FirstOrDefault();

            if (chitiet != null)
            {
                db.ChiTietPhieuDNXKs.DeleteOnSubmit(chitiet);
                db.SubmitChanges();
            }
            else
            {
                throw new Exception("Invald Details");
            }
        }
        public int InsertPDNXKChiTiet(eChiTietPhieuDeNghiXuatKho Chitiet)
        {
            var sp = from i in db.SanPhams
                     where i.MaSP == Chitiet.MaSP
                     select i;

            if (sp.Any())
            {
                var c = from i in db.ChiTietPhieuDNXKs
                        where i.MaSP == Chitiet.MaSP && i.MaPhieuDNXK == Chitiet.SoPhieu
                        select i;
                if (c.Any())
                {
                    return(0);

                    throw new Exception("There have already");
                }
                else
                {
                    ChiTietPhieuDNXK newct = new ChiTietPhieuDNXK();
                    newct.MaPhieuDNXK = Chitiet.SoPhieu;
                    newct.MaSP        = Chitiet.MaSP;
                    newct.GhiChu      = Chitiet.GhiChu;
                    newct.SoLuong     = Chitiet.SoLuong;
                    db.ChiTietPhieuDNXKs.InsertOnSubmit(newct);
                    db.SubmitChanges();
                    return(1);
                }
            }
            else
            {
                return(2);

                throw new Exception("Invaild SanPham");
            }
        }