Exemple #1
0
        private void user_Basic_Load(object sender, EventArgs e)
        {
            u_id = Log.log.u_id;                                                                                    //获得登录账号
            string sql = "select * from [user],[college] where [user].c_id=[college].c_id and u_id='" + u_id + "'"; //利用学号查询学生详细信息

            con = dButil.SqlOpen();
            cmd = new SqlCommand(sql, con);//执行sql语句
            SqlDataReader reader = cmd.ExecuteReader();

            reader.Read();
            text_id.Text   = u_id;
            text_name.Text = reader["u_name"].ToString(); //获取用户姓名

            sex = reader["u_sex"].ToString();             //获取用户性别,储存在字符串中
            if (sex == "男")
            {
                rbtn_male.Checked = true;//选中男
            }
            else
            {
                rbtn_female.Checked = true;//选中女
            }

            College();                                            //下拉框加载学院
            college = cmb_college.SelectedIndex;                  //获得初始选中的学院索引值

            tel           = reader["u_tel"].ToString();           //获取用户手机号,储存在字符串中
            text_tel.Text = tel;                                  //显示在文本框中

            text_position.Text = reader["u_position"].ToString(); //获取用户所在用户组
            text_number.Text   = reader["u_number"].ToString();   //获取用户可借数量
            text_book.Text     = reader["u_book"].ToString();     //获取用户总借书数量
            con.Close();
        }
Exemple #2
0
        DButil dButil = new DButil(); //实例化DButil工具类

        private void admin_FeedBack_Load(object sender, EventArgs e)
        {
            string f_btn = Log.log.f_btn;                                              //获得储存在log类中的反馈编号
            string sql   = "select * from feedback where f_id='" + Log.log.f_id + "'"; //利用编号查询内容

            con = dButil.SqlOpen();                                                    //打开数据库
            cmd = new SqlCommand(sql, con);                                            //执行数据库语句
            SqlDataReader reader = cmd.ExecuteReader();                                //返回内容

            reader.Read();
            text_id.Text    = reader["f_id"].ToString();         //获得用户id显示在用户id文本框中
            text_stm.Text   = reader["f_smntime"].ToString();    //获得提交时间显示在提交时间文本框中
            text_atm.Text   = reader["f_asrtime"].ToString();    //获得回复时间显示在回复时间文本框中
            text_title.Text = reader["f_title"].ToString();      //获得反馈标题显示在反馈标题文本框中
            rtb_cnt.Text    = reader["f_content"].ToString();    //获得反馈内容显示在反馈内容文本框中
            rtb_rcd.Text    = reader["f_asrcontent"].ToString(); //获得回复内容显示在回复内容文本框中
            text_solve.Text = reader["f_solve"].ToString();      //获得获得是否已回复的值显示在是否已回复文本框中

            if (f_btn == "回复")
            {
                rtb_rcd.TabStop   = true;   //设置成tab键能获得焦点
                rtb_rcd.ReadOnly  = false;  //设置成可输入
                rtb_rcd.Multiline = false;  //这个与下个配合刷新该控件的样式
                rtb_rcd.Multiline = true;   //这个与上个配合刷新该控件的样式
                btn_no.Visible    = true;   //返回按钮设置为显示
                btn_ok.Text       = "确认回复"; //设置确认按钮的文本为确认回复
            }
            else
            {
                rtb_rcd.TabStop  = false; //设置成无法为tab键获得焦点
                rtb_rcd.ReadOnly = true;  //设置为不可输入
            }
            con.Close();                  //关闭数据库
        }
Exemple #3
0
        /// <summary>
        /// 修改密码事件
        /// </summary>
        /// <param name="sql"></param>
        /// <returns></returns>
        public bool EditPwd(String sql)
        {
            con = dButil.SqlOpen();                        //打开数据库
            int        n;                                  //定义个n判断
            SqlCommand command = new SqlCommand(sql, con); ////储存传递过来的sql语句

            n = command.ExecuteNonQuery();                 //执行sql语句,返回受影响的记录行
            con.Close();                                   //关闭数据库
            if (n > 0)                                     //判断是否存在受影响的行
            {
                return(true);                              //返回true为修改成功
            }
            return(false);                                 //false为失败
        }
