Movie record management system modification and comments, complete code, management system comments

Source: Internet
Author: User

Movie record management system modification and comments, complete code, management system comments


1 using System; // introduces the core namespace, which is the foundation of all classes. 2 using System. collections. generic; // introduce the namespace of the Collection class. You can use the collection class 3 using System, such as the Generic class. componentModel; // introduce the ComponentModel namespace 4 using System. data; // introduce the Data operation namespace, such as DataSet Class 5 using System. drawing; // introduce the Drawing namespace and use the Class 6 using System such as Color. linq; // The namespace provides the class and interface 7 using System that supports query using language integration query (LINQ. text; // introduce the namespace for Text operations, such as StringBuilder and character operations. windows. forms; // introduces the form namespace and supports window Class 9 using System. configuration; // configure the namespace, including the classes related to application Configuration, such as ConfigurationManager [manually add] 10 using System. data. sqlClient; // SqlCommand (using command or assembly reference) [manually add] 11 12 /********************************* **************************************** * ****** 13 * Add a reference, you can add the required library, instead of adding the corresponding library file through using 14 *. This is also because the reference has a system, therefore, you can add 15 ************************************ ******************************* * **********/16 17 /************************* * 18 19 * modifier: liu Zhizhi 20 21 ** Description: FrmLogin. implementation of cs for user login forms 22 23 ******************************* * ********************/24 25 namespace movie record management system 26 {27 public partial class FrmLogin: form/* FrmLogin class name. Form is the base class. FrmLogin: Form indicates that the FrmLogin class is a subclass and inherits the Form of the parent class. */28 {29 30 public FrmLogin () /* partial indicates that the partial type definition allows you to split the class, structure, or interface definition into multiple files */31 {32 InitializeComponent ();/* Initialize all controls on the form, run */33} 34 in the initialization window before the window is displayed. // first set to connect to the configuration file to set up the App. config 35 // Of course, The ConfigurationManager system does not use its namespace by default. Therefore, you need to parse the 36 // configuration file App. config defines "str", add name = "str", and str can have different names, as long as ConnectionStrings ["str"] is consistent, you can connect to the configuration file App. config 38 string connStr = ConfigurationManager. connectionStr Ings ["str"]. connectionString; 39 40 /************************************* ************************************* 41 * private means: this event or method can be referenced in the closest forward braces. 42 *************************************** * **********************************/43 private void btnLogin_Click (object sender, eventArgs e) // the sender of the two parameters 44 {45 // is the btnLogin_Click you clicked. You can use the type conversion to obtain reference of btnLogin_Click: e is the parameters of the click event. 46 // use SqlConnection to connect to the conn in database 47 // using. Its scope is limited to 48 using (SqlConnection conn = new SqlConnection (connStr) in {} of using )) 49 {50 // create an SQL query statement 51 /***************************** **************************************** * ****************** 52 * select * from Movie. dbo. movieAccount where MUserName = 'Liu Zhizhi '53 *. The result is "123450" 54 *. To assign the string to aql, the preceding query statement is divided into three parts as the statement output 55 **************************** **** **************************************** * ***********/56 string SQL = "select MUserPwd from MovieAccount where MUserName = '" + txtName. text + "'"; // three part of the syntax statement is assigned to SQL 57 58 // create SqlCommand execution command 59 using (SqlCommand cmd = new SqlCommand (SQL, conn )) 60 {61 // open the database connection 62 conn. open (); 63 // use SqlDataReader to read 64 using (SqlDataReader sdr = cmd. executeReader () 65 {66 // SqlDataReader one entry starting from 1st data entries in the database Read 67 if (sdr. read () // If the account is successfully Read (the username in the text box exists in the Database) 68 {69 // The 1st passwords are assigned to the string pwd, the 70 // Trim () method is to remove the blank string 71 string pwd = sdr. getString (0 ). trim (); // auto-increment of each row. You need to lock the column. GetString (0) indicates locking the first column of pwd, that is, a series of passwords! 72 // if the password entered in the text box = PASSWORD 73 in the database if (pwd = txtPwd. text) 74 {75 // indicates that the password under this account is correct and the system logon is successful 76 MessageBox. show ("the system is successfully logged on. You are redirected to the home page... "); 77 FrmManager manager = new FrmManager (); 78 manager. show (); 79 this. hide (); // Hide the current element. Find the name of the edited form, you will know which 80} 81 else 82 {83 // otherwise the password is wrong and enter the password 84 MessageBox again. show ("Incorrect password! Enter it again! "); 85 // and the current password is automatically cleared 86 txtPwd. text = ""; 87} 88} 89 else 90 {91 // If reading account data fails, the user name does not exist 92 MessageBox. show ("the user name does not exist. Please enter it again! "); 93 // and automatically clear account name 94 txtName. text = ""; 95} 96} 97} 98} 99} 100 private void FrmLogin_Load (object sender, EventArgs e) 101 {102 /************************************ * *********************** 103 * double-click the control, to jump to the event editing code, you need to use the property instead of double-clicking. The logon button is clicked by default, double-click to go to the editing page, and click 104 ********************************* * *************************/105} 106 107 private void label2_Click (object sender, eventArgs e) 108 {109 110} 111 private void txtPwd_TextChanged (object sender, EventArgs e) 112 {113 114} 115 private void txtName_TextChanged (object sender, EventArgs e) 118 {119 120} 121 122 private void btnLogin_KeyPress (object sender, KeyPressEventArgs e) // form parameter 123 {124 if (e. keyChar = 13) 125 {126 btnLogin_Click (sender, e); // real parameter, name can be the same 127 // int c = add (5, 6); // function call, here is the name (parameter 1, parameter 2) 128} 129} 130 131 /********************************* **************************************** * ** 132 * private int add (int, int B) // Private + Type + name (type parameter 1, type parameter 2) 133*{134 * return a + B; 135 *} 136 ************************************ ***************************************/ 137 138 139} 140}

