private void AddButton_Click(object sender, EventArgs e) { messageLabel.Text = ""; if (companyComboBox.Text.Equals("-Select-") || companyComboBox.Text == "") { messageLabel.Text = "Select Company"; return; } if (categoryComboBox.Text.Equals("-Select-") || categoryComboBox.Text == "") { messageLabel.Text = "Select Category"; return; } if (itemComboBox.Text.Equals("-Select-") || itemComboBox.Text == "") { messageLabel.Text = "Select Category"; return; } stockOut = new StockOut(); messageLabel.Text = ""; //Stockout Quantity textfield checking if (String.IsNullOrEmpty(stockOutQuantityTextBox.Text)) { messageLabel.Text = "Enter Stock Out Quantity"; return; } if (System.Text.RegularExpressions.Regex.IsMatch(stockOutQuantityTextBox.Text, "[^0-9]")) { messageLabel.Text = "Enter Numeric Digits"; return; } //avaiability checking int quantityOut = Convert.ToInt32(stockOutQuantityTextBox.Text); int availableQuantity = Convert.ToInt32(availableQuantityTextBox.Text); int reorderLevel = Convert.ToInt32(reorderLevelTextBox.Text); if (quantityOut > availableQuantity) { messageLabel.Text = "No Product as Your order"; return; } if ((availableQuantity - quantityOut) <= reorderLevel) { messageLabel.Text = "Item is Under reorderLevel"; } stockOut.ItemName = itemComboBox.Text; stockOut.CompanyName = companyComboBox.Text; stockOut.Quantity = Convert.ToInt32(stockOutQuantityTextBox.Text); item.Name = itemComboBox.Text; item.CategoryID = Convert.ToInt32(categoryComboBox.SelectedValue); item.CompanyID = Convert.ToInt32(companyComboBox.SelectedValue); dataTable = _stockOutManager.GetAvailableQuantityAndReorderLevel(item); stockOut.ItemID = Convert.ToInt32(dataTable.Rows[0]["ID"].ToString()); listStockOut.Add(stockOut); stockOutDataGridView.DataSource = null; stockOutDataGridView.DataSource = listStockOut; //Adding SI column foreach (DataGridViewRow row in stockOutDataGridView.Rows) { row.Cells["SL"].Value = (row.Index + 1).ToString(); } //Preview companyComboBox.Text = "-Select-"; categoryComboBox.Text = "-Select-"; itemComboBox.Text = "-Select-"; reorderLevelTextBox.Text = "<View>"; availableQuantityTextBox.Text = "<View>"; stockOutQuantityTextBox.Text = ""; }