コード例 #1
0
        private void button4_Click(object sender, EventArgs e)
        {
            int id = (int)dataGridView1.SelectedRows[0].Cells[0].Value;

            rdb.delete(id);
            this.Close();
            Form f = new Ready_Product();

            f.Show();
        }
コード例 #2
0
        private void button1_Click(object sender, EventArgs e)
        {
            SqlConnection conn = new SqlConnection("Data Source=DELL-PC\\SQLEXPRESS;Initial Catalog=NGOIdatabase;Integrated Security=True");

            conn.Open();
            try
            {
                SqlCommand comd = conn.CreateCommand();
                comd.CommandType = CommandType.Text;
                DateTime d = Convert.ToDateTime(dateTimePicker1.Text);
                if (textBox1.Text == "")
                {
                    //MessageBox.Show("I will create new");
                    Ready_Product r   = new Ready_Product();
                    int           abc = Int32.Parse(textBox4.Text);
                    int           id;
                    //SqlDataAdapter sda = new SqlDataAdapter ( "Select Product_id from Ready_products where product_name=" +comboBox1, conn);
                    SqlDataAdapter sda = new SqlDataAdapter("select * from Ready_Products where Product_name=" + comboBox1, conn);
                    sda.Fill(dt);
                    id = Int32.Parse(dt.Rows[0]["Product_id"].ToString());
                    // r.get(id);
                    // abc = abc + r.Quantity;
                    comd.CommandText = "Update Ready_products SET Quantity='" + abc + "'where Product_id = " + textBox1.Text;
                    this.Close();
                    r.Show();
                }

                else
                {
                    //MessageBox.Show("I will update");
                    comd.CommandText = "UPDATE Ready_products SET Prooduct_name='" + comboBox1.Text + "',Product_packing'" + comboBox2.Text + "',Quantity='" + textBox3.Text + "',Price='" + textBox4.Text + "',date_created='" + d.Year + "-" + d.Month + "-" + d.Day + "',Remarks='" + textBox5.Text + "' where Product_id=" + textBox1.Text;
                }
                //comd.CommandText = "INSERT INTO Ready_products (Product_name, Product_packing, Quantity, Price, date_created, Remarks) values ('" + textBox2.Text + "','" + comboBox2.Text + "','" + textBox3.Text + "','" + textBox4.Text + "','" + dateTimePicker1.Text + "','" + textBox5.Text + "','" + "')";
                comd.ExecuteNonQuery();
                Ready_productsdb rdb = new Ready_productsdb();
                dataGridView1.DataSource = rdb.selectall();
                conn.Close();
                // Ready_productsdb rdb = new Ready_productsdb;
                rdb.selectall();
            }


            catch (Exception e2)
            {
                MessageBox.Show(e2.Message);
            }
            reset_layout();
        }
コード例 #3
0
        private void button1_Click(object sender, EventArgs e)
        {
            Ready_Product f1 = new Ready_Product();

            f1.ShowDialog();
        }