Esempio n. 1
0
        private bool FindRecord(string scode)
        {
            Conn connect = new Conn();

            if (connect.OpenConnection() == true)
            {
                query = "SELECT * FROM student WHERE Reg_No='" + scode + "'";
                MySqlCommand    cmd        = new MySqlCommand(query, connect.connection);
                MySqlDataReader dataReader = cmd.ExecuteReader();
                //Read the data and store them in the list
                if (dataReader.Read())
                {
                    connect.CloseConnection();
                    return(true);
                }
                else
                {
                    connect.CloseConnection();
                    return(false);
                }
            }
            else
            {
                return(true);
            }
        }
Esempio n. 2
0
        private bool FindRecord2(string scode)
        {
            Conn connect = new Conn();

            if (connect.OpenConnection() == true)
            {
                query = "SELECT * FROM staff WHERE Staff_No='" + Sessions.userID + "' and Phone_No='" + Sessions.phoneNo + "' and Passsword='" + scode + "'";

                MySqlCommand    cmd        = new MySqlCommand(query, connect.connection);
                MySqlDataReader dataReader = cmd.ExecuteReader();
                //Read the data and store them in the list
                if (dataReader.Read())
                {
                    if (dataReader["Passsword"].ToString() == scode && dataReader["Phone_No"].ToString() == Sessions.phoneNo && dataReader["Staff_No"].ToString() == Sessions.userID)
                    {
                        connect.CloseConnection();
                        return(true);
                    }
                    else
                    {
                        connect.CloseConnection();
                        return(false);
                    }
                }
                else
                {
                    connect.CloseConnection();
                    return(false);
                }
            }
            else
            {
                return(true);
            }
        }
Esempio n. 3
0
        private void btnDelete_Click(object sender, EventArgs e)
        {
            if (cboCourseProgCode.Visible == false)
            {
                MessageBox.Show("Select Records to Delete", "MMUST CIMS", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                cboCourseProgCode.Visible = true;
                cboCourseProgCode.Focus();
            }
            else if (cboCourseProgCode.Text.Replace(" ", "") == "" && cboCourseProgCode.Visible == true)
            {
                MessageBox.Show("Ensure all fields are filled!", "MMUST CIMS", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                cboCourseProgCode.Focus();
            }
            else if (cboCourseCode.Text.Replace(" ", "") == "")
            {
                MessageBox.Show("Ensure all fields are filled!", "MMUST CIMS", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                cboCourseCode.Focus();
            }
            else if (cboSemester.Text.Replace(" ", "") == "")
            {
                MessageBox.Show("Ensure all fields are filled!", "MMUST CIMS", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                cboSemester.Focus();
            }
            else if (cboYoS.Text.Replace(" ", "") == "")
            {
                MessageBox.Show("Ensure all fields are filled!", "MMUST CIMS", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                cboYoS.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 program_course WHERE ProgCourse_Code='" + cboCourseProgCode.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();
                    GetProgCourses();
                }
            }
        }
Esempio n. 4
0
        private void cboLoadingCode_SelectedIndexChanged(object sender, EventArgs e)
        {
            Conn connect = new Conn();

            if (connect.OpenConnection() == true)
            {
                query = "SELECT * FROM loading WHERE Loading_Code='" + cboLoadingCode.Text.ToString() + "'";
                MySqlCommand    cmd        = new MySqlCommand(query, connect.connection);
                MySqlDataReader dataReader = cmd.ExecuteReader();
                //Read the data and store them in the list
                if (dataReader.Read())
                {
                    cboLoadingCode.Text = dataReader["Loading_Code"].ToString();
                    cboCourse.Text      = dataReader["ProgCourse_Code"].ToString();
                    cboSemester.Text    = dataReader["Semester"].ToString();
                    txtVenue.Text       = dataReader["Venue"].ToString();
                    txtTime.Text        = dataReader["Lecture_Time"].ToString();
                    cboAcYr.Text        = dataReader["Academic_Year"].ToString();
                    cboStaffName.Text   = GetStaff(dataReader["Staff_No"].ToString());
                    lblStaffNo.Text     = dataReader["Staff_No"].ToString();
                    lodCode             = cboLoadingCode.Text;
                }
                connect.CloseConnection();
            }
        }
Esempio n. 5
0
        private void cboRegNo_SelectedIndexChanged(object sender, EventArgs e)
        {
            Conn connect = new Conn();

            if (connect.OpenConnection() == true)
            {
                query = "SELECT * FROM student WHERE Reg_No='" + cboRegNo.Text.ToString() + "'";
                MySqlCommand    cmd        = new MySqlCommand(query, connect.connection);
                MySqlDataReader dataReader = cmd.ExecuteReader();
                //Read the data and store them in the list
                if (dataReader.Read())
                {
                    txtStudentName.Text   = dataReader["Student_Name"].ToString();
                    cboProgCode.Text      = dataReader["Program_Code"].ToString();
                    cboSemester.Text      = dataReader["Semester"].ToString();
                    cboYoS.Text           = dataReader["Year_of_Study"].ToString();
                    txtPostalAddress.Text = dataReader["Postal_Address"].ToString();
                    txtPostalCode.Text    = dataReader["Postal_Code"].ToString();
                    txtTown.Text          = dataReader["Town"].ToString();
                    txtResidence.Text     = dataReader["Residence"].ToString();
                    txtEmail.Text         = dataReader["Email_Address"].ToString();
                    txtPhoneNo.Text       = dataReader["Phone_No"].ToString();
                    if (dataReader["Status"].ToString() == "1")
                    {
                        chkStatus.CheckState = CheckState.Checked;
                    }
                    else
                    {
                        chkStatus.CheckState = CheckState.Unchecked;
                    }
                    studentCode = cboRegNo.Text;
                }
                connect.CloseConnection();
            }
        }
Esempio n. 6
0
        private void btnFind_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 program ORDER BY Program_Code ASC";
                    }
                    else if (cboSearchCriteria.Text == "Department Code")
                    {
                        query = "SELECT * FROM program WHERE Department_Code LIKE '" + searchval + "' ORDER BY Program_Code ASC";
                    }
                    else if (cboSearchCriteria.Text == "Program Code")
                    {
                        query = "SELECT * FROM program WHERE Program_Code LIKE '" + searchval + "' ORDER BY Program_Code ASC";
                    }
                    else if (cboSearchCriteria.Text == "Program Name")
                    {
                        query = "SELECT * FROM department WHERE Program_Name LIKE '" + searchval + "' ORDER BY Program_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["Program_Code"].ToString().Replace(" ", "") != "")
                        {
                            string[] row = new string[] { dataReader["Program_Code"].ToString(), dataReader["Program_Name"].ToString(), dataReader["Department_Code"].ToString(), dataReader["Description"].ToString() };
                            dataGridView1.Rows.Add(row);
                        }
                    }


                    connect.CloseConnection();
                }
            }
        }
