private void button_Search_Click(object sender, EventArgs e)
 {
     if (comboBox_Search.Text == " ")
     {
         MessageBox.Show("请先选择要查找的类型!");
     }
     if (comboBox_Search.Text == "账号")
     {
         string    sql = "select * from Login_ID where 账号 ='" + textBox_Search.Text.ToString() + "' ";
         DataTable dt  = new DataTable();
         dt = DataBaseApplication.GetDataTableValue(sql);//执行sql语句
         dataGridView1.DataSource = dt;
     }
     if (comboBox_Search.Text == "手机号码")
     {
         string    sql = "select * from Login_ID where 电话号码 ='" + textBox_Search.Text.ToString() + "' ";
         DataTable dt  = new DataTable();
         dt = DataBaseApplication.GetDataTableValue(sql);//执行sql语句
         dataGridView1.DataSource = dt;
     }
     if (comboBox_Search.Text == "邮箱")
     {
         string    sql = "select * from Login_ID where 邮箱 ='" + textBox_Search.Text.ToString() + "' ";
         DataTable dt  = new DataTable();
         dt = DataBaseApplication.GetDataTableValue(sql);//执行sql语句
         dataGridView1.DataSource = dt;
     }
     if (comboBox_Search.Text == "姓名")
     {
         string    sql = "select * from Login_ID where 姓名 ='" + textBox_Search.Text.ToString() + "' ";
         DataTable dt  = new DataTable();
         dt = DataBaseApplication.GetDataTableValue(sql);//执行sql语句
         dataGridView1.DataSource = dt;
     }
 }
Exemple #2
0
        private void ReturnBook_Load(object sender, EventArgs e)
        {
            //发邮件控件是否可见
            if (PublicPassBy.level != "管理员")
            {
                send_email.Visible = false;
                btn_all.Visible    = false;
            }
            //时间显示
            timer1.Interval = 1000;
            timer1.Start();
            //底部状态栏数据
            LoginForm lg = new LoginForm();

            level1 = PublicPassBy.level;
            if (level1 == "用户")
            {
                tSSL2.Text = "权限级别:普通用户";
            }
            else
            {
                tSSL2.Text = "权限级别:管理员";
            }

            tSSL5.Text = "  " + PublicPassBy._name;
            //
            if (PublicPassBy.level == "用户")
            {
                string    sql = "select * from Borrow_List where 借阅人账号='" + PublicPassBy.id + "'";
                DataTable dt  = new DataTable();
                dt = DataBaseApplication.GetDataTableValue(sql);//执行sql语句
                dataGridView1.DataSource = dt;
            }
        }
Exemple #3
0
        private void OK_Click(object sender, EventArgs e)
        {
            string sql = "insert into Book_Recommend(书名,排行) values('" + textBox_top1.Text + "','1'),('" + textBox_top2.Text + "','2'),('" + textBox_top3.Text + "','3'),('" + textBox_top4.Text + "','4'),('" + textBox_top5.Text + "','5')";

            DataBaseApplication.ExecuteNonQuery(sql);
            this.Close();
        }
