Table Item Delete Table

Source: Internet
Author: User

1 usingSystem;2 usingSystem.Collections.Generic;3 usingSystem.ComponentModel;4 usingSystem.Data;5 usingSystem.Drawing;6 usingSystem.Linq;7 usingSystem.Text;8 usingSystem.Threading.Tasks;9 usingSystem.Windows.Forms;Ten usingSystem.Data.SqlClient; One  A  - namespaceRestaurant Review - { the      Public Partial classForm1:form -     { -          PublicForm1 () -         { + InitializeComponent (); -         } +  A         Private voidForm1_Load (Objectsender, EventArgs e) at         { -Loaddeskinfobydelid (0); -  -         } -         stringstr ="Data Source=.;i Nitial catalog=mysql;integrated security=true"; -         Private voidLoaddeskinfobydelid (intp) in         { -             //Enquiry tolist<deskinfo> list =NewList<deskinfo>(); +              -             stringsql ="SELECT * from deskinfo where Deskdelflag ="+p; theSqlConnection con =NewSqlConnection (str); * con. Open (); $SqlCommand cmd =NewSqlCommand (sql, con);Panax NotoginsengSqlDataReader reader =cmd. ExecuteReader (); -             if(reader. HasRows) the             { +                  while(reader. Read ()) A                 { theList. ADD (NewDeskinfo () +                                    { -Deskid = Convert.ToInt32 (reader["Deskid"]), $Deskname = reader["Deskname"]. ToString (), $Desknamepinyin = reader["Desknamepinyin"]. ToString (), -Desknum = reader["Desknum"]. ToString () -                                    }); the                 } -             }WuyiDGV. DataSource =list; theDGV. rows[0]. Selected =false; -DGV. AutoGenerateColumns =false; Wu  - con. Dispose (); About cmd. Dispose (); $ Reader. Dispose (); -         } -  -         Private voidBtnok_click (Objectsender, EventArgs e) A         { +             //Add the             stringsql =string. Format ("INSERT INTO Deskinfo (deskname,desknamepinyin,deskdelflag,desknum) VALUES (' {0} ', ' {1} ', 0, ' {2} ')", txtname.text,txtpinyin.text,txtnum.text); -SqlConnection con =NewSqlConnection (str); $ con. Open (); theSqlCommand cmd =NewSqlCommand (Sql,con); the cmd. ExecuteNonQuery (); theLoaddeskinfobydelid (0); the con. Dispose (); - cmd. Dispose (); in         } the  the         Private voidBtndel_click (Objectsender, EventArgs e) About         { the             //Delete the             intDelid = Convert.ToInt32 (DGV. selectedrows[0]. cells[0]. Value); the             stringsql ="Update Deskinfo Set deskdelflag = 1 where deskid ="+Delid; +SqlConnection con =NewSqlConnection (str); - con. Open (); theSqlCommand cmd =NewSqlCommand (Sql,con);Bayi cmd. ExecuteNonQuery (); theLoaddeskinfobydelid (0); the  -  -  the con. Dispose (); the cmd. Dispose (); the         } the  -  the  the     } the}

Table Item Delete Table

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.