public IActionResult Save(SalesForm salesForm) { if (salesForm.ID == 0) { _context.SalesForms.Add(salesForm); } else { _context.SalesForms.Update(salesForm); } _context.SaveChanges(); return(RedirectToAction("Edit", new { id = salesForm.ID })); }
public ActionResult SaveSales(SalesForm model) { try { SalesLayanEntities14 db = new SalesLayanEntities14(); Sales_Record sale_prod = new Sales_Record(); sale_prod.unit_price = model.Unit_price; sale_prod.unit_purchase = model.Unit_purchase; sale_prod.prod_id = model.Prod_id; sale_prod.emp_id = model.Emp_id; sale_prod.Dates = model.Dates; sale_prod.cust_id = model.Cust_id; db.Sales_Record.Add(sale_prod); db.SaveChanges(); int latestProdId = sale_prod.sales_id; TempData["status"] = "Success"; string sql = "update product set prod_quantity=prod_quantity- @sold_quantity where prod_id= @Prod_ID"; using (var sqlCon = new SqlConnection(@"Data Source=LAPTOP-L99NV78V\LAYANSQL;Initial Catalog=SalesLayan;User ID=sa;Password=Layangrade@17;")) using (var cmd = new SqlCommand(sql, sqlCon)) { //Have to guess at types and lengths here. Use actual types and lengths from the database cmd.Parameters.Add("@sold_quantity", SqlDbType.SmallInt).Value = model.Unit_purchase; cmd.Parameters.Add("@Prod_ID", SqlDbType.SmallInt).Value = model.Prod_id; sqlCon.Open(); cmd.ExecuteNonQuery(); } } catch (Exception ex) { throw ex; } return(RedirectToAction("SalesIndex")); }
/// <summary> /// Add a sales form to the database /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnAddSalesForm_Click(object sender, RoutedEventArgs e) { SalesForm sf = new SalesForm { DateIssued = (DateTime)dpDateIssued.SelectedDate , Amount = decimal.Parse(tbAmount.Text) }; int salesFormAdded = DAL.AddSalesForm(sf); lvShowData.Items.Clear(); if (salesFormAdded > 0) { lvShowData.Items.Add("Success! The Sales Form was added to the database."); } else { lvShowData.Items.Add("Failure! The Sales Form was not added to the database."); } }
private void sales_Click(object sender, EventArgs e) { SalesForm salesForm = new SalesForm(); salesForm.ShowDialog(); }
private void ribbonButton3_Click(object sender, EventArgs e) { SalesForm frm = new SalesForm(); frm.ShowDialog(); }
private void addSalesToolStripMenuItem_Click(object sender, EventArgs e) { SalesForm sForm = new SalesForm(); sForm.Show(); }
/// <summary> /// Update all the texboxes on the form /// </summary> /// <param name="sf"></param> private void UpdateSalesFormTextboxes(SalesForm sf) { tbSalesFormID.Text = sf.ID.ToString(); dpDateIssued.SelectedDate = sf.DateIssued; tbAmount.Text = sf.Amount.ToString(); }
public WayToPayForm(SalesForm form) { InitializeComponent(); salesForm = form; }
private void button1_Click(object sender, EventArgs e) { SalesForm sf = new SalesForm(); sf.ShowDialog(); }
private void salesToolStripMenuItem_Click(object sender, EventArgs e) { SalesForm sf = new SalesForm(); sf.ShowDialog(); }
//clicks eg buttons #region ui_clicks private void UI_BTN_CLICKS(object sender, EventArgs e) { Button input = (Button)sender; switch (input.Name) {// case "salesBtn": { SalesForm sform = new SalesForm(); sform.ShowDialog(); break; } case "refreshRecentlyListBtn": { currentListOfProducts = productController.getStartUpProductsFromStore(); this.renderProductsUI(); break; } case "switchDisplayFormatBtn": { this.switchCurrentDisplayFormat(); this.searchKeyTxt.Text = ""; currentListOfProducts = productController.getStartUpProductsFromStore(); this.renderProductsUI(); break; } case "goToDashBoardBtn": { //F_OrdersMaintainer pf = (F_OrdersMaintainer)this.ParentForm; //pf.Connector_2_dashboard(); break; } case "searchBtn": { //currentListOfProducts = productController.getProductsBasedOnSearchKey(searchKeyTxt.Text); if (searchKeyTxt.Text == "") { currentListOfProducts = productController.getStartUpProductsFromStore(); } else { currentListOfProducts = productController.getProductsBasedOnSearchKey(searchKeyTxt.Text); } this.renderProductsUI(); if (this.autoSelectItemCheckBox.Checked == true && currentListOfProducts.Count == 1) { //MessageBox.Show("Auto select"); G_POS.POS.Forms.POSForm pf = (G_POS.POS.Forms.POSForm) this.ParentForm; pf.connect_store_n_receipt_send_this_item(currentListOfProducts[0]); this.putSearchOnFocus(); this.searchKeyTxt.Text = ""; } break; } case "btnClearSearchBox": { this.searchKeyTxt.Text = ""; currentListOfProducts = productController.getStartUpProductsFromStore(); this.renderProductsUI(); break; } case "EXITBtn": //clearReceiptSectBtn { pollDisplay("0"); Application.Exit(); /*F_OrdersMaintainer pf = (F_OrdersMaintainer)this.ParentForm; * pf.Connector_store_2_receipt_clear_receipt_items(); * //hide table no show * tableNoLbl.Visible = false; * tableNoTxt.Visible = false; * tableNoTxt.Text = -1 + ""; * this.TABLE_NO_SHOW = 0;*/ //this.putSearchOnFocus(); break; } case "forTableBtn": { if ((tableNoLbl.Visible == true) && (tableNoTxt.Visible = true)) { tableNoLbl.Visible = false; tableNoTxt.Visible = false; this.TABLE_NO_SHOW = 0; } else { tableNoLbl.Visible = true; tableNoTxt.Visible = true; this.TABLE_NO_SHOW = 1; } break; } //prev and next btn case "nextBtn": { int max_page = (this.currentListOfProducts.Count / this.COUNTS_PER_PAGE); if (this.CURRENT_PAGE == max_page) { this.COUNTS_REMAINDER = (this.currentListOfProducts.Count % this.COUNTS_PER_PAGE); } if (this.COUNTS_REMAINDER != 0) { max_page += 1; } //MessageBox.Show("items :" + currentListOfProducts.Count + "\nmax:" + max_page + "\nCurr:" + this.CURRENT_PAGE + "\nRemainder" + this.COUNTS_REMAINDER); //check if (!(this.CURRENT_PAGE >= max_page)) { this.CURRENT_PAGE += 1; this.renderProductsUI(); } else { } //max page this.putSearchOnFocus(); break; } case "prevBtn": { this.COUNTS_REMAINDER = 0; //basic if (!(this.CURRENT_PAGE - 1 == 0)) { this.CURRENT_PAGE -= 1; this.renderProductsUI(); } else { } //-1 this.putSearchOnFocus(); break; } case "currentOrdersBtn": //MyRestaurant.Restaurant.Controls.OrdersFlow.CurrentOrders.CurrentOrdersForm fm = new MyRestaurant.Restaurant.Controls.OrdersFlow.CurrentOrders.CurrentOrdersForm(); //fm.ShowDialog(); break; case "x": break; } }