private void InitChildViewBag(SalesDetailViewModel info) { ViewBag.PriceKindList = new SelectList(this._GlobalService.GetPriceKindList(), "Key", "Value", info?.PriceKindID); ViewBag.ConditionKindList = new SelectList(this._GlobalService.GetConditionKindList(), "Key", "Value", info?.ConditionID); }
public ActionResult _Item(string id) { //child action don't share the same ViewBag with its “parents” action var info = new SalesDetailViewModel() { SeqNo = 0, Discount = 100, Qty = 1, IsDirty = true }; InitChildViewBag(null); return(PartialView("_Item", info)); }
private void AddOrders(SalesDetailViewModel salesModel) { foreach (var details in salesModel .Invoice .InvoiceDetails .Select(id => { id.Product = db.Products.First(p => p.Id == id.ProductId); return(id); } ) .Where(id => id.InOrder > 0) .GroupBy(s => s.Product.Provider)) { var order = new PurchaseOrder() { UserId = User.Identity.GetUserId(), Date = DateTime.Now, Created = DateTime.Now, PurchaseOrderStatusId = 1 }; foreach (var orderDetail in details) { order.PurchaseOrderDetails.Add(new PurchaseOrderDetail() { ProductId = orderDetail.ProductId, UnitPrice = orderDetail.Product.PurchasePrice, Quantity = orderDetail.InOrder }); } var total = order.PurchaseOrderDetails.Sum(po => po.Quantity * po.UnitPrice); order.Total = total; salesModel.Invoice.PurchaseOrders.Add(order); } db.SaveChanges(); }
private void PartNumberDropdown_SelectedIndexChanged(object sender, EventArgs e) { if (PartNumberDropdown.SelectedIndex != -1 && saleDetails != null) { _oldUnitPrice = 0m; int id = (int)PartNumberDropdown.SelectedValue; SalesDetailViewModel details = saleDetails.FirstOrDefault(a => a.AutoPartDetailId == id); if (details != null) { //Get Previously returned value of this invoice number int customerId = (int)CustomerDropdown.SelectedValue; string invNumber = InvoiceDropdown.SelectedItem.ToString(); int qtyReturned = this.salesReturnController.FetchQuantityReturned(customerId, invNumber, id, ReturnId); //Get quantities in grid int qtyInGrid = 0; if (list.Any()) { qtyInGrid = list.Where(a => a.PartDetailId == id && a.InvoiceNumber == invNumber).Sum(a => a.Quantity); } AutoPartTextbox.Text = details.AutoPartName; //Qty that can be returned int qtyLimit = details.Quantity - qtyReturned - qtyInGrid; QtyTextbox.Text = qtyLimit.ToString(); QtyLimit = qtyLimit; _oldUnitPrice = details.DiscountedPrice; UnitPriceTextbox.Text = _oldUnitPrice.ToString("N2"); } QtyTextbox.Focus(); } }