Пример #1
0
        public bool UpdateTax(MstTax tax, TaxSiteDocMap taxsitedocmap)
        {
            try
            {
                taxsitedocmap.SiteCode           = CommonModel.SiteCode;
                taxsitedocmap.TaxName            = tax.TaxName;
                taxsitedocmap.IsDocumentLevelTax = false;


                Context.TaxSiteDocMap.Add(taxsitedocmap);
                Context.SaveChanges();

                MstTax existTax = Context.MstTax.Where(a => a.TaxCode == tax.TaxCode && a.STATUS == true).FirstOrDefault();
                existTax.TaxName       = tax.TaxName;
                existTax.Value         = tax.Value;
                existTax.Inclusive     = tax.Inclusive;
                existTax.Type          = tax.Type;
                existTax.UPDATEDON     = DateTime.Now;
                existTax.UPDATEDAT     = tax.UPDATEDAT;
                existTax.UPDATEDBY     = tax.UPDATEDBY;
                existTax.InterStateTax = tax.InterStateTax;
                Context.Entry <MstTax>(existTax).State = EntityState.Modified;
                Context.SaveChanges();
                // Context.Entry<MstTax>(tax).State = EntityState.Modified;


                return(true);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Пример #2
0
 public bool SaveTax(MstTax tax, TaxSiteMapping taxSiteMap, TaxSiteDocMap taxsitedocmap)
 {
     using (var context = ContextFactory.CreateContext())
     {
         using (var dbTran = context.Database.BeginTransaction())
         {
             try
             {
                 Context.MstTax.Add(tax);
                 Context.TaxSiteMapping.Add(taxSiteMap);
                 Context.TaxSiteDocMap.Add(taxsitedocmap);
                 Context.SaveChanges();
                 dbTran.Commit();
                 return(true);
             }
             catch (Exception ex)
             {
                 dbTran.Rollback();
                 throw ex;
             }
             finally
             {
                 context.Dispose();
             }
         }
     }
 }