private void 添加书目_Click(object sender, EventArgs e)
        {
            string bookname = txt_bookname.Text.Trim();
            string press    = txt_press.Text.Trim();

            if (bookname == "" || press == "")
            {
                MessageBox.Show("请填入完整信息");
            }
            else if (check_book_exist(bookname))
            {
            }
            else
            {
                string sql = "insert into bookUserWanted1(username,bookname,press) values(";
                sql += "'" + username + "',";
                sql += "'" + bookname + "',";
                sql += "'" + press + "')";
                try
                {
                    SQLServer.ExecuteNonQuery(sql);
                    MessageBox.Show("登记成功!");
                    Close();
                }
                catch (Exception ex)
                {
                    MessageBox.Show("登记失败!");
                    Console.WriteLine(ex);
                }
            }
        }
Ejemplo n.º 2
0
        private void 还书_Click(object sender, EventArgs e)
        {
            if (dataGridView1.SelectedRows.Count > 0)
            {
                MessageBoxButtons messButton = MessageBoxButtons.OKCancel;
                DialogResult      dr         = MessageBox.Show("确定要还书吗?", "确定还书", messButton);
                if (dr == DialogResult.OK)
                {
                    string sql = "delete from bookReturning1 where UserName  ="******"'" + dataGridView1.SelectedRows[0].Cells["UserName"].Value.ToString() + "'";
                    sql += "and BookNum =";
                    sql += "'" + dataGridView1.SelectedRows[0].Cells["BookNum"].Value.ToString() + "'";

                    string sql2 = "update [User] set Number =Number-1 where UserName="******"'" + dataGridView1.SelectedRows[0].Cells["UserName"].Value.ToString() + "'";

                    try
                    {
                        SQLServer.ExecuteNonQuery(sql);
                        MessageBox.Show("还书成功!");
                        SQLServer.ExecuteNonQuery(sql2);
                        loadData();
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show("还书失败!");
                        Console.WriteLine(ex);
                    }
                }
            }
        }
Ejemplo n.º 3
0
        private void  除条目ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (dataGridView1.SelectedRows.Count > 0)
            {
                MessageBoxButtons messButton = MessageBoxButtons.OKCancel;
                DialogResult      dr         = MessageBox.Show("确定要删除吗?", "确定删除", messButton);
                if (dr == DialogResult.OK)
                {
                    string sql2 = "delete from bookUserWanted1 where bookname =";
                    sql2 += "'" + dataGridView1.SelectedRows[0].Cells["bookname"].Value.ToString() + "'";
                    sql2 += "and username = "******"'" + dataGridView1.SelectedRows[0].Cells["username"].Value.ToString() + "'";

                    try
                    {
                        SQLServer.ExecuteNonQuery(sql2);
                        MessageBox.Show("删除成功!");
                        load_data();
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show("删除失败!");
                        Console.WriteLine(ex);
                    }
                }
            }
        }
 private void 还书ToolStripMenuItem_Click(object sender, EventArgs e)
 {
     if (dataGridView1.SelectedRows.Count > 0)
     {
         MessageBoxButtons messButton = MessageBoxButtons.OKCancel;
         DialogResult      dr         = MessageBox.Show("确定要还书吗?", "确定还书", messButton);
         if (dr == DialogResult.OK)
         {
             string sql = "delete from ordertable where UserName  ="******"'" + username + "'";
             sql += "and ordertable.OrderNum =";
             sql += "'" + dataGridView1.SelectedRows[0].Cells["OrderNum"].Value.ToString() + "'";
             string sql3 = "insert into bookReturning1 (BookNum,UserName) values(";
             sql3 += "'" + dataGridView1.SelectedRows[0].Cells["OrderNum"].Value.ToString() + "',";
             sql3 += "'" + username + "')";
             try
             {
                 SQLServer.ExecuteNonQuery(sql);
                 MessageBox.Show("还书成功等待管理员审核!");
                 SQLServer.ExecuteNonQuery(sql3);
                 load_data();
             }
             catch (Exception ex)
             {
                 MessageBox.Show("还书失败!");
                 Console.WriteLine(ex);
             }
         }
     }
 }
Ejemplo n.º 5
0
        private void 修改密码_Click_1(object sender, EventArgs e)
        {
            string password  = txt_oldpassword.Text.Trim();
            string password1 = txt_newpassword.Text.Trim();
            string password2 = txt_password_repeat.Text.Trim();

            if (check_pass(password, password1, password2))
            {
                if (CodeLevel(password1) < 2)
                {
                }
                else
                {
                    string sql = "update [User] set Code =";
                    sql += "'" + password1 + "'";
                    sql += "where UserName = "******"'" + username + "'";
                    try
                    {
                        SQLServer.ExecuteNonQuery(sql);
                        MessageBox.Show("修改成功!");
                        this.Close();
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show("修改失败!");
                        Console.WriteLine(ex);
                    }
                }
            }
        }