Esempio n. 7
0
        private void btnQuit_Click(object sender, EventArgs e)
        {
            //this.Dispose();
            Conn connn = new Conn();

            connn.CloseConnection();
            Application.Exit();
        }
Esempio n. 8
0
        private void frmLogin_Load(object sender, EventArgs e)
        {
            Conn connn = new Conn();

            connn.CloseConnection();
            lblConfirmPassword.Visible = false;
            lblStaffNo.Text            = "Staff No:";
            lblPhoneNo.Text            = "Phone No:";
            gboxReset.Visible          = false;
            groupBox1.Left             = (this.ClientSize.Width - groupBox1.Width) / 2;
            groupBox1.Top = (this.ClientSize.Height - groupBox1.Height) / 2;
        }
Esempio n. 9
0
        private void cboStaffNo_SelectedIndexChanged(object sender, EventArgs e)
        {
            Conn connect = new Conn();

            if (connect.OpenConnection() == true)
            {
                query = "SELECT * FROM staff WHERE Staff_No='" + cboStaffNo.Text.ToString() + "'";
                MySqlCommand    cmd        = new MySqlCommand(query, connect.connection);
                MySqlDataReader dataReader = cmd.ExecuteReader();
                //Read the data and store them in the list
                if (dataReader.Read())
                {
                    cboStaffNo.Text         = dataReader["Staff_No"].ToString();
                    txtPfNo.Text            = dataReader["Pf_No"].ToString();
                    txtStaffName.Text       = dataReader["Staff_Name"].ToString();
                    txtDesignation.Text     = dataReader["Designation"].ToString();
                    cboDepCode.Text         = dataReader["Department_Code"].ToString();
                    txtStaffID.Text         = dataReader["Staff_ID"].ToString();
                    txtPostalAddress.Text   = dataReader["Postal_Address"].ToString();
                    txtPostalCode.Text      = dataReader["Postal_Code"].ToString();
                    txtTown.Text            = dataReader["Town"].ToString();
                    txtResidence.Text       = dataReader["Residence"].ToString();
                    txtEmail.Text           = dataReader["Email_Address"].ToString();
                    txtPhoneNo.Text         = dataReader["Phone_No"].ToString();
                    txtOffice.Text          = dataReader["Office"].ToString();
                    txtTimeAvailable.Text   = dataReader["Time_Available"].ToString();
                    txtLoginName.Text       = dataReader["Login_Name"].ToString();
                    txtPassword.Text        = dataReader["Passsword"].ToString();
                    txtConfirmPassword.Text = dataReader["Passsword"].ToString();
                    cboPriviledges.Text     = dataReader["Priviledges"].ToString();
                    if (dataReader["Status"].ToString() == "1")
                    {
                        chkStatus.CheckState = CheckState.Checked;
                    }
                    else
                    {
                        chkStatus.CheckState = CheckState.Unchecked;
                    }
                    staffCode = cboStaffNo.Text;
                }
                connect.CloseConnection();
            }
        }
Esempio n. 10
0
        private void cboFacultyCode_SelectedIndexChanged(object sender, EventArgs e)
        {
            Conn connect = new Conn();

            if (connect.OpenConnection() == true)
            {
                query = "SELECT * FROM faculty WHERE Faculty_Code='" + cboFacultyCode.Text.ToString() + "'";
                MySqlCommand    cmd        = new MySqlCommand(query, connect.connection);
                MySqlDataReader dataReader = cmd.ExecuteReader();
                //Read the data and store them in the list
                if (dataReader.Read())
                {
                    txtFacultyName.Text = dataReader["Faculty_Name"].ToString();
                    txtDescription.Text = dataReader["Description"].ToString();
                    facCode             = cboFacultyCode.Text;
                }
                connect.CloseConnection();
            }
        }
