示例#1
0
        private void UpdateItemButton_Click(object sender, EventArgs e)
        {
            MessageBox.Show(ItemTypeComb.SelectedIndex.ToString());

            String ItemName  = TextBoxItemName.Text;
            String ItemPrice = TextBoxPrice.Text;
            int    stockout  = (int)numericUpDown1.Value;
            double price     = 0;

            double.TryParse(ItemPrice, out price);
            String timeUpdated = DateTime.Now.ToString();

            Con.Open();
            SqlCommand DataBaseOject;

            if (ItemTypeComb.SelectedIndex != (-1))
            {
                String itemCode = StockItemList[ItemTypeComb.SelectedIndex];
                DataBaseOject = new SqlCommand(@"UPDATE       StockItems
                      SET [ItemCode] = '" + itemCode + "', [ItemName] ='" + ItemName + "', [ItemPrice] ='" + price + "',[StockCount] ='" + stockout + "', [DateUpdated] ='" + timeUpdated + "'WHERE (StockID='" + ID + "')", Con);
            }
            else
            {
                DataBaseOject = new SqlCommand(@"UPDATE       StockItems
                      SET [ItemCode] = '" + ityps + "', [ItemName] ='" + ItemName + "', [ItemPrice] ='" + price + "',[StockCount] ='" + stockout + "', [DateUpdated] ='" + timeUpdated + "'WHERE (StockID='" + ID + "')", Con);
            }
            DataBaseOject.ExecuteNonQuery();
            Con.Close();
            MessageBox.Show("Update successfully!!");
            Stock_Managment Sm = new Stock_Managment();

            Sm.Dispose();

            this.Dispose();
        }
示例#2
0
        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");
            }
        }
示例#3
0
        private void metroTileStock_Click(object sender, EventArgs e)
        {
            Stock_Managment sm = new Stock_Managment();

            sm.Show();
        }