Sprint Stage Day 9

Source: Internet
Author: User

Project Progress

Yesterday finally completed the teacher part of the content, today we re-start to the previous department setup can not achieve the content has been written, the lack of deletion and query has also been supplemented, in connection with the database has also been modified and updated.

There is a problem

Because it is difficult to finish the content before, today re-pick up, the idea of some confusion, in the writing and student teacher management is also different, so it is still difficult to write, the database connection is always a problem.

Experience

Fortunately, because of the success of a few parts, and then pick up the first part of the original, the method also has some inspiration, although not exactly the same, but more handy. So we have a few people together through the search data, the Internet will be the department set up this part of the content has been modified to supplement the perfect, finally completed. Through the group work, our cooperation more tacit understanding, know how to do a project, team division and cooperation. In just a few weeks we have become condensed from the loose, the power of this project. Whether it is knowledge or experience, I feel very fruitful!

Here are some of the code

using system;using system.collections.generic;using system.componentmodel;using system.data;using System.drawing;using system.linq;using system.text;using system.windows.forms;using System.Data.OleDb;using System.configuration;namespace gengdancontactsmis_winform{ PublicPartialclassDepartmentfrm: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"];*/String sql= "Select DepartmentID as part number, departmentname as department name from Department"; DataSet DS= db. GetDataSet (SQL, "Department"); Datagridview1.datasource= ds. tables["Department"]; }        Private voidbtnAdd_Click (object sender, 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 ();*/String sql= "INSERT into Department (departmentid,departmentname) VALUES (" + Txtdepartmentid.text + ", '" + Txtdepartmentname.text + " ‘)"; Db.            ExecuteSQL (SQL);        Binddepartment (); }        Private voidBtnupdate_click (object sender, EventArgs e) {intRowIndex =DataGridView1.CurrentCell.RowIndex; String DepartmentID= Datagridview1.rows[rowindex]. Cells[0].            Value.tostring (); String Departmentname= Datagridview1.rows[rowindex]. Cells[1].            Value.tostring (); String sql= "Update Department set departmentname= '" + departmentname + "' where departmentid=" +DepartmentID; Db.        ExecuteSQL (SQL); }        Private voidBtndelete_click (object sender, EventArgs e) {intRowIndex =DataGridView1.CurrentCell.RowIndex; String DepartmentID= Datagridview1.rows[rowindex]. Cells[0].            Value.tostring (); String sql= "Delete from Department where departmentid=" +DepartmentID; Db.            ExecuteSQL (SQL);        Binddepartment (); }        Private voidbtnSearch_Click (object sender, EventArgs e) {/*String sql = "SELECT * from Department where departmentid=" +txtdepartmentid.text; DataSet ds = db.            GetDataSet (SQL, "D"); Datagridview1.datasource = ds. tables["D"];*/String sql= "SELECT * from Department where departmentname= '" + txtdepartmentname.text+ "'"; DataSet DS= db. GetDataSet (SQL, "D"); Datagridview1.datasource= ds. tables["D"]; }        Private voidBtncancel_click (object sender, EventArgs e) { This.        Close (); }        Private voidDepartmentfrm_load (object sender, EventArgs e) {} }}

Record Person: Yu Yue

Sprint Stage Day 9

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.