Exemple #4
0
        int count = 0;                //用来判断开始时间的按钮控件是单击的第几次,为0打开日历,为1关闭日历

        //填充表内容的databind方法
        public void databind(string sql)
        {
            Dgv_fbk.AutoGenerateColumns = false;//不自动生成列,从数据库可能取得很多列,使其不显示在DataGridView中
            con = dButil.SqlOpen();
            cmd = new SqlCommand(sql, con);
            sda = new SqlDataAdapter(cmd);
            ds  = new DataSet();                              //ds初始化
            sda.Fill(ds);                                     //把查询内容添加到ds中
            bindingSource1.DataSource       = ds.Tables[0];
            bindingNavigator1.BindingSource = bindingSource1; //连接数据源
            Dgv_fbk.DataSource = bindingSource1;              //导出到dataGridView1中显示并用下列代码对于列名
            for (int i = 0; i < 6; i++)
            {
                Dgv_fbk.Columns[i].DataPropertyName = ds.Tables[0].Columns[i].ColumnName;
            }
            con.Close();//关闭数据库
        }
Exemple #5
0
        DButil dButil = new DButil(); //实例化DButil工具类

        //填充表内容的databind方法
        public void databind(string sql)
        {
            Dgv_borrow.AutoGenerateColumns = false;           //不自动生成列,从数据库可能取得很多列,使其不显示在DataGridView中
            con = dButil.SqlOpen();
            cmd = new SqlCommand(sql, con);                   //储存sql语句
            sda = new SqlDataAdapter(cmd);                    //适配器及执行查询
            ds  = new DataSet();                              //ds初始化
            sda.Fill(ds);                                     //把查询内容添加到ds中
            bindingSource1.DataSource       = ds.Tables[0];   //封装数据
            bindingNavigator1.BindingSource = bindingSource1; //获得数据
            Dgv_borrow.DataSource           = bindingSource1; //导出到dataGridView1中显示并用下列代码对于列名
            for (int i = 0; i < 8; i++)                       //循环添加
            {
                Dgv_borrow.Columns[i].DataPropertyName = ds.Tables[0].Columns[i].ColumnName;
            }
            con.Close();
        }
Exemple #6
0
 /// <summary>
 /// 判断传递管理的user_college是真还是假
 /// 绑定下拉列表,添加数据库中的学院或类别
 /// 为真添加学院
 /// 为假添加类别
 /// </summary>
 /// <param name="sql_col">数据库语句命名</param>
 /// <param name="college">表名</param>
 /// <param name="c_college">学院</param>
 public void type()
 {
     if (Log.log.user_college == true)
     {
         con = dButil.SqlOpen();
         //初始化,comboBox1绑定客户表
         string         sql = "select c_college from [college]"; //查询有多少学院
         SqlDataAdapter sda = new SqlDataAdapter(sql, con);      //创建sql适配器
         DataSet        ds  = new DataSet();                     //创建ds缓存
         sda.Fill(ds);                                           //添加到ds缓存中
         cmb_type.DataSource    = ds.Tables[0].DefaultView;      //取出数据源填充到列表中'
         cmb_type.DisplayMember = "c_college";                   //列表中显示的值对应的字段名
         cmb_type.SelectedIndex = 0;
         con.Close();                                            //关闭数据库
     }
     else
     {
         con = dButil.SqlOpen();
         //初始化,comboBox1绑定客户表
         string         sqltype = "select t_name from [type]";      //查询有多少类别
         SqlDataAdapter sda     = new SqlDataAdapter(sqltype, con); //创建sql适配器
         DataSet        ds      = new DataSet();                    //创建ds缓存
         sda.Fill(ds);                                              //添加到ds缓存中
         cmb_type.DataSource    = ds.Tables[0].DefaultView;         //取出数据源填充到列表中
         cmb_type.DisplayMember = "t_name";                         //列表中显示的值对应的字段名
         cmb_type.SelectedIndex = 0;
         con.Close();                                               //关闭数据库
     }
 }
