Exemple #1
0
        private void dataGridViewStock_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            int rowIndex = e.RowIndex;

            if (rowIndex >= 0)
            {
                if (e.ColumnIndex == dataGridViewStock.Columns["detailsButton"].Index)
                {
                    int    id     = (int)dataGridViewStock.Rows[rowIndex].Cells["id"].Value;
                    string name   = (string)dataGridViewStock.Rows[rowIndex].Cells["name"].Value;
                    string color  = (string)dataGridViewStock.Rows[rowIndex].Cells["color"].Value;
                    string size   = (string)dataGridViewStock.Rows[rowIndex].Cells["size"].Value;
                    int    stock  = (int)dataGridViewStock.Rows[rowIndex].Cells["stock"].Value;
                    int    needed = (int)dataGridViewStock.Rows[rowIndex].Cells["needed"].Value;
                    int    order  = 0;
                    if (dataGridViewStock.Rows[rowIndex].Cells["ordered"].Value != DBNull.Value)
                    {
                        order = (int)dataGridViewStock.Rows[rowIndex].Cells["ordered"].Value;
                    }
                    int minimum = (int)dataGridViewStock.Rows[rowIndex].Cells["min_amount"].Value;

                    StockInfo   stockInfo   = new StockInfo(id, name, color, size, stock, needed, order, minimum);
                    StockDetail stockDetail = new StockDetail(user, stockInfo);
                    stockDetail.Show();
                    this.Close();
                }
            }
        }
        private static void ButtonReturnToStockDetail_Click(object sender, EventArgs e)
        {
            Control     button      = (Control)sender;
            absStock    form        = (absStock)button.Parent;
            StockDetail stockDetail = new StockDetail(form.user, form.stockInfo);

            stockDetail.Show();
            form.Close();
        }
        private void buttonConfirm_Click(object sender, EventArgs e)
        {
            stockInfo.ordered += (int)numericUpDownQuantity.Value;
            stockInfo.CalculateBalance();
            DBConnection.UpdateStock(stockInfo);
            int selectedProvider = (int)StockProviderInfo.Rows[comboBoxProvider.SelectedIndex]["id"];

            DBConnection.InsertNewPartOrder(selectedProvider, DateTime.Now, dateTimePicker1.Value, 100, stockInfo.id, (int)numericUpDownQuantity.Value);
            StockDetail stockDetail = new StockDetail(user, stockInfo);

            stockDetail.Show();
            Close();
        }