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