Exemplo n.º 1
0
        private void editToolStripMenuItem_Click(object sender, EventArgs e)
        {
            try {
                string eid = lvStudents.FocusedItem.SubItems[0].Text;

                frmStudent fs = new frmStudent(eid);
                if (fs.ShowDialog() == DialogResult.OK)
                {
                    loadStudents();
                }
            } catch {}
        }
Exemplo n.º 2
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            string fname, mi, lname, ext, gender, cur, sy, lev, sec, adv;

            cur = cmbCurriculum.Text.ToUpper();
            sy  = cmbSchoolYear.Text.ToUpper();
            lev = cmbLevel.Text.ToUpper();
            sec = cmbSection.Text.ToUpper();
            adv = cmbAdviser.Text.ToUpper();

            if ((cur.Length != 0) || (sy.Length != 0) || (lev.Length != 0) || (adv.Length != 0))
            {
                frmStudent fs = new frmStudent();
                if (fs.ShowDialog() == DialogResult.OK)
                {
                    fname = fs.fname;
                    mi    = fs.mi;
                    lname = fs.lname;
                    ext   = fs.ext;

                    gender = fs.gender;

                    try {
                        OleDbConnection con = new OleDbConnection(conString);

                        OleDbCommand cmd = new OleDbCommand("INSERT INTO tblStudent(fname, mi, lname, ext, gender, curriculum, schoolyear, slevel, ssection, adviser) VALUES ('" + fname + "', '" + mi + "', '" + lname + "', '" + ext + "', '" + gender + "', '" + cur + "', '" + sy + "', '" + lev + "', '" + sec + "', '" + adv + "');", con);

                        con.Open();
                        cmd.ExecuteNonQuery();
                        con.Close();
                        add = true;
                        loadStudents();
                    } catch (Exception ex) {
                        MessageBox.Show("Error: " + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                    }
                }
            }
            else
            {
                MessageBox.Show("All fields are required!", "Prompt", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
            }
        }