ASP. NET implements the student management system,

Source: Internet
Author: User
Tags email string

ASP. NET implements the student management system,

Specific controls and main attributes required by the student management system:

1. logon form

Basic controls:

Label)

Main attributes:Image (the Image displayed on the tag)

Text (Text displayed on tags)

TextBox (text box Control)

Main attributes:PasswordChar (indicates the characters displayed in the text box when used as a password box, rather than the actual entered text)

Button)

ComboBox (drop-down box) attribute: SelectedItem: gets the currently selected item

Event:Click (when the control is clicked)

Private void butStyle_Click (object sender, EventArgs e) {string str = "Data source = .; initial 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 successful"); this. hide (); FormMain frm = new FormMain (); frm. show () ;}} catch (Exception) {MessageBox. show ("exit");} finally {con. close ();}

Sender is the event source, indicating the object where the event occurred. when the event occurs, the event source is the button.

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

The Close () method is a Form-like Form method used to Close the Form.

2. Myschool Administrator

01. Add an event handler to the "add student" menu item in the menu bar,The Code is as follows:

Private void added 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; // gender string stugender = string. empty; if (radioman. checked) {stugender = "1";} else {stugender = "0";} // bind the data int gid = GeadIdName () in the drop-down box; // contact number string StuPhone = textphone. text; // address string StuAddress = textAddress. text; // Date DateTime dt = dateBirthday. value; // email 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 +"', '"+ StuEmail +"') "; string str =" Data source = .; initial 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 ("added successfully");} con. close ();}

3. query 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"]); // 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); // associate lvItem and ListView with lvlist. items. add (LvItem);} dr. close () ;}} catch (Exception) {throw ;}finally {con. close () ;}// call private void Formselect_Load (object sender, EventArgs e) {string SQL = "select StudentNO, StudentName, 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; // gender string stugender = string. empty; if (radioman. checked) {stugender = "1";} else {stugender = "0";} // bind the data int gid = GeadIdName () in the drop-down box; // contact number string StuPhone = textphone. text; // address string StuAddress = textAddress. text; // Date DateTime dt = dateBirthday. value; // email string StuEmail = textEmail. text; // LoginPwd, StudentName, Gender, GradeId, Phone, Address, Birthday, Email string SQL = @ "update Student set StudentName = '" + stuname + "', gender = "+ stugender +", GradeId = '"+ gid +"', phone = '"+ StuPhone +"', Address = '"+ StuAddress + "', birthday = '"+ dt +"', Email = '"+ StuEmail +" 'where studentNo =' "+ textNo. text + "'"; string str = "Data source = .; initial 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 ("modified successfully");} con. close ();}

The above is the key code for implementing the student management system. I hope it will be helpful for your learning. You can create a student management system and expand the functions of the student management system.

Articles you may be interested in:
  • C ++ implements a simple student management system
  • Graduation Design of JavaWeb web construction web book store
  • C # design of cinema Ticketing System (1)
  • C # design of cinema Ticketing System (2)
  • C # design of cinema Ticketing System (3)
  • C # design of cinema Ticketing System (4)

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.