Exemple #4
0
        private void toolStripButton2_Click(object sender, EventArgs e)
        {
            if (dataGridView1.DataSource != null)
            {
                DialogResult result = MessageBox.Show("确认归还?", "温馨提示", MessageBoxButtons.OKCancel);
                if (result == DialogResult.OK)
                {
                    //执行删除语句
                    MessageBox.Show("还书成功!");
                }
                select_ID = (string)dataGridView1.CurrentCell.Value;
                //从在借单中删除
                string sql = "delete from Borrow_List where 书籍序列号='" + select_ID + "'";
                DataBaseApplication.ExecuteNonQuery(sql);
                //获取书名
                bookname = (string)dataGridView1.CurrentRow.Cells[3].Value.ToString();
                PublicPassBy.IMDB_Bookname = bookname;
                PublicPassBy.IMDB_Bookid   = select_ID;
                //添加进还书单
                string sql1 = "insert into Return_List values('" + select_ID + "','" + dataGridView1.CurrentRow.Cells[1].Value.ToString() + "','" + DateTime.Now.ToLongDateString().ToString() + "','" + dataGridView1.CurrentRow.Cells[3].Value.ToString() + "','" + PublicPassBy._name + "','" + PublicPassBy.email + "')";
                DataBaseApplication.ExecuteNonQuery(sql1);
                //加库存
                string sql2 = "update Books_Info set 库存数=库存数+1 where 书籍序列号='" + select_ID + "'";
                DataBaseApplication.ExecuteNonQuery(sql2);

                //询问是否写书评
                IMDB write = new IMDB();
                write.ShowDialog();
                this.Close();
            }
        }
        private void button1_Click(object sender, EventArgs e)
        {
            string sql = "insert into Book_Recommend_Reader (书名,作者,出版社)values('" + textBox_BookName + "','" + textBox_Author + "','" + textBox_Press + "')";

            DataBaseApplication.ExecuteNonQuery(sql);
            MessageBox.Show("感谢您的推荐!");
            this.Close();
        }
        private void toolStripLabel3_Click(object sender, EventArgs e)
        {
            string    sql = "select * from Books_Info ";
            DataTable dt  = new DataTable();

            dt = DataBaseApplication.GetDataTableValue(sql);//执行sql语句
            dataGridView1.DataSource = dt;
        }
        private void button1_Click(object sender, EventArgs e)
        {
            string sql = "select * from Login_ID";

            DataBaseApplication.ExecuteNonQuery(sql);
            DataTable dt = new DataTable();

            dt = DataBaseApplication.GetDataTableValue(sql);//执行sql语句
            dataGridView1.DataSource = dt;
        }
Exemple #8
0
        private void btn_all_Click(object sender, EventArgs e)
        {
            string sql = "select * from Borrow_List";

            DataBaseApplication.ExecuteNonQuery(sql);
            DataTable dt = new DataTable();

            dt = DataBaseApplication.GetDataTableValue(sql);
            dataGridView1.DataSource = dt;
        }
Exemple #9
0
        private void BorrowBook_Load(object sender, EventArgs e)
        {
            string    sql = "select * from Books_Info where 书籍序列号='" + select_ID.ToString() + "'";
            DataTable dt  = new DataTable();

            dt = DataBaseApplication.GetDataTableValue(sql);
            textBox_No.Text     = dt.Rows[0][0].ToString();
            textBox_Name.Text   = dt.Rows[0][1].ToString();
            textBox_Author.Text = dt.Rows[0][2].ToString();
            textBox_Press.Text  = dt.Rows[0][3].ToString();
            textBox_ID.Text     = PublicPassBy.id;
            textBox_Who.Text    = PublicPassBy._name;
        }
Exemple #10
0
        private void button1_Click(object sender, EventArgs e)
        {
            DialogResult result = MessageBox.Show("确认删除?", "温馨提示", MessageBoxButtons.OKCancel);

            if (result == DialogResult.OK)
            {
                //执行删除语句
                MessageBox.Show("删除成功!");
            }
            string sql = "TRUNCATE TABLE Book_Recommend ";

            //string sql = "delete * from Book_Recommend";
            DataBaseApplication.ExecuteNonQuery(sql);
        }
Exemple #11
0
        private void button_OK_Click(object sender, EventArgs e)
        {
            string sql = "insert into Borrow_List values('" + textBox_No.Text.ToString() + "','" + textBox_ID.Text.ToString() + "','" + DateTime.Now.ToLongDateString().ToString() + "','" + textBox_Name.Text.ToString() + "','" + PublicPassBy._name + "', '" + DateTime.Now.AddDays(30).ToString() + "','" + PublicPassBy.email + "')";

            DataBaseApplication.ExecuteNonQuery(sql);
            string sql1 = "update Books_Info set 库存数=库存数-1 where 书籍序列号='" + textBox_No.Text.ToString() + "' ";

            DataBaseApplication.ExecuteNonQuery(sql1);
            MessageBox.Show("借阅成功!");
            //积分更新
            string sqln = "update Login_ID set 积分=积分+1 where 账号='" + textBox_ID.Text.ToString() + "' ";

            DataBaseApplication.ExecuteNonQuery(sqln);
            this.Close();
        }