Exemple #7
0
        /// <summary>
        /// 绑定下拉列表,添加数据库中的学院
        /// </summary>
        /// <param name="sqltype">数据库语句</param>
        /// <param name="college">表名</param>
        /// <param name="c_college">字段名</param>
        public void BookType()
        {
            con = dButil.SqlOpen();                                                               //打开i数据库
            //初始化,comboBox1绑定学院表
            string         sqltype = "select c_college from [college]";                           //查询有多少类别
            SqlDataAdapter sda     = new SqlDataAdapter(sqltype, con);
            DataSet        ds      = new DataSet();                                               //创建ds缓存

            sda.Fill(ds);                                                                         //添加到ds缓存中
            cmb_college.DataSource    = ds.Tables[0].DefaultView;                                 //取出数据源填充到列表中
            cmb_college.DisplayMember = "c_college";                                              //列表中显示的值对应的字段名
            string sql = "select c_id from [college] where c_college='" + cmb_college.Text + "'"; //查学院第一个的列的id

            cmd = new SqlCommand(sql, con);                                                       ////储存需要执行的c_id语句
            int c_id = Convert.ToInt16(cmd.ExecuteScalar());                                      //返回c_id值,用于这边选中,执行c_id语句

            cmb_college.SelectedIndex = c_id;                                                     //设置索引为c_id
            con.Close();                                                                          //关闭数据库
        }
Exemple #8
0
        /// <summary>
        /// 查询表首列的方法
        /// </summary>
        /// <param name="sql">数据库查询语句</param>
        public int ExecuteScalar(string sql)
        {
            DButil        dButil = new DButil();                         //实例化连接数据库类
            SqlConnection con    = dButil.SqlOpen();                     //打开数据库
            SqlCommand    cmd    = new SqlCommand(sql, con);             //储存需要执行的sql语句
            int           n      = Convert.ToInt16(cmd.ExecuteScalar()); //赋值管理员编号,执行sql语句

            con.Close();                                                 //关闭数据库
            return(n);
        }
Exemple #9
0
        //添加判断
        public static int ExecuteNonQuery(string sql)
        {
            DButil        butil = new DButil();
            SqlConnection con   = butil.SqlOpen();          //打开//储存需要执行的sql语句数据库
            SqlCommand    cmd   = new SqlCommand(sql, con); //储存sql语句
            int           n     = cmd.ExecuteNonQuery();    //执行sql语句

            con.Close();                                    //关闭数据库
            return(n);
        }
Exemple #10
0
        DButil dButil = new DButil(); //实例化DButil工具类

        private void admin_userEdit_Load(object sender, EventArgs e)
        {
            string user_id = Log.log.user_id;
            string sql     = "select * from [user] where u_id='" + user_id.ToString() + "'";

            con = dButil.SqlOpen();                     //打开数据库
            cmd = new SqlCommand(sql, con);
            sdr = cmd.ExecuteReader();                  //储存结果
            sdr.Read();                                 //检测是否有数据
            text_id.Text    = user_id;                  //学号/工号
            text_name.Text  = sdr["u_name"].ToString(); //在姓名文本框中显示查询到的姓名
            mtext_tel.Text  = sdr["u_tel"].ToString();  //在手机号文本框中显示查询到的手机号
            mtext_card.Text = sdr["u_card"].ToString(); //在身份证文本框中显示查询到的身份证
            cmb_sex.Items.Add(sdr["u_sex"].ToString()); //获得性别
            cmb_sex.SelectedIndex = 0;                  //并选中性别
            if (cmb_sex.Text == "男")                    //如果是男,下拉框就添加女,否则添加男
            {
                cmb_sex.Items.Add("女");
            }
            else
            {
                cmb_sex.Items.Add("男");
            }

            cmb_position.Items.Add(sdr["u_position"].ToString());
            cmb_position.SelectedIndex = 0;
            if (cmb_position.Text == "学生")//如果是学生组,下拉框就添加老师组,否则添加学生组
            {
                cmb_position.Items.Add("老师");
            }
            else
            {
                cmb_position.Items.Add("学生");
            }
            College();
            con.Close();//关闭数据库
        }
Exemple #11
0
        //加载事件
        private void user_Home_Load(object sender, EventArgs e)
        {
            string        sql    = "select u_name,u_number from [user] where u_id='" + Log.log.u_id + "'"; //sql查询可借数量语句
            DButil        dButil = new DButil();                                                           //实例化DButil工具类
            SqlConnection con    = dButil.SqlOpen();                                                       //打开数据库
            SqlCommand    cmd    = new SqlCommand(sql, con);                                               //执行sql查询
            SqlDataReader reader = cmd.ExecuteReader();                                                    //创建个只读结果集

            reader.Read();
            string user_name = reader["u_name"].ToString();            //取出结果

            Log.log.user_number = Convert.ToInt16(reader["u_number"]); //取出可借图书数量结果,并储存在log类中调用
            con.Close();                                               //关闭数据库
            lbl_username.Text = "欢迎您,尊敬的用户:" + user_name;
        }
