Sprint Stage Day11

Source: Internet
Author: User

Project Progress: Department, professional, class management these three no students, the teacher management part of the input projects, so the form is relatively simple, the code is simple, the process is smooth, with the previous writing experience, a lot of code can be copied directly over, the more the more successful writing, The last module has been run to the last department.

Experience: practice makes perfect, more exercises to master!

Department Management Code:

usingSystem;usingSystem.Collections.Generic;usingSystem.ComponentModel;usingSystem.Data;usingSystem.Drawing;usingSystem.Linq;usingSystem.Text;usingSystem.Windows.Forms;usingSystem.Data.OleDb;usingSystem.Configuration;namespacegengdancontactsmis_winform{ Public Partial classDepartmentfrm:form {//string constr;DB DB;  Publicdepartmentfrm () {//constr = configurationmanager.connectionstrings["ConnectionString"]. ToString (); InitializeComponent (); DB=NewDB ();        Binddepartment (); }        voidbinddepartment () {/*//string constr = @ "Provider=microsoft.ace.oledb.12.0;data source=|                        DATADIRECTORY|\GENGDANCONTACTSDB.ACCDB ";            OleDbConnection con = new OleDbConnection (CONSTR);            String sql = "Select DepartmentID as part number, departmentname as department name from Department";            OleDbDataAdapter ADP = new OleDbDataAdapter (sql, con);            DataSet ds = new DataSet (); Adp.            Fill (ds, "Department"); Datagridview1.datasource = ds. tables["Department"];*/            stringsql ="Select DepartmentID as department number, departmentname as department name from Department"; DataSet DS= db. GetDataSet (SQL,"Department"); Datagridview1.datasource= ds. tables["Department"]; }        Private voidbtnAdd_Click (Objectsender, EventArgs e) {           /*//String constr = @ "Provider=microsoft.ace.oledb.12.0;data source=|            DATADIRECTORY|\GENGDANCONTACTSDB.ACCDB ";            OleDbConnection con = new OleDbConnection (CONSTR); String sql = "INSERT into Department (departmentid,departmentname) VALUES (" + Txtdepartmentid.text + ", '" + Txtdepartmentna Me.            Text + "')";            OleDbCommand cmd = new OleDbCommand (Sql,con); Con.            Open (); Cmd.            ExecuteNonQuery ();            MessageBox.Show ("department information added successfully!"); Con.            Close (); Binddepartment ();*/            stringsql ="INSERT INTO Department (departmentid,departmentname) VALUES ("+ Txtdepartmentid.text +", '"+ Txtdepartmentname.text +"')"; Db.            ExecuteSQL (SQL);        Binddepartment (); }        Private voidBtnupdate_click (Objectsender, EventArgs e) {            intRowIndex =DataGridView1.CurrentCell.RowIndex; stringDepartmentID = Datagridview1.rows[rowindex]. cells[0].            Value.tostring (); stringDepartmentname = Datagridview1.rows[rowindex]. cells[1].            Value.tostring (); stringsql ="Update Department set departmentname= '"+ Departmentname +"' where departmentid="+DepartmentID; Db.        ExecuteSQL (SQL); }        Private voidBtndelete_click (Objectsender, EventArgs e) {            intRowIndex =DataGridView1.CurrentCell.RowIndex; stringDepartmentID = Datagridview1.rows[rowindex]. cells[0].            Value.tostring (); stringsql ="Delete from Department where departmentid="+DepartmentID; Db.            ExecuteSQL (SQL);        Binddepartment (); }        Private voidbtnSearch_Click (Objectsender, EventArgs e) {                      /*String sql = "SELECT * from Department where departmentid=" +txtdepartmentid.text; DataSet ds = db.            GetDataSet (SQL, "D"); Datagridview1.datasource = ds. tables["D"];*/            stringsql ="SELECT * from Department where departmentname= '"+ txtdepartmentname.text+"'"; DataSet DS= db. GetDataSet (SQL,"D"); Datagridview1.datasource= ds. tables["D"]; }        Private voidBtncancel_click (Objectsender, EventArgs e) {             This.        Close (); }    }}

Record Person: Wendy

Sprint Stage Day11

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.