Exemple #12
0
 private void Add_Book_Load(object sender, EventArgs e)
 {
     if (type == "2")
     {
         string    sql = "select * from Books_Info where 书籍序列号='" + select_ID.ToString() + "'";
         DataTable dt  = new DataTable();
         dt = DataBaseApplication.GetDataTableValue(sql);
         textBox_No.Text       = dt.Rows[0][0].ToString();
         textBox_BookName.Text = dt.Rows[0][1].ToString();
         textBox_Author.Text   = dt.Rows[0][2].ToString();
         textBox_Press.Text    = dt.Rows[0][3].ToString();
         textBox_Price.Text    = dt.Rows[0][4].ToString();
         textBox_Storage.Text  = dt.Rows[0][5].ToString();
         button3.Visible       = false;
     }
 }
        private void submit_Click(object sender, EventArgs e)
        {
            if (richTextBox1 != null && textBox_Rate != null)
            {
                string sql = "insert into IMDB values('" + richTextBox1.Text.ToString() + "','" + PublicPassBy.IMDB_Bookname + "','" + PublicPassBy.IMDB_Bookid + "','" + PublicPassBy.id + "','" + textBox_Rate.Text + "')";
                DataBaseApplication.ExecuteNonQuery(sql);
                DialogResult result = MessageBox.Show("确认提交?", "温馨提示", MessageBoxButtons.OKCancel);
                if (result == DialogResult.OK)
                {
                    //执行删除语句
                    MessageBox.Show("提交成功!");
                }
            }
            else
            {
                MessageBox.Show("请先填写完整!");
            }

            this.Close();
        }
        private void MainForm_Load(object sender, EventArgs e)
        {
            //时间显示
            timer1.Interval = 1000;
            timer1.Start();
            //底部状态栏数据
            LoginForm lg = new LoginForm();

            level1 = PublicPassBy.level;
            if (level1 == "用户")
            {
                tSSL2.Text = "权限级别:普通用户";
            }
            else
            {
                tSSL2.Text = "权限级别:管理员";
            }

            tSSL5.Text = "  " + PublicPassBy._name;
            //权限设置
            if (level1 == "用户")
            {
                Add_User.Visible = false;
                新用户注册ToolStripMenuItem.Visible = false;
                Add_Books.Visible             = false;
                热门推荐ToolStripMenuItem.Visible = false;
                新书入库ToolStripMenuItem.Visible = false;
            }
            //热门推荐
            string    sql = "select 书名,排行 from Book_Recommend";
            DataTable dt  = new DataTable();

            DataBaseApplication.ExecuteNonQuery(sql);
            dt            = DataBaseApplication.GetDataTableValue(sql);
            label1_1.Text = dt.Rows[0][0].ToString();
            label2_2.Text = dt.Rows[1][0].ToString();
            label3_3.Text = dt.Rows[2][0].ToString();
            label4_4.Text = dt.Rows[3][0].ToString();
            label5_5.Text = dt.Rows[4][0].ToString();
        }
        private void toolStripButton1_Click(object sender, EventArgs e)
        {
            if (toolStripComboBox1.Text == "")
            {
                MessageBox.Show("请添加完整!");
            }
            if (toolStripComboBox1.Text == "书名")
            {
                string sql = "select distinct 书名,作者,出版社 from Books_Info where  书名 like '%" + toolStripTextBox1.Text.ToString() + "%' ";

                DataTable dt = new DataTable();
                dt = DataBaseApplication.GetDataTableValue(sql);//执行sql语句
                dataGridView1.DataSource = dt;
            }
            if (toolStripComboBox1.Text == "作者")
            {
                string    sql = "select * from Books_Info where 作者 like '%" + toolStripTextBox1.Text.ToString() + "%' ";
                DataTable dt  = new DataTable();
                dt = DataBaseApplication.GetDataTableValue(sql);//执行sql语句
                dataGridView1.DataSource = dt;
            }
        }
