private void button1_Click(object sender, EventArgs e) { var color = (string)_cbbColor.SelectedItem; var size = (string)_cbbSize.SelectedItem; if (_txtItemPrice.IsNull() || _txtQuantity.IsNull() || _txtTotalPrice.IsNull()) { return; } var newOrder = new InputProductModel() { Id = Identify.Id, GroupId = _currentProductGroup.Id, GroupName = _currentProductGroup.Name, ProductId = _currentProduct.Id, ProductName = _currentProduct.Name, ColorId = _allColors.Where(p => p.Name.Equals(color)).FirstOrDefault().Id, ColorName = color, SizeId = _allSizes.Where(p => p.Name.Equals(size)).FirstOrDefault().Id, SizeName = size, Quantity = _txtQuantity.ToNumber(), ItemPrice = _txtItemPrice.ToCurrency(), TotalPrice = (_txtTotalPrice.ToCurrency()), }; _currentListModel.Add(newOrder); BindingList <InputProductModel> dataSource = new BindingList <InputProductModel>(_currentListModel); _gvOrder.DataSource = dataSource; _txtSum.Text = _currentListModel.Sum(p => p.TotalPrice.ToPrice()).ToCurrency(); _txtSumQuantity.Text = _currentListModel.Sum(p => p.Quantity).ToString(); }
public ResponseModel <Product> Update([FromForm] InputProductModel product) { ResponseModel <Product> productResult = new ResponseModel <Product>(); try { productResult = _productManager.Update(new Product { CategoryID = product.CategoryID, ProductName = product.ProductName, UnitStock = product.UnitStock, Price = product.Price, ProductDescription = product.ProductDescription }); var photo = photoManager.GetByProductId(productResult.result.ProductID); var photoResult = FileStorageHelper.UpdateFile(product.Photo, Path.Combine(Environment.CurrentDirectory, "wwwroot", photo.result.PhotoUrl)); var photoDBResult = photoManager.Update(new Photo { PhotoID = photo.result.PhotoID, PhotoUrl = photoResult.result, ProductID = photo.result.ProductID, isMain = photo.result.isMain }); return(productResult); } catch (Exception ex) { productResult.Success = false; productResult.Message = ex.Message; } return(productResult); }
public ResponseModel <Product> Add([FromForm] InputProductModel inputProductModel) { // var photoListFromForm = HttpContext.Request.Form.Files["photoList"]; ResponseModel <Product> productResult = new ResponseModel <Product>(); try { var photoResult = FileStorageHelper.UploadFile(inputProductModel.Photo); productResult = _productManager.Add(new Product { ProductName = inputProductModel.ProductName, ProductDescription = inputProductModel.ProductDescription, Price = inputProductModel.Price, UnitStock = inputProductModel.UnitStock, CategoryID = inputProductModel.CategoryID }); var photoDBResult = photoManager.Add(new Photo { ProductID = productResult.result.ProductID, PhotoUrl = photoResult.result }); } catch (Exception ex) { productResult.Success = false; productResult.Message = ex.Message; } return(productResult); }
public ChangeOrderProductDialog(InputProductModel model) { InitializeComponent(); _txtGroup.Text = model.GroupName; _txtQuantity.Text = model.Quantity.ToString(); _txtProduct.Text = model.ProductName; _txtColor.Text = model.ColorName; _txtSize.Text = model.SizeName; _txtPrice.Text = model.ItemPrice; _model = model; }
public SelectItemSizeDialog(InputProductModel model) { InitializeComponent(); _model = model; var props = ProductPropertiesRepository.Instance.GetAll(); _sizes = props.Where(p => p.Type == ProductType.Size).ToList(); _txtLabel.Text = model.ProductName + " - " + model.ColorName + " - " + model.SizeName; _cbbSize.Items.Clear(); if (_sizes.Count > 0) { foreach (var item in _sizes) { _cbbSize.Items.Add(item.Name); } _cbbSize.SelectedIndex = 0; } }
void LoadOldOrder() { _btnFinish.Enabled = false; _btnChange.Visible = true; button1.Enabled = false; _btnDelete.Enabled = false; var order = OrderInputTotalRepository.Instance.GetById(_orderId); _txtName.Text = order.OrderName; _txtSum.Text = order.TotalPrice.ToCurrency(); var items = OrderInputItemRepository.Instance.GetByOrderId(_orderId); foreach (var item in items) { var product = ProductRepository.Instance.GetById(item.ProductId); var newOrder = new InputProductModel() { Id = item.Id, GroupName = _currentListGroups.Where(p => p.Id == product.GroupId).FirstOrDefault().Name, ProductId = product.Id, ProductName = product.Name, ColorName = _allColors.Where(p => p.Id == item.ColorId).FirstOrDefault().Name, SizeName = _allSizes.Where(p => p.Id == item.SizeId).FirstOrDefault().Name, Quantity = item.Quantity, ItemPrice = item.Price.ToCurrency(), TotalPrice = (item.Price * item.Quantity).ToCurrency(), ColorId = item.ColorId, SizeId = item.SizeId, ParentId = item.OrderInputId, }; _currentListModel.Add(newOrder); } _txtSumQuantity.Text = items.Sum(p => p.Quantity).ToString(); BindingList <InputProductModel> dataSource = new BindingList <InputProductModel>(_currentListModel); _gvOrder.DataSource = dataSource; }
private void gridView1_FocusedRowObjectChanged(object sender, DevExpress.XtraGrid.Views.Base.FocusedRowObjectChangedEventArgs e) { var modelId = _gvOrder.GetIdFocus(); _currentModel = _currentListModel.Where(p => p.Id == modelId).FirstOrDefault(); }
private void gridView2_FocusedRowObjectChanged(object sender, DevExpress.XtraGrid.Views.Base.FocusedRowObjectChangedEventArgs e) { var productSaleId = _gridProduct.GetIdFocus(); _currentProductModel = _currentListProductModel.Where(p => p.Id == productSaleId).FirstOrDefault(); }