private void button3_Click(object sender, EventArgs e) { if (!(comboBox4.Text == "") || !(textBox2.Text == "")) { MessageBox.Show("You still have some info left to be added to the grid"); return; } decimal billamount; string classs, session, term, namess, billamountgrid; reportManDataSetTableAdapters.BillTableAdapter insBill = new reportManDataSetTableAdapters.BillTableAdapter(); for (int j = 0; j <= this.dataGridView1.RowCount - 1; j++) { classs = dataGridView1.Rows[j].Cells[2].Value.ToString(); session = dataGridView1.Rows[j].Cells[3].Value.ToString(); term = dataGridView1.Rows[j].Cells[4].Value.ToString(); namess = dataGridView1.Rows[j].Cells[0].Value.ToString(); billamountgrid = dataGridView1.Rows[j].Cells[1].Value.ToString(); billamount = Convert.ToDecimal(billamountgrid); insBill.InsertQuery("", namess, classs, session, term, DateTime.Today, billamount, 0); } MessageBox.Show("Database Updated Successfully"); dataGridView1.Rows.Clear(); comboBox2.Enabled = true; comboBox3.Enabled = true; comboBox1.Enabled = true; comboBox1.SelectedIndex = -1; comboBox2.SelectedIndex = -1; comboBox3.SelectedIndex = -1; comboBox4.SelectedIndex = -1; }
private void button1_Click(object sender, EventArgs e) { DateTime dop; decimal amountpaid; reportManDataSetTableAdapters.BillTableAdapter insBill = new reportManDataSetTableAdapters.BillTableAdapter(); reportManDataSetTableAdapters.RecieptsTableAdapter insRec = new reportManDataSetTableAdapters.RecieptsTableAdapter(); if (comboBox1.Text == "") { MessageBox.Show("You need to select a class"); comboBox1.Focus(); return; } if (comboBox2.Text == "") { MessageBox.Show("You need to select a student name"); comboBox2.Focus(); return; } if (comboBox3.Text == "") { MessageBox.Show("You need to select a session"); comboBox3.Focus(); return; } if (comboBox4.Text == "") { MessageBox.Show("You need to select a term"); comboBox4.Focus(); return; } if (textBox1.Text == "") { MessageBox.Show("You need to enter the teller number"); textBox1.Focus(); return; } if (textBox2.Text == "") { MessageBox.Show("You need to enter the amount paid"); textBox2.Focus(); return; } dop = (DateTime)dateTimePicker1.Value; amountpaid = Convert.ToDecimal(textBox2.Text); balance = balance - amountpaid; // insBill.InsertQuery("", namess, classs, session, term, DateTime.Today, billamount, 0); insBill.InsertQuery(textBox1.Text, comboBox2.Text, comboBox1.Text, comboBox3.Text, comboBox4.Text, dop, 0, amountpaid); insRec.InsertQuery(textBox1.Text, comboBox2.Text, comboBox1.Text, comboBox3.Text, comboBox4.Text, dop, balance, amountpaid, "", "", ""); RecieptsFind rec = new RecieptsFind(); rec.tellerNumber = textBox1.Text.Trim(); rec.namess = comboBox2.Text.Trim(); rec.classs = comboBox1.Text.Trim(); rec.session = comboBox3.Text.Trim(); rec.term = comboBox4.Text.Trim(); rec.dop = dop; rec.balance = balance; rec.amountpaid = amountpaid; comboBox1.SelectedIndex = -1; comboBox2.SelectedIndex = -1; comboBox3.SelectedIndex = -1; comboBox4.SelectedIndex = -1; textBox1.Clear(); textBox2.Clear(); label8.Text = ""; // comboBox1.Focus(); rec.ShowDialog(); }