Seventh time operation (user repair System)

Source: Internet
Author: User

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.sqlclient;namespace Theuserservice        {public partial class Form1:form {public Form1 () {InitializeComponent ();        } Dbcon db = new Dbcon ();                private void Denglu_click (object sender, EventArgs e) {Db.dbcon ();  if (Textboxname.text! = "" & Textboxpass.text! = "") {string com = "SELECT count (*)                    PassWord from User_info where username= ' "+ textboxname.text +" ' ";                    SqlCommand comm = new SqlCommand (COM, db.conn); int a = (int) Comm.                    ExecuteScalar (); if (a = = 0) {This.label1.Text = "username does not exist Oh!"                        Please re-enter the user name • • "; MessageBox.Show ("User name does not exist!             ");       } else {String com1 = "SELECT count (*) PassWord from                        User_info where username= ' "+ Textboxname.text +" ' and password= ' "+ textboxpass.text +" ' ";                        SqlCommand comd = new SqlCommand (COM1, db.conn); int a1 = (int) comd.                        ExecuteScalar (); if (a1 = = 0) {this.label1.Text = "wrong password!                            Please re-enter the password • • "; MessageBox.Show ("Password error Oh!")                        "); } else {this.label1.Text = "Login succeeded!"                                                        Welcome • • ";                            WINDOWSFORMSAPPLICATION1.FORM3 fm = new WINDOWSFORMSAPPLICATION1.FORM3 (textboxname.text); Fm.                            Show (); MessageBox.Show ("Login Successful!                        ");               }} db.conn.Close (); } else {this.label1.Text = "user name or password cannot be empty!"                "; }} private void Button1_Click (object sender, EventArgs e) {windowsformsappli Cation1.            FORM2 fm = new Windowsformsapplication1.form2 (); Fm.        Show (); private void Form1_Load (object sender, EventArgs e) {}}}

FORM2;

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.sqlclient;using Theuserservice; namespace windowsformsapplication1{public partial class Form2:form {public Form2 () {in        Itializecomponent ();        } Dbcon db = new Dbcon ();            private void Button1_Click (object sender, EventArgs e) {Db.dbcon ();            String name = This.txtxname.Text.Trim ();            String pwd1 = This.txtpwd1.Text.Trim ();            String pwd2 = This.txtpwd2.Text.Trim (); if (name = = "") {MessageBox.Show ("username cannot be empty!                ");            Return } if (pwd1 = = "") {MessageBox.Show ("Password cannot be empty!                ");            Return } if (pwd2 = = "") {MessageBox.Show ("Please enter the password again!")                "); Return; } if (pwd1 = = pwd2) {String sql = "INSERT into User_info (Username,password) values                (' + name + ' ', ' ' + pwd1 + ') ';                SqlCommand comd = new SqlCommand (sql, db.conn); int a1 = db.                ExecuteSQL (SQL); if (A1 > 0) {MessageBox.Show ("Registration is successful, please return to login!")                    "); This.                    Hide ();                    FORM1 fm = new Form1 (); Fm.                Show (); } else {MessageBox.Show ("Please try again!                "); }} else {MessageBox.Show ("two times password inconsistent, please re-enter!")            "); }} private void Button2_Click (object sender, EventArgs e) {Form1 fm = new for            M1 (); Fm.        Show (); private void Form2_load (object sender, EventArgs e) {}}}

Form3:

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 theuserservice;using System.Data.SqlClient;        namespace windowsformsapplication1{public partial class Form3:form {Dbcon db = new Dbcon ();        public string name = "";            Public Form3 (String value) {InitializeComponent ();         THIS.name = value;            private void Button1_Click (object sender, EventArgs e) {if (This.txtaddress.Text.Trim () = = "") {MessageBox.Show ("The repair failed! Please enter the repair location!                ");            Return } if (This.txtleixing.Text.Trim () = = "") {MessageBox.Show ("Repair failed! Please input the repair content!                ");            Return } String sql = "INSERT into Repair_info (Username,leixing,didian,leirong,riqi,cishu) VALUES ('" + name + "', '" + ComboBox1.SelectedItem.ToStriNg () + "', '" + This.txtaddress.Text + "', '" + This.txtleixing.Text + "', '" + Time.Now.ToShortDateString () + "', ' 1 ')";            SqlCommand comd = new SqlCommand (sql, db.conn); int a1 = db.            ExecuteSQL (SQL); if (A1 > 0) {MessageBox.Show ("Repair successful!                ");                This.txtleixing.Text = "";                This.txtaddress.Text = "";            This.comboBox1.Text = "Computer class"; }} private void Button2_Click (object sender, EventArgs e) {this.        Close (); private void Form3_load (object sender, EventArgs e) {} private void Combobox1_selectedindex Changed (object sender, EventArgs e) {}}}

dbcon.cs;

Using system;using system.collections.generic;using system.linq;using system.text;using System.Data.SqlClient;using System.data;using System.windows.forms;namespace theuserservice{class Dbcon {public string connectstring = The Data source=.;i        Nitial catalog=repair;integrated security=true ";        Public SqlConnection conn = new SqlConnection ();                public void Dbcon () {try {conn = new SqlConnection (connectstring); Conn.            Open ();            } catch (Exception e) {MessageBox.Show ("database connection not successful" + e.tostring ());            }} public int executesql (String SqlString) {int count =-1;            SqlConnection connectiontemp = new SqlConnection (connectstring);            Connectiontemp.open ();                try {SqlCommand cmd = new SqlCommand (SqlString, connectiontemp); Count = cmd. ExecuteNonQuery ();            } catch {count =-1;            } finally {connectiontemp.close ();        } return count;   }    }}

Database creation:

Test:

  

Design ideas:

(1) understand the problem. After we have looked at the requirements, the next step is to follow the incremental requirements of the analysis, added a registration interface and a repair interface.

(2) Create a new repair list at the same time, the name is Repair_info, confirm the output content. We should be able to use the code to implement the database additions and deletions to the operation, in order to achieve user registration.

(3) Design the repair interface. Make the design of each quick operation flow, how to input, how to output, how to judge, how to submit and so on.

(4) write the whole code. The algorithm that we determine is manifested, resulting in C # code.

(5) Test and solve the problem. Compile run, multiple tests, see if the results are the same as expected, if different, then find the problem and modify, and eventually form a qualified program.

Team Division:

Person in charge: resonant, responsible for code specification and code implementation (3.5 points)

Team member: Li Bin, responsible for code errors and PSP analysis (2 points)

Team member: Shinguo, responsible for database creation and landscaping (1.5 points)

Team member: Liu Yuanhai, responsible for design ideas and testing (1.5 points)

Team member: Yi Tantan, responsible for control typesetting and team summary (1.5 points)

PSP Time Consuming:

Team Summary:

The increase in the implementation of the job, so the beginning is still more troublesome point. This is the implementation of three interface to the database operation, this time the increase is mainly the database

Database knowledge, simple interface framework and less complex code for us is still better to do, the database is nothing more than connection, Command, DataReader

Datasets are used to manipulate these objects. At the same time, we have learned a lot from the books on database in C #.

However, this small project we do is not very good, for the number of repair, the same user each repair +1 this did not complete the demand. Logical competence, but we don't know how to solve it.

Seventh time operation (user repair System)

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.