Ejemplo n.º 6
0
        private void 确认绑定_Click(object sender, EventArgs e)
        {
            string userworkplace = txt_userworkplace.Text.Trim();
            string useraddress   = txt_useraddress.Text.Trim();
            string sex           = comboBoxsex.Text.Trim();
            string year          = comboBoxyear.Text.Trim();
            string month         = comboBoxmonth.Text.Trim();
            string day           = comboBoxday.Text.Trim();
            string sql           = "update [User] set UserWorkPlace =";

            sql += "'" + userworkplace + "'";
            sql += ",UserAddress=";
            sql += "'" + useraddress + "'";
            sql += ",Sex=";
            sql += "'" + sex + "'";
            sql += ",Birthday=";
            sql += "'" + year + "." + month + "." + day + "'";
            sql += "where UserName = "******"'" + username + "'";
            try
            {
                SQLServer.ExecuteNonQuery(sql);
                MessageBox.Show("绑定成功!");
                Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show("绑定失败!");
                Console.WriteLine(ex);
            }
        }
Ejemplo n.º 7
0
        private void 修改密码_Click(object sender, EventArgs e)
        {
            string username  = txt_oldusername.Text.Trim();
            string username1 = txt_newusername.Text.Trim();
            string username2 = txt_username_repeat.Text.Trim();

            if (check_pass(username, username1, username2))
            {
                string sql = "update [User] set UserName ="******"'" + username1 + "'";
                sql += "where UserName = "******"'" + username + "'";
                string sql1 = "update ReaderType set UserName ="******"'" + username1 + "'";
                sql1 += "where UserName = "******"'" + username + "'";


                try
                {
                    SQLServer.ExecuteNonQuery(sql);
                    SQLServer.ExecuteNonQuery(sql1);
                    MessageBox.Show("修改成功!");
                    this.Close();
                }
                catch (Exception ex)
                {
                    MessageBox.Show("修改失败!");
                    Console.WriteLine(ex);
                }
            }
        }
Ejemplo n.º 8
0
        private void 注册_Click_1(object sender, EventArgs e)
        {
            string username        = txt_username.Text.Trim();
            string identitycard    = "";
            string cardid          = "";
            string userworkplace   = "  ";
            string sex             = "  ";
            string useraddress     = "  ";
            string birthday        = "  ";
            string usertype        = "读者";
            string password        = txt_password.Text.Trim();
            string passwordConfirm = txt_password_confirm.Text.Trim();
            string number          = "5";

            if (username == "" || password == "" || passwordConfirm == "")
            {
                MessageBox.Show("请填入所有信息");
            }
            else if (password != passwordConfirm)
            {
                MessageBox.Show("两次输入的密码不一致");
            }
            else if (CodeLevel(password) < 2)
            {
            }
            else
            {
                if (!check_user_exist(username))//检测用户名是否存在,此处为用户名不存在的条件
                {
                    string sql2 = "insert into ReaderType (UserName ,UserType)values(";
                    sql2 += "'" + username + "',";
                    sql2 += "'" + usertype + "')";
                    string sql1 = "insert into [User] (UserName,CardID,ID,UserWorkPlace,Code,UserAddress,Sex ,Birthday,Number)values(";
                    sql1 += "'" + username + "',";
                    sql1 += "'" + cardid + "',";
                    sql1 += "'" + identitycard + "',";
                    sql1 += "'" + userworkplace + "',";
                    sql1 += "'" + password + "',";
                    sql1 += "'" + useraddress + "',";
                    sql1 += "'" + sex + "',";
                    sql1 += "'" + birthday + "',";
                    sql1 += "'" + number + "')";
                    SQLServer.ExecuteNonQuery(sql2);
                    try
                    {
                        SQLServer.ExecuteNonQuery(sql1);

                        MessageBox.Show("注册成功!", "提示");
                        FormLogin formLogin = new FormLogin(txt_username.Text.Trim());//注册成功返回FormLogin页面,同时将username自动填写到用户名栏
                        formLogin.Show();
                        Close();
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show("注册失败!", "提示" + ex.Message);
                    }
                }
            }
        }
