private async void ExecuteShowLoginAsync() { try { using (SalesDB db = new SalesDB()) { if (!db.Database.Exists()) { db.Users.AddOrUpdate(x => x.ID, new User() { ID = "حماده", Password = "******" }); db.SaveChanges(); } var user = userServ.GetUser(); } } #pragma warning disable CS0168 // The variable 'ex' is declared but never used catch (Exception ex) #pragma warning restore CS0168 // The variable 'ex' is declared but never used { var configuration = new Configuration(); configuration.TargetDatabase = new DbConnectionInfo("Server=.\\sqlexpress;Database=HamadaSalesDB;Trusted_Connection=True;", "System.Data.SqlClient"); var migrator = new DbMigrator(configuration); migrator.Update(); //_restoreBackupDialog.DataContext = this; //await _currentWindow.ShowMetroDialogAsync(_restoreBackupDialog); //return; } _loginDialog.DataContext = this; await _currentWindow.ShowMetroDialogAsync(_loginDialog); }
public List <Stock> GetStocks() { using (SalesDB db = new SalesDB()) { return(db.Stocks.OrderBy(o => o.Name).ToList()); } }
public Safe GetLastSafe() { using (SalesDB db = new SalesDB()) { return(db.Safes.OrderByDescending(o => o.RegistrationDate).FirstOrDefault()); } }
public bool IsExistInClientInfo(int id) { using (SalesDB db = new SalesDB()) { return(db.ClientsInfo.Any(s => s.CategoryID == id)); } }
public Stock GetStock(string name) { using (SalesDB db = new SalesDB()) { return(db.Stocks.SingleOrDefault(s => s.Name == name)); } }
public List <Category> GetCategories() { using (SalesDB db = new SalesDB()) { return(db.Categories.AsNoTracking().Include(i => i.Company).Include(s => s.Stock).OrderBy(o => o.Company.Name).ThenBy(t => t.Name).ToList()); } }
public List <Category> SearchCategories(string key, int page) { using (SalesDB db = new SalesDB()) { return(db.Categories.Include(i => i.Company).Include(s => s.Stock).Where(w => w.Isarchived == false && (w.Name + w.Color + w.Company.Name + w.Stock.Name).Contains(key)).OrderBy(o => o.Company.Name).ThenBy(t => t.Name).Skip((page - 1) * 17).Take(17).Include(i => i.SuppliesCategories).Include(i => i.SalesCategories).ToList()); } }
public DateTime GetLastDate(int clientID) { using (SalesDB db = new SalesDB()) { return(db.ClientsAccounts.Where(w => w.ClientID == clientID).Max(d => d.Date).Date); } }
public List <ClientAccount> GetClientAccounts(int clientID, DateTime dtFrom, DateTime dtTo) { using (SalesDB db = new SalesDB()) { return(db.ClientsAccounts.Where(w => w.ClientID == clientID && w.Date >= dtFrom && w.Date <= dtTo).OrderByDescending(o => o.RegistrationDate).ToList()); } }
public Client GetClient(string name) { using (SalesDB db = new SalesDB()) { return(db.Clients.SingleOrDefault(s => s.Name == name)); } }
public List <Client> GetClients() { using (SalesDB db = new SalesDB()) { return(db.Clients.OrderBy(o => o.Name).ToList()); } }
public Client GetClient(int id) { using (SalesDB db = new SalesDB()) { return(db.Clients.SingleOrDefault(s => s.ID == id)); } }
public bool IsExistInClientAccounts(int id) { using (SalesDB db = new SalesDB()) { return(db.ClientsAccounts.Any(s => s.ClientID == id)); } }
public SupplyFuture GetSupplyFuture(int supplyID) { using (SalesDB db = new SalesDB()) { return(db.SuppliesFuture.SingleOrDefault(s => s.SupplyID == supplyID)); } }
public Category GetCategory(int id) { using (SalesDB db = new SalesDB()) { return(db.Categories.SingleOrDefault(s => s.ID == id)); } }
public List <ClientAccount> SearchClientsAccounts(string search, int page, DateTime dtFrom, DateTime dtTo) { using (SalesDB db = new SalesDB()) { return(db.ClientsAccounts.Include(i => i.Client).Where(w => (w.Statement + w.Client.Name).Contains(search) && w.Date >= dtFrom && w.Date <= dtTo).OrderByDescending(o => o.RegistrationDate).Skip((page - 1) * 17).Take(17).ToList()); } }
public Category GetCategory(string name, int companyID) { using (SalesDB db = new SalesDB()) { return(db.Categories.SingleOrDefault(s => s.Name == name && s.CompanyID == companyID)); } }
public int GetClientsAccountsNumer(string key) { using (SalesDB db = new SalesDB()) { return(db.ClientsAccounts.Include(i => i.Client).Where(w => (w.Statement + w.Client.Name).Contains(key)).Count()); } }
public int GetCategoriesNumer(string key) { using (SalesDB db = new SalesDB()) { return(db.Categories.Where(w => w.Isarchived == false).Include(i => i.Company).Include(s => s.Stock).Where(w => (w.Name + w.Company.Name + w.Stock.Name).Contains(key)).Count()); } }
public int GetClientsAccountsNumer(string key, DateTime dtFrom, DateTime dtTo) { using (SalesDB db = new SalesDB()) { return(db.ClientsAccounts.Include(i => i.Client).Where(w => (w.Statement + w.Client.Name).Contains(key) && w.Date >= dtFrom && w.Date <= dtTo).Count()); } }
public bool IsExistInSupplies(int id) { using (SalesDB db = new SalesDB()) { return(db.SuppliesCategories.Any(s => s.CategoryID == id)); } }
public decimal?GetTotalCredit(string key, DateTime dtFrom, DateTime dtTo) { using (SalesDB db = new SalesDB()) { return(db.ClientsAccounts.Include(i => i.Client).Where(w => (w.Statement + w.Client.Name).Contains(key) && w.Date >= dtFrom && w.Date <= dtTo).Sum(s => s.Credit)); } }
public DateTime GetLastDate(int id) { using (SalesDB db = new SalesDB()) { var supply = db.SuppliesCategories.Include(i => i.Supply).AsEnumerable().Where(w => w.CategoryID == id).LastOrDefault(); var sale = db.SalesCategories.Include(i => i.Sale).AsEnumerable().Where(w => w.CategoryID == id).LastOrDefault(); if (supply == null && sale == null) { return(Convert.ToDateTime(DateTime.Now.ToShortDateString())); } else if (supply == null && sale != null) { return(sale.Sale.Date); } else if (supply != null && sale == null) { return(supply.Supply.Date); } else { if (supply.Supply.Date < sale.Sale.Date) { return(sale.Sale.Date); } else { return(supply.Supply.Date); } } } }
public List <SupplyCategory> GetOldCosts(int categoryID, int clientID) { using (SalesDB db = new SalesDB()) { return(db.SuppliesCategories.Where(w => w.CategoryID == categoryID).Include(i => i.Supply).Where(w => w.Supply.ClientID == clientID).OrderByDescending(o => o.Supply.Date).Take(4).ToList()); } }
public bool IsExistInCategories(int id) { using (SalesDB db = new SalesDB()) { return(db.Categories.Any(s => s.StockID == id)); } }
public List <SupplyCategory> GetSupplyCategories(int supplyID) { using (SalesDB db = new SalesDB()) { return(db.SuppliesCategories.Where(w => w.SupplyID == supplyID).ToList()); } }
public decimal?GetSaleRecallsSum(int saleID) { using (SalesDB db = new SalesDB()) { return(db.SalesRecalls.Where(w => w.SaleID == saleID).Sum(s => s.Qty)); } }
public List <SupplyCategoryVM> GetSupplyCategoriesVM(int supplyID) { using (SalesDB db = new SalesDB()) { return(db.SuppliesCategories.Where(w => w.SupplyID == supplyID).Include(c => c.Category).Include(c => c.Category.Company).Select(s => new SupplyCategoryVM { Category = s.Category.Name, CategoryID = s.CategoryID, Company = s.Category.Company.Name, Cost = s.Cost, CostAfterDiscount = s.CostAfterDiscount, CostAfterTax = s.CostAfterTax, CostTotal = s.CostTotal, CostTotalAfterDiscount = s.CostTotalAfterDiscount, CostTotalAfterTax = s.CostTotalAfterTax, Discount = s.Discount, DiscountValue = s.DiscountValue, DiscountValueTotal = s.DiscountValueTotal, Qty = s.Qty, SupplyID = s.SupplyID, Tax = s.Tax, TaxValue = s.TaxValue, TaxValueTotal = s.TaxValueTotal, Price = s.Price }).ToList()); } }
public decimal?GetCurrentAccount() { using (SalesDB db = new SalesDB()) { return(db.Safes.Sum(s => s.Amount)); } }
public User GetUser() { using (SalesDB db = new SalesDB()) { return(db.Users.FirstOrDefault()); } }