private void NewStudent_FormClosing(object sender, FormClosingEventArgs e) { if (dataGridView1.Rows.Count > 1) { DialogResult res = MessageBox.Show("You have some unsaved work, would you like to save your work?", "Confirmation", MessageBoxButtons.YesNoCancel); if (res == DialogResult.Yes) { string fname, mname, sname, fullname, clas, gender; reportManDataSetTableAdapters.StudentInfoTableAdapter stdinfo = new reportManDataSetTableAdapters.StudentInfoTableAdapter(); for (int j = 0; j <= (this.dataGridView1.RowCount - 1) - 1; j++) { //adcode = DataGridView4.Item(8, j).Value.ToString sname = dataGridView1.Rows[j].Cells[0].Value.ToString(); fname = dataGridView1.Rows[j].Cells[1].Value.ToString(); mname = dataGridView1.Rows[j].Cells[2].Value.ToString(); fullname = sname + " " + fname + " " + mname; clas = dataGridView1.Rows[j].Cells[3].Value.ToString(); gender = dataGridView1.Rows[j].Cells[4].Value.ToString(); ///////// stdinfo.InsertQuery(fname, mname, sname, fullname, gender, clas, "YES"); } } else if (res == DialogResult.No) { e.Cancel = false; } else { e.Cancel = true; return; } } }
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e) { // int cnt = dtStudents.Rows.Count; string studNames; string src = ConfigurationManager.ConnectionStrings[1].ConnectionString; using (SqlConnection con = new SqlConnection(src)) { SqlCommand cmd = new SqlCommand("truncate table defaulters", con); con.Open(); cmd.ExecuteNonQuery(); } DataTable dtStudents; DataTable dtBillAmount, dtAmountPaid; decimal TotalAmountPaid, TotalBillAmount, balance; reportManDataSetTableAdapters.StudentInfoTableAdapter activeStudents = new reportManDataSetTableAdapters.StudentInfoTableAdapter(); reportManDataSetTableAdapters.BillBillAmountTableAdapter BBA = new reportManDataSetTableAdapters.BillBillAmountTableAdapter(); reportManDataSetTableAdapters.BillAmountPaidTableAdapter BAP = new reportManDataSetTableAdapters.BillAmountPaidTableAdapter(); reportManDataSetTableAdapters.defaultersTableAdapter insDefaulters = new reportManDataSetTableAdapters.defaultersTableAdapter(); dtStudents = activeStudents.GetDataByActiveClassStudents(comboBox1.Text); foreach (DataRow dr in dtStudents.Rows) { // subj = drt[0].ToString(); studNames = dr[4].ToString().Trim(); dtBillAmount = BBA.GetDataByTotalBillAmount(studNames); try { TotalBillAmount = Convert.ToDecimal(dtBillAmount.Rows[0]["TotalBill"].ToString()); } catch { TotalBillAmount = 0; } dtAmountPaid = BAP.GetDataByTotalAmountPaid(studNames); try { TotalAmountPaid = Convert.ToDecimal(dtAmountPaid.Rows[0]["TotalAmountPaid"].ToString()); } catch { TotalAmountPaid = 0; } balance = TotalBillAmount - TotalAmountPaid; insDefaulters.InsertQuery(studNames, comboBox1.Text, TotalBillAmount, TotalAmountPaid, balance); // MessageBox.Show(studNames + " "+TotalBillAmount+ " "+TotalAmountPaid+ " "+balance); this.defaultersTableAdapter.FillByClassDefaulters(this.reportManDataSet.defaulters, comboBox1.Text); this.reportViewer1.RefreshReport(); } }
private void button2_Click(object sender, EventArgs e) { if (!(textBox1.Text == "") || !(textBox2.Text == "") || !(textBox3.Text == "")) { MessageBox.Show("You still have some info left to be added to the grid"); return; } string fname, mname, sname, fullname, clas, gender; reportManDataSetTableAdapters.StudentInfoTableAdapter stdinfo = new reportManDataSetTableAdapters.StudentInfoTableAdapter(); for (int j = 0; j <= this.dataGridView1.RowCount - 1; j++) { //adcode = DataGridView4.Item(8, j).Value.ToString sname = dataGridView1.Rows[j].Cells[0].Value.ToString(); fname = dataGridView1.Rows[j].Cells[1].Value.ToString(); mname = dataGridView1.Rows[j].Cells[2].Value.ToString(); fullname = sname + " " + fname + " " + mname; clas = dataGridView1.Rows[j].Cells[3].Value.ToString(); gender = dataGridView1.Rows[j].Cells[4].Value.ToString(); //////// stdinfo.InsertQuery(fname, mname, sname, fullname, gender, clas,"YES"); } MessageBox.Show("Database Updated Successfully"); dataGridView1.Rows.Clear(); }
private void button3_Click(object sender, EventArgs e) { reportManDataSetTableAdapters.StudentInfoTableAdapter insstudent = new reportManDataSetTableAdapters.StudentInfoTableAdapter(); /* if (textBox1.Text == "") * { * MessageBox.Show("You need to enter the student's admission number number"); * textBox1.Focus(); * return; * }*/ if (textBox2.Text == "") { MessageBox.Show("You need to enter student's surname"); textBox2.Focus(); return; } if (textBox3.Text == "") { MessageBox.Show("You need to enter student's first name"); textBox3.Focus(); return; } /* if (textBox4.Text == "") * { * MessageBox.Show("You need to enter student's other names"); * textBox4.Focus(); * return; * }*/ /*if (comboBox7.Text == "") * { * MessageBox.Show("You need to pick a scholarship type"); * * comboBox7.Focus(); * return; * }*/ if (comboBox9.Text == "") { MessageBox.Show("You need to pick the student school i.e ACE or CONVENTIONAL"); comboBox9.Focus(); return; } if (comboBox5.Text == "") { MessageBox.Show("You need to pick a gendre"); // textBox4.Focus(); // this.tabControl1.TabPages[1].Focus(); // tabControl1.SelectedTab = tabPage2; comboBox5.Focus(); return; } if (comboBox6.Text == "") { MessageBox.Show("You need to pick a class for the student"); // textBox4.Focus(); // this.tabControl1.TabPages[1].Focus(); // tabControl1.SelectedTab = tabPage2; comboBox6.Focus(); return; } if (textBox5.Text == "") { MessageBox.Show("You need to enter Parent/Guardian full names"); // textBox4.Focus(); // this.tabControl1.TabPages[1].Focus(); tabControl1.SelectedTab = tabPage2; textBox5.Focus(); return; } if (textBox6.Text == "") { MessageBox.Show("You need to enter Parent/Guardian office number"); // textBox4.Focus(); //this.tabControl1.TabPages[1].Focus(); tabControl1.SelectedTab = tabPage2; textBox6.Focus(); return; } if (textBox7.Text == "") { MessageBox.Show("You need to enter Parent/Guardian home number"); // textBox4.Focus(); // this.tabControl1.TabPages[1].Focus(); tabControl1.SelectedTab = tabPage2; textBox7.Focus(); return; } if (textBox9.Text == "") { MessageBox.Show("You need to enter Parent/Guardian addresss"); // textBox4.Focus(); // this.tabControl1.TabPages[1].Focus(); tabControl1.SelectedTab = tabPage2; textBox9.Focus(); return; } if (checkBox1.Checked == true) { active = "YES"; activemain = true; } else { active = "NO"; activemain = false; } fullname = textBox2.Text + " " + textBox3.Text + " " + textBox4.Text; DataTable mydt = new DataTable(); mydt = this.studentInfoTableAdapter.GetDataByStudentExistence(fullname); if (mydt.Rows.Count != 0) { MessageBox.Show("Student with this names already exists in the database, you might consider changing the other names field"); textBox4.Focus(); return; } dob = (DateTime)dateTimePicker1.Value; doe = (DateTime)dateTimePicker2.Value; if (filepath == "C:\\reportMAN\\StudentPassport\\blank.jpg") { ; } { DialogResult reslt = MessageBox.Show("You did not include the student passport, if you don't include it now, you will not be able to include it in the future.Will you want to include a passport? Then click the BROWSE FOR PASSPORT BUTTON", "Do you want to include a passport?", MessageBoxButtons.YesNo); if (reslt == DialogResult.No) { //insstudent.InsertQuery(textBox1.Text, textBox3.Text, textBox4.Text, textBox2.Text, fullname, comboBox1.Text, comboBox2.Text, textBox5.Text, textBox9.Text, textBox6.Text, textBox7.Text, textBox8.Text, comboBox5.Text, comboBox3.Text, comboBox4.Text, comboBox6.Text,active,dob,filepath); insstudent.InsertQuery(textBox1.Text, textBox3.Text, textBox4.Text, textBox2.Text, fullname, comboBox1.Text, comboBox2.Text, textBox5.Text, textBox9.Text, textBox6.Text, textBox7.Text, textBox8.Text, comboBox5.Text, comboBox3.Text, comboBox4.Text, comboBox6.Text, active, dob, filepath, comboBox7.Text, textBox12.Text, textBox10.Text, activemain, comboBox8.Text, doe, comboBox9.Text, textBox11.Text); // MessageBox.Show("database updated"); this.Close(); } else { if (opfil.ShowDialog() != DialogResult.OK) { return; } opfil.ShowDialog(); filepath = opfil.FileName; pictureBox1.Load(filepath); } } }
private void button2_Click(object sender, EventArgs e) { reportManDataSetTableAdapters.StudentInfoTableAdapter insstudent = new reportManDataSetTableAdapters.StudentInfoTableAdapter(); /*if (textBox1.Text == "") * { * MessageBox.Show("You need to enter the student's admission number number"); * textBox1.Focus(); * * return; * }*/ if (textBox2.Text == "") { MessageBox.Show("You need to enter student's surname"); textBox2.Focus(); return; } if (textBox3.Text == "") { MessageBox.Show("You need to enter student's first name"); textBox3.Focus(); return; } /* if (textBox4.Text == "") * { * MessageBox.Show("You need to enter student's other names"); * textBox4.Focus(); * return; * }*/ if (comboBox5.Text == "") { MessageBox.Show("You need to pick a gendre"); // textBox4.Focus(); // this.tabControl1.TabPages[1].Focus(); // tabControl1.SelectedTab = tabPage2; comboBox5.Focus(); return; } /* if (comboBox6.Text == "") * { * MessageBox.Show("You need to pick a class for the student"); * // textBox4.Focus(); * // this.tabControl1.TabPages[1].Focus(); * // tabControl1.SelectedTab = tabPage2; * comboBox6.Focus(); * return; * }*/ if (comboBox8.Text == "") { MessageBox.Show("You need to pick a religion"); // textBox4.Focus(); // this.tabControl1.TabPages[1].Focus(); // tabControl1.SelectedTab = tabPage2; comboBox8.Focus(); return; } /* if (comboBox9.Text == "") * { * MessageBox.Show("You need to pick the student school i.e ACE or CONVENTIONAL"); * * comboBox9.Focus(); * return; * }*/ if (textBox5.Text == "") { MessageBox.Show("You need to enter Parent/Guardian full names"); // textBox4.Focus(); // this.tabControl1.TabPages[1].Focus(); tabControl1.SelectedTab = tabPage2; textBox5.Focus(); return; } if (textBox6.Text == "") { MessageBox.Show("You need to enter Parent/Guardian office number"); // textBox4.Focus(); //this.tabControl1.TabPages[1].Focus(); tabControl1.SelectedTab = tabPage2; textBox6.Focus(); return; } if (textBox7.Text == "") { MessageBox.Show("You need to enter Parent/Guardian home number"); // textBox4.Focus(); // this.tabControl1.TabPages[1].Focus(); tabControl1.SelectedTab = tabPage2; textBox7.Focus(); return; } if (textBox9.Text == "") { MessageBox.Show("You need to enter Parent/Guardian addresss"); // textBox4.Focus(); // this.tabControl1.TabPages[1].Focus(); tabControl1.SelectedTab = tabPage2; textBox9.Focus(); return; } if (checkBox1.Checked == true) { active = "YES"; activemain = true; } else { active = "NO"; activemain = false; } //// reportManDataSetTableAdapters.StudentInfoTableAdapter insStudentInfo = new reportManDataSetTableAdapters.StudentInfoTableAdapter(); //// insStudentInfo.InsertQuery(textBox1.Text,textBox3.Text,textBox4.Text,textBox2.Text,""); fullname = textBox2.Text + " " + textBox3.Text + " " + textBox4.Text; DataTable mydt = new DataTable(); mydt = this.studentInfoTableAdapter.GetDataByStudentExistence(fullname); if (mydt.Rows.Count != 0) { MessageBox.Show("Student with this names already exists in the database, you might consider changing the other names field"); textBox4.Focus(); return; } dob = (DateTime)dateTimePicker1.Value; doe = (DateTime)dateTimePicker2.Value; // insstudent.InsertQuery(textBox1.Text, textBox3.Text, textBox4.Text, textBox2.Text, fullname, comboBox1.Text, comboBox2.Text, textBox5.Text, textBox9.Text, textBox6.Text, textBox7.Text, textBox8.Text, comboBox5.Text, comboBox3.Text, comboBox4.Text, comboBox6.Text, "YES", dob, filepath); insstudent.InsertQuery(textBox1.Text, textBox3.Text, textBox4.Text, textBox2.Text, fullname, comboBox1.Text, comboBox2.Text, textBox5.Text, textBox9.Text, textBox6.Text, textBox7.Text, textBox8.Text, comboBox5.Text, comboBox3.Text, comboBox4.Text, comboBox6.Text, active, dob, filepath, comboBox7.Text, textBox12.Text, textBox10.Text, activemain, comboBox8.Text, doe, comboBox9.Text, textBox11.Text); // MessageBox.Show("database updated"); textBox1.Clear(); textBox2.Clear(); textBox3.Clear(); textBox4.Clear(); textBox5.Clear(); textBox6.Clear(); textBox7.Clear(); textBox8.Clear(); textBox9.Clear(); textBox11.Clear(); textBox12.Clear(); textBox10.Clear(); comboBox1.SelectedIndex = -1; comboBox2.SelectedIndex = -1; comboBox3.SelectedIndex = -1; comboBox4.SelectedIndex = -1; comboBox5.SelectedIndex = -1; comboBox6.SelectedIndex = -1; comboBox7.SelectedIndex = -1; comboBox8.SelectedIndex = -1; comboBox9.SelectedIndex = -1; tabControl1.SelectedTab = tabPage1; filepath = "C:\\reportMAN\\StudentPassport\\blank.jpg"; pictureBox1.Load(filepath); textBox1.Focus(); }
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(); }