public ActionResult Detail(string dfn, string ifn) { OrderDetailModel model = new OrderDetailModel(); model.Patient = this.CurrentPatient; OrderDetailResult result = this.DashboardRepository.Orders.GetDetail(dfn, ifn); if (!result.Success) { this.Error(result.Message); } else { model.OrderDetail = result.OrderDetail; } // *** Set return url *** if (TempData.ContainsKey(ReturnUrl)) { model.ReturnUrl = TempData[ReturnUrl].ToString(); TempData[ReturnUrl] = TempData[ReturnUrl]; } return(View(model)); }
private void btnUpdate_Click(object sender, EventArgs e) { dataSender.SetData("dataState", true); int index = dvgDetail.SelectedRows[0].Index; OrderDetailResult orderDetail = GetDataFromView(); OrderDetailResult old = (OrderDetailResult)bindingSource[index]; products[products.FindIndex(x => x.product_id == old.product_id)].quantity -= (short)(orderDetail.quantity - old.quantity); bindingSource[index] = orderDetail; RefreshGridView(); }
private OrderDetailResult GetDataFromView() { OrderDetailResult detail = new OrderDetailResult(); dynamic selected = cbProduct.SelectedItem; detail.order_id = orderId; detail.product_id = selected.product_id; detail.discount = double.Parse(edtDiscount.Text == ""?"0":edtDiscount.Text); detail.quantity = edtAmount.Text == "" ? (short)1 : short.Parse(edtAmount.Text); detail.price = selected.price * detail.quantity - selected.price * detail.quantity * detail.discount / 100; detail.product_name = selected.product_name; return(detail); }
private void btnAdd_Click(object sender, EventArgs e) { dataSender.SetData("dataState", true); OrderDetailResult detail = GetDataFromView(); if (sellBuss.CheckQuantity(products[products.FindIndex(x => x.product_id == detail.product_id)], detail)) { bindingSource.Add(detail); RefreshGridView(); return; } MessageBox.Show("số lượng tồn kho không đủ"); }