Beispiel #1
0
        public float Discount(Master item, float price, POSDBContext db)
        {
            double Discount = 0;

            try
            {
                if (item.Discount == -1)
                {
                    return(0);
                }
                else if (item.Discount > 0)
                {
                    return(price * ((float)item.Discount / 100));
                }
                else

                {
                    Discount = (double)(from i in db.Groups where i.GroupId == item.GroupId select i.Discount).SingleOrDefault();
                    return(price * ((float)Discount / 100));
                }
            }
            catch (Exception)
            {
                return(-1);
            }
        }
Beispiel #2
0
        public static bool TestDBConnection()
        {
            bool result = true;

            db = new POSDBContext();

            try
            {
                /// Hangs if connectionString is invalid rather than throw an exception
                db.Database.Connection.Open();

                /// Initially, I was just trying to call DatabaseExists but, this hangs as well if the conn string is invalid
                if (!db.Database.Exists())
                {
                    result = false;
                    throw new Exception("Database doesn't exist.");
                }
            }
            catch (Exception ex)
            {
                result = false;
                throw new Exception("Error:" + ex.Message + "\n\nDetailed Error: " + ex.StackTrace);
            }
            finally
            {
                DB.resetConnString();
            }

            return(result);
        }
Beispiel #3
0
        public JsonResult GetProducts(string term)
        {
            POSDBContext  p = new POSDBContext();
            List <string> products;

            products = p.Products.Where(x => x.Title.StartsWith(term))
                       .Select(y => y.Title).ToList();

            return(Json(products, JsonRequestBehavior.AllowGet));
        }
Beispiel #4
0
        public float PaymentPrice(Master item, int paymentid, POSDBContext db)
        {
            double Discount = 0;

            try
            {
                Discount = (double)(from i in db.ItemPrices where i.PaymentId == paymentid && i.ItemId == item.ItemId select i.Price).SingleOrDefault();


                return((float)Discount);
            }
            catch (Exception)
            {
                return(-1);
            }
        }
Beispiel #5
0
        public string Isreversabel(Master item, Tickets ticket, POSDBContext db)
        {
            try
            {
                if (item.DaysReverse == -1)
                {
                    return(" الصنف " + item.ItemName + " غير قابل للترجيع ");
                }
                else if (item.DaysReverse > 0)
                {
                    TimeSpan ts           = DateTime.Now - ticket.CreatedDate;
                    int      NumberOfDays = (int)ts.TotalDays;

                    if (NumberOfDays > item.DaysReverse)
                    {
                        return(" الصنف " + item.ItemName + " غير قابل للترجيع بعد " + item.DaysReverse + " يوم ");
                    }
                }
                else
                {
                    Groups g = (from i in db.Groups where i.GroupId == item.GroupId select i).SingleOrDefault();
                    if (g.DaysReverse == 0)
                    {
                        return(" الأصناف في المجموعة  " + g.GroupDes + " غير قابلة للترجيع بعد ");
                    }


                    TimeSpan ts           = DateTime.Now - ticket.CreatedDate;
                    int      NumberOfDays = (int)ts.TotalDays;

                    if (NumberOfDays > g.DaysReverse)
                    {
                        return(" الأصناف في المجموعة  " + g.GroupDes + " غير قابلة للترجيع بعد " + g.DaysReverse + " يوم ");
                    }
                }

                return("Done");
            }
            catch (Exception)
            {
                return("error");
            }
        }
Beispiel #6
0
 public static void resetConnString()
 {
     db.Dispose();
     db = new POSDBContext();
 }
Beispiel #7
0
 public GroupsController(POSDBContext context)
 {
     _context = context;
 }
Beispiel #8
0
 public PosRepo(POSDBContext dbContext, IGenerateID generateID)
 {
     _dbContext  = dbContext;
     _generateID = generateID;
 }
Beispiel #9
0
 public OrderDetailRepo(POSDBContext context) : base(context)
 {
 }
Beispiel #10
0
 public HomeController(POSDBContext context)
 {
     _context = context;
 }
Beispiel #11
0
 public POSController(POSDBContext context)
 {
     _context  = context;
     _context2 = context;
 }
Beispiel #12
0
 public ProductRepository(POSDBContext context)
     : base(context)
 {
 }
Beispiel #13
0
 public InvoiceRepository(POSDBContext context)
     : base(context)
 {
 }
Beispiel #14
0
 public AccountRepository(POSDBContext context)
     : base(context)
 {
 }
Beispiel #15
0
 public GenericRepository(POSDBContext context)
 {
     entities = context;
 }
Beispiel #16
0
 public PaymentController(POSDBContext context)
 {
     _context = context;
     //if (HttpContext.Session.GetString("_Name") == null)
     //    _context = context;
 }
Beispiel #17
0
 public MainController(POSDBContext context)
 {
     _context = context;
 }
Beispiel #18
0
 public OrderRepo(POSDBContext context) : base(context)
 {
     this.context = context;
 }
Beispiel #19
0
 public CategoryRepository(POSDBContext context)
     : base(context)
 {
 }
Beispiel #20
0
 public ItemsController(POSDBContext context)
 {
     _context = context;
 }
Beispiel #21
0
 public ProductRepo(POSDBContext context) : base(context)
 {
     this.context = context;
 }
Beispiel #22
0
 public Repository(POSDBContext context)
 {
     this.Context = context;
 }
 public CustomersController(POSDBContext context)
 {
     _context = context;
 }