private void btnLogin_Click(object sender, EventArgs e) { if (radManager.Checked == true) { int read = userInfo.adminLogin(txtID.Text, txtPwd.Text); if (read > 0)//判断密码用户是否正确 { //登录成功 Manager manager = new Manager(this); this.Hide(); manager.Show(); } else { MessageBox.Show("登录失败!"); } } if (radReader.Checked == true) { //连接数据库,判断是否存在用户 int read = 0 ; read = userInfo.userLogin(txtID.Text.Trim(), txtPwd.Text.Trim()); if (read > 0)//判断密码用户是否正确 {//登录成功 this.Hide(); Reader reader = new Reader(txtID.Text,this); reader.Show(); } else { MessageBox.Show("登录失败!"); } } }
/// <summary> /// 保存图书信息 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnSave_Click(object sender, EventArgs e) { string pat3 = @"^[1-9]\d*\.\d*|0\.\d*[1-9]\d*$";//浮点数 bool m3 = Regex.IsMatch(txtPrice.Text.Trim(), pat3); string pat2 = @"\d{4}-\d{2}-\d{2}"; bool m2 = Regex.IsMatch(txtPressDate.Text.Trim(), pat2); if (txtISBN.Text == "") { MessageBox.Show("ISBN号不能为空!", "提示"); } else if (txtName.Text == "") { MessageBox.Show("书名不能为空!", "提示"); } else if (txtAuthor.Text == "") { MessageBox.Show("作者不能为空!", "提示"); } else if (txtStock.Text == "") { MessageBox.Show("库存不能为空!", "提示"); } else if (!m3) { MessageBox.Show("图书价格应为XX.XX元!", "提示!"); } else if (!m2) { MessageBox.Show("时间格式错误!", "提示!"); } else { ///查询是否已经有记录存在 int intcont = booksInfo.findBookByIsbn(txtISBN.Text, txtName.Text); if (intcont != 0)//判断是否添加了相同的记录 { try { System.IO.MemoryStream ms = new System.IO.MemoryStream(); this.pbCover.Image.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg);//将当期pic int rows = booksInfo.adminModifyBook(txtISBN.Text, txtName.Text, txtAuthor.Text, txtPress.Text, txtPressDate.Text, txtPrice.Text, txtContent.Text, txtStock.Text, ms.ToArray()); MessageBox.Show("修改成功!"); } catch { MessageBox.Show("未进行修改"); } } if (intcont == 0) { try { System.IO.MemoryStream ms = new System.IO.MemoryStream(); this.pbCover.Image.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg); int rows = booksInfo.adminAddBook(txtISBN.Text, txtName.Text, txtAuthor.Text, txtPress.Text, txtPressDate.Text, txtPrice.Text, txtContent.Text, txtStock.Text, ms.ToArray()); MessageBox.Show("添加成功!"); } catch { MessageBox.Show("未进行修改"); } } } this.Close(); manager.Show(); manager.Manager_Load(manager, null);//刷新datagridview }
private void btuQuit_Click(object sender, EventArgs e) { this.Close(); manager.Show(); manager.Manager_Load(this, null); }