Exemple #1
0
        public static int UpdateRecord(eTblPurchaseHistory eobj)
        {
            using (OneFineRateEntities db = new OneFineRateEntities())
            {
                try
                {
                    OneFineRate.tblPurchaseHistory obj = (OneFineRate.tblPurchaseHistory)OneFineRateAppUtil.clsUtils.ConvertToObject(eobj, new OneFineRate.tblPurchaseHistory());
                    db.tblPurchaseHistories.Attach(obj);
                    db.Entry(obj).State = System.Data.Entity.EntityState.Modified;
                    return(db.SaveChanges());
                }
                catch (DbEntityValidationException dbEx)
                {
                    foreach (var validationErrors in dbEx.EntityValidationErrors)
                    {
                        foreach (var validationError in validationErrors.ValidationErrors)
                        {
                            Trace.TraceInformation("Property: {0} Error: {1}", validationError.PropertyName, validationError.ErrorMessage);
                        }
                    }

                    throw;
                }
                catch (Exception)
                {
                    throw;
                }
            }
        }
Exemple #2
0
        public static long AddRecordAndGetId(eTblPurchaseHistory eobj)
        {
            using (OneFineRateEntities db = new OneFineRateEntities())
            {
                try
                {
                    OneFineRate.tblPurchaseHistory purchangeHistory = (OneFineRate.tblPurchaseHistory)OneFineRateAppUtil.clsUtils.ConvertToObject(eobj, new OneFineRate.tblPurchaseHistory());
                    db.tblPurchaseHistories.Add(purchangeHistory);
                    var status = db.SaveChanges();
                    return(purchangeHistory.iPurchaseId);
                }
                catch (DbEntityValidationException dbEx)
                {
                    foreach (var validationErrors in dbEx.EntityValidationErrors)
                    {
                        foreach (var validationError in validationErrors.ValidationErrors)
                        {
                            Trace.TraceInformation("Property: {0} Error: {1}", validationError.PropertyName, validationError.ErrorMessage);
                        }
                    }

                    throw;
                }
                catch (Exception)
                {
                    throw;
                }
            }
        }