Exemple #16
0
        private void BorrowBook1_Load(object sender, EventArgs e)
        {
            string sql = "select * from Books_Info where 书名='" + Select_ID + "'and 库存数!=0";

            DataBaseApplication.ExecuteNonQuery(sql);
            DataTable dt = new DataTable();

            dt = DataBaseApplication.GetDataTableValue(sql);//执行sql语句
            dataGridView1.DataSource = dt;
            //书评展示
            string sql1 = "select 书评,评分 from IMDB where 书名='" + Select_ID + "'";

            DataBaseApplication.ExecuteNonQuery(sql1);
            DataTable dt1 = new DataTable();

            dt1 = DataBaseApplication.GetDataTableValue(sql1);
            dataGridView2.DataSource = dt1;
            //平均分
            string sql2 = "select avg(评分) from IMDB where 书名='" + Select_ID + "'";

            DataBaseApplication.ExecuteNonQuery(sql2);
            DataTable dt2 = new DataTable();

            dt2          = DataBaseApplication.GetDataTableValue(sql2);
            avgRate.Text = dt2.Rows[0][0].ToString();
            //--------------------------------控件大小随窗体大小变化

            /*  this.Resize += new EventHandler(BorrowBook1_Resize);
             *
             * X = this.Width;
             * Y = this.Height;
             *
             * setTag(this);
             * BorrowBook1_Resize(new object(), new EventArgs());*/
            //---------------------------------控件大小随窗体大小变化
        }