Ejemplo n.º 9
0
 private void 借书ToolStripMenuItem_Click(object sender, EventArgs e)
 {
     if (!check_is_binded(username))
     {
         MessageBox.Show("您还未绑定身份,不能使用该功能!");
     }
     else
     {
         if (get_user_borrowed_num(username) == "5")
         {
             MessageBox.Show("您已经借了5本书,达到上限");
         }
         else if (dataGridView1.SelectedRows.Count > 0)
         {
             MessageBoxButtons messButton = MessageBoxButtons.OKCancel;
             DialogResult      dr         = MessageBox.Show("确定要借这本书吗?", "确定", messButton);
             if (dr == DialogResult.OK)
             {
                 if (!check_book_user_exist(username, dataGridView1.SelectedRows[0].Cells["BookNum"].Value.ToString()))
                 {
                     string sql = "insert into ordertable(UserName,OrderNum,OrderBookName)values( ";
                     sql += "'" + username + "',";
                     sql += "'" + dataGridView1.SelectedRows[0].Cells["BookNum"].Value.ToString() + "',";
                     sql += "'" + dataGridView1.SelectedRows[0].Cells["BookName"].Value.ToString() + "')";
                     string sql2 = "update [User] set Number = Number +1 where UserName = "******"'" + username + "'";
                     try
                     {
                         SQLServer.ExecuteNonQuery(sql);
                         MessageBox.Show("借书成功!");
                         load_data();
                         SQLServer.ExecuteNonQuery(sql2);
                         FormUserBorrowedBooks formBorrowedBooks = new FormUserBorrowedBooks(username);
                         Visible = false;
                         formBorrowedBooks.ShowDialog();
                         Visible = true;
                     }
                     catch (Exception ex)
                     {
                         MessageBox.Show("借书失败");
                         Console.WriteLine(ex);
                     }
                 }
                 else
                 {
                     MessageBox.Show("您已经借过这本书");
                 }
             }
         }
     }
 }
Ejemplo n.º 10
0
 private void 重置密码ToolStripMenuItem_Click(object sender, EventArgs e)
 {
     if (dataGridView1.SelectedRows.Count > 0)
     {
         MessageBoxButtons messButton = MessageBoxButtons.OKCancel;
         DialogResult      dr         = MessageBox.Show("确定要重置该用户的密码吗?", "确定", messButton);
         if (dr == DialogResult.OK)
         {
             string thisusername = dataGridView1.SelectedRows[0].Cells["UserName"].Value.ToString();
             string sql          = "update [User] set Code ='a123456'";
             sql += "where UserName = "******"'" + thisusername + "'";
             SQLServer.ExecuteNonQuery(sql);
             MessageBox.Show("重置成功!");
         }
     }
 }
Ejemplo n.º 11
0
        private void button1_Click(object sender, EventArgs e)
        {
            string message = textBox1.Text.Trim().ToString();
            string reply   = " ";
            string sql     = "insert into message(UserMessage,Reply) values (";

            sql += "'" + message + "',";
            sql += "'" + reply + "')";
            try
            {
                SQLServer.ExecuteNonQuery(sql);
                MessageBox.Show("留言成功!", "提示");
            }
            catch (Exception ex)
            {
                MessageBox.Show("留言失败!");
                Console.WriteLine(ex);
            }
        }
Ejemplo n.º 12
0
 private void  除ToolStripMenuItem_Click(object sender, EventArgs e)
 {
     if (dataGridView1.SelectedRows.Count > 0)
     {
         MessageBoxButtons messButton = MessageBoxButtons.OKCancel;
         DialogResult      dr         = MessageBox.Show("确定要删除该用户吗?", "确定", messButton);
         if (dr == DialogResult.OK)
         {
             string thisusername = dataGridView1.SelectedRows[0].Cells["UserName"].Value.ToString();
             string sql          = "delete from [User] where UserName="******"'" + thisusername + "'";
             string sql2 = "delete from ReaderType where UserName="******"'" + thisusername + "'";
             SQLServer.ExecuteNonQuery(sql);
             SQLServer.ExecuteNonQuery(sql2);
             MessageBox.Show("删除成功!");
         }
     }
 }
 private void button2_Click(object sender, EventArgs e)
 {
     if (dataGridView1.SelectedRows.Count > 0)
     {
         if (dataGridView1.SelectedRows[0].Cells["UserType"].Value.ToString() != "读者" && dataGridView1.SelectedRows[0].Cells["UserName"].Value.ToString() != "admin" && dataGridView1.SelectedRows[0].Cells["UserName"].Value.ToString() != username)
         {
             MessageBoxButtons messButton = MessageBoxButtons.OKCancel;
             DialogResult      dr         = MessageBox.Show("确定要移除该管理员权限吗?", "确定", messButton);
             if (dr == DialogResult.OK)
             {
                 string thisusername = dataGridView1.SelectedRows[0].Cells["UserName"].Value.ToString();
                 string sql          = "update ReaderType set UserType ='读者'";
                 sql += "where UserName = "******"'" + thisusername + "'";
                 SQLServer.ExecuteNonQuery(sql);
                 MessageBox.Show("移除成功!");
             }
         }
         else if (dataGridView1.SelectedRows[0].Cells["UserType"].Value.ToString() != "读者" && dataGridView1.SelectedRows[0].Cells["UserName"].Value.ToString() == username && username != "admin")
         {
             MessageBoxButtons messButton = MessageBoxButtons.OKCancel;
             DialogResult      dr         = MessageBox.Show("确定要移除您的管理员权限吗?", "确定", messButton);
             if (dr == DialogResult.OK)
             {
                 string thisusername = dataGridView1.SelectedRows[0].Cells["UserName"].Value.ToString();
                 string sql          = "update ReaderType set UserType ='读者'";
                 sql += "where UserName = "******"'" + thisusername + "'";
                 SQLServer.ExecuteNonQuery(sql);
                 MessageBox.Show("移除成功!");
                 this.Close();
             }
         }
         else if (dataGridView1.SelectedRows[0].Cells["UserName"].Value.ToString() == "admin")
         {
             MessageBox.Show("该用户管理员权限不可移除", "提示");
         }
         else
         {
             MessageBox.Show("该用户已经是读者", "提示");
         }
     }
 }
