Esempio n. 1
0
        private bool FindRecord(string schval)
        {
            query = "SELECT * FROM student WHERE Reg_No='" + schval + "'";
            conn cn = new conn();

            if (cn.OpenConnection() == true)
            {
                MySqlCommand    cmd        = new MySqlCommand(query, cn.connect);
                MySqlDataReader dataReader = cmd.ExecuteReader();
                //Read the data and store them in the list
                if (dataReader.Read())
                {
                    cn.CloseConnection();
                    return(true);
                }
                else
                {
                    cn.CloseConnection();
                    return(false);
                }
            }
            else
            {
                return(false);
            }
        }
Esempio n. 2
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (txtDepID.Text == "")
            {
                MessageBox.Show("Ensure all fields are filled!", "KUNIS Messaging System", MessageBoxButtons.OK, MessageBoxIcon.Error);
                txtDepID.Focus();
            }
            else if (txtDepName.Text == "")
            {
                MessageBox.Show("Ensure all fields are filled!", "KUNIS Messaging System", MessageBoxButtons.OK, MessageBoxIcon.Error);
                txtDepName.Focus();
            }
            else if (txtRoom.Text == "")
            {
                MessageBox.Show("Ensure all fields are filled!", "KUNIS Messaging System", MessageBoxButtons.OK, MessageBoxIcon.Error);
                txtRoom.Focus();
            }
            else if (txtDescription.Text == "")
            {
                MessageBox.Show("Ensure all fields are filled!", "KUNIS Messaging System", MessageBoxButtons.OK, MessageBoxIcon.Error);
                txtDescription.Focus();
            }
            else if (cboSchoolID.Text == "")
            {
                MessageBox.Show("Ensure all fields are filled!", "KUNIS Messaging System", MessageBoxButtons.OK, MessageBoxIcon.Error);
                cboSchoolID.Focus();
            }
            else
            {
                if (FindRecord(txtDepID.Text) == true)
                {
                    MessageBox.Show(txtDepID.Text + " already exists!", "KUNIS Messaging System", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    txtDepID.Focus();
                }
                else
                {
                    query = "INSERT INTO department VALUES('" + txtDepID.Text + "','" + txtDepName.Text + "','" + txtRoom.Text + "','" + txtDescription.Text + "','" + cboSchoolID.Text + "')";
                    conn cn = new conn();
                    if (cn.OpenConnection() == true)
                    {
                        if (MessageBox.Show("Are you sure you want to save record?", "KUNIS Messaging System", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                        {
                            MySqlCommand cmd = new MySqlCommand(query, cn.connect);
                            cmd.ExecuteNonQuery();

                            cleanData();
                            MessageBox.Show("Records Saved!", "KUNIS Messaging System", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        }
                        else
                        {
                            MessageBox.Show("Records not Saved!", "KUNIS Messaging System", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                            txtDepID.Focus();
                        }
                    }
                    cn.CloseConnection();
                }
            }
        }
Esempio n. 3
0
        private void btnDelete_Click(object sender, EventArgs e)
        {
            if (txtDepID.Text == "")
            {
                MessageBox.Show("Ensure all fields are filled!", "KUNIS Messaging System", MessageBoxButtons.OK, MessageBoxIcon.Error);
                txtDepID.Focus();
            }
            else if (txtDepName.Text == "")
            {
                MessageBox.Show("Ensure all fields are filled!", "KUNIS Messaging System", MessageBoxButtons.OK, MessageBoxIcon.Error);
                txtDepName.Focus();
            }
            else if (txtRoom.Text == "")
            {
                MessageBox.Show("Ensure all fields are filled!", "KUNIS Messaging System", MessageBoxButtons.OK, MessageBoxIcon.Error);
                txtRoom.Focus();
            }
            else if (txtDescription.Text == "")
            {
                MessageBox.Show("Ensure all fields are filled!", "KUNIS Messaging System", MessageBoxButtons.OK, MessageBoxIcon.Error);
                txtDescription.Focus();
            }
            else if (cboSchoolID.Text == "")
            {
                MessageBox.Show("Ensure all fields are filled!", "KUNIS Messaging System", MessageBoxButtons.OK, MessageBoxIcon.Error);
                cboSchoolID.Focus();
            }
            else
            {
                query = "DELETE FROM department WHERE Department_ID='" + txtSearch.Text + "'";
                conn cn = new conn();
                if (cn.OpenConnection() == true)
                {
                    if (MessageBox.Show("Are you sure you want to delete Record?", "KUNIS Messaging System", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                    {
                        MySqlCommand cmd = new MySqlCommand(query, cn.connect);
                        cmd.ExecuteNonQuery();

                        cleanData();
                        MessageBox.Show("Records Deleted!", "KUNIS Messaging System", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                    else
                    {
                        MessageBox.Show("Records failed to delete!", "KUNIS Messaging System", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                        txtSearch.Focus();
                    }
                }

                cn.CloseConnection();
            }
        }
Esempio n. 4
0
        private void btnEdit_Click(object sender, EventArgs e)
        {
            if (txtDepID.Text == "")
            {
                MessageBox.Show("Ensure all fields are filled!", "KUNIS Messaging System", MessageBoxButtons.OK, MessageBoxIcon.Error);
                txtDepID.Focus();
            }
            else if (txtDepName.Text == "")
            {
                MessageBox.Show("Ensure all fields are filled!", "KUNIS Messaging System", MessageBoxButtons.OK, MessageBoxIcon.Error);
                txtDepName.Focus();
            }
            else if (txtRoom.Text == "")
            {
                MessageBox.Show("Ensure all fields are filled!", "KUNIS Messaging System", MessageBoxButtons.OK, MessageBoxIcon.Error);
                txtRoom.Focus();
            }
            else if (txtDescription.Text == "")
            {
                MessageBox.Show("Ensure all fields are filled!", "KUNIS Messaging System", MessageBoxButtons.OK, MessageBoxIcon.Error);
                txtDescription.Focus();
            }
            else if (cboSchoolID.Text == "")
            {
                MessageBox.Show("Ensure all fields are filled!", "KUNIS Messaging System", MessageBoxButtons.OK, MessageBoxIcon.Error);
                cboSchoolID.Focus();
            }
            else
            {
                query = "UPDATE department SET Department_ID='" + txtDepID.Text + "',Department_Name='" + txtDepName.Text + "',Room='" + txtRoom.Text + "',Description='" + txtDescription.Text + "',School_ID='" + cboSchoolID.Text + "' WHERE Department_ID='" + txtSearch.Text + "'";
                conn cn = new conn();
                if (cn.OpenConnection() == true)
                {
                    if (MessageBox.Show("Are you sure you want to save changes?", "KUNIS Messaging System", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                    {
                        MySqlCommand cmd = new MySqlCommand(query, cn.connect);
                        cmd.ExecuteNonQuery();

                        cleanData();
                        MessageBox.Show("Changes Saved!", "KUNIS Messaging System", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                    else
                    {
                        MessageBox.Show("Changes Failed to Save!", "KUNIS Messaging System", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                        txtSearch.Focus();
                    }
                }

                cn.CloseConnection();
            }
        }
Esempio n. 5
0
        private void AssignUserID()
        {
            conn cn = new conn();

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

                        //MessageBox.Show(txtStaffNo.Text);
                    }
                }
                else
                {
                    txtUserID.Text = "EMP/0001";
                }
                cn.CloseConnection();
            }
        }
Esempio n. 6
0
 private void txtSearch_TextChanged(object sender, EventArgs e)
 {
     if (txtSearch.Text != "")
     {
         query = "SELECT * FROM user WHERE User_ID LIKE '" + txtSearch.Text + "'";
         conn cn = new conn();
         if (cn.OpenConnection() == true)
         {
             MySqlCommand    cmd        = new MySqlCommand(query, cn.connect);
             MySqlDataReader dataReader = cmd.ExecuteReader();
             //Read the data and store them in the list
             if (dataReader.Read())
             {
                 txtUserID.Text          = dataReader["User_ID"].ToString();
                 txtUserName.Text        = dataReader["User_Name"].ToString();
                 txtLoginName.Text       = dataReader["Login_Name"].ToString();
                 txtPassword.Text        = dataReader["Passsword"].ToString();
                 txtConfirmPassword.Text = dataReader["Passsword"].ToString();
                 cboPriviledges.Text     = dataReader["Priviledges"].ToString();
                 txtPhoneNo.Text         = dataReader["Phone_No"].ToString();
                 if (dataReader["Status"].ToString() == "True")
                 {
                     chckStatus.CheckState = CheckState.Checked;
                 }
                 else
                 {
                     chckStatus.CheckState = CheckState.Unchecked;
                 }
             }
             else
             {
                 txtUserID.Text          = "";
                 txtUserName.Text        = "";
                 txtLoginName.Text       = "";
                 txtPassword.Text        = "";
                 txtConfirmPassword.Text = "";
                 cboPriviledges.Text     = "";
                 txtPhoneNo.Text         = "";
                 chckStatus.CheckState   = CheckState.Unchecked;
             }
         }
         cn.CloseConnection();
     }
 }
Esempio n. 7
0
        private void addDepartment()
        {
            query = "SELECT * FROM department ORDER BY Department_ID ASC";
            conn cn = new conn();

            if (cn.OpenConnection() == true)
            {
                MySqlCommand    cmd        = new MySqlCommand(query, cn.connect);
                MySqlDataReader dataReader = cmd.ExecuteReader();
                this.cboDepID.Items.Clear();
                while (dataReader.Read())
                {
                    if (dataReader["Department_ID"].ToString().Replace(" ", "") != "")
                    {
                        this.cboDepID.Items.Add(dataReader["Department_ID"].ToString());
                    }
                }
            }
        }
Esempio n. 8
0
        private void btnLogin_Click(object sender, EventArgs e)
        {
            if (txtLoginName.Text.Replace(" ", "") == "")
            {
                MessageBox.Show("Ensure all fields are filled!", "KUNIS Messaging System", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                txtLoginName.Focus();
            }
            else if (txtPassword.Text == "")
            {
                MessageBox.Show("Ensure all fields are filled!", "KUNIS Messaging System", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                txtPassword.Focus();
            }
            else
            {
                conn   connect = new conn();
                string query   = "SELECT * FROM  user WHERE Login_Name='" + txtLoginName.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.connect);
                    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() == txtLoginName.Text && dataReader["Passsword"].ToString() == txtPassword.Text)
                        {
                            Sessions.username  = dataReader["User_Name"].ToString();
                            Sessions.prev      = dataReader["Priviledges"].ToString();
                            Sessions.userID    = dataReader["User_ID"].ToString();
                            Sessions.loginTime = DateTime.Now.ToString();
                            MDI1 mdi = new MDI1();
                            mdi.Visible = true;
                            this.Hide();
                        }
                        else
                        {
                            MessageBox.Show("Username/Password Mismatch!\nPlease Try again!", "KUNIS Messaging System", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                            txtLoginName.Text = "";
                            txtPassword.Text  = "";
                            txtLoginName.Focus();
                        }
                    }
                    else
                    {
                        MessageBox.Show("Username/Password Mismatch!\nPlease Try again!", "KUNIS Messaging System", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                        txtLoginName.Text = "";
                        txtPassword.Text  = "";
                        txtLoginName.Focus();
                    }

                    //close Data Reader
                    dataReader.Close();


                    //close connection
                    connect.CloseConnection();
                }
            }
        }
Esempio n. 9
0
        private void btnDelete_Click(object sender, EventArgs e)
        {
            if (txtUserID.Text == "")
            {
                MessageBox.Show("Ensure all fields are filled!", "KUNIS Messaging System", MessageBoxButtons.OK, MessageBoxIcon.Error);
                txtUserID.Focus();
            }
            else if (txtUserName.Text == "")
            {
                MessageBox.Show("Ensure all fields are filled!", "KUNIS Messaging System", MessageBoxButtons.OK, MessageBoxIcon.Error);
                txtUserName.Focus();
            }
            else if (txtLoginName.Text == "")
            {
                MessageBox.Show("Ensure all fields are filled!", "KUNIS Messaging System", MessageBoxButtons.OK, MessageBoxIcon.Error);
                txtLoginName.Focus();
            }
            else if (txtPassword.Text == "")
            {
                MessageBox.Show("Ensure all fields are filled!", "KUNIS Messaging System", MessageBoxButtons.OK, MessageBoxIcon.Error);
                txtPassword.Focus();
            }
            else if (txtConfirmPassword.Text == "")
            {
                MessageBox.Show("Ensure all fields are filled!", "KUNIS Messaging System", MessageBoxButtons.OK, MessageBoxIcon.Error);
                txtConfirmPassword.Focus();
            }
            else if (txtConfirmPassword.Text != txtPassword.Text)
            {
                MessageBox.Show("Password mismatch!", "KUNIS Messaging System", MessageBoxButtons.OK, MessageBoxIcon.Error);
                txtPassword.Text        = "";
                txtConfirmPassword.Text = "";
                txtPassword.Focus();
            }
            else if (cboPriviledges.Text == "")
            {
                MessageBox.Show("Ensure all fields are filled!", "KUNIS Messaging System", MessageBoxButtons.OK, MessageBoxIcon.Error);
                cboPriviledges.Focus();
            }
            else if (txtPhoneNo.Text == "")
            {
                MessageBox.Show("Ensure all fields are filled!", "KUNIS Messaging System", MessageBoxButtons.OK, MessageBoxIcon.Error);
                txtPhoneNo.Focus();
            }
            else
            {
                int sts;
                if (chckStatus.CheckState == CheckState.Checked)
                {
                    sts = 1;
                }
                else
                {
                    sts = 0;
                }
                query = "DELETE FROM user WHERE User_ID='" + txtSearch.Text + "'";
                conn cn = new conn();
                if (cn.OpenConnection() == true)
                {
                    if (MessageBox.Show("Are you sure you want to delete record?", "KUNIS Messaging System", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                    {
                        MySqlCommand cmd = new MySqlCommand(query, cn.connect);
                        cmd.ExecuteNonQuery();

                        cleanData();
                        MessageBox.Show("Record deleted!", "KUNIS Messaging System", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                    else
                    {
                        MessageBox.Show("Record not deleted!", "KUNIS Messaging System", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                        txtUserID.Focus();
                    }
                }
                cn.CloseConnection();
            }
        }
Esempio n. 10
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            long   phone;
            string phn = txtPhoneNo.Text.Replace("+", "").Trim().ToString();

            if (txtUserID.Text == "")
            {
                MessageBox.Show("Ensure all fields are filled!", "KUNIS Messaging System", MessageBoxButtons.OK, MessageBoxIcon.Error);
                txtUserID.Focus();
            }
            else if (txtUserName.Text == "")
            {
                MessageBox.Show("Ensure all fields are filled!", "KUNIS Messaging System", MessageBoxButtons.OK, MessageBoxIcon.Error);
                txtUserName.Focus();
            }
            else if (txtLoginName.Text == "")
            {
                MessageBox.Show("Ensure all fields are filled!", "KUNIS Messaging System", MessageBoxButtons.OK, MessageBoxIcon.Error);
                txtLoginName.Focus();
            }
            else if (txtPassword.Text == "")
            {
                MessageBox.Show("Ensure all fields are filled!", "KUNIS Messaging System", MessageBoxButtons.OK, MessageBoxIcon.Error);
                txtPassword.Focus();
            }
            else if (txtConfirmPassword.Text == "")
            {
                MessageBox.Show("Ensure all fields are filled!", "KUNIS Messaging System", MessageBoxButtons.OK, MessageBoxIcon.Error);
                txtConfirmPassword.Focus();
            }
            else if (txtConfirmPassword.Text != txtPassword.Text)
            {
                MessageBox.Show("Password mismatch!", "KUNIS Messaging System", MessageBoxButtons.OK, MessageBoxIcon.Error);
                txtPassword.Text        = "";
                txtConfirmPassword.Text = "";
                txtPassword.Focus();
            }
            else if (cboPriviledges.Text == "")
            {
                MessageBox.Show("Ensure all fields are filled!", "KUNIS Messaging System", MessageBoxButtons.OK, MessageBoxIcon.Error);
                cboPriviledges.Focus();
            }
            else if (txtPhoneNo.Text == "")
            {
                MessageBox.Show("Ensure all fields are filled!", "KUNIS Messaging System", MessageBoxButtons.OK, MessageBoxIcon.Error);
                txtPhoneNo.Focus();
            }
            else if (!long.TryParse(phn, out phone))
            {
                MessageBox.Show("Invalid Phone Number!", "Looptech International Messaging System", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                txtPhoneNo.Focus();
            }
            else if (!txtPhoneNo.Text.Contains("+"))
            {
                MessageBox.Show("Invalid Phone Number!", "Looptech International Messaging System", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                txtPhoneNo.Focus();
            }
            else
            {
                if (FindRecord(txtUserID.Text) == true)
                {
                    MessageBox.Show(txtUserID.Text + " already exists!", "KUNIS Messaging System", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    txtUserID.Focus();
                }
                else
                {
                    int sts;
                    if (chckStatus.CheckState == CheckState.Checked)
                    {
                        sts = 1;
                    }
                    else
                    {
                        sts = 0;
                    }
                    query = "INSERT INTO user VALUES('" + txtUserID.Text + "','" + txtUserName.Text + "','" + txtLoginName.Text + "','" + txtPassword.Text + "','" + sts + "','" + cboPriviledges.Text + "','" + txtPhoneNo.Text + "')";
                    conn cn = new conn();
                    if (cn.OpenConnection() == true)
                    {
                        if (MessageBox.Show("Are you sure you want to save record?", "KUNIS Messaging System", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                        {
                            MySqlCommand cmd = new MySqlCommand(query, cn.connect);
                            cmd.ExecuteNonQuery();

                            cleanData();
                            MessageBox.Show("Records Saved!", "KUNIS Messaging System", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        }
                        else
                        {
                            MessageBox.Show("Records not Saved!", "KUNIS Messaging System", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                            txtUserID.Focus();
                        }
                    }
                    cn.CloseConnection();
                }
            }
        }
Esempio n. 11
0
 private void btnSearch_Click(object sender, EventArgs e)
 {
     if (txtMessage.Text == "")
     {
         MessageBox.Show("Type message first!", "KUNIS Messaging System", MessageBoxButtons.OK, MessageBoxIcon.Error);
         txtMessage.Focus();
     }
     else if (txtSubject.Text == "")
     {
         MessageBox.Show("Type Subject First!", "KUNIS Messaging System", MessageBoxButtons.OK, MessageBoxIcon.Error);
         txtSubject.Focus();
     }
     else if (cboCriteriaSearch.Text == "")
     {
         MessageBox.Show("Please select Criteria!", "KUNIS Messaging System", MessageBoxButtons.OK, MessageBoxIcon.Error);
         cboCriteriaSearch.Focus();
     }
     else if (txtSearch.Text == "")
     {
         MessageBox.Show("Type Search First!", "KUNIS Messaging System", MessageBoxButtons.OK, MessageBoxIcon.Error);
         txtSearch.Focus();
     }
     else
     {
         query = "";
         if (cboCriteriaSearch.Text == "All")
         {
             query = "SELECT * FROM student WHERE Status=1";
         }
         else if (cboCriteriaSearch.Text == "Programme")
         {
             query = "SELECT * FROM student WHERE Status=1 and Prog_ID='" + txtSearch.Text + "'";
         }
         else if (cboCriteriaSearch.Text == "Reg No")
         {
             query = "SELECT * FROM student WHERE Status=1 and Reg_No='" + txtSearch.Text + "'";
         }
         else if (cboCriteriaSearch.Text == "Department")
         {
             query = "SELECT * FROM studentview WHERE Status=1 and Department_ID='" + txtSearch.Text + "'";
         }
         else if (cboCriteriaSearch.Text == "School")
         {
             query = "SELECT * FROM studentview WHERE Status=1 and School_ID='" + txtSearch.Text + "'";
         }
         else
         {
             MessageBox.Show("Invalid Criteria", "KUNIS Messaging System", MessageBoxButtons.OK, MessageBoxIcon.Error);
             cboCriteriaSearch.Focus();
         }
         conn cn = new conn();
         if (cn.OpenConnection() == true)
         {
             MySqlCommand    cmd        = new MySqlCommand(query, cn.connect);
             MySqlDataReader dataReader = cmd.ExecuteReader();
             this.dataGridView1.Rows.Clear();
             while (dataReader.Read())
             {
                 string msg = "";
                 msg = "Dear " + dataReader["Student_Name"].ToString() + ",\n Subject: " + txtSubject.Text + " \n Message:" + txtMessage.Text;
                 string[] row = new string[] { dataReader["Phone_No"].ToString(), txtSubject.Text, msg, "Pending", "--", "--", "SMS" };
                 dataGridView1.Rows.Add(row);
             }
         }
         cn.CloseConnection();
     }
 }
Esempio n. 12
0
 private void txtSearch_TextChanged(object sender, EventArgs e)
 {
     if (txtSearch.Text != "")
     {
         query = "SELECT * FROM student WHERE Reg_No LIKE '" + txtSearch.Text + "'";
         conn cn = new conn();
         if (cn.OpenConnection() == true)
         {
             MySqlCommand    cmd        = new MySqlCommand(query, cn.connect);
             MySqlDataReader dataReader = cmd.ExecuteReader();
             //Read the data and store them in the list
             if (dataReader.Read())
             {
                 txtRegNo.Text    = dataReader["Reg_No"].ToString();
                 txtStudName.Text = dataReader["Student_Name"].ToString();
                 dtPicDoB.Value   = Convert.ToDateTime(dataReader["DoB"].ToString());
                 if (dataReader["Gender"].ToString() == "Male")
                 {
                     rbtnMale.Checked = true;
                 }
                 else
                 {
                     rbtnFemale.Checked = true;
                 }
                 txtEmail.Text         = dataReader["Email_Address"].ToString();
                 txtPostalAddress.Text = dataReader["Postal_Address"].ToString();
                 txtPhoneNo.Text       = dataReader["Phone_No"].ToString();
                 txtPic.Text           = dataReader["Photo"].ToString().Replace("__", "\\");
                 if (txtPic.Text != "")
                 {
                     pictureBox1.Image = Image.FromFile(txtPic.Text);
                 }
                 else
                 {
                     pictureBox1.Image = null;
                 }
                 if (dataReader["Status"].ToString() == "True")
                 {
                     chckStatus.CheckState = CheckState.Checked;
                 }
                 else
                 {
                     chckStatus.CheckState = CheckState.Unchecked;
                 }
                 cboProgID.Text = dataReader["Prog_ID"].ToString();
             }
             else
             {
                 txtRegNo.Text         = "";
                 txtStudName.Text      = "";
                 txtPhoneNo.Text       = "";
                 dtPicDoB.Value        = DateTime.Now;
                 rbtnMale.Checked      = true;
                 rbtnFemale.Checked    = false;
                 txtEmail.Text         = "";
                 txtPostalAddress.Text = "";
                 txtPic.Text           = "";
                 pictureBox1.Image     = null;
                 chckStatus.CheckState = CheckState.Checked;
                 cboProgID.Text        = "";
             }
         }
         cn.CloseConnection();
     }
 }
Esempio n. 13
0
        private void btnDelete_Click(object sender, EventArgs e)
        {
            long   phone;
            string phn = txtPhoneNo.Text.Replace("+", "").Trim().ToString();

            if (txtRegNo.Text == "")
            {
                MessageBox.Show("Ensure all fields are filled!", "KUNIS Messaging System", MessageBoxButtons.OK, MessageBoxIcon.Error);
                txtRegNo.Focus();
            }
            else if (txtStudName.Text == "")
            {
                MessageBox.Show("Ensure all fields are filled!", "KUNIS Messaging System", MessageBoxButtons.OK, MessageBoxIcon.Error);
                txtStudName.Focus();
            }
            else if (txtEmail.Text == "")
            {
                MessageBox.Show("Ensure all fields are filled!", "KUNIS Messaging System", MessageBoxButtons.OK, MessageBoxIcon.Error);
                txtEmail.Focus();
            }
            else if (!IsValidEmail(txtEmail.Text.Replace(" ", "").ToString()))
            {
                MessageBox.Show("Invalid Email", "KUNIS Messaging System", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                txtEmail.Focus();
            }
            else if (txtPostalAddress.Text == "")
            {
                MessageBox.Show("Ensure all fields are filled!", "KUNIS Messaging System", MessageBoxButtons.OK, MessageBoxIcon.Error);
                txtPostalAddress.Focus();
            }
            else if (cboProgID.Text == "")
            {
                MessageBox.Show("Ensure all fields are filled!", "KUNIS Messaging System", MessageBoxButtons.OK, MessageBoxIcon.Error);
                cboProgID.Focus();
            }
            else if (txtPhoneNo.Text == "")
            {
                MessageBox.Show("Ensure all fields are filled!", "KUNIS Messaging System", MessageBoxButtons.OK, MessageBoxIcon.Error);
                txtPhoneNo.Focus();
            }
            else if (!long.TryParse(phn, out phone))
            {
                MessageBox.Show("Invalid Phone Number!", "Looptech International Messaging System", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                txtPhoneNo.Focus();
            }
            else if (!txtPhoneNo.Text.Contains("+"))
            {
                MessageBox.Show("Invalid Phone Number!", "Looptech International Messaging System", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                txtPhoneNo.Focus();
            }
            else
            {
                int    sts;
                string gnder;
                if (chckStatus.CheckState == CheckState.Checked)
                {
                    sts = 1;
                }
                else
                {
                    sts = 0;
                }
                if (rbtnFemale.Checked == true)
                {
                    gnder = "Female";
                }
                else
                {
                    gnder = "Male";
                }
                query = "DELETE FROM student WHERE Reg_No='" + txtSearch.Text + "'";
                conn cn = new conn();
                if (cn.OpenConnection() == true)
                {
                    if (MessageBox.Show("Are you sure you want to delete record?", "KUNIS Messaging System", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                    {
                        MySqlCommand cmd = new MySqlCommand(query, cn.connect);
                        cmd.ExecuteNonQuery();

                        cleanData();
                        MessageBox.Show("Records Deleted!", "KUNIS Messaging System", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                    else
                    {
                        MessageBox.Show("Records not Deleted!", "KUNIS Messaging System", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                        txtRegNo.Focus();
                    }
                }
                cn.CloseConnection();
            }
        }
Esempio n. 14
0
        private void btnEdit_Click(object sender, EventArgs e)
        {
            long   phone;
            string phn = txtPhoneNo.Text.Replace("+", "").Trim().ToString();

            if (txtRegNo.Text == "")
            {
                MessageBox.Show("Ensure all fields are filled!", "KUNIS Messaging System", MessageBoxButtons.OK, MessageBoxIcon.Error);
                txtRegNo.Focus();
            }
            else if (txtStudName.Text == "")
            {
                MessageBox.Show("Ensure all fields are filled!", "KUNIS Messaging System", MessageBoxButtons.OK, MessageBoxIcon.Error);
                txtStudName.Focus();
            }
            else if (txtEmail.Text == "")
            {
                MessageBox.Show("Ensure all fields are filled!", "KUNIS Messaging System", MessageBoxButtons.OK, MessageBoxIcon.Error);
                txtEmail.Focus();
            }
            else if (!IsValidEmail(txtEmail.Text.Replace(" ", "").ToString()))
            {
                MessageBox.Show("Invalid Email", "KUNIS Messaging System", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                txtEmail.Focus();
            }
            else if (txtPostalAddress.Text == "")
            {
                MessageBox.Show("Ensure all fields are filled!", "KUNIS Messaging System", MessageBoxButtons.OK, MessageBoxIcon.Error);
                txtPostalAddress.Focus();
            }
            else if (cboProgID.Text == "")
            {
                MessageBox.Show("Ensure all fields are filled!", "KUNIS Messaging System", MessageBoxButtons.OK, MessageBoxIcon.Error);
                cboProgID.Focus();
            }
            else if (txtPhoneNo.Text == "")
            {
                MessageBox.Show("Ensure all fields are filled!", "KUNIS Messaging System", MessageBoxButtons.OK, MessageBoxIcon.Error);
                txtPhoneNo.Focus();
            }
            else if (!long.TryParse(phn, out phone))
            {
                MessageBox.Show("Invalid Phone Number!", "Looptech International Messaging System", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                txtPhoneNo.Focus();
            }
            else if (!txtPhoneNo.Text.Contains("+"))
            {
                MessageBox.Show("Invalid Phone Number!", "Looptech International Messaging System", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                txtPhoneNo.Focus();
            }
            else
            {
                int    sts;
                string gnder;
                if (chckStatus.CheckState == CheckState.Checked)
                {
                    sts = 1;
                }
                else
                {
                    sts = 0;
                }
                if (rbtnFemale.Checked == true)
                {
                    gnder = "Female";
                }
                else
                {
                    gnder = "Male";
                }
                string pic;
                pic   = txtPic.Text.Replace("\\", "__");
                query = "UPDATE student SET Reg_No='" + txtRegNo.Text + "',Student_Name='" + txtStudName.Text + "',Phone_No='" + txtPhoneNo.Text + "',DoB='" + dtPicDoB.Value.ToString("yyyy-MM-dd") + "',Gender='" + gnder + "',Email_Address='" + txtEmail.Text + "',Postal_Address='" + txtPostalAddress.Text + "',Status='" + sts + "',Prog_ID='" + cboProgID.Text + "',Photo='" + pic + "' WHERE Reg_No='" + txtSearch.Text + "'";
                conn cn = new conn();
                if (cn.OpenConnection() == true)
                {
                    if (MessageBox.Show("Are you sure you want to save changes?", "KUNIS Messaging System", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                    {
                        MySqlCommand cmd = new MySqlCommand(query, cn.connect);
                        cmd.ExecuteNonQuery();

                        cleanData();
                        MessageBox.Show("Records Saved!", "KUNIS Messaging System", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                    else
                    {
                        MessageBox.Show("Records not Saved!", "KUNIS Messaging System", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                        txtRegNo.Focus();
                    }
                }
                cn.CloseConnection();
            }
        }