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); } }
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); }
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)); }
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); } }
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"); } }
public static void resetConnString() { db.Dispose(); db = new POSDBContext(); }
public GroupsController(POSDBContext context) { _context = context; }
public PosRepo(POSDBContext dbContext, IGenerateID generateID) { _dbContext = dbContext; _generateID = generateID; }
public OrderDetailRepo(POSDBContext context) : base(context) { }
public HomeController(POSDBContext context) { _context = context; }
public POSController(POSDBContext context) { _context = context; _context2 = context; }
public ProductRepository(POSDBContext context) : base(context) { }
public InvoiceRepository(POSDBContext context) : base(context) { }
public AccountRepository(POSDBContext context) : base(context) { }
public GenericRepository(POSDBContext context) { entities = context; }
public PaymentController(POSDBContext context) { _context = context; //if (HttpContext.Session.GetString("_Name") == null) // _context = context; }
public MainController(POSDBContext context) { _context = context; }
public OrderRepo(POSDBContext context) : base(context) { this.context = context; }
public CategoryRepository(POSDBContext context) : base(context) { }
public ItemsController(POSDBContext context) { _context = context; }
public ProductRepo(POSDBContext context) : base(context) { this.context = context; }
public Repository(POSDBContext context) { this.Context = context; }
public CustomersController(POSDBContext context) { _context = context; }