public void DataViwer()
        {
            DataTable tab = new DataTable();

            tab.Columns.Add("Student ID");
            tab.Columns.Add("Firstname");
            tab.Columns.Add("Lastname");
            tab.Columns.Add("Department");
            tab.Columns.Add("Batch No");
            tab.Columns.Add("Date of Birth");
            tab.Columns.Add("Gender");
            tab.Columns.Add("Email");
            tab.Columns.Add("Phone No");
            tab.Columns.Add("Remarks");

            string          sqlcode = "SELECT * FROM student_data";
            MySqlDataReader data    = curd.SelectQ(sqlcode);

            while (data.Read())
            {
                tab.Rows.Add(data.GetString("student_id"), data.GetString("firstname"), data.GetString("lastname"), data.GetString("department"), data.GetString("batch_no"), data.GetString("dob"), data.GetString("gender"), data.GetString("email"), data.GetString("phone_no"), data.GetString("remarks"));
            }

            data_view.DataSource = tab;
        }
예제 #2
0
        private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            comboBox2.Items.Clear();

            string sqlcode = "SELECT DISTINCT batch_no FROM student_data where department = '" + comboBox1.Text + "'";

            MySqlDataReader data = curd.SelectQ(sqlcode);

            while (data.Read())
            {
                comboBox2.Items.Add(data.GetString(0));
            }
        }
예제 #3
0
        private void button1_Click_1(object sender, EventArgs e)
        {
            curd_functions  curd1 = new curd_functions();
            string          sql   = "SELECT username, password FROM user_account";
            MySqlDataReader data  = curd1.SelectQ(sql);


            string server_username = "";
            string server_password = "";

            while (data.Read())
            {
                server_username = data.GetString("username");
                server_password = data.GetString("password");
            }


            string entered_username = username.Text;
            string entered_password = password.Text;


            if (entered_username == server_username && entered_password == server_password)
            {
                loading_screen LS = new loading_screen();
                LS.Show();
                this.Hide();
            }
            else
            {
                MessageBox.Show("Password or username is invalid", "Authentication Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                username.Clear();
                password.Clear();
                username.Focus();
            }
        }
예제 #4
0
        private void insert_btn_Click(object sender, EventArgs e)
        {
            string          selectCurrrentPassowrdSQL = "SELECT password from user_account";
            MySqlDataReader data = curd.SelectQ(selectCurrrentPassowrdSQL);

            string current_password_from_server = "";

            while (data.Read())
            {
                current_password_from_server = data.GetString(0);
            }

            string current_password_from_user = current_password.Text;

            if (new_password.Text.Length >= 8)
            {
                if (current_password_from_user == current_password_from_server)
                {
                    string NewPassword     = new_password.Text;
                    string ConfirmPassowrd = confirm_password.Text;

                    if (NewPassword == ConfirmPassowrd)
                    {
                        string update_code = "UPDATE user_account SET password = '******'";
                        curd.CUD(update_code);
                        MessageBox.Show("Password has been updated successfully.");
                        current_password.Clear();
                        new_password.Clear();
                        confirm_password.Clear();
                        this.Hide();
                    }
                    else
                    {
                        MessageBox.Show("Confirm password does not match.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        current_password.Clear();
                        new_password.Clear();
                        confirm_password.Clear();
                    }
                }
                else
                {
                    MessageBox.Show("Current password is wrong.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    current_password.Clear();
                    new_password.Clear();
                    confirm_password.Clear();
                }
            }
            else
            {
                MessageBox.Show("Password must be at least 8 characters long.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                current_password.Clear();
                new_password.Clear();
                confirm_password.Clear();
            }
        }