Exemple #12
0
        DButil dButil = new DButil(); //实例化DButil工具类

        //窗体加载事件
        private void user_SeeFeedback_Load(object sender, EventArgs e)
        {
            //利用编号查询内容
            string sql = "select * from feedback where f_id='" + Log.log.user_fid + "'";

            con = dButil.SqlOpen();                     //打开数据库
            cmd = new SqlCommand(sql, con);             //执行数据库语句
            SqlDataReader reader = cmd.ExecuteReader(); //返回内容

            reader.Read();
            text_id.Text    = reader["u_id"].ToString();         //获得用户id显示在用户id文本框中
            text_stm.Text   = reader["f_smntime"].ToString();    //获得提交时间显示在提交时间文本框中
            text_atm.Text   = reader["f_asrtime"].ToString();    //获得回复时间显示在回复时间文本框中
            text_title.Text = reader["f_title"].ToString();      //获得反馈标题显示在反馈标题文本框中
            rtb_cnt.Text    = reader["f_content"].ToString();    //获得反馈内容显示在反馈内容文本框中
            rtb_rcd.Text    = reader["f_asrcontent"].ToString(); //获得回复内容显示在回复内容文本框中
            text_solve.Text = reader["f_solve"].ToString();      //获得获得是否已回复的值显示在是否已回复文本框中
            con.Close();                                         //关闭数据库
        }
