private void SaleReprint_Load(object sender, EventArgs e) { using (var p = new POSEntities()) { var s = p.Sales.FirstOrDefault(x => x.Id == sale.Id); datas = s.SoldItems.OrderBy(x => x.Product.Item.Name).Select(y => new DataListHolder(y.Product.Item.Name, y.SerialNumber, y.Quantity, y.ItemPrice, y.Discount ?? 0)).ToList(); } }
private void EditSaleDetails_Load(object sender, EventArgs e) { using (var p = new POSEntities()) { transactionDate.Value = p.Sales.FirstOrDefault(x => x.Id == SaleId).Date.Value; var customers = p.Customers.Select(x => x.Name).ToArray(); customerOption.Items.AddRange(customers); customerOption.AutoCompleteCustomSource.AddRange(customers); } }
static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); ExcelPackage.LicenseContext = LicenseContext.NonCommercial; bool backup = false; bool signedOut = false; UserManager.instance = new UserManager(); /// prompt connection initialization before going to login if (Connections.Tools.ConnectionNotSet) Application.Run(new ConnectionConfigurations()); do { signedOut = false; var login = new Forms.LoginForm(); Application.Run(login); if (login.LoginSuccessful) { login.Dispose(); backup = true; var main = new Main(); Application.Run(main); signedOut = main.IsSigneout; main.Dispose(); } GC.Collect(); } while (signedOut); if (backup) { try { using (var p = new POSEntities()) p.Database.ExecuteSqlCommand(TransactionalBehavior.DoNotEnsureTransaction, @"EXEC [dbo].[sp_backup]"); } catch (Exception ex) { Console.WriteLine(ex.Message); } } //Application.Run(new SellItem()); }
public bool SetId(int id) { using (var p = new POSEntities()) { sale = p.Sales.FirstOrDefault(x => x.Id == id); if (sale != null) { Initialize(sale); return(true); } } return(false); }
private async Task loadSalesAsync() { await Task.Run(() => { using (var pos = new POSEntities()) { ///filter sales by date selected in datePicker var sales = pos.Sales.Where(x => x.Date.Value.Day == datePicker.Value.Day && x.Date.Value.Month == datePicker.Value.Month && x.Date.Value.Year == datePicker.Value.Year && x.SaleType == "Regular"); ///if sales need to be filtered by user bool is0Index = false; usersOption.InvokeIfRequired(() => is0Index = usersOption.SelectedIndex == 0); if (!is0Index) { string username = string.Empty; usersOption.InvokeIfRequired(() => username = usersOption.Text); sales = sales.Where(x => x.Login.Username == username); } ///clear the table first salesTable.InvokeIfRequired(() => salesTable.Rows.Clear()); try { ///populate the table foreach (var i in sales) { salesTable.InvokeIfRequired(() => salesTable.Rows.Add(i.Id, i.Customer.Name, i.Login.Username, i.Total)); } } catch { } ///set the label to grand total label1.InvokeIfRequired(() => label1.Text = string.Format("Total: ₱ {0:n}", totalSales)); label9.InvokeIfRequired(() => label9.Text = string.Format("₱ {0:n}", totalSales)); updateResult(); } }); }
private async Task loadCustomerAsync() { using (var p = new POSEntities()) { string[] customers = null; await Task.Run(() => { customers = p.Customers.Select(x => x.Name).ToArray(); }); cusoterOption.InvokeIfRequired(() => { cusoterOption.Items.AddRange(customers); cusoterOption.AutoCompleteCustomSource.AddRange(customers); }); } }
private void SellItem_Load(object sender, EventArgs e) { handler.ReferencedTextbox = textBox1; handler.OnSearch += Handler_OnSearch; handler.OnTextCleared += Handler_OnTextCleared; using (var p = new POSEntities()) inventoryItems = p.InventoryItems.Select(x => new InventoryDetails() { Id = x.Id, Barcode = x.Product.Item.Barcode, Serial = x.SerialNumber, Name = x.Product.Item.Name, Supplier = x.Product.Supplier.Name, Qty = x.Quantity, Price = x.Product.Item.SellingPrice }).ToArray(); }
private void button1_Click(object sender, EventArgs e) { if (MessageBox.Show("Are you sure you want to make this changes?", "", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) { return; } using (var p = new POSEntities()) { var s = p.Sales.FirstOrDefault(x => x.Id == SaleId); s.Customer = p.Customers.FirstOrDefault(x => x.Name == customerOption.Text.Trim()); s.Date = transactionDate.Value; p.SaveChanges(); } DialogResult = DialogResult.OK; }
private async Task loadDataAsync() { ///load the users first await Task.Run(() => { using (var pos = new POSEntities()) { ///get the users data var users = pos.Logins.Select(x => x.Username).ToArray(); usersOption.InvokeIfRequired(() => { ///then put it in combobox usersOption.Items.AddRange(users); ///make sure that all users is selected usersOption.SelectedIndex = 0; usersOption.SelectedIndexChanged += usersOption_SelectedIndexChanged; }); } }); ///load the sales associated with user await loadSalesAsync(); }