Esempio n. 11
0
        private void GetStaffs()
        {
            Conn connect = new Conn();

            if (connect.OpenConnection() == true)
            {
                query = "SELECT * FROM staff WHERE Priviledges='Staff' ORDER BY Staff_Name ASC";
                MySqlCommand    cmd        = new MySqlCommand(query, connect.connection);
                MySqlDataReader dataReader = cmd.ExecuteReader();
                //Read the data and store them in the list
                this.cboStaffName.Items.Clear();
                while (dataReader.Read())
                {
                    if (dataReader["Staff_Name"].ToString().Replace(" ", "") != "")
                    {
                        this.cboStaffName.Items.Add(dataReader["Staff_Name"].ToString());
                    }
                }
                connect.CloseConnection();
            }
        }
Esempio n. 12
0
        private void GetStudent()
        {
            Conn connect = new Conn();

            if (connect.OpenConnection() == true)
            {
                query = "SELECT * FROM student ORDER BY Reg_No ASC";
                MySqlCommand    cmd        = new MySqlCommand(query, connect.connection);
                MySqlDataReader dataReader = cmd.ExecuteReader();
                //Read the data and store them in the list
                this.cboRegNo.Items.Clear();
                while (dataReader.Read())
                {
                    if (dataReader["Reg_No"].ToString().Replace(" ", "") != "")
                    {
                        this.cboRegNo.Items.Add(dataReader["Reg_No"].ToString());
                    }
                }
                connect.CloseConnection();
            }
        }
Esempio n. 13
0
        private void cboProgramCode_SelectedIndexChanged(object sender, EventArgs e)
        {
            Conn connect = new Conn();

            if (connect.OpenConnection() == true)
            {
                query = "SELECT * FROM program WHERE Program_Code='" + cboProgramCode.Text.ToString() + "'";
                MySqlCommand    cmd        = new MySqlCommand(query, connect.connection);
                MySqlDataReader dataReader = cmd.ExecuteReader();
                //Read the data and store them in the list
                if (dataReader.Read())
                {
                    cboProgramCode.Text = dataReader["Program_Code"].ToString();
                    cboDepCode.Text     = dataReader["Department_Code"].ToString();
                    txtProgName.Text    = dataReader["Program_Name"].ToString();
                    txtDescription.Text = dataReader["Description"].ToString();
                    progCode            = cboProgramCode.Text;
                }
                connect.CloseConnection();
            }
        }
Esempio n. 14
0
        private void GetPrograms()
        {
            Conn connect = new Conn();

            if (connect.OpenConnection() == true)
            {
                query = "SELECT * FROM program ORDER BY Program_Code ASC";
                MySqlCommand    cmd        = new MySqlCommand(query, connect.connection);
                MySqlDataReader dataReader = cmd.ExecuteReader();
                //Read the data and store them in the list
                this.cboProgCode.Items.Clear();
                while (dataReader.Read())
                {
                    if (dataReader["Program_Code"].ToString().Replace(" ", "") != "")
                    {
                        this.cboProgCode.Items.Add(dataReader["Program_Code"].ToString());
                    }
                }
                connect.CloseConnection();
            }
        }
Esempio n. 15
0
        private void AssignStaffNo()
        {
            Conn connect = new Conn();

            if (connect.OpenConnection() == true)
            {
                query = "SELECT * FROM staff ORDER BY Staff_No DESC";
                MySqlCommand    cmd        = new MySqlCommand(query, connect.connection);
                MySqlDataReader dataReader = cmd.ExecuteReader();
                //Read the data and store them in the list
                //this.cboStaffNo.Items.Clear();
                int stffNo;
                if (dataReader.Read())
                {
                    if (dataReader["Staff_No"].ToString().Replace(" ", "") != "")
                    {
                        stffNo = Convert.ToInt32((dataReader["Staff_No"].ToString().Substring(4)));
                        if (stffNo < 9)
                        {
                            txtStaffNo.Text = "EMP/000" + (stffNo + 1);
                        }
                        else if (stffNo >= 9 && stffNo < 99)
                        {
                            txtStaffNo.Text = "EMP/00" + (stffNo + 1);
                        }
                        else if (stffNo >= 99 && stffNo < 999)
                        {
                            txtStaffNo.Text = "EMP/0" + (stffNo + 1);
                        }
                        else
                        {
                            txtStaffNo.Text = "EMP/" + (stffNo + 1);
                        }

                        //MessageBox.Show(txtStaffNo.Text);
                    }
                }
                connect.CloseConnection();
            }
        }
Esempio n. 16
0
        private void cboCourseProgCode_SelectedIndexChanged(object sender, EventArgs e)
        {
            Conn connect = new Conn();

            if (connect.OpenConnection() == true)
            {
                query = "SELECT * FROM program_course WHERE ProgCourse_Code='" + cboCourseProgCode.Text.ToString() + "'";
                MySqlCommand    cmd        = new MySqlCommand(query, connect.connection);
                MySqlDataReader dataReader = cmd.ExecuteReader();
                //Read the data and store them in the list
                if (dataReader.Read())
                {
                    cboCourseCode.Text     = dataReader["Course_Code"].ToString();
                    cboSemester.Text       = dataReader["Semester"].ToString();
                    cboProgCode.Text       = dataReader["Program_Code"].ToString();
                    cboCourseProgCode.Text = dataReader["ProgCourse_Code"].ToString();
                    cboYoS.Text            = dataReader["Year_of_Study"].ToString();
                    cosProgCode            = cboCourseProgCode.Text;
                }
                connect.CloseConnection();
            }
        }
Esempio n. 17
0
        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);
        }
Esempio n. 18
0
        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();
                    }
                }
            }
        }
