protected void addButton_Click(object sender, EventArgs e) { messageLevel.Text = ""; StockOut stockOut = new StockOut(); stockOut.CompanyId = Convert.ToInt32(companyDropDownList.SelectedValue); stockOut.Company = companyDropDownList.SelectedItem.Text; stockOut.ItemId = Convert.ToInt32(itemDropDownList.SelectedValue); stockOut.Item = itemDropDownList.SelectedItem.Text; stockOut.StockOutQuantity = Convert.ToInt32(stockOutQuantityTextBox.Text); stockOut.AvailableQuantity = Convert.ToInt32(availableQuantityTextBox.Text); if ((stockOut.AvailableQuantity - stockOut.StockOutQuantity) >= 0) { StockIn stockIn = new StockIn(); stockIn.ItemId = Convert.ToInt32(itemDropDownList.SelectedValue); stockIn.AvailableQuantity = stockOut.StockOutQuantity - stockOut.AvailableQuantity; if (ViewState["stockOutItem"] == null) { List <StockOut> stockOuts = new List <StockOut>(); stockOuts.Add(stockOut); stockOut.AvailableQuantity = stockOut.AvailableQuantity - stockOut.StockOutQuantity; ViewState["stockOutItem"] = stockOuts; stockOutGridView.DataSource = stockOuts; stockOutGridView.DataBind(); } else { List <StockOut> stockOuts = (List <StockOut>)ViewState["stockOutItem"]; bool hasItem = false; foreach (var stock in stockOuts) { if (stock.Item == stockOut.Item) { hasItem = true; stock.StockOutQuantity = stock.StockOutQuantity + stockOut.StockOutQuantity; stock.AvailableQuantity = stock.AvailableQuantity - stockOut.StockOutQuantity; stockOut.AvailableQuantity = stock.AvailableQuantity; } } if (hasItem != true) { stockOut.AvailableQuantity = stockOut.AvailableQuantity - stockOut.StockOutQuantity; stockOuts.Add(stockOut); } stockOutGridView.DataSource = stockOuts; stockOutGridView.DataBind(); } availableQuantityTextBox.Text = stockOut.AvailableQuantity.ToString(); } else { messageLevel.Text = "Available quantity will not be negative"; } availableQuantityTextBox.Text = stockOut.AvailableQuantity.ToString(); }
// add data on a list for temporaray table public void AddStockListForTemporaryTable(Items item, int companyId, int itemId, int stockOutQuantity) { // add to a StockOutList (for temporary) if (ViewState["StockOutListVS"] == null) { StockOut stockOut = new StockOut(); List <StockOut> stockOutList = new List <StockOut>(); stockOut.CompanyId = companyId; stockOut.ItemId = itemId; stockOut.Date = DateTime.Today.ToString("yyyy/MM/dd"); stockOut.StockOutQuantity = stockOutQuantity; stockOut.Type = "No"; stockOutList.Add(stockOut); // update viewState ViewState["StockOutListVS"] = stockOutList; } else { StockOut stockOut = new StockOut(); List <StockOut> listStockOut = (List <StockOut>)ViewState["StockOutListVS"]; int previousQuantity = 0; int index = -1; for (int i = 0; i < listStockOut.Count; i++) { if (listStockOut[i].ItemId == itemId) { index = i; previousQuantity = listStockOut[i].StockOutQuantity + stockOutQuantity; } } if (index == -1) { stockOut.CompanyId = companyId; stockOut.ItemId = itemId; stockOut.Date = DateTime.Today.ToString("yyyy/MM/dd"); stockOut.StockOutQuantity = stockOutQuantity; stockOut.Type = "No"; listStockOut.Add(stockOut); } else { listStockOut[index].StockOutQuantity = previousQuantity; } // update viewState ViewState["StockOutListVS"] = listStockOut; } }
protected void btnLost_Click(object sender, EventArgs e) { foreach (GridViewRow g1 in stockOutGridView.Rows) { StockOut item = new StockOut(); item.ItemName = g1.Cells[1].Text; item.StockOutQuantity = Int32.Parse(g1.Cells[3].Text); item.Status = "Lost"; //outputMsgLabel.Text = stockOutManager.StockOutUpdate(item); } }
private void lostButton_Click(object sender, EventArgs e) { StockOut aStockOut = new StockOut(); MessageBox.Show(aStockOut.ItemName + aStockOut.Status); string message = aStockOutManager.SaveStockReport(stockOuts, "Lost"); string msg = aStockOutManager.StockOut(stockOuts); MessageBox.Show(msg); //MessageBox.Show(message); stockOutListView.Items.Clear(); stockOuts.Clear(); }
protected void btnLost_Click(object sender, EventArgs e) { foreach (GridViewRow g1 in stockOutGridView.Rows) { StockOut item = new StockOut(); item.ItemName = g1.Cells[1].Text; item.StockOutQuantity = Int32.Parse(g1.Cells[3].Text); item.Status = "Lost"; outputMsgLabel.Text = stockOutManager.StockOutUpdate(item); } itemDropDownList.SelectedItem.Value = "-1"; itemDropDownList.SelectedItem.Text = "--Please Select--"; stockInTextBox.Text = ""; reorderTextBox.Text = ""; availableQty.Text = ""; }
protected void lostButton_Click(object sender, EventArgs e) { List <StockOut> outs = new List <StockOut>(); foreach (GridViewRow row in stockOutGridView.Rows) { StockOut soldStockOut = new StockOut(); soldStockOut.Item = row.Cells[1].Text; soldStockOut.Company = row.Cells[2].Text; soldStockOut.Quantity = Convert.ToInt32(row.Cells[3].Text); soldStockOut.Type = "Lost"; outs.Add(soldStockOut); } messageLabel.Text = aStockOutManager.SaveStockOut(outs); EvacuateGridView(); DisableButtons(); }
private void addButton_Click(object sender, EventArgs e) { try { if (Convert.ToInt32(avialableQuantityTextBox.Text) >= Convert.ToInt32(stockOutQuantityTextBox.Text)) { StockOut _stockOut = new StockOut(); _stockOut.CategoryId = Convert.ToInt32(categoryComboBox.SelectedValue); _stockOut.CategoryName = categoryComboBox.Text; _stockOut.CompanyId = Convert.ToInt32(companyComboBox.SelectedValue); _stockOut.CompanyName = companyComboBox.Text; _stockOut.ItemId = Convert.ToInt32(itemComboBox.SelectedValue); _stockOut.ItemName = itemComboBox.Text; _stockOut.OutQuantity = Convert.ToInt32(stockOutQuantityTextBox.Text); avialableQuantityTextBox.Text = (Convert.ToInt32(avialableQuantityTextBox.Text) - _stockOut.OutQuantity).ToString(); _stockOut.Quantity = Convert.ToInt32(avialableQuantityTextBox.Text); _stockOut.Date = DateTime.Today; stockOutQuantityTextBox.ResetText(); stockOutList.Add(_stockOut); stockOutDataGridView.DataSource = null; stockOutDataGridView.DataSource = stockOutList; stockOutDataGridView.Columns["CategoryId"].Visible = false; stockOutDataGridView.Columns["CompanyId"].Visible = false; stockOutDataGridView.Columns["ItemId"].Visible = false; stockOutDataGridView.Columns["Date"].Visible = false; stockOutDataGridView.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; if (Convert.ToInt32(reorderLevelTextBox.Text) > _stockOut.Quantity) { MessageBox.Show("Product is going OUT OF STOCK", "WARNING!!"); } } } catch (Exception exception) { MessageBox.Show("Something is WRONG!!!"); } }
protected void lostButton_Click(object sender, EventArgs e) { List <StockOutVM> sOutVms = new List <StockOutVM>(); sOutVms = (List <StockOutVM>)ViewState["StockOutItems"]; if (sOutVms != null) { foreach (var stockItem in sOutVms) { StockOut aStockOut = new StockOut(); aStockOut.ItemId = stockItem.ItemId; aStockOut.StockOutQuantity = stockItem.StockOutQuantity; aStockOut.Flag = "Lost"; aStockOut.StockOutDate = DateTime.Now; if (aStockOutManager.SaveStockOut(aStockOut)) { messageLabel.Text = "saved"; Item aItem = new Item(); aItem = aItemManager.GetItemInfo(aStockOut.ItemId); int updatedValue = aItem.AvailableQuantity - aStockOut.StockOutQuantity; aItemManager.UpdateAvailabelQuantity(aStockOut.ItemId, updatedValue); stockOutGridView.DataSource = null; stockOutGridView.DataBind(); ViewState["StockOutItems"] = null; } else { messageLabel.Text = "not saved"; } } } else { messageLabel.Text = "please first select"; } }
protected void lostButton_Click(object sender, EventArgs e) { foreach (GridViewRow row in stockOutGridView.Rows) { StockIn stockIn = new StockIn(); StockOut stockOut = new StockOut(); stockOut.Item = ((Label)row.FindControl("ItemNameLabel")).Text; stockOut.Company = ((Label)row.FindControl("companyNameLabel")).Text; stockOut.StockOutQuantity = Convert.ToInt32(((Label)row.FindControl("stockOutQuantityLabel")).Text); stockOut.ActionType = "Lost"; stockOut.ItemId = itemManager.GetItemIdByItemName(stockOut.Item); stockOut.AvailableQuantity = stockInManager.GetAvailableQuantity(stockOut.ItemId) - stockOut.StockOutQuantity; messageLevel.Text = stockOutManager.AddStockOut(stockOut); stockIn.ItemId = stockOut.ItemId; stockIn.AvailableQuantity = stockOut.AvailableQuantity; stockInManager.UpdateAvailableQuantity(stockIn); } SettingNull(); }
private void addButton_Click(object sender, EventArgs e) { StockOut aStockOut = new StockOut(); aStockOut.ItemName = itemComboBox.Text; try { aStockOut.Quantity = Convert.ToInt32(quantityTextBox.Text); } catch (Exception) { MessageBox.Show("Please input Reorder Level numeric characters only"); quantityTextBox.Text = ""; return; } aStockOut.AvailableQuantity = Convert.ToInt32(availableQuentityTextBox.Text); aStockOut.Date = DateTime.Today; aStockOut.CategoryId = (int)itemComboBox.SelectedValue; aStockOut.CompanyId = (int)companyNameComboBox.SelectedValue; aStockOut.CompanyName = companyNameComboBox.Text; aStockOut.ItemId = (int)itemComboBox.SelectedValue; aStockOut.ReorderLevel = Convert.ToInt32(reorderLevelTextBox.Text); bool check = aStockOut.StockOut(aStockOut.Quantity); if (check == true) { stockOuts.Add(aStockOut); } else { MessageBox.Show("Stock Not Available"); } StockOutListView(); Clear(); }
private void StockOutButton_Click(object sender, EventArgs e) { StockOut stockOut = new StockOut(); stockOut.Show(this); }