public int Update()
        {
            var t = new Can_tru_no_nhap_ngoai //Make sure you have a table called test in DB
               {
               ID = this.ID,
               Id_chat_luong = this.Id_chat_luong,
               Ma_vat_tu = this.Ma_vat_tu,                   // ID = Guid.NewGuid(),
               So_luong_can_tru = this.So_luong_can_tru,
               Ma_phieu_nhap = this.Ma_phieu_nhap,
               Ma_phieu_nhap_no = this.Ma_phieu_nhap_no,
               };

               DatabaseHelper help = new DatabaseHelper();
               help.ConnectDatabase();
               int temp = 0;
               using (var dbcxtransaction = help.ent.Database.BeginTransaction())
               {
               using (var context = help.ent)
               {
                   context.Can_tru_no_nhap_ngoai.Attach(t);
                   context.Entry(t).State = EntityState.Modified;
                   temp = help.ent.SaveChanges();
                   dbcxtransaction.Commit();

               }

               }
               return temp;
        }
        public int Insert(DatabaseHelper help)
        {
            {
               try
               {
                   var t = new Can_tru_no_nhap_ngoai //Make sure you have a table called test in DB
                   {
                       Id_chat_luong = this.Id_chat_luong,
                       Ma_vat_tu = this.Ma_vat_tu,                   // ID = Guid.NewGuid(),
                       So_luong_can_tru = this.So_luong_can_tru,
                       Ma_phieu_nhap = this.Ma_phieu_nhap,
                       Ma_phieu_nhap_no = this.Ma_phieu_nhap_no,
                   };

                   help.ent.Can_tru_no_nhap_ngoai.Add(t);
                   help.ent.SaveChanges();
                   //dbcxtransaction.Commit();
                   return 1;
               }
               catch (Exception ex)
               {
                   //dbcxtransaction.Rollback();
                   return 0;

               }
               }
        }
        public int Update(DatabaseHelper help)
        {
            var t = new Can_tru_no_nhap_ngoai //Make sure you have a table called test in DB
               {
               ID = this.ID,
               Id_chat_luong = this.Id_chat_luong,
               Ma_vat_tu = this.Ma_vat_tu,                   // ID = Guid.NewGuid(),
               So_luong_can_tru = this.So_luong_can_tru,
               Ma_phieu_nhap = this.Ma_phieu_nhap,
               Ma_phieu_nhap_no = this.Ma_phieu_nhap_no,
               };

               int temp = 0;

               {
               using (var context = help.ent)
               {
                   context.Can_tru_no_nhap_ngoai.Attach(t);
                   context.Entry(t).State = EntityState.Modified;
                   temp = help.ent.SaveChanges();

               }

               }
               return temp;
        }