Esempio n. 19
0
        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();
                }
            }
        }
Esempio n. 20
0
        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 (cboYoSSearch.Text.Replace(" ", "") == "")
            {
                MessageBox.Show("Ensure all fields are filled!", "MMUST CIMS", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                cboYoSSearch.Focus();
            }
            else
            {
                Conn connect = new Conn();
                int  sts;
                if (chkStatusSearch.CheckState == CheckState.Checked)
                {
                    sts = 1;
                }
                else
                {
                    sts = 0;
                }
                if (connect.OpenConnection() == true)
                {
                    string searchval = "%" + txtSearchValue.Text + "%";
                    if (cboSearchCriteria.Text == "All")
                    {
                        query = "SELECT * FROM student WHERE Semester='" + cboSemesterSearch.Text + "' AND Year_of_Study='" + cboYoSSearch.Text + "' AND Status=" + sts + " ORDER BY Reg_No ASC";
                    }
                    else if (cboSearchCriteria.Text == "Reg No")
                    {
                        query = "SELECT * FROM student WHERE Reg_No LIKE '" + searchval + "' AND Semester='" + cboSemesterSearch.Text + "' AND Year_of_Study='" + cboYoSSearch.Text + "' AND Status=" + sts + " ORDER BY Reg_No ASC";
                    }
                    else if (cboSearchCriteria.Text == "Name")
                    {
                        query = "SELECT * FROM student WHERE Student_Name LIKE '" + searchval + "' AND Semester='" + cboSemesterSearch.Text + "' AND Year_of_Study='" + cboYoSSearch.Text + "' AND Status=" + sts + " ORDER BY Reg_No ASC";
                    }
                    else if (cboSearchCriteria.Text == "Program")
                    {
                        query = "SELECT * FROM student WHERE Program_Code LIKE '" + searchval + "' AND Semester='" + cboSemesterSearch.Text + "' AND Year_of_Study='" + cboYoSSearch.Text + "' AND Status=" + sts + " ORDER BY Reg_No ASC";
                    }
                    else if (cboSearchCriteria.Text == "Phone No")
                    {
                        query = "SELECT * FROM student WHERE Phone_No LIKE '" + searchval + "' AND Semester='" + cboSemesterSearch.Text + "' AND Year_of_Study='" + cboYoSSearch.Text + "' AND Status=" + sts + " ORDER BY Reg_No 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["Reg_No"].ToString().Replace(" ", "") != "")
                        {
                            string[] row = new string[] { dataReader["Reg_No"].ToString(), dataReader["Student_Name"].ToString(), dataReader["Program_Code"].ToString(), dataReader["Semester"].ToString(), dataReader["Year_of_Study"].ToString(), dataReader["Phone_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 = "Student Details";
                        printDocument1.Print();
                    }
                }
            }
        }
Esempio n. 21
0
        private void btnPostCourses_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 courses_done";
                //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 Program_Code FROM program_course ORDER BY Program_Code 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 Year_of_Study FROM program_course WHERE Program_Code='" + dataReader1["Program_Code"].ToString() + "' ORDER BY Year_of_Study ASC";
                        MySqlCommand    cmd2        = new MySqlCommand(query2, connect2.connection);
                        MySqlDataReader dataReader2 = cmd2.ExecuteReader();
                        while (dataReader2.Read())
                        {
                            if (connect3.OpenConnection() == true)
                            {
                                query3 = "SELECT DISTINCT Semester FROM program_course WHERE Year_of_Study='" + dataReader2["Year_of_Study"].ToString() + "' AND Program_Code='" + dataReader1["Program_Code"].ToString() + "' ORDER BY Course_Code ASC";
                                MySqlCommand    cmd3        = new MySqlCommand(query3, connect3.connection);
                                MySqlDataReader dataReader3 = cmd3.ExecuteReader();
                                while (dataReader3.Read())
                                {
                                    if (connect4.OpenConnection() == true)
                                    {
                                        query4 = "SELECT * FROM program_course WHERE Semester='" + dataReader3["Semester"] + "' and  Year_of_Study='" + dataReader2["Year_of_Study"] + "' and Program_Code='" + dataReader1["Program_Code"].ToString() + "' ORDER BY Course_Code ASC";
                                        MySqlCommand    cmd4        = new MySqlCommand(query4, connect4.connection);
                                        MySqlDataReader dataReader4 = cmd4.ExecuteReader();
                                        msg = "";
                                        while (dataReader4.Read())
                                        {
                                            msg = msg + " " + dataReader4["Course_Code"];
                                        }
                                        if (connect5.OpenConnection() == true)
                                        {
                                            query5 = "INSERT INTO courses_done(Program_Code,Academic_Year,Semester,Message) VALUES('" + dataReader4["Program_Code"].ToString() + "', '" + dataReader4["Year_of_Study"].ToString() + "', '" + dataReader4["Semester"].ToString() + "','" + 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);
        }
Esempio n. 22
0
        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();
                }
            }
        }
Esempio n. 23
0
        private void btnDelete_Click(object sender, EventArgs e)
        {
            if (cboRegNo.Visible == false)
            {
                MessageBox.Show("Select Records to Delete", "MMUST CIMS", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                cboRegNo.Visible = true;
                cboRegNo.Focus();
            }
            else if (cboRegNo.Text.Replace(" ", "") == "" && cboRegNo.Visible == true)
            {
                MessageBox.Show("Ensure all fields are filled!", "MMUST CIMS", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                txtRegNo.Focus();
            }
            else if (txtStudentName.Text.Replace(" ", "") == "")
            {
                MessageBox.Show("Ensure all fields are filled!", "MMUST CIMS", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                txtStudentName.Focus();
            }
            else if (cboProgCode.Text.Replace(" ", "") == "")
            {
                MessageBox.Show("Ensure all fields are filled!", "MMUST CIMS", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                cboProgCode.Focus();
            }
            else if (cboSemester.Text.Replace(" ", "") == "")
            {
                MessageBox.Show("Ensure all fields are filled!", "MMUST CIMS", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                cboSemester.Focus();
            }
            else if (cboYoS.Text.Replace(" ", "") == "")
            {
                MessageBox.Show("Ensure all fields are filled!", "MMUST CIMS", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                cboYoS.Focus();
            }
            else if (txtPostalAddress.Text.Replace(" ", "") == "")
            {
                MessageBox.Show("Ensure all fields are filled!", "MMUST CIMS", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                txtPostalAddress.Focus();
            }
            else if (txtPostalCode.Text.Replace(" ", "") == "")
            {
                MessageBox.Show("Ensure all fields are filled!", "MMUST CIMS", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                txtPostalCode.Focus();
            }
            else if (txtTown.Text.Replace(" ", "") == "")
            {
                MessageBox.Show("Ensure all fields are filled!", "MMUST CIMS", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                txtTown.Focus();
            }
            else if (txtResidence.Text.Replace(" ", "") == "")
            {
                MessageBox.Show("Ensure all fields are filled!", "MMUST CIMS", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                txtResidence.Focus();
            }
            else if (txtEmail.Text.Replace(" ", "") == "")
            {
                MessageBox.Show("Ensure all fields are filled!", "MMUST CIMS", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                txtEmail.Focus();
            }
            else if (txtPhoneNo.Text.Replace(" ", "") == "")
            {
                MessageBox.Show("Ensure all fields are filled!", "MMUST CIMS", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                txtPhoneNo.Focus();
            }
            else if (txtPhoneNo.Text.Length.ToString() != "13" || (txtPhoneNo.Text.Replace("+", "")).ToString() == "")
            {
                MessageBox.Show("Invalid Phone Number!", "MMUST CIMS", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                txtPhoneNo.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 student WHERE Reg_No='" + cboRegNo.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();
                    GetStudent();
                }
            }
        }
Esempio n. 24
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            long   phone;
            string phn        = txtPhoneNo.Text.Replace("+", "").Trim().ToString();
            string postalcode = txtPostalCode.Text.Trim().ToString();
            string stName     = txtStudentName.Text.Trim().ToString();

            if (txtRegNo.Text.Replace(" ", "") == "" && cboRegNo.Visible == false)
            {
                MessageBox.Show("Ensure all fields are filled!", "MMUST CIMS", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                txtRegNo.Focus();
            }
            else if (cboRegNo.Text.Replace(" ", "") == "" && cboRegNo.Visible == true)
            {
                MessageBox.Show("Ensure all fields are filled!", "MMUST CIMS", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                txtRegNo.Focus();
            }
            else if (txtStudentName.Text.Replace(" ", "") == "")
            {
                MessageBox.Show("Ensure all fields are filled!", "MMUST CIMS", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                txtStudentName.Focus();
            }
            else if (IsCharacter(txtStudentName.Text.ToString()))
            {
                MessageBox.Show("Invalid Name!", "MMUST CIMS", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                txtStudentName.Focus();
            }
            else if (cboProgCode.Text.Replace(" ", "") == "")
            {
                MessageBox.Show("Ensure all fields are filled!", "MMUST CIMS", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                cboProgCode.Focus();
            }
            else if (cboSemester.Text.Replace(" ", "") == "")
            {
                MessageBox.Show("Ensure all fields are filled!", "MMUST CIMS", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                cboSemester.Focus();
            }
            else if (cboYoS.Text.Replace(" ", "") == "")
            {
                MessageBox.Show("Ensure all fields are filled!", "MMUST CIMS", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                cboYoS.Focus();
            }
            else if (txtPostalAddress.Text.Replace(" ", "") == "")
            {
                MessageBox.Show("Ensure all fields are filled!", "MMUST CIMS", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                txtPostalAddress.Focus();
            }
            else if (txtPostalCode.Text.Replace(" ", "") == "")
            {
                MessageBox.Show("Ensure all fields are filled!", "MMUST CIMS", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                txtPostalCode.Focus();
            }
            else if (!long.TryParse(postalcode, out phone))
            {
                MessageBox.Show("Invalid Postal Code!", "MMUST CIMS", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                txtPostalCode.Focus();
            }
            else if (txtTown.Text.Replace(" ", "") == "")
            {
                MessageBox.Show("Ensure all fields are filled!", "MMUST CIMS", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                txtTown.Focus();
            }
            else if (txtResidence.Text.Replace(" ", "") == "")
            {
                MessageBox.Show("Ensure all fields are filled!", "MMUST CIMS", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                txtResidence.Focus();
            }
            else if (txtEmail.Text.Replace(" ", "") == "")
            {
                MessageBox.Show("Ensure all fields are filled!", "MMUST CIMS", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                txtEmail.Focus();
            }
            else if (!IsValidEmail(txtEmail.Text.Replace(" ", "").ToString()))
            {
                MessageBox.Show("Invalid Email", "MMUST CIMS", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                txtEmail.Focus();
            }
            else if (txtPhoneNo.Text.Replace(" ", "") == "")
            {
                MessageBox.Show("Ensure all fields are filled!", "MMUST CIMS", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                txtPhoneNo.Focus();
            }
            else if (txtPhoneNo.Text.Length != 13)
            {
                MessageBox.Show("Invalid Phone Number!", "MMUST CIMS", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                txtPhoneNo.Focus();
            }
            else if (!long.TryParse(phn, out phone))
            {
                MessageBox.Show("Invalid Phone Number!", "MMUST CIMS", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                txtPhoneNo.Focus();
            }
            else if (!txtPhoneNo.Text.Contains("+"))
            {
                MessageBox.Show("Invalid Phone Number!", "MMUST CIMS", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                txtPhoneNo.Focus();
            }
            else
            {
                string msg = "";
                int    op;
                int    status;
                if (chkStatus.CheckState == CheckState.Checked)
                {
                    status = 1;
                }
                else
                {
                    status = 0;
                }
                if (studentCode == "")
                {
                    if (FindRecord(txtRegNo.Text.ToString()) == false)
                    {
                        query = "INSERT INTO student VALUES('" + txtRegNo.Text.ToString() + "', '" + txtStudentName.Text.ToString() + "','" + cboProgCode.Text + "', '" + cboSemester.Text.ToString() + "','" + cboYoS.Text.ToString() + "','" + txtPostalAddress.Text + "','" + txtPostalCode.Text + "','" + txtTown.Text + "','" + txtResidence.Text + "','" + txtEmail.Text + "','" + txtPhoneNo.Text + "'," + status + ")";
                        msg   = "Records have been successfully saved";
                        op    = 0;
                    }
                    else
                    {
                        query = "UPDATE student SET Reg_No='" + txtRegNo.Text + "',Student_Name='" + txtStudentName.Text.ToString() + "', Program_Code= '" + cboProgCode.Text.ToString() + "', Semester='" + cboSemester.Text.ToString() + "', Year_of_Study='" + cboYoS.Text.ToString() + "', Postal_Address='" + txtPostalAddress.Text + "',Postal_Code='" + txtPostalCode.Text + "',Town='" + txtTown.Text + "',Residence='" + txtResidence.Text + "',Email_Address='" + txtEmail.Text + "',Phone_No='" + txtPhoneNo.Text + "',Status=" + status + " WHERE Reg_No='" + txtRegNo.Text.ToString() + "'";
                        msg   = "Records have been Successfully updated!";
                        op    = 1;
                    }
                }
                else
                {
                    query = "UPDATE student SET Reg_No='" + cboRegNo.Text + "',Student_Name='" + txtStudentName.Text.ToString() + "', Program_Code= '" + cboProgCode.Text.ToString() + "', Semester='" + cboSemester.Text.ToString() + "', Year_of_Study='" + cboYoS.Text.ToString() + "', Postal_Address='" + txtPostalAddress.Text + "',Postal_Code='" + txtPostalCode.Text + "',Town='" + txtTown.Text + "',Residence='" + txtResidence.Text + "',Email_Address='" + txtEmail.Text + "',Phone_No='" + txtPhoneNo.Text + "',Status=" + status + " WHERE Reg_No='" + studentCode + "'";
                    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 cmdd = new MySqlCommand(query, connect.connection);

                        //Execute command
                        cmdd.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();
                    GetStudent();
                }
            }
        }
Esempio n. 25
0
        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();
                }
            }
        }
Esempio n. 26
0
        private void frmLogin_UnLoad(object sender, EventArgs e)
        {
            Conn connn = new Conn();

            connn.CloseConnection();
        }
Esempio n. 27
0
        private void btnRequest_Click(object sender, EventArgs e)
        {
            if (txtConfirmPassword.Visible == false)
            {
                var    chars       = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
                var    stringChars = new char[8];
                var    random      = new Random();
                long   phone;
                string phn = txtPhoneNo.Text.Replace("+", "").Trim().ToString();

                for (int i = 0; i < stringChars.Length; i++)
                {
                    stringChars[i] = chars[random.Next(chars.Length)];
                }

                var finalString = new String(stringChars);

                if (txtStaffNo.Text == "")
                {
                    MessageBox.Show("Ensure all fields are filled!", "MMUST CIMS", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    txtStaffNo.Focus();
                }
                else if (txtPhoneNo.Text == "")
                {
                    MessageBox.Show("Ensure all fields are filled!", "MMUST CIMS", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    txtPhoneNo.Focus();
                }
                else if (txtPhoneNo.Text.Length != 13)
                {
                    MessageBox.Show("Invalid Phone Number!", "MMUST CIMS", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    txtPhoneNo.Focus();
                }
                else if (!long.TryParse(phn, out phone))
                {
                    MessageBox.Show("Invalid Phone Number!", "MMUST CIMS", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    txtPhoneNo.Focus();
                }
                else if (!txtPhoneNo.Text.Contains("+"))
                {
                    MessageBox.Show("Invalid Phone Number!", "MMUST CIMS", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    txtPhoneNo.Focus();
                }
                else
                {
                    if (FindRecord(txtStaffNo.Text, txtPhoneNo.Text) == true)
                    {
                        //MessageBox.Show(finalString);
                        Sessions.phoneNo = txtPhoneNo.Text.Trim();
                        Sessions.userID  = txtStaffNo.Text;
                        string senders = "MCIMS";
                        string subject = "MCIMS Passwword Reset";
                        string body    = "Your new Password is " + finalString + ". If you did not request for password reset, Please contact system administrator urgently";
                        query = "UPDATE staff SET Passsword='" + finalString + "' WHERE Staff_No='" + txtStaffNo.Text.ToString() + "' AND Phone_No='" + txtPhoneNo.Text.ToString() + "'";
                        string query1  = "INSERT INTO messages(Direction,Type,Status,Sender,Recipient,Subject,Body) VALUES(2,2,1,'" + senders + "','" + Sessions.phoneNo + "','" + subject + "','" + body + "')";
                        Conn   connect = new Conn();
                        connect.CloseConnection();
                        if (connect.OpenConnection() == true)
                        {
                            //create command and assign the query and connection from the constructor
                            MySqlCommand cmd = new MySqlCommand(query, connect.connection);

                            //Execute command
                            cmd.ExecuteNonQuery();
                            //create command and assign the query and connection from the constructor
                        }
                        connect.CloseConnection();
                        Conn connect2 = new Conn();
                        if (connect2.OpenConnection() == true)
                        {
                            //create command and assign the query and connection from the constructor
                            MySqlCommand cmd = new MySqlCommand(query1, connect2.connection);

                            //Execute command
                            cmd.ExecuteNonQuery();
                        }
                        connect2.CloseConnection();
                        MessageBox.Show("New password has been sent to your phone number", "MMUST CIMS", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        lblStaffNo.Text            = "Reset Code:";
                        lblPhoneNo.Text            = "Password:"******"";
                        txtPhoneNo.Text            = "";
                        txtConfirmPassword.Text    = "";
                        txtPassword2.Visible       = true;
                        txtConfirmPassword.Visible = true;
                        lblConfirmPassword.Visible = true;
                        txtStaffNo.Focus();
                    }
                    else
                    {
                        MessageBox.Show("Staff Details do not exist!\nPlease try again or contact system administrator", "MMUST CIMS", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                        txtStaffNo.Text   = "";
                        txtPhoneNo.Text   = "";
                        txtPassword2.Text = "";
                        txtStaffNo.Focus();
                    }
                }
            }
            else
            {
                if (txtStaffNo.Text.Trim() == "")
                {
                    MessageBox.Show("Ensure all fields are filled!", "MMUST CIMS", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    txtStaffNo.Focus();
                }
                else if (txtPassword2.Text == "")
                {
                    MessageBox.Show("Ensure all fields are filled!", "MMUST CIMS", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    txtPassword2.Focus();
                }
                else if (txtPassword2.Text.Length < 5)
                {
                    MessageBox.Show("Weak Password, Put 5 or more characters", "MMUST CIMS", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    txtPassword2.Focus();
                }
                else if (txtConfirmPassword.Text == "")
                {
                    MessageBox.Show("Ensure all fields are filled!", "MMUST CIMS", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    txtConfirmPassword.Focus();
                }
                else if (txtPassword2.Text != txtConfirmPassword.Text)
                {
                    MessageBox.Show("Password Mismatch!", "MMUST CIMS", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    txtPassword2.Text       = "";
                    txtConfirmPassword.Text = "";
                    txtPassword2.Focus();
                }
                else if (FindRecord2(txtStaffNo.Text) == false)
                {
                    MessageBox.Show("Invalid Code!", "MMUST CIMS", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    txtStaffNo.Text = "";
                    txtStaffNo.Focus();
                }
                else
                {
                    //MessageBox.Show(finalString);
                    query = "UPDATE staff SET Passsword='" + txtPassword2.Text.ToString() + "' WHERE Staff_No='" + Sessions.userID + "' AND Phone_No='" + Sessions.phoneNo + "'";
                    Conn connect = new Conn();
                    connect.CloseConnection();
                    if (connect.OpenConnection() == true)
                    {
                        //create command and assign the query and connection from the constructor
                        MySqlCommand cmd = new MySqlCommand(query, connect.connection);

                        //Execute command
                        cmd.ExecuteNonQuery();
                    }
                    connect.CloseConnection();
                    MessageBox.Show("Password has been successfully reset!", "MMUST CIMS", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    lblStaffNo.Text            = "Staff No:";
                    lblPhoneNo.Text            = "Phone No:";
                    txtStaffNo.Text            = "";
                    txtPhoneNo.Text            = "";
                    txtConfirmPassword.Text    = "";
                    txtPassword2.Text          = "";
                    txtPassword2.Visible       = false;
                    txtConfirmPassword.Visible = false;
                    lblConfirmPassword.Visible = false;
                    gboxReset.Visible          = false;
                    txtUsername.Text           = "";
                    txtPassword.Text           = "";
                    Sessions.phoneNo           = "";
                    Sessions.userID            = "";
                    txtUsername.Focus();
                }
            }
        }
Esempio n. 28
0
        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();
                    }
                }
            }
        }
Esempio n. 29
0
        private void btnLogin_Click(object sender, EventArgs e)
        {
            if (txtUsername.Text.Replace(" ", "") == "")
            {
                MessageBox.Show("Ensure all fields are filled!", "MMUST CIMS", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                txtUsername.Focus();
            }
            else if (txtPassword.Text == "")
            {
                MessageBox.Show("Ensure all fields are filled!", "MMUST CIMS", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                txtPassword.Focus();
            }
            else
            {
                Conn connect = new Conn();
                query = "SELECT * FROM  staff WHERE Login_Name='" + txtUsername.Text.ToString() + "' AND Passsword='" + txtPassword.Text.ToString() + "' AND Status=1";

                //open connection
                if (connect.OpenConnection() == true)
                {
                    //create command and assign the query and connection from the constructor
                    MySqlCommand    cmd        = new MySqlCommand(query, connect.connection);
                    MySqlDataReader dataReader = cmd.ExecuteReader();

                    //Read the data and store them in the list
                    if (dataReader.Read())
                    {
                        //list[0].Add(dataReader["id"] + "");
                        //list[1].Add(dataReader["name"] + "");
                        if (dataReader["Login_Name"].ToString() == txtUsername.Text && dataReader["Passsword"].ToString() == txtPassword.Text)
                        {
                            Sessions.username  = dataReader["Staff_Name"].ToString();
                            Sessions.prev      = dataReader["Priviledges"].ToString();
                            Sessions.userID    = dataReader["Staff_No"].ToString();
                            Sessions.loginTime = DateTime.Now.ToString();
                            MDIParent1 mdi = new MDIParent1();
                            mdi.Visible = true;
                            this.Hide();
                        }
                        else
                        {
                            MessageBox.Show("Username/Password Mismatch!\nPlease Try again!", "MMUST CIMS", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                            txtUsername.Text = "";
                            txtPassword.Text = "";
                            txtUsername.Focus();
                        }
                    }
                    else
                    {
                        MessageBox.Show("Username/Password Mismatch!\nPlease Try again!", "MMUST CIMS", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                        txtUsername.Text = "";
                        txtPassword.Text = "";
                        txtUsername.Focus();
                    }

                    //close Data Reader
                    dataReader.Close();


                    //close connection
                    connect.CloseConnection();
                }
            }
        }
Esempio n. 30
0
        private void btnDelete_Click(object sender, EventArgs e)
        {
            if (cboStaffNo.Visible == false)
            {
                MessageBox.Show("Select Records to Delete", "MMUST CIMS", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                cboStaffNo.Visible = true;
                cboStaffNo.Focus();
            }
            else if (cboStaffNo.Text.Replace(" ", "") == "" && cboStaffNo.Visible == true)
            {
                MessageBox.Show("Ensure all fields are filled!", "MMUST CIMS", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                cboStaffNo.Focus();
            }
            else if (txtPfNo.Text.Replace(" ", "") == "")
            {
                MessageBox.Show("Ensure all fields are filled!", "MMUST CIMS", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                txtPfNo.Focus();
            }
            else if (txtStaffName.Text.Replace(" ", "") == "")
            {
                MessageBox.Show("Ensure all fields are filled!", "MMUST CIMS", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                txtStaffName.Focus();
            }
            else if (txtDesignation.Text.Replace(" ", "") == "")
            {
                MessageBox.Show("Ensure all fields are filled!", "MMUST CIMS", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                txtDesignation.Focus();
            }
            else if (cboDepCode.Text.Replace(" ", "") == "")
            {
                MessageBox.Show("Ensure all fields are filled!", "MMUST CIMS", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                cboDepCode.Focus();
            }
            else if (txtStaffID.Text.Replace(" ", "") == "")
            {
                MessageBox.Show("Ensure all fields are filled!", "MMUST CIMS", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                txtStaffID.Focus();
            }
            else if (txtPostalAddress.Text.Replace(" ", "") == "")
            {
                MessageBox.Show("Ensure all fields are filled!", "MMUST CIMS", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                txtPostalAddress.Focus();
            }
            else if (txtPostalCode.Text.Replace(" ", "") == "")
            {
                MessageBox.Show("Ensure all fields are filled!", "MMUST CIMS", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                txtPostalCode.Focus();
            }
            else if (txtTown.Text.Replace(" ", "") == "")
            {
                MessageBox.Show("Ensure all fields are filled!", "MMUST CIMS", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                txtTown.Focus();
            }
            else if (txtResidence.Text.Replace(" ", "") == "")
            {
                MessageBox.Show("Ensure all fields are filled!", "MMUST CIMS", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                txtResidence.Focus();
            }
            else if (txtEmail.Text.Replace(" ", "") == "")
            {
                MessageBox.Show("Ensure all fields are filled!", "MMUST CIMS", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                txtEmail.Focus();
            }
            else if (txtPhoneNo.Text.Replace(" ", "") == "")
            {
                MessageBox.Show("Ensure all fields are filled!", "MMUST CIMS", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                txtPhoneNo.Focus();
            }
            else if (txtOffice.Text.Replace(" ", "") == "")
            {
                MessageBox.Show("Ensure all fields are filled!", "MMUST CIMS", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                txtOffice.Focus();
            }
            else if (txtTimeAvailable.Text.Replace(" ", "") == "")
            {
                MessageBox.Show("Ensure all fields are filled!", "MMUST CIMS", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                txtTimeAvailable.Focus();
            }
            else if (txtLoginName.Text.Replace(" ", "") == "")
            {
                MessageBox.Show("Ensure all fields are filled!", "MMUST CIMS", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                txtLoginName.Focus();
            }
            else if (txtPassword.Text.Replace(" ", "") == "")
            {
                MessageBox.Show("Ensure all fields are filled!", "MMUST CIMS", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                txtPassword.Focus();
            }
            else if (cboPriviledges.Text.Replace(" ", "") == "")
            {
                MessageBox.Show("Ensure all fields are filled!", "MMUST CIMS", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                cboPriviledges.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 staff WHERE Staff_No='" + cboStaffNo.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();
                    GetStaff();
                }
            }
        }