Пример #1
0
        /*   private void btnDelete_Click(object sender, EventArgs e)
         * {
         *     int n = 0;
         *     for (int i = 0; i < dataGridView1.Rows.Count; i++)
         *     {
         *         DataGridViewRow r = dataGridView1.Rows[i];
         *         if (r.Cells[0].Value != null)
         *             if (((bool)r.Cells[0].Value) == true)
         *             {
         *                 MessageBox.Show("Item ID = " + r.Cells[2].Value.ToString());
         *                 n++;
         *
         *                 SqlCommand cmd = new SqlCommand("delete from Items where item_id = @n");
         *                 cmd.Parameters.AddWithValue("@n", (int)r.Cells[2].Value);
         *                 DAO.UpdateTable(cmd);
         *                 dataGridView1.Rows.Remove(r);
         *                 i--;
         *             }
         *
         *     }
         *
         *     MessageBox.Show(string.Format("Deleted {0} item", n));
         * }
         */

        private void btnAdd_Click(object sender, EventArgs e)
        {
            frmAdd frm = new frmAdd();

            this.Hide();
            frm.ShowDialog();
            this.Show();
            DataTable dt = DAO.GetDataTable("SELECT item_id as ID, Items, Price,short_description as Descriptions, c.category_name as Category from Items i inner join Categories c on i.category_id = c.category_id");

            dataGridView1.DataSource = dt;
        }