1 using System; 2 using System. collections. generic; 3 using System. componentModel; 4 using System. data; 5 using System. drawing; 6 using System. linq; 7 using System. text; 8 using System. windows. forms; 9 using System. configuration; // configure the namespace, including the classes related to application Configuration, such as ConfigurationManager [manually add] 10 using System. data. sqlClient; // SqlCommand (using command or assembly reference) [manually add] 11 12 namespace movie record management system 13 {14 public partial class FrmMa Nager: Form15 {16 public FrmManager () 17 {18 InitializeComponent (); 19} 20 // first set to connect to the configuration file to build the App. config, the displayed new form requires //// to insert data 21 // Of course, The ConfigurationManager system here does not use its namespace by default. Therefore, you need to parse the 22 // configuration file App. config defines "str", add name = "str", and str can have different names, as long as ConnectionStrings ["str"] is consistent, you can connect to the configuration file App. config ///// write a record to the database, and the displayed form should be carried out according to the login Method 24 // For example, in the material management system, we need to put all the host names in the configuration file, 25 // Data Source = 127.0.0.1 (access this level, write pc201 here 50330 host name); Initial Catalog = Movie (Database Name); Persist Security Info = True; User ID = sa; Password = 123456 (Consistent after modification); 26 string connStr = ConfigurationManager. connectionStrings ["str"]. connectionString; 27 28 /************************************* ************************************* 29 * private means: this event or method can be referenced in the closest forward braces. 30 *************************************** * ***********************************/31 32 private void button#click (object sender, eventArgs e) 33 {34 MessageBox. show (this. richTextBox1.Text + "saved successfully! "); 35 using (SqlConnection conn = new SqlConnection (connStr) // see the configuration file line for connStr, that is, start the database connection operation 36 {37 conn. open (); 38 // + two three parts in total, that is, to operate in this format, be sure to modify the application 39 string SQL = "INSERT INTO MovieText (MText) VALUES ('"+ richTextBox1.Text +"') "; // Database Operation Command (select as an identifier when creating a table, automatically + 1) 40 MessageBox. show (SQL); 41 SqlCommand cmd = new SqlCommand (SQL, conn); // instantiate limit 42 cmd. executeNonQuery (); // the corresponding operation 43 conn. close (); 44} 45} 46} 47}

1 <? Xml version = "1.0" encoding = "UTF-8"?> // Configuration file 2 <configuration> 3 <connectionStrings> 4 5 <add name = "str" connectionString = "Data Source = PC201503301006; Initial Catalog = Movie; integrated Security = True "/> 6 </connectionStrings> 7 </configuration>
1 using System. windows. forms; 2 3 namespace movie record management system 4 {5 static class Program 6 {7 /// <summary> 8 // main entry point of the application. 9 /// </summary> // Note 10 [STAThread] 11 static void Main () 12 {13 Application. enableVisualStyles (); 14 Application. setCompatibleTextRenderingDefault (false); 15 Application. run (new FrmLogin (); 16} 17} 18}

 

 

 

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.