private void SellButton_Click(object sender, EventArgs e) { bool isSuccessfull = false; foreach (DataGridViewRow row in stockOutDataGridView.Rows) { foreach (DataGridViewCell cell in row.Cells) { GridViewData.Add(cell.Value.ToString()); } string ItemName = GridViewData[2]; string ItemId = stockOutManager.GetItemId(ItemName).ToString(); GridViewData.Add(ItemId); GridViewData.Add("Sell"); bool isAdded = stockOutManager.AddStockOut(GridViewData); if (isAdded) { //long quantity = Convert.ToInt64(GridViewData[3]); bool isUpdated = stockOutManager.UpdateTable(GridViewData); if (isUpdated) { isSuccessfull = true; } } } if (isSuccessfull == true) { MessageBox.Show("Stock Out Successfull!"); } stockOutDataGridView.Rows.Clear(); }
protected void sellButton_Click(object sender, EventArgs e) { //List<GridView> gridViews = (List<GridView>) ViewState["stockOutItem"]; 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 = "Sell"; 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(); }