txtQueryInfo.Text = \ } }
public MessageBoxButtons Error { get; set; }
private void btnUpdate_Click(object sender, EventArgs e) {
if (!stuDic.ContainsKey(txtQueryInfo.Text)) {
MessageBox.Show(\用户不存在\错误\MessageBoxIcon.Error); return; } else {
panel1.Visible = true;
StuInfo stu = stuDic[txtQueryInfo.Text]; txtID.Text = stu.Id;
txtName.Text =stu.Name; txtClass.Text = stu.Classes;
txtTelephone.Text =stu.Telephone; this.Height = 400; txtID.Enabled = false; } } }
4、现有一半价为r的圆,半价r随机产生(0-100之间实数), 输出圆周长及圆面积。 class Program {
static void Main(string[] args) {
double r, Zc,area;
Random rd = new Random(); r = rd.Next(0, 100); Zc = 2 * Math.PI * r;
area = Math.PI * (Math.Pow(r, 2));
Console.WriteLine(\圆半径r{0},圆周长是{1},圆面积是{2}\ Console.ReadKey();
} }
5、现数据库bookShopDB中有如下用户表tab_user 编号 id int 主键 自增 用户名 username varchar(50) 密码 password varchar(50) 用户类型 type tinyint
请编程实现用户的登录,登录界面有txtUsername,txtPassword分别接受用户名与密码。
private void btnSubmit_Click(object sender, EventArgs e) {
if (txtPassword.Text == \ {
MessageBox.Show(\用户名及密码不能为空!\ return; }
SqlConnection conn = new SqlConnection();
conn.ConnectionString = @\Catalog=BookShopDB;Trusted_Connection=True\ conn.Open();
SqlCommand cmd = new SqlCommand(); cmd.Connection = conn;
cmd.CommandText = @%username='\
+\ SqlDataReader dr = cmd.ExecuteReader(); if (dr.HasRows) {
MessageBox.Show(\登录成功!\ mainForm mf = new mainForm(); mf.Show(); this.Hide(); } else {
MessageBox.Show(\用户名或密码错误,登录失败!\ txtUsername.Text = \ txtPassword.Text = \ }
conn.Close(); }