private void button3_Click(object sender, EventArgs e) { SqlConnection con = new SqlConnection("Data Source=DESKTOP-GB0LHG2\\MSSQLSERVER01;Database=daudFactoryDB;Integrated Security=True"); con.Open(); SqlCommand cmd = con.CreateCommand(); cmd.CommandType = CommandType.Text; cmd.CommandText = "INSERT INTO orders (customer,material, quantity, price) values ('" + textBox1.Text + "','" + comboBox2.Text + "','" + textBox5.Text + "','" + textBox6.Text + "')"; cmd.ExecuteNonQuery(); ordersdb edb = new ordersdb(); if (comboBox1.Text == "Delivered") { cmd.CommandType = CommandType.Text; cmd.CommandText = "INSERT INTO sales (product,quantity, area, date) values ('" + comboBox2.Text + "','" + textBox5.Text + "','" + comboBox3.Text + "','" + dateTimePicker1.Text + "')"; cmd.ExecuteNonQuery(); salesdb sdb = new salesdb(); } comboBox2.Text = ""; textBox5.Text = ""; textBox6.Text = ""; //dataGridView2.DataSource = edb.selectal(); con.Close(); }
private void dataGridView1_MouseClick(object sender, MouseEventArgs e) { string id = dataGridView1.SelectedRows[0].Cells[0].Value.ToString(); ordersdb odb = new ordersdb(); odb.get(Int32.Parse(id)); string cus_name = odb.name; dataGridView2.ColumnHeadersDefaultCellStyle.Font = new Font("Arial", 12); dataGridView2.SelectionMode = DataGridViewSelectionMode.FullRowSelect; ordersdb sdb = new ordersdb(); textBox1.Text = cus_name; dataGridView2.DataSource = sdb.selectall(cus_name); }