public void Remove(int id) { StartCash sc = StartCash.SingleOrDefault(e => e.id == id); if (sc != null) { sc.Delete(); } }
public void Add(StartCash startCash) { StartCash sc = new StartCash(); sc.sellerId = startCash.sellerId; sc.saleId = startCash.saleId; sc.cashAmount = startCash.cashAmount; sc.Save(); }
private void btnAdd_Click(object sender, EventArgs e) { if (cboContBy.SelectedIndex > -1) { if (txtAmount.Text.Trim().Length > 0) { int contBy; double cash; int.TryParse(cboContBy.SelectedValue.ToString(), out contBy); double.TryParse(txtAmount.Text.Trim(), out cash); if (contBy > 0 && cash > 0) { StartCash startCash = new StartCash(); startCash.saleId = SaleId; startCash.sellerId = contBy; startCash.cashAmount = cash; if (startCash.IsValid) { StartCashController startCashController = new StartCashController(); startCashController.Add(startCash); if (!KeepOpenOnAdd) { this.Close(); } else { ClearFields(); } } else { MessageBox.Show(startCash.Validator().ErrorMessage, "Invalid Data", MessageBoxButtons.OK, MessageBoxIcon.Information); } } else { MessageBox.Show("Please enter a valid amount.", "Invalid Data", MessageBoxButtons.OK, MessageBoxIcon.Information); } } else { MessageBox.Show("Please enter an amount.", "Invalid Amount", MessageBoxButtons.OK, MessageBoxIcon.Information); txtAmount.SelectAll(); txtAmount.Focus(); } } else { MessageBox.Show("Please select a valid seller.", "Invalid Seller", MessageBoxButtons.OK, MessageBoxIcon.Information); cboContBy.Focus(); } }
public void Edit(StartCash startCash) { StartCash sc = StartCash.SingleOrDefault(e => e.id == startCash.id); if (sc != null) { sc.sellerId = startCash.sellerId; sc.cashAmount = startCash.cashAmount; sc.Save(); } }
public IQueryable <Total> GetTotalsBySaleId(int saleId) { var saleTotal = (from s in Sale.All() join o in Order.All() on s.id equals o.saleId join oi in OrderItem.All() on o.id equals oi.orderId join se in Seller.All() on oi.sellerId equals se.id where s.endDate == null && o.complete == 1 group oi by se.id into g select new { SaleTotal = g.Sum(e => e.price), SellerId = g.Key }).ToList(); var contributeTotal = (from s in Sale.All() join sc in StartCash.All() on s.id equals sc.saleId join se in Seller.All() on sc.sellerId equals se.id where s.endDate == null group sc by se.id into g select new { ContributeTotal = g.Sum(e => e.cashAmount), SellerId = g.Key }).ToList(); var sellers = (from se in Seller.All() select se).ToList(); var total = (from se in sellers join st in saleTotal on se.id equals st.SellerId into h from st in h.DefaultIfEmpty() join sc in contributeTotal on se.id equals sc.SellerId into g from sc in g.DefaultIfEmpty() let a = GetSellerName((int)se.id) orderby se.name ascending select new Total() { name = a, startingContribution = sc == null ? 0 : sc.ContributeTotal, saleTotal = st == null ? 0 : st.SaleTotal, total = (sc == null ? 0 : sc.ContributeTotal) + (st == null ? 0 : st.SaleTotal) }); return(total.AsQueryable()); }
private void btnSave_Click(object sender, EventArgs e) { if (cboContBy.SelectedIndex > -1) { if (txtAmount.Text.Trim().Length > 0) { StartCash startCash = new StartCash(); double amount; int sellerId; double.TryParse(txtAmount.Text.Replace("$", ""), out amount); int.TryParse(cboContBy.SelectedValue.ToString(), out sellerId); startCash.cashAmount = amount; startCash.sellerId = sellerId; startCash.id = Id; if (startCash.IsValid) { StartCashController startCashController = new StartCashController(); startCashController.Edit(startCash); this.Close(); } else { MessageBox.Show(startCash.Validator().ErrorMessage, "Invalid Data", MessageBoxButtons.OK, MessageBoxIcon.Information); } } else { MessageBox.Show("Please enter an amount.", "Invalid Data", MessageBoxButtons.OK, MessageBoxIcon.Information); txtAmount.SelectAll(); txtAmount.Focus(); } } else { MessageBox.Show("Please select a valid seller.", "Invalid Seller", MessageBoxButtons.OK, MessageBoxIcon.Information); cboContBy.Focus(); } }
public void Edit(StartCash startCash) { _startCashRepository.Edit(startCash); }
public void Add(StartCash startCash) { _startCashRepository.Add(startCash); }