private void ItemSales_Click(object sender, RoutedEventArgs e) { frmContent.NavigationService.RemoveBackEntry(); SalesProduct sales = new SalesProduct(); frmContent.Content = sales; }
public double AvailableQuantity(SalesProduct salesProduct) { //Connection //string connectionString = @"Server=DESKTOP-0LIAG2C\SQLEXPRESS; Database=BusinessManagementSystem; Integrated Security=True"; SqlConnection sqlConnection = new SqlConnection(connectionString); //Command string commandString = @"Select AvailableQuantity From Purchase WHERE CategoryId ='" + salesProduct.CategoryId + "' And ProductId = '" + salesProduct.ProductId + "'"; SqlCommand sqlCommand = new SqlCommand(commandString, sqlConnection); //Open sqlConnection.Open(); //With DataReader SqlDataReader sqlDataReader = sqlCommand.ExecuteReader(); while (sqlDataReader.Read()) { salesProduct.AvailableQuantity = Convert.ToInt32(sqlDataReader["AvailableQuantity"]); } double avail = salesProduct.AvailableQuantity; //Close sqlConnection.Close(); return(avail); }
public bool UpdateAvailableQuantityPurchase(SalesProduct salesProduct) { bool isUpdate = false; //Connection //string connectionString = @"Server=DESKTOP-0LIAG2C\SQLEXPRESS; Database=BusinessManagementSystem; Integrated Security=True"; SqlConnection sqlConnection = new SqlConnection(connectionString); //Command //UPDATE Purchase SET AvailableQuantity = 10 WHERE CategoryId = 1 and ProductId = 2; string commandString = @"UPDATE Purchase SET AvailableQuantity = " + salesProduct.AvailableQuantity + " WHERE CategoryId = " + salesProduct.CategoryId + " and ProductId = " + salesProduct.ProductId + ""; SqlCommand sqlCommand = new SqlCommand(commandString, sqlConnection); //Open sqlConnection.Open(); //Insert int isExecuted = sqlCommand.ExecuteNonQuery(); if (isExecuted > 0) { isUpdate = true; } //Close sqlConnection.Close(); return(isUpdate); }
public bool SalesAdd(SalesProduct salesProduct) { bool isAdded = false; //Connection //string connectionString = @"Server=DESKTOP-0LIAG2C\SQLEXPRESS; Database=BusinessManagementSystem; Integrated Security=True"; SqlConnection sqlConnection = new SqlConnection(connectionString); //Command //INSERT INTO Category (Code, Name) Values ('1234', 'arafat') string commandString = @"INSERT INTO SalesProduct (CategoryId, ProductId,AvailableQuantity,Quantity,MRP,TotalMRP) Values (" + salesProduct.CategoryId + "," + salesProduct.ProductId + ",'" + salesProduct.AvailableQuantity + "','" + salesProduct.Quantity + "','" + salesProduct.MRP + "','" + salesProduct.TotalMRP + "')"; SqlCommand sqlCommand = new SqlCommand(commandString, sqlConnection); //Open sqlConnection.Open(); //Insert int isExecuted = sqlCommand.ExecuteNonQuery(); if (isExecuted > 0) { isAdded = true; } //Close sqlConnection.Close(); return(isAdded); }
public ActionResult DeleteConfirmed(int id) { SalesProduct salesProduct = db.SalesProducts.Find(id); db.SalesProducts.Remove(salesProduct); db.SaveChanges(); return(RedirectToAction("Index")); }
private async Task DelItem(SalesProduct item) { if (item == null) { _dialogService.LongAlert("没找到商品信息!"); return; } await DelProduct(item.GuId); }
public ActionResult Edit([Bind(Include = "Id,Product_Name,Product_Price,Product_Quantity,Product_Description,Id_Provider")] SalesProduct salesProduct) { if (ModelState.IsValid) { db.Entry(salesProduct).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.Id_Provider = new SelectList(db.SalesProviders, "Id", "Provider_Name", salesProduct.Id_Provider); return(View(salesProduct)); }
// GET: SalesProducts/Delete/5 public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } SalesProduct salesProduct = db.SalesProducts.Find(id); if (salesProduct == null) { return(HttpNotFound()); } return(View(salesProduct)); }
public async Task UpdateSalesProduct(SalesProduct updatedItem) { var salesProduct = _SalesProducts.FirstOrDefault(d => d.Id == updatedItem.Id); if (salesProduct == null) { return; } salesProduct.Weight = updatedItem.Weight; salesProduct.CommssionRate = updatedItem.CommssionRate; salesProduct.ShippingCost = updatedItem.ShippingCost; await _SalesProductRepo.Save(_SalesProducts); }
// GET: SalesProducts/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } SalesProduct salesProduct = db.SalesProducts.Find(id); if (salesProduct == null) { return(HttpNotFound()); } ViewBag.Id_Provider = new SelectList(db.SalesProviders, "Id", "Provider_Name", salesProduct.Id_Provider); return(View(salesProduct)); }
public ActionResult SaleProduct([Bind(Include = "Id,Product_Name,Product_Price,Product_Quantity,Product_Description,Id_Provider")] SalesProduct salesProduct, int cantidadProducto, int precioVenta) { if (ModelState.IsValid) { Sale sale = new Sale { Total_Sale = precioVenta }; db.Sales.Add(sale); salesProduct.Product_Quantity -= cantidadProducto; db.Entry(salesProduct).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.Id_Provider = new SelectList(db.SalesProviders, "Id", "Provider_Name", salesProduct.Id_Provider); return(View(salesProduct)); }
public List <SalesProduct> Display() { //Connection //string connectionString = @"Server=DESKTOP-0LIAG2C\SQLEXPRESS; Database=BusinessManagementSystem; Integrated Security=True"; SqlConnection sqlConnection = new SqlConnection(connectionString); //Command //INSERT INTO Items (Name, Price) Values ('Black', 120) string commandString = @"SELECT * FROM SalesProduct"; SqlCommand sqlCommand = new SqlCommand(commandString, sqlConnection); //Open sqlConnection.Open(); //With DataReader SqlDataReader sqlDataReader = sqlCommand.ExecuteReader(); List <SalesProduct> salesProduct = new List <SalesProduct>(); while (sqlDataReader.Read()) { SalesProduct salesProducts = new SalesProduct(); salesProducts.Id = Convert.ToInt32(sqlDataReader["Id"]); salesProducts.CategoryId = Convert.ToInt32(sqlDataReader["CategoryId"]); salesProducts.ProductId = Convert.ToInt32(sqlDataReader["ProductId"]); salesProducts.AvailableQuantity = Convert.ToInt32(sqlDataReader["AvailableQuantity"]); salesProducts.Quantity = Convert.ToInt32(sqlDataReader["Quantity"]); salesProducts.MRP = Convert.ToInt32(sqlDataReader["MRP"]); salesProducts.TotalMRP = Convert.ToInt32(sqlDataReader["TotalMRP"]); salesProduct.Add(salesProducts); } //Close sqlConnection.Close(); return(salesProduct); }
public Task <CommandResult> ProductSales([FromBody] SalesDTO salesDTO) { var salesCommand = new SalesCommand { SalesId = Guid.NewGuid().ToString(), SalesDate = salesDTO.SalesDate }; foreach (SalesProductDTO productDTO in salesDTO.SalesProducts) { var product = new SalesProduct { ProductId = productDTO.ProductId, ProductName = productDTO.ProductName, UnitName = productDTO.UnitName, SalesUnitPrice = productDTO.UnitPrice, SalesQuantity = productDTO.Quantity }; salesCommand.SalesProducts.Add(product); } return(commandBus.Send <SalesCommand, CommandResult>(salesCommand)); }
private void submitButton_Click(object sender, EventArgs e) { if (customerComboBox.Text == "-Select-") { MessageBox.Show("Select a customer"); return; } salesDataGridView.DataSource = null; Sales _sale = new Sales(); _sale.CustomerId = Convert.ToInt32(customerComboBox.SelectedValue); _sale.Date = salesDateTimePicker.Value; _sale.LoyalityPoint = Convert.ToInt32(loyalityPointTextBox.Text); _sale.GrandTotal = Convert.ToDouble(grandTotalTextBox.Text); _sale.Discount = Convert.ToDouble(discountTextBox.Text); _sale.DiscountAmount = Convert.ToDouble(discountAmountTextBox.Text); _sale.PayableAmount = Convert.ToDouble(payableAmountTextBox.Text); bool isSubmited = _salesManager.Submit(_sale); if (isSubmited) { MessageBox.Show("Saved"); } else { MessageBox.Show("Not Saved"); } SalesProduct salesProduct = new SalesProduct(); salesProduct.CategoryId = Convert.ToInt32(categoryComboBox.SelectedValue); salesProduct.ProductId = Convert.ToInt32(productComboBox.SelectedValue); availableQuantityTextBox.Text = _salesManager.AvailableQuantity(salesProduct).ToString(); loyalityPointTextBox.Text = Loyality(Convert.ToDouble(grandTotalTextBox.Text)).ToString(); }
private async Task OnSelectItem(SalesProduct item) { try { if (item != null) { var parameter = new NavigationParameters() { { "data", "Tradition" }, { "productid", item.GuId }, { "action", "edit" } }; await _navigationService.NavigateAsync("AddProducts", parameter); } else { _dialogService.LongAlert("操作无效!"); } } catch (Exception ex) { _dialogService.LongAlert(ex.Message); } }
public bool SalesAdd(SalesProduct salesProduct) { return(_salesRepo.SalesAdd(salesProduct)); }
public double AvailableQuantity(SalesProduct salesProduct) { return(_salesRepo.AvailableQuantity(salesProduct)); }
public bool UpdateAvailableQuantityPurchase(SalesProduct salesProduct) { return(_salesRepo.UpdateAvailableQuantityPurchase(salesProduct)); }
private void addButton_Click(object sender, EventArgs e) { // Set as Mandatory if (String.IsNullOrEmpty(quantityTextBox.Text)) { MessageBox.Show("Quantity Can not be Empty!!!"); return; } if (String.IsNullOrEmpty(mrpTextBox.Text)) { MessageBox.Show("MRP Can not be Empty!!!"); return; } if (String.IsNullOrEmpty(availableQuantityTextBox.Text)) { MessageBox.Show("Available Quantity Can not be Empty!!!"); return; } if (String.IsNullOrEmpty(totalMrpTextBox.Text)) { MessageBox.Show("Total MRP Can not be Empty!!!"); return; } if (categoryComboBox.Text == "-Select-") { MessageBox.Show("Select a category"); return; } if (productComboBox.Text == "-Select-") { MessageBox.Show("Select a product"); return; } SalesProduct salesProduct = new SalesProduct(); salesProduct.CategoryId = Convert.ToInt32(categoryComboBox.SelectedValue); salesProduct.ProductId = Convert.ToInt32(productComboBox.SelectedValue); salesProduct.AvailableQuantity = Convert.ToInt32(availableQuantityTextBox.Text); salesProduct.Quantity = Convert.ToInt32(quantityTextBox.Text); salesProduct.MRP = Convert.ToDouble(mrpTextBox.Text); salesProduct.TotalMRP = Convert.ToDouble(totalMrpTextBox.Text); salesProduct.ProductName = productComboBox.Text; if (_salesProducts == null) { _salesProducts = new List <SalesProduct>(); } if (Convert.ToInt32(availableQuantityTextBox.Text) >= Convert.ToInt32(quantityTextBox.Text)) { _salesProducts.Add(salesProduct); MessageBox.Show(" Saved"); Sales _sale = new Sales(); grandTotalTextBox.Text = GrandTotal(Convert.ToDouble(totalMrpTextBox.Text)).ToString(); //loyalityPointTextBox.Text = Loyality(Convert.ToDouble(grandTotalTextBox.Text)).ToString(); discountTextBox.Text = Discount(Convert.ToInt32(loyalityPointTextBox.Text)).ToString(); discountAmountTextBox.Text = DiscountAmount(Convert.ToDouble(grandTotalTextBox.Text), Convert.ToDouble(discountTextBox.Text)).ToString(); payableAmountTextBox.Text = PayableAmount(Convert.ToDouble(grandTotalTextBox.Text), Convert.ToDouble(discountAmountTextBox.Text)).ToString(); // availableQuantity = _salesManager.AvailableQuantity(salesProduct); availableQuantity = Convert.ToDouble(availableQuantityTextBox.Text); //availableQuantityTextBox.Text = availableQuantity.ToString(); availableQuantityTextBox.Text = AvailableQuantity(Convert.ToInt32(quantityTextBox.Text)).ToString(); salesDataGridView.DataSource = null; salesDataGridView.DataSource = _salesProducts; } }
public static T ToModel <T>(this SalesProduct entity) where T : class { return(Mapper.Map <SalesProduct, T>(entity)); }