Exemplo n.º 1
0
        private void 我的借阅情况ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            panel4.Visible = true;
            panel5.Visible = true;
            panel1.Visible = false;
            panel2.Visible = true;
            panel3.Visible = false;
            textBox6.Text  = DateTime.Now.ToShortDateString().ToString();
            Sql1          sqlHelper = new Sql1();
            SqlConnection con       = sqlHelper.GetConnection();

            con.Open();
            string strQuery1 = "select Borrow.Bid as 书籍编号, Borrow.Sid as 读者编号, Borrowtime as 借出时间 From Borrow,Reback Where Returntime='未还        ' and Borrow.Bid=Reback.Bid and Borrow.Sid=Reback.Sid and Borrow.Sid='" + str0 + "'";
            string strQuery2 = "select Bid as 书籍编号, Sid as 读者编号, Returntime as 归还时间 from Reback Where Sid='" + str0 + "' and Returntime!='未还        '";

            try
            {
                DataSet   ds1 = sqlHelper.GetDataSet(strQuery1);
                DataTable dt1 = ds1.Tables[0];
                dataGridView2.DataSource = dt1;

                DataSet   ds2 = sqlHelper.GetDataSet(strQuery2);
                DataTable dt2 = ds2.Tables[0];
                dataGridView3.DataSource = dt2;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Exemplo n.º 2
0
        private void 借阅书籍ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            panel3.Visible = true;
            panel2.Visible = true;
            panel1.Visible = false;
            panel4.Visible = false;
            panel5.Visible = false;
            textBox4.Text  = DateTime.Now.ToShortDateString().ToString();
            Sql1          sqlHelper = new Sql1();
            SqlConnection con       = sqlHelper.GetConnection();

            con.Open();
            string strQuery = "select Bid as 书籍编号, Bname as 书名, Bpress as 出版社, Bstate as 状态, Bwriter as 作者, Bdate as 出版时间 from Books";

            try
            {
                DataSet   ds = sqlHelper.GetDataSet(strQuery);
                DataTable dt = ds.Tables[0];

                dataGridView1.DataSource = dt;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Exemplo n.º 3
0
        private void 用户管理ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            K = 1;

            panel1.Visible = false;
            panel4.Visible = true;
            panel6.Visible = false;
            panel5.Visible = false;
            Sql1          sqlHelper = new Sql1();
            SqlConnection con       = sqlHelper.GetConnection();

            con.Open();
            string strQuery = "select Sid as 学号, Sname as 姓名 from Students";

            try
            {
                DataSet   ds = sqlHelper.GetDataSet(strQuery);
                DataTable dt = ds.Tables[0];

                dataGridView1.DataSource = dt;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Exemplo n.º 4
0
        private void button3_Click(object sender, EventArgs e)
        {
            //刷新显示
            Sql1          sqlHelper = new Sql1();
            SqlConnection con       = sqlHelper.GetConnection();

            con.Open();
            string strQuery = "select Bid as 书籍编号, Bname as 书名, Bpress as 出版社, Bstate as 状态, Bwriter as 作者, Bdate as 出版时间 from Books";

            try
            {
                DataSet   ds = sqlHelper.GetDataSet(strQuery);
                DataTable dt = ds.Tables[0];

                dataGridView1.DataSource = dt;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            textBox1.Text         = null;
            textBox2.Text         = null;
            textBox3.Text         = null;
            comboBox1.Text        = null;
            textBox5.Text         = null;
            dateTimePicker1.Value = DateTime.Now;
        }
Exemplo n.º 5
0
        private void 书籍借阅管理ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            K = 2;

            panel1.Visible = false;
            panel4.Visible = false;
            panel6.Visible = false;
            panel5.Visible = false;
            Sql1          sqlHelper = new Sql1();
            SqlConnection con       = sqlHelper.GetConnection();

            con.Open();
            string strQuery = "select Borrow.Bid as 书籍编号, Borrow.Sid as 读者编号, Borrowtime as 借出时间, Returntime as 归还时间 From Borrow, Reback Where Borrow.Bid=Reback.Bid";

            try
            {
                DataSet   ds = sqlHelper.GetDataSet(strQuery);
                DataTable dt = ds.Tables[0];

                dataGridView1.DataSource = dt;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Exemplo n.º 6
0
        private void button1_Click(object sender, EventArgs e)
        {
            //查询书籍
            //string strnum = comboBox1.Items[comboBox1.SelectedIndex].ToString();
            string str      = textBox1.Text.Trim();
            string strQuery = "Select Bid as 书籍编号, Bname as 书名, Bpress as 出版社, Bstate as 状态, Bwriter as 作者, Bdate as 出版时间 From Books ";

            /*if (strnum.Length > 0)
             * {
             *  strQuery += " And Btapy='" + strnum + "'";
             * }
             */
            if (str.Length > 0)
            {
                strQuery += " where Bname LIKE'%" + str + "%'";
            }

            try
            {
                Sql1      sqlHelper = new Sql1();
                DataSet   ds        = sqlHelper.GetDataSet(strQuery);
                DataTable dt        = ds.Tables[0];

                dataGridView1.DataSource = dt;

                if (dt.Rows.Count == 0)
                {
                    MessageBox.Show("没有符合条件的记录", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else
                {
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }