private void savebtn_Click(object sender, EventArgs e)
        {
            string       sex;
            DialogResult result = MessageBox.Show("Are You Sure You Want To Save?", "Save", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

            if (result == DialogResult.Yes)
            {
                DBConnect conn = new DBConnect();
                conn.OpenConnection();
                if (femaleradiobtn.Checked)
                {
                    sex = "F";
                }
                else
                {
                    sex = "M";
                }
                string query1 = "INSERT INTO student(StuNo,FullName,LName,Initials,Address,ContactNo,Sex,Batch,Degree,SpSubject,NID,DeptNo,UserName,IntakeYear) VALUES('" + stunotxt.Text + "','" + fullnametxt.Text + "','" + lnametxt.Text + "','" + initialstxt.Text + "','" + addresstxt.Text + "','" + mobiletxt.Text + "','" + sex + "','" + Batchtxt.Text + "','S','Kandyan Dance','" + NIDtxt.Text + "','DKAN 01','" + stunotxt.Text + "','" + intyeartxt.Text + "')";
                if (conn.OpenConnection() == true)
                {
                    MySqlCommand cmd = new MySqlCommand(query1, conn.connection);
                    cmd.ExecuteNonQuery();
                    conn.CloseConnection();
                }
                this.Close();
                Form3 f3 = new Form3();
                f3.Show();
            }
        }
        private void stunotxt_TextChanged(object sender, EventArgs e)
        {
            DBConnect conn = new DBConnect();

            conn.OpenConnection();
            string query1 = "SELECT * FROM student where StuNo='" + stunotxt.Text + "'";

            if (conn.OpenConnection() == true)
            {
                MySqlCommand    cmd        = new MySqlCommand(query1, conn.connection);
                MySqlDataReader datareader = cmd.ExecuteReader();
                while (datareader.Read())
                {
                    fullnametxt.Text = datareader.GetString(1);
                    lnametxt.Text    = datareader.GetString(2);
                    initialstxt.Text = datareader.GetString(3);
                    addresstxt.Text  = datareader.GetString(4);
                    mobiletxt.Text   = datareader.GetString(5);
                    NIDtxt.Text      = datareader.GetString(10);
                    intyeartxt.Text  = datareader.GetString(13);
                    Batchtxt.Text    = datareader.GetString(7);
                    string sex = datareader.GetString(6);
                    if (sex == "M")
                    {
                        maleradiobtn.Checked = true;
                    }
                    else
                    {
                        femaleradiobtn.Checked = true;
                    }
                }
                datareader.Close();
                conn.CloseConnection();
            }
        }
        private void btnDelete_Click(object sender, EventArgs e)
        {
            DBConnect    conn        = new DBConnect();
            string       deleteQuery = "delete from account where UserName='******'";
            DialogResult result      = MessageBox.Show("Are you sure to delete record?", "delete", MessageBoxButtons.OKCancel, MessageBoxIcon.Question);

            if (result == DialogResult.OK)
            {
                if (conn.OpenConnection() == true)
                {
                    MySqlCommand cmd = new MySqlCommand(deleteQuery, conn.connection);

                    if (cmd.ExecuteNonQuery() == 1)
                    {
                        MessageBox.Show("Deleted");
                    }
                    else
                    {
                        MessageBox.Show("Not Deleted");
                    }
                    conn.CloseConnection();
                }
                else
                {
                }
            }
            else
            {
                MessageBox.Show("Not deleted");
            }
            populateDGV();
        }
예제 #4
0
        private void cdeletebtn_Click(object sender, EventArgs e)
        {
            DBConnect    conn        = new DBConnect();
            string       deleteQuery = "delete from subject where SubjectId='" + cidtxt.Text + "'";
            DialogResult result      = MessageBox.Show("Are you sure to delete record?", "delete", MessageBoxButtons.OKCancel, MessageBoxIcon.Question);

            if (result == DialogResult.OK)
            {
                if (conn.OpenConnection() == true)
                {
                    MySqlCommand cmd = new MySqlCommand(deleteQuery, conn.connection);

                    if (cmd.ExecuteNonQuery() == 1)
                    {
                        MessageBox.Show("Course is Deleted");
                    }
                    else
                    {
                        MessageBox.Show("Course is not Deleted");
                    }
                    conn.CloseConnection();
                }
                else
                {
                }
            }
            else
            {
                MessageBox.Show("Course is not deleted");
            }
            clearbtn.PerformClick();
        }
예제 #5
0
        private void loginlbl_Click(object sender, EventArgs e)
        {
            if (conn.OpenConnection() == true)
            {
                string          query         = "select*from account where UserName='******' and Password='******'";
                MySqlCommand    SelectCommand = new MySqlCommand(query, conn.connection);
                MySqlDataReader myReader;

                myReader = SelectCommand.ExecuteReader();
                int count = 0;
                while (myReader.Read())
                {
                    count = count + 1;
                }
                if (count == 1)
                {
                    Form3  new_form = new Form3();
                    string uname    = this.unametxt.Text;
                    string pword    = this.pwordtxt.Text;
                    new_form.prop  = uname;
                    new_form.prop2 = pword;
                    new_form.Show();
                    this.Hide();
                }

                else if ((unametxt.Text == "admin") && (pwordtxt.Text == "admin"))
                {
                    Form2     new_form1 = new Form2();
                    string    uname     = this.unametxt.Text;
                    string    pword     = this.pwordtxt.Text;
                    asettings admin     = new asettings();
                    admin.pword = pword;
                    admin.pword = pword;
                    new_form1.Show();
                    this.Hide();
                }

                /*else if ((unametxt.Text == "user") && (pwordtxt.Text == "user"))
                 * {
                 *  Form3 new_form = new Form3();
                 *  new_form.Show();
                 *  this.Hide();
                 * }*/

                else
                {
                    MessageBox.Show("Incorrect username/password!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    unametxt.Text = "";
                    pwordtxt.Text = "";
                    unametxt.Focus();
                }
            }
            conn.CloseConnection();
        }
        private void areports_Load(object sender, EventArgs e)
        {
            DBConnect conn  = new DBConnect();
            string    Query = "SELECT * FROM student";

            conn.OpenConnection();
            MySqlCommand    command = new MySqlCommand(Query, conn.connection);
            MySqlDataReader reader  = command.ExecuteReader();

            while (reader.Read())
            {
                stureportcombo.Items.Add(reader.GetString("StuNo"));
            }
            conn.CloseConnection();
        }
예제 #7
0
        private void caddbtn_Click(object sender, EventArgs e)
        {
            DBConnect conn = new DBConnect();

            conn.OpenConnection();
            this.addconversions();
            string query1 = "INSERT INTO subject(SubjectId,SubCode,SubName,SubType,Subcredit,Sem,YearId,AcYear,DeptNo) VALUES('" + cid + "','" + ccodetxt.Text + "','" + ctitletxt.Text + "','" + ctype + "','" + ccreditstxt.Text + "','" + csem + "','" + cyear + "','" + cacayeartxt.Text + "','" + cdept + "')";

            if (conn.OpenConnection() == true)
            {
                MySqlCommand cmd = new MySqlCommand(query1, conn.connection);
                cmd.ExecuteNonQuery();
                conn.CloseConnection();
            }
            MessageBox.Show("Course is Added");
            clearbtn.PerformClick();
        }
        public void populateDGV()
        {
            //populate the datagridview
            DBConnect conn = new DBConnect();

            conn.OpenConnection();
            string selectQuery = "SELECT*FROM account";

            //ListSortDirection direction;
            //dataGridView_accou.Sort(dataGridView_accou.Columns["password"], direction);
            //    dataGridView_accou.Sort(dataGridView_accou.Columns[1], ListSortDirection.Ascending);
            DataTable        table   = new DataTable();
            MySqlDataAdapter adapter = new MySqlDataAdapter(selectQuery, conn.connection);

            adapter.Fill(table);
            // dataGridView_accou.Sort(dataGridView_accou.Columns[1], ListSortDirection.Ascending);
            dataGridView_accou.DataSource = table;
            conn.CloseConnection();
        }
예제 #9
0
 private void savebtn_Click(object sender, EventArgs e)
 {
     if (pword == currentpwordtxt.Text && (newpwordtxt.Text == confirmpwordtxt.Text))
     {
         DBConnect conn = new DBConnect();
         conn.OpenConnection();
         string          query1 = "update account set Password = '******' where UserName = '******' ";
         MySqlCommand    cmd    = new MySqlCommand(query1, conn.connection);
         MySqlDataReader rdr    = cmd.ExecuteReader();
         conn.CloseConnection();
     }
     else if (pword != currentpwordtxt.Text)
     {
         MessageBox.Show("curreent password is wrong");
     }
     else
     {
         MessageBox.Show("new password is wrong");
     }
 }
        private void btnShow_Click(object sender, EventArgs e)
        {
            DBConnect conn        = new DBConnect();
            string    updateQuery = "UPDATE account SET UserName='******',Password='******',PasswordHint='" + this.txtPasswotd.Text + "' WHERE UserName='******';";

            if (conn.OpenConnection() == true)
            {
                MySqlCommand cmd = new MySqlCommand(updateQuery, conn.connection);
                if (cmd.ExecuteNonQuery() == 1)
                {
                    MessageBox.Show("Data Updated Successfully");
                }
                else
                {
                    MessageBox.Show("Query Not Executed");
                }
                conn.CloseConnection();
            }
            populateDGV();
        }
        private void btnAdd_Click(object sender, EventArgs e)
        {
            DBConnect conn = new DBConnect();

            conn.OpenConnection();
            string query1 = "INSERT INTO account(UserName,Password,PasswordHint) VALUES ('" + txtUsername.Text + "','" + txtPasswotd.Text + "','" + txtPasswotd.Text + "')";

            if (conn.OpenConnection() == true)
            {
                MySqlCommand cmd = new MySqlCommand(query1, conn.connection);
                if (cmd.ExecuteNonQuery() == 1)
                {
                    MessageBox.Show("Save data");
                }
                else
                {
                    MessageBox.Show("Query Not Executed");
                }
                conn.CloseConnection();
            }
            populateDGV();
        }
예제 #12
0
        private void ceditbtn_Click(object sender, EventArgs e)
        {
            DBConnect conn = new DBConnect();

            this.addconversions();
            string updateQuery = "UPDATE subject SET SubjectId='" + this.cid + "',SubCode='" + this.ccodetxt.Text + "',SubName='" + this.ctitletxt.Text + "',SubType='" + this.ctype + "',SubCredit='" + this.ccredit + "',Sem='" + this.csem + "',YearId='" + this.cyear + "',AcYear='" + this.cacayeartxt.Text + "',DeptNo='" + this.cdept + "' WHERE SubjectId='" + this.cid + "';";

            if (conn.OpenConnection() == true)
            {
                MySqlCommand cmd = new MySqlCommand(updateQuery, conn.connection);
                if (cmd.ExecuteNonQuery() == 1)
                {
                    MessageBox.Show("Data Updated Successfully");
                }
                else
                {
                    MessageBox.Show("Query Not Executed");
                }
                conn.CloseConnection();
            }
            clearbtn.PerformClick();
        }
예제 #13
0
        private void cidtxt_TextChanged(object sender, EventArgs e)
        {
            DBConnect conn = new DBConnect();

            conn.OpenConnection();
            string query1 = "SELECT * FROM subject where SubjectId='" + cidtxt.Text + "'";

            if (conn.OpenConnection() == true)
            {
                MySqlCommand    cmd        = new MySqlCommand(query1, conn.connection);
                MySqlDataReader datareader = cmd.ExecuteReader();
                while (datareader.Read())
                {
                    ccodetxt.Text  = datareader.GetString(1);
                    ctitletxt.Text = datareader.GetString(2);
                    if (datareader.GetString(3) == "C")
                    {
                        ctypetxt.Text = "Core";
                    }
                    else if (datareader.GetString(3) == "E")
                    {
                        ctypetxt.Text = "Elective";
                    }
                    else
                    {
                        ctypetxt.Text = "Auxilary";
                    }

                    ccreditstxt.Text = Convert.ToString(datareader.GetInt32(4));
                    if (datareader.GetString(5) == "1")
                    {
                        csemtxt.Text = "Semester 1";
                    }
                    else
                    {
                        csemtxt.Text = "Semester 2";
                    }
                    if (datareader.GetString(6) == "1")
                    {
                        cyeartxt.Text = "One";
                    }
                    else if (datareader.GetString(6) == "2")
                    {
                        cyeartxt.Text = "Two";
                    }
                    else if (datareader.GetString(6) == "3")
                    {
                        cyeartxt.Text = "Three";
                    }
                    else
                    {
                        cyeartxt.Text = "Four";
                    }
                    cacayeartxt.Text = datareader.GetString(7);
                    if (datareader.GetString(8) == "DKAN 01")
                    {
                        cdepttxt.Text = "Kandyan Dance";
                    }
                    else if (datareader.GetString(8) == "DKAN 02")
                    {
                        cdepttxt.Text = "Low-Country Dance";
                    }
                    else if (datareader.GetString(8) == "DKAN 03")
                    {
                        cdepttxt.Text = "Sabaragamuwa Dance";
                    }
                    else if (datareader.GetString(8) == "DKAN 04")
                    {
                        cdepttxt.Text = "Indian and Asian Dance";
                    }
                    else if (datareader.GetString(8) == "DKAN 05")
                    {
                        cdepttxt.Text = "Percussion Music";
                    }
                    else if (datareader.GetString(8) == "DKAN 06")
                    {
                        cdepttxt.Text = "History and Theory of Dance and Drama";
                    }
                    else
                    {
                        cdepttxt.Text = "Theatre, Ballet and Modern Dance";
                    }
                }
                datareader.Close();
                conn.CloseConnection();
            }
        }