資源簡介
實現用戶登錄,查詢,修改,刪除。數據庫。

代碼片段和文件信息
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?cl
{
????public?partial?class?Form1?:?Form
????{
????????private?int?nLoginCount?=?0;
????????private?const?int?MAX_LOGIN_COUNT?=?3;
????????public?Form1()
????????{
????????????InitializeComponent();
????????}
????????private?void?button1_Click(object?sender?EventArgs?e)
????????{
????????????string?str_name?=?““;
????????????string?str_pass?=?““;
????????????int?li_usercount?=?0;
????????????string?str_sql?=?““;
????????????string?str_con?=?““;
????????????if?(textBox1.Text?==?null?||?textBox1.Text.Equals(““))
????????????{
????????????????MessageBox.Show(“請輸入用戶名“);
????????????????return;
????????????}
????????????if?(textBox2.Text?==?null?||?textBox2.Text.Equals(““))
????????????{
????????????????MessageBox.Show(“請輸入密碼“);
????????????????return;
????????????}
????????????str_name?=?textBox1.Text;
????????????str_pass?=?textBox2.Text;
????????????str_con?=?Properties.Settings.Default.userConnectionString;
????????????//str_sql?=?“select?count(*)?from?user?where?username=‘“?+?str_name?+?“‘?and?password=‘“?+?str_pass?+?“‘“;
????????????str_sql?=?“select?count(*)?from?users?where?username=‘“?+?str_name?+?“‘?and?password=‘“?+?str_pass?+?“‘“;
????????????SqlConnection?con?=?new?SqlConnection(str_con);
????????????SqlCommand?com?=?new?SqlCommand();
????????????com.Connection?=?con;
????????????com.CommandText?=?str_sql;
????????????try
????????????{
????????????????con.Open();
????????????????li_usercount?=?(int)com.ExecuteScalar();
????????????}
????????????catch?(Exception?ex)
????????????{
????????????????MessageBox.Show(ex.Message);
????????????}
????????????finally
????????????{
????????????????con.Close();
????????????}
????????????if?(li_usercount?>?0)
????????????{
????????????????this.DialogResult?=?DialogResult.OK;
????????????????{
????????????????????Form2?frmNew?=?new?Form2();
????????????????????frmNew.Show();
????????????????}
????????????}
????????????else
????????????{
????????????????nLoginCount++;
????????????????if?(nLoginCount?==?MAX_LOGIN_COUNT)
??????????????????//?Over?3?times
????????????????????this.DialogResult?=?DialogResult.Cancel;
???????????????else
???????????????{
????????????????MessageBox.Show(“用戶名或密碼錯誤,請重新輸入!“);
????????????????textBox1.Focus();
????????????????this.DialogResult?=?DialogResult.None;
???????????????????}
????????????}
????????}
????????private?void?label1_Click(object?sender?EventArgs?e)
????????{
????????}
????????private?void?label2_click(object?sender?EventArgs?e)
????????{
????????}
????????private?void?button2_Click(object?sender?EventArgs?e)
????????{
?????????????this.DialogResult?=?DialogResult.Cancel;
????????}
????????private?void?form1
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件???????8189??2011-11-07?19:39??C#\cl\09710112.csproj
?????文件????????486??2011-10-26?16:43??C#\cl\09710112.csproj.user
?????文件????????427??2011-11-03?00:16??C#\cl\app.config
?????文件??????38912??2011-11-07?19:59??C#\cl\bin\Debug\cl.exe
?????文件????????427??2011-11-03?00:16??C#\cl\bin\Debug\cl.exe.config
?????文件??????91648??2011-11-07?19:59??C#\cl\bin\Debug\cl.pdb
?????文件??????14328??2011-12-26?16:35??C#\cl\bin\Debug\cl.vshost.exe
?????文件????????427??2011-11-03?00:16??C#\cl\bin\Debug\cl.vshost.exe.config
?????文件????????490??2009-06-11?05:14??C#\cl\bin\Debug\cl.vshost.exe.manifest
?????文件????2293760??2011-11-20?13:57??C#\cl\bin\Debug\date\users.mdf
?????文件?????573440??2011-11-20?13:57??C#\cl\bin\Debug\date\users_log.ldf
?????文件??????11331??2011-11-03?00:19??C#\cl\date\users.Designer.cs
?????文件????2293760??2011-11-07?16:09??C#\cl\date\users.mdf
?????文件??????????3??2011-10-26?16:22??C#\cl\date\users.xsc
?????文件???????1576??2011-10-26?16:22??C#\cl\date\users.xsd
?????文件??????????3??2011-10-26?16:22??C#\cl\date\users.xss
?????文件?????573440??2011-11-07?16:09??C#\cl\date\users_log.ldf
?????文件???????3887??2011-11-05?22:34??C#\cl\Form1.cs
?????文件???????6437??2011-11-05?22:34??C#\cl\Form1.Designer.cs
?????文件???????5814??2011-11-05?22:34??C#\cl\Form1.resx
?????文件???????2953??2011-11-07?19:41??C#\cl\Form2.cs
?????文件???????6451??2011-11-07?19:39??C#\cl\Form2.Designer.cs
?????文件???????6012??2011-11-07?19:39??C#\cl\Form2.resx
?????文件???????8412??2011-11-07?19:58??C#\cl\Form3.cs
?????文件??????15320??2011-11-07?19:55??C#\cl\Form3.Designer.cs
?????文件???????5814??2011-11-07?19:55??C#\cl\Form3.resx
?????文件???????6873??2011-11-07?19:54??C#\cl\Form4.cs
?????文件??????14271??2011-11-07?19:54??C#\cl\Form4.Designer.cs
?????文件???????5814??2011-11-07?19:54??C#\cl\Form4.resx
?????文件???????1930??2011-11-07?18:37??C#\cl\Form5.cs
............此處省略42個文件信息
- 上一篇:WPF呼吸閃爍效果例子242779
- 下一篇:HC-06AT指令工具
評論
共有 條評論