private void button1_Click(object sender, EventArgs e) { DataTable dt = new DataTable(); reportManDataSetTableAdapters.StudentInfoTableAdapter studInfo = new reportManDataSetTableAdapters.StudentInfoTableAdapter(); if (comboBox1.Text == "") { MessageBox.Show("You need to select a category"); comboBox1.Focus(); return; } if (comboBox2.Text == "") { MessageBox.Show("You need to select an item"); comboBox2.Focus(); return; } if (comboBox1.Text == "EXT. EXAMS") { if (comboBox3.Text == "") { MessageBox.Show("You need to select a class"); comboBox3.Focus(); return; } if (radioButton1.Checked == false && radioButton2.Checked == false) { MessageBox.Show("You need to select a student name or number"); return; } if (radioButton1.Checked && comboBox4.Text == "") { MessageBox.Show("You need to select a student admission number"); comboBox4.Focus(); return; } if (radioButton2.Checked && comboBox5.Text == "") { MessageBox.Show("You need to select a student name"); comboBox5.Focus(); return; } if (textBox2.Text == "") { MessageBox.Show("You need to enter a quantity"); textBox2.Focus(); return; } if (System.Convert.ToDecimal(textBox2.Text) < 1) { MessageBox.Show("You need to enter a quantity greater than 0"); textBox2.Focus(); return; } if (textBox3.Text == "") { MessageBox.Show("You need to enter a price"); textBox3.Focus(); return; } if (System.Convert.ToDecimal(textBox3.Text) < 1) { MessageBox.Show("You need to enter a price greater than 0"); textBox3.Focus(); return; } if (comboBox6.Text == "") { MessageBox.Show("You need to select a session"); comboBox6.Focus(); return; } if (comboBox7.Text == "") { MessageBox.Show("You need to select a term"); comboBox7.Focus(); return; } if (radioButton1.Checked == true) { admissionNumber = comboBox4.Text; dt = studInfo.GetDataByAdminNumber(admissionNumber); studentName = dt.Rows[0][4].ToString(); //dt.Rows[0][4].ToString(); } if (radioButton2.Checked == true) { studentName = comboBox5.Text; dt = studInfo.GetDataByFullname(studentName); admissionNumber = dt.Rows[0][0].ToString(); } transdate = (DateTime)dateTimePicker1.Value; quan = Convert.ToInt32(textBox2.Text); price = Convert.ToDecimal(textBox3.Text); amount = quan * price; rev.InsertQuery(textBox1.Text, transdate, studentName, admissionNumber, "", "", comboBox1.Text, comboBox6.Text, comboBox7.Text, comboBox3.Text, comboBox2.Text, "REVENUE", quan, 0, amount, "CASH", textBox4.Text, price); } /////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////// if (comboBox1.Text == "PTA" || comboBox1.Text == "OTHERS") { if (textBox3.Text == "") { MessageBox.Show("You need to amount in the price field"); textBox3.Focus(); return; } if (System.Convert.ToDecimal(textBox3.Text) < 1) { MessageBox.Show("You need to enter an amount greater than 0"); textBox3.Focus(); return; } if (comboBox6.Text == "") { MessageBox.Show("You need to select a session"); comboBox6.Focus(); return; } if (comboBox7.Text == "") { MessageBox.Show("You need to select a term"); comboBox7.Focus(); return; } transdate = (DateTime)dateTimePicker1.Value; quan = 1; price = Convert.ToDecimal(textBox3.Text); amount = quan * price; // rev.InsertQuery(textBox1.Text, transdate, studentName, admissionNumber, "", "", comboBox1.Text, comboBox6.Text, comboBox7.Text, comboBox3.Text, comboBox2.Text, "REVENUE", quan, 0, amount, "CASH", textBox4.Text, price); rev.InsertQuery(textBox1.Text, transdate, "", "", "", "", comboBox1.Text, comboBox6.Text, comboBox7.Text, "", comboBox2.Text, "REVENUE", quan, 0, amount, "CASH", textBox4.Text, price); } textBox1.Text = ""; textBox2.Text = ""; textBox3.Text = ""; textBox4.Text = ""; comboBox4.SelectedIndex = -1; //textBox3.Text = ""; comboBox1.SelectedIndex = -1; comboBox2.SelectedIndex = -1; comboBox3.SelectedIndex = -1; comboBox5.SelectedIndex = -1; comboBox6.SelectedIndex = -1; comboBox7.SelectedIndex = -1; radioButton1.Checked = false; radioButton2.Checked = false; radioButton1.Enabled = false; radioButton2.Enabled = false; comboBox4.Enabled = false; comboBox5.Enabled = false; // comboBox5.Enabled = false; textBox1.Focus(); }
private void button2_Click(object sender, EventArgs e) { if (comboBox1.Text == "") { MessageBox.Show("You need to select a category"); comboBox1.Focus(); return; } if (comboBox4.Text == "") { MessageBox.Show("You need to select an item"); comboBox1.Focus(); return; } if (comboBox1.Text == "UNIFORMS" || comboBox1.Text == "BOOKS") { if (comboBox5.Text == "") { MessageBox.Show("You need to select a class"); comboBox5.Focus(); return; } if (radioButton1.Checked == false && radioButton2.Checked == false) { MessageBox.Show("You need to select a student name or a student number"); return; } if (radioButton1.Checked == true && comboBox6.Text == "") { MessageBox.Show("You need to select a student admission number"); comboBox6.Focus(); return; } if (radioButton2.Checked == true && comboBox7.Text == "") { MessageBox.Show("You need to select a student name"); comboBox7.Focus(); return; } if (textBox4.Text == "") { MessageBox.Show("You need to enter quantity"); textBox4.Focus(); return; } quan = Convert.ToInt32(textBox4.Text); if (quan < 1) { MessageBox.Show("Quantity must be a number greater than Zero"); textBox4.Focus(); return; } if (textBox2.Text == "") { MessageBox.Show("You need to enter Price of the item"); textBox2.Focus(); return; } price = Convert.ToDecimal(textBox2.Text); if (price < 0) { MessageBox.Show("Price must be an amount"); textBox2.Focus(); return; } if (comboBox2.Text == "") { MessageBox.Show("You need to select a session"); comboBox2.Focus(); return; } if (comboBox3.Text == "") { MessageBox.Show("You need to select a term"); comboBox3.Focus(); return; } if (radioButton1.Checked == true) { admissionNumber = comboBox6.Text; dt = studInfo.GetDataByAdminNumber(admissionNumber); studentName = dt.Rows[0][4].ToString(); //dt.Rows[0][4].ToString(); } if (radioButton2.Checked == true) { studentName = comboBox7.Text; dt = studInfo.GetDataByFullname(studentName); admissionNumber = dt.Rows[0][0].ToString(); } dot = (DateTime)dateTimePicker1.Value; amount = quan * price; inv.InsertQuery(textBox1.Text, dot, admissionNumber, studentName, textBox5.Text, "", comboBox1.Text, comboBox4.Text, quan, comboBox2.Text, comboBox3.Text, comboBox5.Text, price, 0); rev.InsertQuery(textBox1.Text, dot, studentName, admissionNumber, "", "", comboBox1.Text, comboBox2.Text, comboBox3.Text, comboBox5.Text, comboBox4.Text, "REVENUE", quan, 0, amount, "CASH", "", price); } else { if (textBox4.Text == "") { MessageBox.Show("You need to enter quantity"); textBox4.Focus(); return; } quan = Convert.ToInt32(textBox4.Text); if (quan < 1) { MessageBox.Show("Quantity must be a number greater than Zero"); textBox4.Focus(); return; } if (comboBox2.Text == "") { MessageBox.Show("You need to select a session"); comboBox2.Focus(); return; } if (comboBox3.Text == "") { MessageBox.Show("You need to select a term"); comboBox3.Focus(); return; } dot = (DateTime)dateTimePicker1.Value; amount = quan * price; inv.InsertQuery(textBox1.Text, dot, "", "", textBox5.Text, "", comboBox1.Text, comboBox4.Text, quan, comboBox2.Text, comboBox3.Text, "", price, 0); // rev.InsertQuery(textBox1.Text, dot, "", "", "", "", comboBox1.Text, comboBox2.Text, comboBox3.Text, comboBox5.Text, comboBox4.Text, "REVENUE", quan, 0, amount, "CASH", "", price); } this.Close(); }