private void button1_Click(object sender, EventArgs e) { DataVerifier dv = new DataVerifier(); dv.Check(string.IsNullOrWhiteSpace(txtID.Text), "请输入商品编码"); dv.CheckIfBeforePass(string.IsNullOrWhiteSpace(txtNum.Text), "请输入实配数量"); dv.CheckIfBeforePass(string.IsNullOrWhiteSpace(txtReaNum.Text), "请输入拍单量"); dv.CheckIfBeforePass(string.IsNullOrWhiteSpace(txtPrice.Text), "请输入单价"); if (dv.Pass) { var result = SaveProduct(); dv.Check(result.Status == "40000", result.Message); if (dv.Pass) { var total = Convert.ToDecimal(result.Data.price) * Convert.ToDecimal(result.Data.real_num); OrderProductList.Add(new OrderProduct { index = OrderProductList.Max(m => m.index) + 1, id = result.Data.id, name = result.Data.name, num = result.Data.num, real_num = result.Data.real_num, price = result.Data.price, unit = result.Data.unit, total = (float)total, balance = result.Data.balance }); lblTotal.Text = (orderinfo.Data.total_price + (float)total).ToString(); dgvData.DataSource = null; dgvData.DataSource = orderProductBindingSource; } } dv.ShowMsgIfFailed(); }
public override BotMessage BuildMsg() { using (MarketBotDbContext db = new MarketBotDbContext()) { OrderProductList = db.OrderProduct.Where(o => o.OrderId == OrderId).Include(o => o.Product).ToList(); OrderNumber = db.Orders.Where(o => o.Id == OrderId).FirstOrDefault().Number; } var group = OrderProductList.GroupBy(p => p.ProductId).ToList(); // групируем по товару if (OrderProductList != null) { PostitionsBtn = new InlineKeyboardCallbackButton[group.Count() + 1][]; base.BackBtn = new InlineKeyboardCallbackButton("Назад", BuildCallData("BackToOrder", OrderBot.ModuleName, OrderId)); int Counter = 0; foreach (var product in group) { PostitionsBtn[Counter] = new InlineKeyboardCallbackButton[1]; PostitionsBtn[Counter][0] = ProductPosition(product.Key, (Counter + 1).ToString() + ") " + product.FirstOrDefault().Product.Name + " - " + product.Count().ToString() + " шт."); Counter++; } PostitionsBtn[PostitionsBtn.Length - 1] = new InlineKeyboardCallbackButton[1]; PostitionsBtn[PostitionsBtn.Length - 1][0] = BackBtn; base.MessageReplyMarkup = new InlineKeyboardMarkup(PostitionsBtn); base.TextMessage = "Изменить содержание заказа " + OrderNumber.ToString(); } return(this); }
public void RemoveOrder(int index) { OrderProductList list = orderList[index].ProductList; orderProductLists.Remove(list); orderList.RemoveAt(index); }
public OrderPositionListMessage BuildMessage() { using (MarketBotDbContext db = new MarketBotDbContext()) { OrderProductList = db.OrderProduct.Where(o => o.OrderId == OrderId).Include(o => o.Product).ToList(); OrderNumber = db.Orders.Where(o => o.Id == OrderId).FirstOrDefault().Number; } if (OrderProductList != null) { int Amount = OrderProductList.Count(); PostitionsBtn = new InlineKeyboardCallbackButton[Amount + 1][]; base.BackBtn = new InlineKeyboardCallbackButton("Назад", BuildCallData("BackToOrder", OrderBot.ModuleName, OrderId)); int Counter = 0; foreach (var product in OrderProductList) { PostitionsBtn[Counter] = new InlineKeyboardCallbackButton[1]; PostitionsBtn[Counter][0] = ProductPosition(product.Id, (Counter + 1).ToString() + ") " + product.Product.Name + " - " + product.Count.ToString() + " шт."); Counter++; } PostitionsBtn[Amount] = new InlineKeyboardCallbackButton[1]; PostitionsBtn[Amount][0] = BackBtn; base.MessageReplyMarkup = new InlineKeyboardMarkup(PostitionsBtn); base.TextMessage = "Изменить содержание заказа " + OrderNumber.ToString(); } return(this); }
private void OrderEdit() { var f = OrderProductList.Where(w => w.isChange); foreach (var product in f) { var postdata = string.Format("token={0}&sessionId={1}&id={2}&val={3}", token, User.SessionID, product.id, product.real_num); var htmlstr = Html.Post(str_api + str_OrderEdit, postdata); JsonConvert.DeserializeObject <OrderInfo>(htmlstr); } }
/// ------------------------------------------------------------------- /// /// -------------------- BUTTON HANDLERS ------------------------------ /// /// ------------------------------------------------------------------- /// private void newButton_Click(object sender, EventArgs e) { if (tabControl1.SelectedIndex == 0) { EditCustomerForm editCustomerForm = new EditCustomerForm(); if (editCustomerForm.ShowDialog(this) == DialogResult.OK) { Customer c = new Customer(editCustomerForm.CustomerName, editCustomerForm.CustomerSex, editCustomerForm.CustomerAge, editCustomerForm.CustomerStatus); presenter.onAddCustomer(c); showCustomer(c); EnableSave(); } } else if (tabControl1.SelectedIndex == 1) { ProductForm productForm = new ProductForm(); if (productForm.ShowDialog(this) == DialogResult.OK) { Product p = new Product(productForm.ProdName, productForm.ProductPrice); presenter.onAddProduct(p); showProduct(p); EnableSave(); } } else if (tabControl1.SelectedIndex == 2) { OrderForm orderForm = new OrderForm(CustomerList, ProductList); if (orderForm.ShowDialog(this) == DialogResult.OK) { OrderProductList list = new OrderProductList(orderForm.newOrderProductList, orderForm.newOrderQuantityProductList); int customerIndex = orderForm.CustomerIndex; Order order = new Order(CustomerList[customerIndex], list, orderForm.datePickerValue); presenter.onAddOrder(order, list); EnableSave(); } } }
public static List <OrderProductList> GenerateOrderProductLists(List <Product> productList) { List <OrderProductList> list = new List <OrderProductList>(); for (int i = 0; i < MAX_ORDER_PRODUCT_LISTS; i++) { List <Product> pList = new List <Product>(); List <int> iList = new List <int>(); int q = Rand.Next(MAX_PRODUCT_NUMBER_IN_LIST) + 1; for (int j = 0; j < q; j++) { Product p = productList[Rand.Next(productList.Count)]; pList.Add(p); int quantity = Rand.Next(MAX_QUANTITY_PRODUCT_IN_LIST) + 1; iList.Add(quantity); } OrderProductList orderProductList = new OrderProductList(pList, iList); list.Add(orderProductList); } return(list); }
public void onAddOrder(Order order, OrderProductList list) { model.AddOrder(order); model.AddOrderProductList(list); RefreshMainForm(); }
public void AddOrderProductList(OrderProductList list) { orderProductLists.Add(list); }
public void EditOrderProductList(OrderProductList list, int index) { orderProductLists[index] = list; }