Ejemplo n.º 14
0
        private void 确认绑定_Click_1(object sender, EventArgs e)
        {
            string cardid       = txt_cardid.Text.Trim();
            string identitycard = txt_identitycard.Text.Trim();

            if (cardid == "" || identitycard == "")
            {
                MessageBox.Show("请填入所有信息");
            }
            else if (!checkStudentExist(cardid, identitycard))
            {
                if (!checkStudentsticked(cardid))
                {
                    string sql = "update [User] set CardID =";
                    sql += "'" + cardid + "'";
                    sql += ",ID=";
                    sql += "'" + identitycard + "'";
                    sql += "where UserName = "******"'" + username + "'";
                    try
                    {
                        SQLServer.ExecuteNonQuery(sql);
                        MessageBox.Show("绑定成功!");
                        Close();
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show("绑定失败!");
                        Console.WriteLine(ex);
                    }
                }
                else
                {
                    MessageBox.Show("该学生信息已经绑定过");
                }
            }
            else
            {
                MessageBox.Show("学生信息有错误");
            }
        }
Ejemplo n.º 15
0
        private void 添加新书_Click(object sender, EventArgs e)
        {
            string bookid    = txt_bookid.Text.Trim();
            string bookname  = txt_bookname.Text.Trim();
            string pressname = txt_press.Text.Trim();
            string bookid1   = txt_classification.Text.Trim();
            string isbn      = txt_number.Text.Trim();

            if (bookid == "" || bookname == "" || pressname == "" || bookid1 == "" || isbn == "")
            {
                MessageBox.Show("请填入所有的信息");
            }
            else
            {
                if (!check_pass(bookid))
                {
                    string sql = "insert into Book (BookNum,BookName,BookAuthor,BookID,ISBN)values(";
                    sql += "'" + bookid + "',";
                    sql += "'" + bookname + "',";
                    sql += "'" + pressname + "',";
                    sql += "'" + bookid1 + "',";
                    sql += "'" + isbn + "')";
                    try
                    {
                        SQLServer.ExecuteNonQuery(sql);
                        MessageBox.Show("增书成功!");
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show("增书失败!");
                        Console.WriteLine(ex);
                    }
                }
                else
                {
                    MessageBox.Show("该编号已经被占用");
                }
            }
        }
 private void button1_Click(object sender, EventArgs e)
 {
     if (dataGridView1.SelectedRows.Count > 0)
     {
         if (dataGridView1.SelectedRows[0].Cells["UserType"].Value.ToString() != "管理员")
         {
             MessageBoxButtons messButton = MessageBoxButtons.OKCancel;
             DialogResult      dr         = MessageBox.Show("确定要将该用户设为管理员吗?", "确定", messButton);
             if (dr == DialogResult.OK)
             {
                 string thisusername = dataGridView1.SelectedRows[0].Cells["UserName"].Value.ToString();
                 string sql          = "update ReaderType set UserType ='管理员'";
                 sql += "where UserName = "******"'" + thisusername + "'";
                 SQLServer.ExecuteNonQuery(sql);
                 MessageBox.Show("设置成功!");
             }
         }
         else
         {
             MessageBox.Show("该用户已经是管理员", "提示");
         }
     }
 }