private void Cus_OK_Click(object sender, EventArgs e) { String connsql = "Data Source=PC-20170513IEDS\\SQLEXPRESS;Initial Catalog=BookStore;Integrated Security=True"; try { using (SqlConnection conn = new SqlConnection()) { conn.ConnectionString = connsql; conn.Open(); // 打开数据库连接 //update Customer set nickname = 'lijiarui',cus_age='17'where username = cherry string strcomm = "update Customer set " + "nickname='" + nickname.Text.Trim() + "'," + "cus_sex='" + sex.Text.Trim() + "'," + "cus_age='" + age.Text.Trim() + "'," + "tel='" + tel.Text.Trim() + "'," + "address='" + address.Text.Trim() + "'," + "myinfo='" + myinfo.Text.Trim() + "'where username = '******'"; //update FilTer set 列名 = value where id = 3 SqlCommand comm = new SqlCommand(strcomm, conn); comm.ExecuteNonQuery(); conn.Close(); MessageBox.Show("信息修改成功!"); this.Hide(); CusView cusinfo_form = new CusView(); cusinfo_form.ShowDialog(this);// this.Close(); } } catch (Exception ee) { MessageBox.Show(ee.Message.ToString()); } }
private void back_Click(object sender, EventArgs e) { this.Hide(); CusView cusinfo_form = new CusView(); cusinfo_form.ShowDialog(this);// this.Close(); }
private void Login_Btn_Click(object sender, EventArgs e) { if (status != 0 && status != 1) { MessageBox.Show("请选择登录身份!", "警告"); return; } if (username.Text == "" || password.Text == "") { MessageBox.Show("请输入用户名和密码!", "警告");//提示 } else { SqlConnection conn = new SqlConnection("Data Source=PC-20170513IEDS\\SQLEXPRESS;Initial Catalog=BookStore;Integrated Security=True");//建立连接 conn.Open(); //MessageBox.Show("连接成功!"); if (status == 0) { SqlCommand cmd = new SqlCommand("select * from [Manager] where username='******' and passwd='" + password.Text.Trim() + "'", conn);//这个表名一定要加上[] SqlDataReader sdr = cmd.ExecuteReader(); sdr.Read(); if (sdr.HasRows) { common.SetName(username.Text.Trim().ToString()); conn.Close(); this.Hide(); Manager manager_form = new Manager(); manager_form.ShowDialog(this); this.Close(); } else { MessageBox.Show("账号或密码错误"); } } else { SqlCommand cmd = new SqlCommand("select * from [Customer] where username='******' and passwd='" + password.Text.Trim() + "'", conn);//这个表名一定要加上[] SqlDataReader sdr = cmd.ExecuteReader(); sdr.Read(); if (sdr.HasRows)//登录成功 { common.SetName(username.Text.Trim().ToString()); //MessageBox.Show(common.GetName()); conn.Close(); this.Hide(); CusView cusview_form = new CusView(); cusview_form.ShowDialog(this);// this.Close(); } else { MessageBox.Show("账号或密码错误"); } } } }