public partial class Orders : Form { SqlCommand cmd; SqlConnection cn; SqlDataReader dr; public Orders() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { dataGridView1.Rows.Add(comboBox1.Text,comboBox3.Text, comboBox2.Text,textBox2.Text); } private void Orders_Load(object sender, EventArgs e) { cn = new SqlConnection(); cn.ConnectionString = ConfigurationManager.ConnectionStrings["Key"].ConnectionString; } private void comboBox2_SelectedIndexChanged(object sender, EventArgs e) { Int32 val1 = Convert.ToInt32(comboBox3.Text); Int32 val2 = Convert.ToInt32(comboBox2.Text); Int32 val3 = val1 * val2; textBox2.Text = val3.ToString(); } private void button2_Click(object sender, EventArgs e) { try { dataGridView1.Rows.RemoveAt(dataGridView1.CurrentCell.RowIndex); } catch { MessageBox.Show("Must select the row first"); } } private void button4_Click(object sender, EventArgs e) { int sum = 0; for (int i=0; i < dataGridView1.Rows.Count; ++i) { sum += Convert.ToInt32(dataGridView1.Rows[i].Cells[3].Value); } label7.Text = sum.ToString(); } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)