public int themctpDNXK(eCTPhieuDNXK ctpDNXK)
        {
            if (kiemtractpDNXK(ctpDNXK.soPDNXK, ctpDNXK.maSP))
            {
                var r = from c in db.Tbl_CTPhieuDNXKs
                        where c.maSP == ctpDNXK.maSP
                        select new { c.soluong };
                int kq = Convert.ToInt32(ctpDNXK.soluong);
                foreach (var k in r)
                {
                    kq += Convert.ToInt32(k.soluong);
                }
                IQueryable <Tbl_CTPhieuDNXK> DNXK1 = db.Tbl_CTPhieuDNXKs.Where(x => x.soPDNXK.Equals(ctpDNXK.soPDNXK) && x.maSP.Equals(ctpDNXK.maSP));
                DNXK1.First().soluong = kq;
                db.SubmitChanges();
                return(0);
            }
            Tbl_CTPhieuDNXK nhap = new Tbl_CTPhieuDNXK();

            nhap.soPDNXK = ctpDNXK.soPDNXK;
            nhap.maSP    = ctpDNXK.maSP;
            nhap.soluong = Convert.ToInt32(ctpDNXK.soluong);
            nhap.Ghichu  = ctpDNXK.Ghichu;
            db.Tbl_CTPhieuDNXKs.InsertOnSubmit(nhap);
            db.SubmitChanges();

            return(1);
        }
        public bool kiemtractpDNXK(string spDNXK, string msp)
        {
            Tbl_CTPhieuDNXK r = db.Tbl_CTPhieuDNXKs.Where(x => x.soPDNXK == spDNXK && x.maSP == msp).FirstOrDefault();

            if (r != null)
            {
                return(true);
            }
            return(false);
        }
 public static eCTPhieuDNXK e(Tbl_CTPhieuDNXK k)
 {
     return(new eCTPhieuDNXK(k.soPDNXK, k.maSP, Convert.ToInt32(k.soluong), k.Ghichu));
 }