Beispiel #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;
                }
            }
        }
Beispiel #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;
                }
            }
        }
Beispiel #3
0
        public static eTblPurchaseHistory GetRecord(int purchaseId)
        {
            eTblPurchaseHistory eobj = null;

            using (OneFineRateEntities db = new OneFineRateEntities())
            {
                var dbobj = db.tblPurchaseHistories.Find(purchaseId);
                if (dbobj != null)
                {
                    eobj = (eTblPurchaseHistory)OneFineRateAppUtil.clsUtils.ConvertToObject(dbobj, new eTblPurchaseHistory());
                }
            }
            return(eobj);
        }