private void metroButtonNewStockItem_Click(object sender, EventArgs e) { String itemCode = StockItemList[metroComboBoxItemType.SelectedIndex]; String ItemName = TextBoxItemName.Text; String ItemPrice = TextBoxPrice.Text; int stockout = (int)numericUpDown1.Value; double price = 0; String timeUpdated = DateTime.Now.ToString(); if (double.TryParse(ItemPrice, out price)) { try { Con.Open(); SqlDataAdapter ada = new SqlDataAdapter("SELECT* FROM StockItems", Con); DataTable dt = new DataTable(); ada.Fill(dt); int counts = dt.Rows.Count; int id = counts + 1; cmd = new SqlCommand(@"INSERT INTO StockItems ([StockID] ,[ItemCode] ,[ItemName] ,[ItemPrice] ,[StockCount] ,[DateUpdated]) VALUES('" + id + "','" + itemCode + "','" + ItemName + "','" + ItemPrice + "','" + stockout + "','" + timeUpdated + "')", Con); cmd.ExecuteNonQuery(); Con.Close(); Stock_Managment _emplyForm = new Stock_Managment(); _emplyForm.Show(); this.Dispose(); } catch (Exception ex) { MessageBox.Show(ex.ToString()); Con.Close(); } } else { MessageBox.Show("invalide Price"); } }
private void metroTileStock_Click(object sender, EventArgs e) { Stock_Managment sm = new Stock_Managment(); sm.Show(); }