Asp. NET implementation of student management system _ Practical skills

Source: Internet
Author: User
Tags email string

The specific controls and key attributes required by the Student management system:

1. Login Form

Basic controls:

Label (Label control)

Main properties: Image (images displayed on the label)

Text (displayed on the label)

TextBox (text box control)

Main properties: PasswordChar (indicates the character that is displayed in the text box when it is the password box, not the text that is actually entered)

button (buttons control)

ComboBox (Dropdown) Property: SelectedItem: Gets the currently selected item

Events: Click (Occurs when the control is clicked)

private void Butstyle_click (object sender, EventArgs e)
    {
      string str = "Data source=.;i Nitial Catalog=myschool;uid=sa ";
      SqlConnection con = new SqlConnection (str);
      String sql = "SELECT COUNT (1) from student where studentname= '" + txtUsername.Text + "' and loginpwd= '" + Txtpwd.text + "' ";
      SqlCommand cmd = new SqlCommand (sql, con);
      Try
      {
        con. Open ();
        int count = Convert.ToInt32 (cmd. ExecuteScalar ());
        if (Count > 0)
        {
         MessageBox.Show ("Login succeeded");
          This. Hide ();
          FormMain frm = new FormMain ();
          frm. Show ();
        }
      catch (Exception)
      {

        MessageBox.Show ("exit");
      }
      Finally
      {
        con. Close ();
      }

Sender is the event source that represents the object where this event occurred, and the event source is the button.

E is an event parameter (EventArgs) object, and different events have different parameters.

The close () method is a method of form class form that closes the form.

2.Myschool Administrator

01. Add an event handler to the "Add Student" menu item in the menu bar, as follows

private void New student Toolstripmenuitem_click (object sender, EventArgs e)
    {
      formstudent formstudent = new Formstudent ();
      Formstudent.show ();
    }

02. Add Student Information

 public void Save () {//Add student string pwd = Txtpwd.
      Text; String stuname = Textname.
      Text; Sex string stugender = string.
      Empty; if (radioman.
      Checked) {Stugender = "1";
      else {Stugender = "0";
      }//dropdown box bound data int gid = Geadidname (); Contact Phone String stuphone = Textphone.
      Text;
      Address string stuaddress = Textaddress.text;
      Date datetime dt = Datebirthday.value;
      Mailbox string stuemail = Textemail.text; Loginpwd, Studentname, Gender, Gradeid, Phone, address, birthday, Email String sql = INSERT into Student values (' "+ pwd +" ', ' "+ Stuname +" ', ' "+ Stugender +" ', "+ gid +", ' "+ Stuphone +", ' "+ stuaddress +" ', ' "+ dt +" ', ' "+ S
      Tuemail + "')"; String str = "Data source=.;i
      Nitial Catalog=myschool;uid=sa; ";
      SqlConnection con = new SqlConnection (str);
      SqlCommand cmd = new SqlCommand (sql, con); Con.
      Open (); int COunt = cmd.
      ExecuteNonQuery ();         
      if (Count > 0) {MessageBox.Show ("add success"); Con.
    Close (); }

3. Inquiry Student Information

Query Student Information

    public void Lodadatalistview (String sql) {string str = ' data source=.;
      initial catalog=myschool;uid=sa; ";
      SqlConnection con = new SqlConnection (str);
      SqlCommand cmd = new SqlCommand (sql, con); try {con.
        Open (); SqlDataReader dr = cmd.
        ExecuteReader (); if (Dr!= null) {if (DR). HasRows) {while (DR).
              Read ()) {int Stuno = Convert.ToInt32 (dr["Studentno"]);
              Name string stuname = Convert.ToString (dr["Studentname"]);
              Gender string stugender = Convert.ToString (dr["Gender"]);
              Grade Rank String stugname = convert.tostring (dr["Gradename"));
              ListViewItem Lvitem = new ListViewItem (stuno.tostring ());
              LVITEM.SUBITEMS.ADD (Stuname);
              LVITEM.SUBITEMS.ADD (Stugender);
              LVITEM.SUBITEMS.ADD (Stugname); Get Lvitem and ListView to associate LVL.Ist.
            Items.Add (Lvitem); } Dr.
          Close ();
      A catch (Exception) {throw; finally {con.
      Close (); The private void Formselect_load (object sender, EventArgs e) {String sql = Select Studentno,stud is invoked in the events for form Load
      Entname,gender,gradename from Student,grade where Student.gradeid=grade.gradeid ";
    Lodadatalistview (SQL);
 }

Modify Student Information

public void Upatae () {//Add student string pwd = Txtpwd.
      Text; String stuname = Textname.
      Text; Sex string stugender = string.
      Empty; if (radioman.
      Checked) {Stugender = "1";
      else {Stugender = "0";
      }//dropdown box bound data int gid = Geadidname (); Contact Phone String stuphone = Textphone.
      Text;
      Address string stuaddress = Textaddress.text;
      Date datetime dt = Datebirthday.value;
      Mailbox string stuemail = Textemail.text; Loginpwd, Studentname, Gender, Gradeid, Phone, address, birthday, Email String sql = @ "Update Student set STUDENTN Ame= ' "+ stuname +" ', gender= "+ Stugender +", gradeid= ' "+ gid +" ', phone= ' "+ Stuphone +" ', address= ' "+ stuaddress +" '
      , birthday= ' + dt + ', email= ' "+ stuemail +" ' where studentno= ' "+ Textno.text +" "; String str = "Data source=.;i
      Nitial Catalog=myschool;uid=sa; "; SqlConnection con = new SqlConnection (str);
      SqlCommand cmd = new SqlCommand (sql, con); Con.
      Open (); int count = cmd.
      ExecuteNonQuery ();
        if (Count > 0) {frmselect.selectdata ();
      MessageBox.Show ("Successful modification"); Con.
    Close ();
 }

The above is about the implementation of the student management system of the key code, I hope to help you learn, we can make a student management system, the student management system to expand the function.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.