private void btnPrint_Click(object sender, EventArgs e) { if (cboSearchCriteria.Text.Replace(" ", "") == "") { MessageBox.Show("Ensure all fields are filled!", "MMUST CIMS", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); cboSearchCriteria.Focus(); } else if (txtSearchValue.Text.Replace(" ", "") == "") { MessageBox.Show("Ensure all fields are filled!", "MMUST CIMS", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); txtSearchValue.Focus(); } else if (cboSemesterSearch.Text.Replace(" ", "") == "") { MessageBox.Show("Ensure all fields are filled!", "MMUST CIMS", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); cboSemesterSearch.Focus(); } else if (cboAcYrSearch.Text.Replace(" ", "") == "") { MessageBox.Show("Ensure all fields are filled!", "MMUST CIMS", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); cboAcYrSearch.Focus(); } else { Conn connect = new Conn(); if (connect.OpenConnection() == true) { string searchval = "%" + txtSearchValue.Text + "%"; if (cboSearchCriteria.Text == "All") { query = "SELECT * FROM loading WHERE Semester='" + cboSemesterSearch.Text + "' and Academic_Year='" + cboAcYrSearch.Text + "' ORDER BY Loading_Code ASC"; } else if (cboSearchCriteria.Text == "Course Code") { query = "SELECT * FROM loading WHERE ProgCourse_Code LIKE '" + searchval + "' and Semester='" + cboSemesterSearch.Text + "' and Academic_Year='" + cboAcYrSearch.Text + "' ORDER BY Loading_Code ASC"; } else if (cboSearchCriteria.Text == "Program Code") { query = "SELECT * FROM loading WHERE ProgCourse_Code LIKE '" + searchval + "' and Semester='" + cboSemesterSearch.Text + "' and Academic_Year='" + cboAcYrSearch.Text + "' ORDER BY Loading_Code ASC"; } else { MessageBox.Show("Invalid Criteria", "MMUST CIMS", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); cboSearchCriteria.Focus(); } MySqlCommand cmd = new MySqlCommand(query, connect.connection); MySqlDataReader dataReader = cmd.ExecuteReader(); //Read the data and store them in the list this.dataGridView1.Rows.Clear(); while (dataReader.Read()) { if (dataReader["Loading_Code"].ToString().Replace(" ", "") != "") { string[] row = new string[] { dataReader["Loading_Code"].ToString(), dataReader["ProgCourse_Code"].ToString(), dataReader["Venue"].ToString(), dataReader["Lecture_Time"].ToString(), dataReader["Semester"].ToString(), dataReader["Academic_Year"].ToString(), dataReader["Staff_No"].ToString(), GetStaff(dataReader["Staff_No"].ToString()) }; dataGridView1.Rows.Add(row); } } connect.CloseConnection(); PrintDialog printDial = new PrintDialog(); printDial.Document = printDocument1; printDial.UseEXDialog = true; if (DialogResult.OK == printDial.ShowDialog()) { printDocument1.DocumentName = "Loading Details"; printDocument1.Print(); } } } }
private void btnSave_Click(object sender, EventArgs e) { if (txtLoadingCode.Text.Replace(" ", "") == "" && cboLoadingCode.Visible == false) { MessageBox.Show("Ensure all fields are filled!", "MMUST CIMS", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); txtLoadingCode.Focus(); } else if (cboLoadingCode.Text.Replace(" ", "") == "" && cboLoadingCode.Visible == true) { MessageBox.Show("Ensure all fields are filled!", "MMUST CIMS", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); txtLoadingCode.Focus(); } else if (cboCourse.Text.Replace(" ", "") == "") { MessageBox.Show("Ensure all fields are filled!", "MMUST CIMS", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); cboCourse.Focus(); } else if (txtVenue.Text.Replace(" ", "") == "") { MessageBox.Show("Ensure all fields are filled!", "MMUST CIMS", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); txtVenue.Focus(); } else if (txtTime.Text.Replace(" ", "") == "") { MessageBox.Show("Ensure all fields are filled!", "MMUST CIMS", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); txtTime.Focus(); } else if (cboSemester.Text.Replace(" ", "") == "") { MessageBox.Show("Ensure all fields are filled!", "MMUST CIMS", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); cboSemester.Focus(); } else if (cboAcYr.Text.Replace(" ", "") == "") { MessageBox.Show("Ensure all fields are filled!", "MMUST CIMS", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); cboAcYr.Focus(); } else if (cboStaffName.Text.Replace(" ", "") == "") { MessageBox.Show("Ensure all fields are filled!", "MMUST CIMS", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); cboStaffName.Focus(); } else { string msg = ""; int op; if (lodCode == "") { if (FindRecord(txtLoadingCode.Text.ToString()) == false) { query = "INSERT INTO loading VALUES('" + txtLoadingCode.Text.ToString() + "', '" + cboCourse.Text.ToString() + "','" + txtVenue.Text + "', '" + txtTime.Text.ToString() + "','" + cboSemester.Text.ToString() + "','" + cboAcYr.Text.ToString() + "','" + lblStaffNo.Text + "')"; msg = "Records have been successfully saved"; op = 0; } else { query = "UPDATE loading SET Loading_Code='" + txtLoadingCode.Text + "',ProgCourse_Code='" + cboCourse.Text.ToString() + "', Venue= '" + txtVenue.Text.ToString() + "', Lecture_Time='" + txtTime.Text.ToString() + "', Semester='" + cboSemester.Text.ToString() + "', Academic_Year='" + cboAcYr.Text + "',Staff_No='" + lblStaffNo.Text + "' WHERE Loading_Code='" + txtLoadingCode.Text.ToString() + "'"; msg = "Records have been Successfully updated!"; op = 1; } } else { query = "UPDATE loading SET Loading_Code='" + cboLoadingCode.Text + "',ProgCourse_Code='" + cboCourse.Text.ToString() + "', Venue= '" + txtVenue.Text.ToString() + "', Lecture_Time='" + txtTime.Text.ToString() + "',Semester='" + cboSemester.Text.ToString() + "',Academic_Year='" + cboAcYr.Text + "',Staff_No='" + lblStaffNo.Text + "' WHERE Loading_Code='" + lodCode + "'"; msg = "Records have been Successfully updated!"; op = 1; } //open connection Conn connect = new Conn(); connect.CloseConnection(); if (connect.OpenConnection() == true) { if (op == 0) { optn = "Are you sure you want to Insert these details?"; //optn = MessageBox.Show("Are you sure you want to Insert these details?", "MMUST CIMS", MessageBoxButtons.YesNo,MessageBoxIcon.Question); } else { optn = optn = "Are you sure you want to update these details?"; //optn = MessageBox.Show("Are you sure you want to update these details?", "MMUST CIMS", MessageBoxButtons.YesNoMessageBoxIcon.Question); } if (MessageBox.Show(optn, "MMUST CIMS", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { //create command and assign the query and connection from the constructor MySqlCommand cmd = new MySqlCommand(query, connect.connection); //Execute command cmd.ExecuteNonQuery(); //close connection clean(); MessageBox.Show(msg, "MMUST CIMS", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { clean(); MessageBox.Show("Changes not Effected!", "MMUST CIMS", MessageBoxButtons.OK, MessageBoxIcon.Information); } connect.CloseConnection(); GetLoadings(); } } }
private void btnPostLoading_Click(object sender, EventArgs e) { string msg = ""; Conn connect = new Conn(); Conn connect1 = new Conn(); Conn connect2 = new Conn(); Conn connect3 = new Conn(); Conn connect4 = new Conn(); Conn connect5 = new Conn(); string query1, query2, query3, query4, query5; connect.CloseConnection(); if (connect.OpenConnection() == true) { query = "DELETE FROM lecturer_enquiry"; //create command and assign the query and connection from the constructor MySqlCommand cmd = new MySqlCommand(query, connect.connection); //Execute command cmd.ExecuteNonQuery(); //close connection } connect.CloseConnection(); if (connect1.OpenConnection() == true) { query1 = "SELECT DISTINCT Staff_No FROM loading ORDER BY Staff_No ASC"; MySqlCommand cmd1 = new MySqlCommand(query1, connect1.connection); MySqlDataReader dataReader1 = cmd1.ExecuteReader(); //Read the data and store them in the list while (dataReader1.Read()) { if (connect2.OpenConnection() == true) { query2 = "SELECT DISTINCT Academic_Year FROM loading WHERE Staff_No='" + dataReader1["Staff_No"].ToString() + "' ORDER BY Academic_Year ASC"; MySqlCommand cmd2 = new MySqlCommand(query2, connect2.connection); MySqlDataReader dataReader2 = cmd2.ExecuteReader(); while (dataReader2.Read()) { if (connect3.OpenConnection() == true) { query3 = "SELECT DISTINCT Semester FROM loading WHERE Academic_Year='" + dataReader2["Academic_Year"].ToString() + "' AND Staff_No='" + dataReader1["Staff_No"].ToString() + "' ORDER BY Semester ASC"; MySqlCommand cmd3 = new MySqlCommand(query3, connect3.connection); MySqlDataReader dataReader3 = cmd3.ExecuteReader(); while (dataReader3.Read()) { if (connect4.OpenConnection() == true) { query4 = "SELECT * FROM loading WHERE Semester='" + dataReader3["Semester"] + "' and Academic_Year='" + dataReader2["Academic_Year"] + "' and Staff_No='" + dataReader1["Staff_No"].ToString() + "' ORDER BY Semester ASC"; MySqlCommand cmd4 = new MySqlCommand(query4, connect4.connection); MySqlDataReader dataReader4 = cmd4.ExecuteReader(); msg = ""; while (dataReader4.Read()) { msg = msg + " " + dataReader4["ProgCourse_Code"]; } if (connect5.OpenConnection() == true) { query5 = "INSERT INTO lecturer_enquiry(Academic_Year,Semester,Staff_No,Message) VALUES('" + dataReader4["Academic_Year"] + "', '" + dataReader4["Semester"] + "', '" + dataReader4["Staff_No"] + "','" + msg + "')"; MySqlCommand cmd5 = new MySqlCommand(query5, connect5.connection); //Execute command cmd5.ExecuteNonQuery(); } connect5.CloseConnection(); } connect4.CloseConnection(); } //MessageBox.Show("Connection3"); } connect3.CloseConnection(); } //MessageBox.Show("Connection2"); } connect2.CloseConnection(); } //MessageBox.Show("Connection1"); } connect1.CloseConnection(); MessageBox.Show("Posting Complete!", "MMUST", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); }
private void btnDelete_Click(object sender, EventArgs e) { if (cboLoadingCode.Visible == false) { MessageBox.Show("Select Records to Delete", "MMUST CIMS", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); cboLoadingCode.Visible = true; cboLoadingCode.Focus(); } else if (cboLoadingCode.Text.Replace(" ", "") == "" && cboLoadingCode.Visible == true) { MessageBox.Show("Ensure all fields are filled!", "MMUST CIMS", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); txtLoadingCode.Focus(); } else if (cboCourse.Text.Replace(" ", "") == "") { MessageBox.Show("Ensure all fields are filled!", "MMUST CIMS", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); cboCourse.Focus(); } else if (txtVenue.Text.Replace(" ", "") == "") { MessageBox.Show("Ensure all fields are filled!", "MMUST CIMS", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); txtVenue.Focus(); } else if (txtTime.Text.Replace(" ", "") == "") { MessageBox.Show("Ensure all fields are filled!", "MMUST CIMS", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); txtTime.Focus(); } else if (cboSemester.Text.Replace(" ", "") == "") { MessageBox.Show("Ensure all fields are filled!", "MMUST CIMS", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); cboSemester.Focus(); } else if (cboAcYr.Text.Replace(" ", "") == "") { MessageBox.Show("Ensure all fields are filled!", "MMUST CIMS", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); cboAcYr.Focus(); } else if (cboStaffName.Text.Replace(" ", "") == "") { MessageBox.Show("Ensure all fields are filled!", "MMUST CIMS", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); cboStaffName.Focus(); } else { Conn connect = new Conn(); connect.CloseConnection(); if (connect.OpenConnection() == true) { if (MessageBox.Show("Are you sure you want to delete these details?", "MMUST CIMS", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { query = "DELETE FROM loading WHERE Loading_Code='" + cboLoadingCode.Text + "'"; //create command and assign the query and connection from the constructor MySqlCommand cmd = new MySqlCommand(query, connect.connection); //Execute command cmd.ExecuteNonQuery(); //close connection clean(); MessageBox.Show("Records Successfully Deleted!", "MMUST CIMS", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { clean(); MessageBox.Show("Records Not Deleted!", "MMUST CIMS", MessageBoxButtons.OK, MessageBoxIcon.Information); } connect.CloseConnection(); GetLoadings(); } } }
private void btnSave_Click(object sender, EventArgs e) { int units; string unt = txtUnits.Text.Trim().ToString(); txtCourseCode.Text = txtCourseCode.Text.ToUpper(); cboCourseCode.Text = cboCourseCode.Text.ToUpper(); if (txtCourseCode.Text.Replace(" ", "") == "" && cboCourseCode.Visible == false) { MessageBox.Show("Ensure all fields are filled!", "MMUST CIMS", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); txtCourseCode.Focus(); } else if (cboCourseCode.Text.Replace(" ", "") == "" && cboCourseCode.Visible == true) { MessageBox.Show("Ensure all fields are filled!", "MMUST CIMS", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); txtCourseCode.Focus(); } else if (txtCourseName.Text.Replace(" ", "") == "") { MessageBox.Show("Ensure all fields are filled!", "MMUST CIMS", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); txtCourseName.Focus(); } else if (txtDescription.Text.Replace(" ", "") == "") { MessageBox.Show("Ensure all fields are filled!", "MMUST CIMS", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); txtDescription.Focus(); } else if (cboSemCode.Text.Replace(" ", "") == "") { MessageBox.Show("Ensure all fields are filled!", "MMUST CIMS", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); cboSemCode.Focus(); } else if (cboYoS.Text.Replace(" ", "") == "") { MessageBox.Show("Ensure all fields are filled!", "MMUST CIMS", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); cboYoS.Focus(); } else if (txtUnits.Text.Replace(" ", "") == "") { MessageBox.Show("Ensure all fields are filled!", "MMUST CIMS", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); txtUnits.Focus(); } else if (!int.TryParse(unt, out units)) { MessageBox.Show("Invalid data!", "MMUST CIMS", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); txtUnits.Focus(); } else { string msg = ""; int op; if (cosCode == "") { if (FindRecord(txtCourseCode.Text.ToString()) == false) { query = "INSERT INTO course VALUES('" + txtCourseCode.Text.ToString() + "', '" + txtCourseName.Text.ToString() + "','" + txtDescription.Text + "', '" + cboSemCode.Text.ToString() + "','" + cboYoS.Text.ToString() + "'," + units + ")"; msg = "Records have been successfully saved"; op = 0; } else { query = "UPDATE course SET Course_Code='" + txtCourseCode.Text.ToString() + "', Course_Name= '" + txtCourseName.Text.ToString() + "', Description='" + txtDescription.Text.ToString() + "', Semester='" + cboSemCode.Text.ToString() + "', Year_of_Study='" + cboYoS.Text + "',Units=" + units + " WHERE Course_Code='" + txtCourseCode.Text.ToString() + "'"; msg = "Records have been Successfully updated!"; op = 1; } } else { query = "UPDATE course SET Course_Code='" + cboCourseCode.Text.ToString() + "', Course_Name= '" + txtCourseName.Text.ToString() + "', Description='" + txtDescription.Text.ToString() + "',Semester='" + cboSemCode.Text.ToString() + "',Year_of_Study='" + cboYoS.Text + "',Units=" + units + " WHERE Course_Code='" + cosCode + "'"; msg = "Records have been Successfully updated!"; op = 1; } //open connection Conn connect = new Conn(); connect.CloseConnection(); if (connect.OpenConnection() == true) { if (op == 0) { optn = "Are you sure you want to Insert these details?"; //optn = MessageBox.Show("Are you sure you want to Insert these details?", "MMUST CIMS", MessageBoxButtons.YesNo,MessageBoxIcon.Question); } else { optn = optn = "Are you sure you want to update these details?"; //optn = MessageBox.Show("Are you sure you want to update these details?", "MMUST CIMS", MessageBoxButtons.YesNoMessageBoxIcon.Question); } if (MessageBox.Show(optn, "MMUST CIMS", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { //create command and assign the query and connection from the constructor MySqlCommand cmd = new MySqlCommand(query, connect.connection); //Execute command cmd.ExecuteNonQuery(); //close connection clean(); MessageBox.Show(msg, "MMUST CIMS", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { clean(); MessageBox.Show("Changes not Effected!", "MMUST CIMS", MessageBoxButtons.OK, MessageBoxIcon.Information); } connect.CloseConnection(); GetCourses(); } } }
private void btnSave_Click(object sender, EventArgs e) { txtFacultyCode.Text = txtFacultyCode.Text.ToUpper(); cboFacultyCode.Text = cboFacultyCode.Text.ToUpper(); if (txtFacultyCode.Text.Replace(" ", "") == "" && cboFacultyCode.Visible == false) { MessageBox.Show("Ensure all fields are filled!", "MMUST CIMS", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); txtFacultyCode.Focus(); } else if (cboFacultyCode.Text.Replace(" ", "") == "" && cboFacultyCode.Visible == true) { MessageBox.Show("Ensure all fields are filled!", "MMUST CIMS", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); cboFacultyCode.Focus(); } else if (txtFacultyName.Text.Replace(" ", "") == "") { MessageBox.Show("Ensure all fields are filled!", "MMUST CIMS", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); txtFacultyName.Focus(); } else if (txtDescription.Text.Replace(" ", "") == "") { MessageBox.Show("Ensure all fields are filled!", "MMUST CIMS", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); txtDescription.Focus(); } else { string msg = ""; int op; if (facCode == "") { if (FindRecord(txtFacultyCode.Text.ToString()) == false) { query = "INSERT INTO faculty VALUES('" + txtFacultyCode.Text.ToString() + "', '" + txtFacultyName.Text.ToString() + "', '" + txtDescription.Text.ToString() + "')"; msg = "Records have been successfully saved"; op = 0; } else { query = "UPDATE faculty SET Faculty_Code='" + txtFacultyCode.Text.ToString() + "', Faculty_Name= '" + txtFacultyName.Text.ToString() + "', Description='" + txtDescription.Text.ToString() + "' WHERE Faculty_Code='" + txtFacultyCode.Text.ToString() + "'"; msg = "Records have been Successfully updated!"; op = 1; } } else { query = "UPDATE faculty SET Faculty_Code='" + cboFacultyCode.Text.ToString() + "', Faculty_Name= '" + txtFacultyName.Text.ToString() + "', Description='" + txtDescription.Text.ToString() + "' WHERE Faculty_Code='" + facCode + "'"; msg = "Records have been Successfully updated!"; op = 1; } //open connection Conn connect = new Conn(); if (connect.OpenConnection() == true) { if (op == 0) { optn = "Are you sure you want to Insert these details?"; //optn = MessageBox.Show("Are you sure you want to Insert these details?", "MMUST CIMS", MessageBoxButtons.YesNo,MessageBoxIcon.Question); } else { optn = optn = "Are you sure you want to update these details?"; //optn = MessageBox.Show("Are you sure you want to update these details?", "MMUST CIMS", MessageBoxButtons.YesNoMessageBoxIcon.Question); } if (MessageBox.Show(optn, "MMUST CIMS", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { //create command and assign the query and connection from the constructor MySqlCommand cmd = new MySqlCommand(query, connect.connection); //Execute command cmd.ExecuteNonQuery(); //close connection clean(); MessageBox.Show(msg, "MMUST CIMS", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { clean(); MessageBox.Show("Changes not Effected!", "MMUST CIMS", MessageBoxButtons.OK, MessageBoxIcon.Information); } connect.CloseConnection(); GetFaculties(); } } }
private void btnPrint_Click(object sender, EventArgs e) { if (cboSearchCriteria.Text.Replace(" ", "") == "") { MessageBox.Show("Ensure all fields are filled!", "MMUST CIMS", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); cboSearchCriteria.Focus(); } else if (txtSearchValue.Text.Replace(" ", "") == "") { MessageBox.Show("Ensure all fields are filled!", "MMUST CIMS", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); txtSearchValue.Focus(); } else { Conn connect = new Conn(); if (connect.OpenConnection() == true) { string searchval = "%" + txtSearchValue.Text + "%"; if (cboSearchCriteria.Text == "All") { query = "SELECT * FROM faculty ORDER BY Faculty_Code ASC"; } else if (cboSearchCriteria.Text == "Faculty Code") { query = "SELECT * FROM faculty WHERE Faculty_Code LIKE '" + searchval + "' ORDER BY Faculty_Code ASC"; } else if (cboSearchCriteria.Text == "Faculty Name") { query = "SELECT * FROM faculty WHERE Faculty_Name LIKE '" + searchval + "' ORDER BY Faculty_Code ASC"; } else { MessageBox.Show("Invalid Criteria", "MMUST CIMS", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); cboSearchCriteria.Focus(); } MySqlCommand cmd = new MySqlCommand(query, connect.connection); MySqlDataReader dataReader = cmd.ExecuteReader(); //Read the data and store them in the list this.dataGridView1.Rows.Clear(); while (dataReader.Read()) { if (dataReader["Faculty_Code"].ToString().Replace(" ", "") != "") { string[] row = new string[] { dataReader["Faculty_Code"].ToString(), dataReader["Faculty_Name"].ToString(), dataReader["Description"].ToString() }; dataGridView1.Rows.Add(row); } } connect.CloseConnection(); PrintDialog printDial = new PrintDialog(); printDial.Document = printDocument1; printDial.UseEXDialog = true; if (DialogResult.OK == printDial.ShowDialog()) { printDocument1.DocumentName = "Faculty Details"; printDocument1.Print(); } } } }