Exemple #13
0
 private void btn_ok_Click(object sender, EventArgs e)
 {
     //判断反馈标题是否为空
     if (text_title.Text.Trim() == "")
     {
         //反馈标题为空弹窗提示,警告
         MessageBox.Show("反馈标题不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
     }
     else if (text_conent.Text.Trim() == "")
     {
         //反馈内容为空弹窗提示,警告
         MessageBox.Show("反馈内容不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
     }
     else
     {
         //弹窗进行用户二次确认
         DialogResult dialog = MessageBox.Show("确认进行该反馈提交?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
         if (DialogResult.OK == dialog)//判断是否点击了确认按钮
         {
             //sql插入语句
             string sql = "insert into feedback(u_id,f_title,f_content,f_smntime) values ('" + text_id.Text + "','" + text_title.Text.Trim() + "','" + text_conent.Text.Trim() + "',getdate())";
             con = dButil.SqlOpen();         //打开数据库
             cmd = new SqlCommand(sql, con); //储存sql语句
             int n = cmd.ExecuteNonQuery();  //执行sql语句,返回受影响的行数赋值到n中
             if (n > 0)                      //判断n是否大于0,大于0则成功
             {
                 //成功提交提示
                 dialog = MessageBox.Show("提交反馈成功!点击确认按钮返回反馈记录窗口", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
                 if (dialog == DialogResult.OK)
                 {
                     Close();//关闭当前窗体
                 }
             }
             else
             {
                 //提交失败提示
                 MessageBox.Show("提交反馈失败!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
             }
         }
     }
 }
Exemple #14
0
        DButil dButil = new DButil(); //实例化DButil工具类
        //填充表内容的databind方法
        public void databind(string sql)
        {
            Dgv_SeeBook.AutoGenerateColumns = false; //不自动生成列,从数据库可能取得很多列,使其不显示在DataGridView中
            con = dButil.SqlOpen();
            cmd = new SqlCommand(sql, con);          //储存sql语句
            sda = new SqlDataAdapter(cmd);
            ds  = new DataSet();
            sda.Fill(ds, "Book");//把查询内容添加到ds中,区别type类别换成
            bindingSource1.DataSource = ds.Tables["Book"];
            BindNavig.BindingSource   = bindingSource1;
            Dgv_SeeBook.DataSource    = bindingSource1;
            for (int i = 0; i < 8; i++)
            {
                Dgv_SeeBook.Columns[i].DataPropertyName = ds.Tables["Book"].Columns[i].ColumnName;
            }

            con.Close();//关闭数据库
        }
Exemple #15
0
        /// <summary>
        /// 绑定下拉列表,添加数据库中的类别
        /// </summary>
        /// <param name="sqltype">数据库语句</param>
        /// <param name="type">表名</param>
        /// <param name="t_name">字段名</param>
        public void BookType()
        {
            con = dButil.SqlOpen();
            //初始化,comboBox1绑定客户表
            string         sqltype = "select t_name from [type]";      //查询有多少类别
            SqlDataAdapter sda     = new SqlDataAdapter(sqltype, con); //创建sql适配器
            DataSet        ds      = new DataSet();                    //创建ds缓存

            sda.Fill(ds);                                              //添加到ds缓存中
            cmb_type.DataSource    = ds.Tables[0].DefaultView;         //取出数据源填充到列表中
            cmb_type.DisplayMember = "t_name";                         //列表中显示的值对应的字段名
            string sql = "select t_id from [type] where t_name='" + Log.log.b_type + "'";

            cmd = new SqlCommand(sql, con);                  ////储存需要执行的t_id语句
            int t_id = Convert.ToInt16(cmd.ExecuteScalar()); //返回t_id值,用于这边选中,执行t_id语句

            cmb_type.SelectedIndex = t_id;                   //设置索引为t_id
            con.Close();                                     //关闭数据库
        }
Exemple #16
0
        //添加按钮事件
        private void btn_type_Click(object sender, EventArgs e)
        {
            SqlConnection con; //创建数据库连接对象
            SqlCommand    cmd; //创建sql执行对象
            DButil        dButil = new DButil();

            con = dButil.SqlOpen();//打开数据库

            if (Log.log.user_college == true)
            {
                string sql = "select c_college from college where c_college='" + text_type.Text.Trim() + "'";
                cmd = new SqlCommand(sql, con);                      //执行sql语句
                string name = Convert.ToString(cmd.ExecuteScalar()); //获得是否存在内容
                con.Close();                                         //关闭数据库
                if (text_type.Text.Trim() == "")                     //判断是否输入了类别
                {
                    MessageBox.Show("学院名称不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
                else if (name != "")//判断是否存在该类别
                {
                    //存在提示
                    MessageBox.Show("已存在该学院名称!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
                else
                {
                    DialogResult dialog = MessageBox.Show("确认添加" + text_type.Text.Trim() + "学院?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
                    if (dialog == DialogResult.OK)
                    {
                        con = dButil.SqlOpen();         //打开数据库
                                                        //sql插入语句
                        sql = "insert into college(c_college) values ('" + text_type.Text.Trim() + "')";
                        cmd = new SqlCommand(sql, con); //执行sql语句
                        int n = cmd.ExecuteNonQuery();  //返回影响行
                        con.Close();                    //关闭数据库
                        if (n > 0)
                        {
                            SqlDbHelper dbHelper = new SqlDbHelper();                   //实例化SqlDbHelper类
                            dbHelper.Operation("添加" + text_type.Text.Trim() + "学院成功!"); //插入操作记录
                                                                                        //成功提示
                            MessageBox.Show("添加" + text_type.Text.Trim() + "学院成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        }
                        else
                        {
                            //失败提示
                            MessageBox.Show("添加学院失败!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                    }
                }
            }
            else
            {
                string sql = "select t_name from type where t_name='" + text_type.Text.Trim() + "'";
                cmd = new SqlCommand(sql, con);                      //执行sql语句
                string name = Convert.ToString(cmd.ExecuteScalar()); //获得是否存在内容
                con.Close();                                         //关闭数据库
                if (text_type.Text.Trim() == "")                     //判断是否输入了类别
                {
                    MessageBox.Show("类别不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
                else if (name != "")//判断是否存在该类别
                {
                    //存在提示
                    MessageBox.Show("已存在该类别!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
                else
                {
                    DialogResult dialog = MessageBox.Show("确认添加" + text_type.Text.Trim() + "图书类别?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
                    if (dialog == DialogResult.OK)
                    {
                        con = dButil.SqlOpen();         //打开数据库
                                                        //sql插入语句
                        sql = "insert into type(t_name) values ('" + text_type.Text.Trim() + "')";
                        cmd = new SqlCommand(sql, con); //执行sql语句
                        int n = cmd.ExecuteNonQuery();  //返回影响行
                        con.Close();                    //关闭数据库
                        if (n > 0)
                        {
                            SqlDbHelper dbHelper = new SqlDbHelper();               //实例化SqlDbHelper类
                            dbHelper.Operation("添加新图书类别:" + text_type.Text.Trim()); //插入操作记录
                                                                                    //成功提示
                            MessageBox.Show("添加类别:" + text_type.Text.Trim() + "成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        }
                        else
                        {
                            //失败提示
                            MessageBox.Show("添加类别失败!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                    }
                }
            }
        }