Exemple #17
0
        private void btn_login_Click(object sender, EventArgs e)
        {
            //#1判断非空 trim用于删除空格
            if (this.textBox_id.Text.ToString().Trim() == "" || this.textBox_password.Text.ToString().Trim() == "")
            {
                MessageBox.Show("请补全用户名密码");
                return;
            }
            //要求选择权限类型
            if (radioButton_admin.Checked == false && radioButton_user.Checked == false)
            {
                MessageBox.Show("请选择您的用户身份!");
            }
            //判断权限类型
            if (radioButton_admin.Checked == true)
            {
                level = "管理员";
                PublicPassBy.level = level;
            }
            if (radioButton_user.Checked == true)
            {
                level = "用户";
                PublicPassBy.level = level;
            }
            //判断用户是否存在
            DataTable dt        = new DataTable();
            string    user_name = "";
            string    pass_word = "";

            //读取界面值
            user_name = this.textBox_id.Text.ToString().Trim();
            pass_word = this.textBox_password.Text.ToString().Trim();
            //sql
            string sql = "select * from Login_ID where 账号='" + user_name + "'";

            dt = DataBaseApplication.GetDataTableValue(sql);
            //读取账号所有人的名字
            PublicPassBy._name = dt.Rows[0]["姓名"].ToString();
            //读取账号
            PublicPassBy.id = dt.Rows[0]["账号"].ToString();
            //读取邮箱
            PublicPassBy.email = dt.Rows[0]["邮箱"].ToString();
            //判断用户是否存在
            if (dt.Rows.Count == 0)
            {
                MessageBox.Show("该用户不存在");
                return;
            }
            //判断密码和权限
            if (dt.Rows[0]["密码"].ToString() == pass_word)
            {
                if (dt.Rows[0]["身份"].ToString() == level)
                {
                    SystemLog.loginState = "OK";
                    SystemLog.user_name  = user_name;
                    SystemLog.user_key   = dt.Rows[0]["密码"].ToString();
                    this.Close();
                }
            }
            if (dt.Rows[0]["密码"].ToString() != pass_word)
            {
                MessageBox.Show("用户名和密码不匹配");
            }
            if (dt.Rows[0]["身份"].ToString() != level)
            {
                MessageBox.Show("您无此权限!");
            }
        }
        private void button_OK_Click(object sender, EventArgs e)
        {
            //防错
            q = textBox_Password.Text.Length;//q和p在上面定义
            p = textBox_phonenum.Text.Length;
            k = textBox_ID.Text.Length;
            if (k != 11)
            {
                MessageBox.Show("请输入账号(11位)!");
                m = 2;
            }
            if (k == 11)
            {
                if (q < 9 | q > 11)
                {
                    MessageBox.Show("请输入9-11位的密码!");
                    m = 2;
                }
                if (p != 11)
                {
                    MessageBox.Show("温馨提示:请检查您输入的号码是否正确(11位)!");
                    m = 2;
                }
            }
            if (p == 11)
            {
                if (textBox_Name.Text == "")
                {
                    MessageBox.Show("您的姓名未填写,请输入姓名!");
                }
                m = 2;


                if (textBox_phonenum.Text == "")
                {
                    MessageBox.Show("您的号码未填写,请输入11位号码!");
                }
                m = 2;


                if (q > 8 && q < 12)
                {
                    if (textBox_Password.Text == "")
                    {
                        MessageBox.Show("您的密码未填写,请输入密码!");
                        m = 2;
                    }

                    else
                    {
                        MessageBox.Show(textBox_Password.Text, "请您确认密码:");
                        m = 0;
                    }
                }
                if (textBox_email.Text == "")
                {
                    MessageBox.Show("您的邮箱未填写,请输入邮箱号!");
                    m = 2;
                }
                else
                {
                    MessageBox.Show(textBox_email.Text, "请您确认邮箱地址:");
                    m = m + 1;
                }
            }
            if (m == 1)
            {
                //防错
                if (type == "1")
                {
                    if (PublicPassBy.level != "管理员")
                    {
                        textBox_Title.Text     = "用户";
                        textBox_Title.ReadOnly = true;
                    }
                    string sql = "insert into Login_ID(账号,密码,身份,电话号码,邮箱,姓名,积分)values('" + textBox_ID.Text.ToString() + "','" + textBox_Password.Text.ToString() + "','" + textBox_Title.Text.ToString() + "','" + textBox_phonenum.Text.ToString() + "','" + textBox_email.Text.ToString() + "','" + textBox_Name.Text.ToString() + "',0)";
                    DataBaseApplication.ExecuteNonQuery(sql);
                    MessageBox.Show("添加成功");
                    this.Close();
                }
                if (type == "2")
                {
                    string sql = "update Login_ID set 密码='" + textBox_Password.Text.ToString() + "',身份='" + textBox_Title.Text.ToString() + "',电话号码='" + textBox_phonenum.Text.ToString() + "',邮箱='" + textBox_email.Text.ToString() + "',姓名='" + textBox_Name.Text.ToString() + "' where 账号='" + textBox_ID.Text.ToString() + "'";
                    DataBaseApplication.ExecuteNonQuery(sql);
                    MessageBox.Show("修改成功");
                    this.Close();
                }
            }
        }
 private void Add_User_Load(object sender, EventArgs e)
 {
     //注册界面
     if (type == "0")//首页注册
     {
         textBox_Title.Text     = "用户";
         textBox_Title.ReadOnly = true;
     }
     if (type == "1")
     {
         if (PublicPassBy.level == "用户")
         {
             textBox_Title.Text     = "用户";
             textBox_Title.ReadOnly = true;
         }
     }
     if (type == "2")
     {
         string    sql = "select * from Login_ID where 账号='" + select_ID.ToString() + "'";
         DataTable dt  = new DataTable();
         dt = DataBaseApplication.GetDataTableValue(sql);
         textBox_ID.Text       = dt.Rows[0][0].ToString();
         textBox_Password.Text = dt.Rows[0][1].ToString();
         textBox_Title.Text    = dt.Rows[0][2].ToString();
         textBox_phonenum.Text = dt.Rows[0][3].ToString();
         textBox_email.Text    = dt.Rows[0][4].ToString();
         textBox_Name.Text     = dt.Rows[0][5].ToString();
         textBox_Point.Text    = dt.Rows[0][6].ToString();
         //积分不可修改
         textBox_Point.ReadOnly = true;
     }
     if (type == "3")
     {
         string    sql = "select * from Login_ID where 姓名='" + PublicPassBy._name + "'";
         DataTable dt  = new DataTable();
         dt = DataBaseApplication.GetDataTableValue(sql);
         textBox_ID.Text       = dt.Rows[0][0].ToString();
         textBox_Password.Text = dt.Rows[0][1].ToString();
         textBox_Title.Text    = dt.Rows[0][2].ToString();
         textBox_phonenum.Text = dt.Rows[0][3].ToString();
         textBox_email.Text    = dt.Rows[0][4].ToString();
         textBox_Name.Text     = dt.Rows[0][5].ToString();
         textBox_Point.Text    = dt.Rows[0][6].ToString();
         //积分不可修改
         textBox_Point.ReadOnly = true;
         //用户属性不可改
         textBox_Title.ReadOnly = true;
     }
     if (type == "4")//用户自己查询
     {
         string    sql = "select * from Login_ID where 姓名='" + PublicPassBy._name + "'";
         DataTable dt  = new DataTable();
         dt = DataBaseApplication.GetDataTableValue(sql);
         textBox_ID.Text       = dt.Rows[0][0].ToString();
         textBox_Password.Text = dt.Rows[0][1].ToString();
         textBox_Title.Text    = dt.Rows[0][2].ToString();
         textBox_phonenum.Text = dt.Rows[0][3].ToString();
         textBox_email.Text    = dt.Rows[0][4].ToString();
         textBox_Name.Text     = dt.Rows[0][5].ToString();
         textBox_Point.Text    = dt.Rows[0][6].ToString();
         //查询时只读
         textBox_ID.ReadOnly       = true;
         textBox_Password.ReadOnly = true;
         textBox_Title.ReadOnly    = true;
         textBox_phonenum.ReadOnly = true;
         textBox_email.ReadOnly    = true;
         textBox_Name.ReadOnly     = true;
         textBox_Point.ReadOnly    = true;
     }
 }
Exemple #20
0
 private void button1_Click(object sender, EventArgs e)
 {
     //防错
     #region
     //书籍添加防错
     if (textBox_No.Text == "")
     {
         MessageBox.Show("请添加书籍序列号!");
     }
     if (textBox_BookName.Text == "")
     {
         MessageBox.Show("请输入书名!");
     }
     if (textBox_Author.Text == "")
     {
         MessageBox.Show("请输入作者!");
     }
     if (textBox_Press.Text == "")
     {
         MessageBox.Show("请输入出版社!");
     }
     if (textBox_Price.Text == "")
     {
         MessageBox.Show("请输入价格!");
     }
     if (textBox_Storage.Text == "")
     {
         MessageBox.Show("请输入库存数!");
     }
     if (textBox_No.Text != "")
     {
         if (textBox_BookName.Text != "")
         {
             if (textBox_Author.Text != "")
             {
                 if (textBox_Press.Text != "")
                 {
                     if (textBox_Price.Text != "")
                     {
                         if (textBox_Storage.Text != "")
                         {
                             t = 1;
                         }
                     }
                 }
             }
         }
     }//书籍添加防错
     #endregion
     if (t == 1)
     {
         if (type == "1")
         {
             if (textBox_No.Text == "")
             {
                 MessageBox.Show("请输入记录ID");
                 return;
             }
             string sql = "insert into Books_Info(书籍序列号,书名,作者,出版社,价格,库存数)values('" + textBox_No.Text.ToString() + "','" + textBox_BookName.Text.ToString() + "','" + textBox_Author.Text.ToString() + "','" + textBox_Press.Text.ToString() + "','" + textBox_Price.Text.ToString() + "','" + textBox_Storage.Text.ToString() + "')";
             DataBaseApplication.ExecuteNonQuery(sql);
             MessageBox.Show("添加成功");
             this.Close();
         }
     }
 }