示例#1
0
        public dynamic Add()
        {
            if (this.id > 0)
            {
                return(false);
            }

            WpfEntities db = new WpfEntities();

            try
            {
                db.Customers.Add(this);
                db.SaveChanges();

                return(this.id);
            }
            catch (Exception Exception)
            {
                //JDR: Exception can be logged here
                Console.WriteLine("***EROR_CATCH*** - An error occurred: '{0}'", Exception);

                return(false);
            }
            finally
            {
                db.Dispose();
            }
        }
示例#2
0
 public static List <Customer> GetAll()
 {
     using (WpfEntities db = new WpfEntities())
     {
         return(db.Customers.OrderByDescending(Row => Row.id).ToList());
     }
 }
示例#3
0
        public static dynamic GetByID(int id)
        {
            WpfEntities db = new WpfEntities();

            Customer Customer = db.Customers.Find(id);

            db.Dispose();

            if (Customer == null)
            {
                return(null);
            }

            return(Customer);
        }
示例#4
0
        public bool Save()
        {
            WpfEntities db = new WpfEntities();

            try
            {
                db.Entry(this).State = EntityState.Modified;

                db.SaveChanges();

                return(true);
            }
            catch (Exception Exception)
            {
                //JDR: Exception can be logged here
                Console.WriteLine("***EROR_CATCH*** - An error occurred: '{0}'", Exception);

                return(false);
            }
            finally
            {
                db.Dispose();
            }
        }