-
Notifications
You must be signed in to change notification settings - Fork 0
/
duzhexinxi.cs
85 lines (75 loc) · 2.61 KB
/
duzhexinxi.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
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 登陆
{
public partial class duzhexinxi : Form
{
private SqlConnection sqlConnection1;
private SqlCommand sqlCommand1 = null;
private DataSet ds = null;
// private bool add;
private string strSql;
duzhe dz;
public duzhexinxi()
{
InitializeComponent();
sqlConnection1 = new SqlConnection(dbconnection.connection);
sqlCommand1 = new SqlCommand();
sqlCommand1.Connection = sqlConnection1;
//add = false;
dz = new duzhe();
}
private void duzhexinxi_Load(object sender, EventArgs e)
{
this.strSql = " select Rno 读者号,Rname 读者姓名,Rsex 性别,Rdep 所在系,Rage 年龄 from Reader ";
this.FillDataGrid(strSql);
}
private void FillDataGrid(string sql)
{
if (this.sqlConnection1.State == ConnectionState.Closed)
this.sqlConnection1.Open();
Console.WriteLine(sql);
SqlDataAdapter adapter = new SqlDataAdapter(sql, sqlConnection1);
ds = new DataSet("Reader");
adapter.Fill(ds, "Reader");
this.dataGrid1.SetDataBinding(ds, "Reader");
}
private void button1_Click(object sender, EventArgs e)
{
if (this.Rno.Text == "" || this.Rname.Text == "" || this.Rsex.Text == "")
{
MessageBox.Show("请输入完整信息!", "提示");
return;
}
int Rage = Convert.ToInt32(this.Rage.Text);
string Rno = this.Rno.Text;
string Rname = this.Rname.Text;
string Rsex = this.Rsex.Text;
string Rdep = this.Rdep.Text;
// int Rage= this.Rage.Text;
//int Rage = Convert.ToInt32(this.Rage.Text);
dz.dz_add(Rno, Rname, Rsex, Rdep,Rage);
MessageBox.Show("保存成功!");
this.FillDataGrid(this.strSql);
}
private void button3_Click(object sender, EventArgs e)
{
Rno.Clear();
Rname.Clear();
//Rsex.Clear();
//Rdep.Clear();
//Rage.Clear();
//Ldate.Clear();
}
private void button2_Click(object sender, EventArgs e)
{
}
}
}