Example #1
0
        //修改密码
        private void button_add_Click(object sender, EventArgs e)
        {
            if (CValidateTools.isNull(textBox_oldPwd.Text))
            {
                CValidateTools.showError("请输入旧密码");
                return;
            }

            if (CValidateTools.isNull(textBox_new1.Text))
            {
                CValidateTools.showError("请输入新密码");
                return;
            }

            if (textBox_new1.Text != textBox_new2.Text)
            {
                CValidateTools.showError("二次密码输入不一致");
                return;
            }

            //查询此用户的旧密码是否正确
            string str = "select * from userInfo where AdmName = '#username' and AdmPwd = '#pwd' ";
            str = str.Replace("#username", m_usname);
            str = str.Replace("#pwd", textBox_oldPwd.Text);

            ADOHelper db = new ADOHelper();
            if (!db.ExecuteRead(str).HasRows)
            {
                CValidateTools.showError("旧密码不正确,无法修改新密码");
                return;
            }

            //替换新密码
            string strUpdate = "update userInfo set AdmPwd = '#pwd' where admName = '#admName' ";
            strUpdate = strUpdate.Replace("#admName", m_usname).Replace("#pwd", textBox_new1.Text);

            bool result = false;
            try
            {
                ADOHelper db1 = new ADOHelper();
                result = db1.ExecuteUpdate(strUpdate);
            }
            catch (Exception ex)
            {

                CValidateTools.showError(ex.Message);
                return;
            }

            if (result)
                CValidateTools.showOK("密码重置成功!");
        }
Example #2
0
        //添加用户
        private void button_add_Click(object sender, EventArgs e)
        {
            if (!checkValide())
                return;

            //格式化数据
            string sid = textBox_id.Text;
            string admName = textBox_name.Text;
            string cName = textBox_cname.Text;
            int roleID = int.Parse(comboBox_role.SelectedValue.ToString());
            int depID = int.Parse(comboBox_dep.SelectedValue.ToString());

            //查询记录中是否已经有相同记录

            string queryString = "select * from userInfo where userNumber = '#user1' or  AdmName = '#aname' ";

            string str1 = queryString.Replace("#user1", sid);
            str1 = str1.Replace("#aname", admName);

            ADOHelper db = new ADOHelper();
            if (db.ExecuteRead(str1).HasRows)
            {
                MessageBox.Show("编号或用户名已存在", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            //插入新用户
            string insertString = "insert into userInfo (admname,usernumber,admpwd,roleid,depcid,depid,cname) values( '#admName', '#userNum', '#pwd', #roleID, #depCID, #depID, '#cName' )";
            string str = insertString.Replace("#admName", admName);
            str = str.Replace("#userNum", sid);
            str = str.Replace("#pwd", "888888");
            str = str.Replace("#userNum", sid);
            str = str.Replace("#roleID", roleID.ToString());
            str = str.Replace("#depCID", DevTools.getDepartmentId());//默认用2,2为交管局,1为公安局
            str = str.Replace("#depID", depID.ToString());
            str = str.Replace("#cName", cName);

            if (db.ExecuteUpdate(str))
            {
                CValidateTools.showOK("添加用户成功");
                clearControlData();//清除录入数据

            }
            else
            {
                CValidateTools.showError("添加用户失败");
            }
        }
Example #3
0
        private bool checkLogin()
        {
            //防止sql注入 类似 where user='******' and pwd ='123' or 'a' = 'a'
            if (textBox_uname.Text.IndexOf(" ") > 0 || textBox_upwd.Text.IndexOf(" ") > 0)
            {
                return false;
            }

            //ADOHelper db = new ADOHelper();

            string str = m_strLoginStr;
            str = str.Replace("#username", textBox_uname.Text);
            str = str.Replace("#pwd", textBox_upwd.Text);

            try
            {
                ADOHelper db = new ADOHelper();
                OleDbDataReader result = db.ExecuteRead(str);
                if (!result.HasRows)
                {
                    return false;
                }

                while (result.Read())//保存全局用户信息
                {
                    ClassGlobalUserInfo.cName = result["cName"].ToString();
                    ClassGlobalUserInfo.amdName = result["AdmName"].ToString();
                    ClassGlobalUserInfo.userNumber = result["userNumber"].ToString();
                    ClassGlobalUserInfo.roleID = result["roleID"].ToString();
                    ClassGlobalUserInfo.depId = result["depId"].ToString();
                    ClassGlobalUserInfo.depCId = result["depCId"].ToString();
                }
            }
            catch (Exception se)
            {

                CValidateTools.showError(se.ToString());
                return false;
            }

            return true;
        }
Example #4
0
        public FormuserAdd(int parentLeft, int parentTop)
        {
            m_parentLeft = parentLeft;
            m_parentTop = parentTop;

            this.SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint | ControlStyles.OptimizedDoubleBuffer, true);
            InitializeComponent();

            //给combobox赋值并绑定id
            string strQuery = @" select * from department where depID = 3 and categroyID = " + DevTools.getDepartmentId();//categroyID = 1指公安,2指交警
            //dep =3 ,目前只显示派出所的
            ADOHelper db = new ADOHelper();
            comboBox_dep.DataSource = db.ExecuteGet(strQuery).Tables[0];
            comboBox_dep.DisplayMember = "depName";
            comboBox_dep.ValueMember = "depID";

            strQuery = @" select * from role where id > 5";                     //只列出除系统管理员外的人
            comboBox_role.DataSource = db.ExecuteGet(strQuery).Tables[0];
            comboBox_role.DisplayMember = "roleName";
            comboBox_role.ValueMember = "ID";

            db.Dispose();
        }
Example #5
0
        //重置密码
        private void button1_Click(object sender, EventArgs e)
        {
            if (!ClassGlobalUserInfo.checkValidate())//操作员没有权限
            {
                CValidateTools.showError("权限不足");
                return;
            }

            if (!CValidateTools.checkLength(textBox_id.Text, 1, 20))
            {
                CValidateTools.showError("请先选择一个用户");
                return;
            }

            if (CValidateTools.showYesNoDialog("确定要重置密码吗?") == DialogResult.Cancel)
                return;

            string strUpdate = "update userInfo set AdmPwd = '888888' where userNumber = '#usernumber' ";
            strUpdate = strUpdate.Replace("#usernumber", textBox_id.Text);

            bool result = false;
            try
            {
                ADOHelper db = new ADOHelper();
                result = db.ExecuteUpdate(strUpdate);
            }
            catch (Exception ex)
            {

                CValidateTools.showError(ex.Message);
                return;
            }

            if (result)
                CValidateTools.showOK("密码重置成功!");
        }
Example #6
0
 public ADOHelper()
 {
     con = new OleDbConnection(ADOHelper.ConnectionString());
 }
Example #7
0
        //数据查询
        private void button_inquery_Click(object sender, EventArgs e)
        {
            string str = "#col like '%#value%' ";
            if (comboBox_queryCol.SelectedIndex == 0)
                str = str.Replace("#col", "采集人编号").Replace("#value", textBox_QueryKey.Text);
            else if (comboBox_queryCol.SelectedIndex == 1)
                str = str.Replace("#col", "上传人编号").Replace("#value", textBox_QueryKey.Text);
            else if (comboBox_queryCol.SelectedIndex == 2)
            {
                str = "上传时间 >= '#date1' and 上传时间<= '#date2' ";
                str = str.Replace("#date1", dateTimePicker1.Text).Replace("#date2", dateTimePicker2.Text);
            }
            else if (comboBox_queryCol.SelectedIndex == 3)
                str = str.Replace("#col", "上传标题").Replace("#value", textBox_QueryKey.Text);
            else
                str = str.Replace("#col", "上传备注").Replace("#value", textBox_QueryKey.Text);

            string strQuery = @" select  ID as 编号, uid1 as 采集人编号, uid2 as 上传人编号, uploadTime as 上传时间, uploadTitle as 上传标题,
                                 uploadDes as 上传备注, createTime as 采集时间, fileDir as 保存路径
                                 from fileUpload order by ID DESC";

            ADOHelper db = new ADOHelper();

            DataView dvNewDataViewObject = new DataView();
            dvNewDataViewObject.Table = db.ExecuteGet(strQuery).Tables[0];
            dvNewDataViewObject.RowFilter = str;
            //dview_UploadInfo.DataBindings.Clear();
            //dview_UploadInfo.DataSource = dvNewDataViewObject;
            srcTable = dvNewDataViewObject.ToTable();
            ChangeDataSoure(srcTable);
            InitPageSet(20);
            imageButton_first.PerformClick();//默认先显示第一页
        }
Example #8
0
        private void getUploadData()
        {
            string strQuery = @" select  ID as 编号, uid1 as 采集人编号, uid2 as 上传人编号, uploadTime as 上传时间, uploadTitle as 上传标题,
                                 uploadDes as 上传备注, createTime as 采集时间, fileDir as 保存路径
                                 from fileUpload order by ID DESC";

            ADOHelper db = new ADOHelper();
            //dview_UploadInfo.DataSource = db.ExecuteGet(strQuery).Tables[0];
            srcTable = db.ExecuteGet(strQuery).Tables[0];
        }
Example #9
0
        //保存数据
        private void button_save_Click(object sender, EventArgs e)
        {
            if (!ClassGlobalUserInfo.checkValidate())//操作员没有权限
            {
                CValidateTools.showError("权限不足");
                return;
            }

            if (textBox_uTitle.ReadOnly )
                return;

            if (textBox_uTitle.Text.Length <= 0 || textBox_des.Text.Length <= 0)
            {
                CValidateTools.showError("待修改内容不能为空");
                return;
            }

            string rowID = dview_UploadInfo.Rows[dview_UploadInfo.SelectedCells[0].RowIndex].Cells["编号"].Value.ToString();
            if (rowID == null || rowID.Length <= 0)
            {
                CValidateTools.showError("请选择要修改的数据");
                return;
            }

            string strUpdate = "update fileUpload set uploadTitle = '#title' ,  uploadDes = '#uploadDes'  where ID = #ID1 ";
            strUpdate = strUpdate.Replace("#title", textBox_uTitle.Text).Replace("#uploadDes", textBox_des.Text).Replace("#ID1", rowID);

            bool result = false;
            try
            {
                ADOHelper db = new ADOHelper();
                result = db.ExecuteUpdate(strUpdate);
            }
            catch (Exception ex)
            {
                CValidateTools.showError(ex.Message);
                return;
            }

            if (result)
            {
                CValidateTools.showOK("上传信息修改成功!");

                getUploadData();
                ChangeDataSoure(srcTable);
            }

            textBox_uTitle.ReadOnly = true;
            textBox_des.ReadOnly = true;
        }
Example #10
0
        //条件查询
        private void button_inquery_Click(object sender, EventArgs e)
        {
            if (CValidateTools.containsBlank(textBox_QueryKey.Text))
            {
                CValidateTools.showError("关键字不合法!");
                return;
            }

            /* 一种过滤数据的方法

            string strQuery = @" select u1.AdmName as 用户名, u1.cName as 姓名, u1.userNumber as 编号, d1.depName as 所属部门, r1.roleName as 角色, u1.AddDate as 创建时间 from userInfo u1, department d1, role r1
             where u1.roleID = r1.ID and u1.depCID = d1.categroyID and u1.depID = d1.depID and d1.categroyID = 2 and   #col like '%#value%'  and depCID = 2 ";
            string str = strQuery;
            if (comboBox_queryCol.SelectedIndex == 0)
                str = str.Replace("#col", "userNumber").Replace("#value", textBox_QueryKey.Text );
            else if(comboBox_queryCol.SelectedIndex == 1)
                str = str.Replace("#col", "admName").Replace("#value", textBox_QueryKey.Text);
            else
                str = str.Replace("#col", "cName").Replace("#value", textBox_QueryKey.Text);

            dview_UserInfo.rows

            ADOHelper db = new ADOHelper();
            if (db.ExecuteGet(str) == null)
                return;

            dview_UserInfo.DataBindings.Clear();
            dview_UserInfo.DataSource = db.ExecuteGet(str).Tables[0];

             * */

            //另一种过滤数据的方法

            string str = "#col like '%#value%' ";
            if (comboBox_queryCol.SelectedIndex == 0)
                str = str.Replace("#col", "编号").Replace("#value", textBox_QueryKey.Text);
            else if (comboBox_queryCol.SelectedIndex == 1)
                str = str.Replace("#col", "用户名").Replace("#value", textBox_QueryKey.Text);
            else
                str = str.Replace("#col", "姓名").Replace("#value", textBox_QueryKey.Text);

            string strQuery = @" select u1.AdmName as 用户名, u1.cName as 姓名, u1.userNumber as 编号, d1.depName as 所属部门, r1.roleName as 角色, u1.AddDate as 创建时间 from userInfo u1, department d1, role r1
             where u1.roleID = r1.ID and u1.depCID = d1.categroyID and u1.depID = d1.depID and d1.categroyID = " + DevTools.getDepartmentId();

            ADOHelper db = new ADOHelper();

            DataView dvNewDataViewObject = new DataView();
            dvNewDataViewObject.Table = db.ExecuteGet(strQuery).Tables[0];
            dvNewDataViewObject.RowFilter = str;
            dview_UserInfo.DataBindings.Clear();
            dview_UserInfo.DataSource = dvNewDataViewObject;
        }
Example #11
0
        private void userSearch_Load(object sender, EventArgs e)
        {
            getUserInfo();

            button_modify.Visible = false;
            button_save.Visible = false;

            comboBox_queryCol.Items.Add("编号");
            comboBox_queryCol.Items.Add("用户名");
            comboBox_queryCol.Items.Add("姓名");
            comboBox_queryCol.SelectedIndex = 0;

            //给combobox赋值并绑定id
            string strQuery = @" select * from department where categroyID = " + DevTools.getDepartmentId();
            ADOHelper db = new ADOHelper();
            comboBox_dep.DataSource = db.ExecuteGet(strQuery).Tables[0];
            comboBox_dep.DisplayMember = "depName";
            comboBox_dep.ValueMember = "depID";

            strQuery = @" select * from role where id > 2";
            comboBox_role.DataSource = db.ExecuteGet(strQuery).Tables[0];
            comboBox_role.DisplayMember = "roleName";
            comboBox_role.ValueMember = "ID";
        }
Example #12
0
        private void getUserInfo()
        {
            string strQuery = @" select u1.AdmName as 用户名, u1.cName as 姓名, u1.userNumber as 编号, d1.depName as 所属部门, r1.roleName as 角色, u1.AddDate as 创建时间 from userInfo u1, department d1, role r1
             where u1.roleID = r1.ID and u1.depCID = d1.categroyID and u1.depID = d1.depID and d1.categroyID = " + DevTools.getDepartmentId();

            ADOHelper db = new ADOHelper();
            dview_UserInfo.DataSource = db.ExecuteGet(strQuery).Tables[0];
        }
Example #13
0
        //保存修改
        private void button_save_Click(object sender, EventArgs e)
        {
            if (!ClassGlobalUserInfo.checkValidate())//操作员没有权限
            {
                CValidateTools.showError("权限不足");
                return;
            }

            if (textBox_cname.ReadOnly)
                return;

            int roleID = int.Parse(comboBox_role.SelectedValue.ToString());
            int depID = int.Parse(comboBox_dep.SelectedValue.ToString());

            string strUpdate = "update userInfo set cName = '#cname' ,  depID = #depid , roleID = #roldid where userNumber = '#usernumber'";
            strUpdate = strUpdate.Replace("#cname", textBox_cname.Text).Replace("#depid", depID.ToString()).Replace("#roldid", roleID.ToString()).Replace("#usernumber", textBox_id.Text);

            bool result = false;
            try
            {
                ADOHelper db = new ADOHelper();
                result = db.ExecuteUpdate(strUpdate);
            }
            catch (Exception ex)
            {

                CValidateTools.showError(ex.Message);
                return;
            }

            if (result)
                CValidateTools.showOK("用户修改成功!");

            getUserInfo();

            textBox_cname.ReadOnly = true;
            textBox_id.ReadOnly = true;
        }
Example #14
0
        private bool uploadFileToDB(string filename, string strCreateTime)
        {
            string uploadString = @"insert into fileUpload (uid1,uid2,uploadTime,uploadTitle,uploadDes,createTime,fileDir)
                                    values ( '#uid1', '#uid2', '#uploadTime', '#uploadTitle','#uploadDes','#createTime','#fileDir')";

            uploadString = uploadString.Replace("#uid1", comboBox_uid1.SelectedValue.ToString()).Replace("#uid2", ClassGlobalUserInfo.userNumber);
            uploadString = uploadString.Replace("#uploadTime",dateTimePicker1.Value.ToString("yyyy/MM/dd HH:mm:ss"));
            uploadString = uploadString.Replace("#uploadTitle",textBox_uTitle.Text);
            uploadString = uploadString.Replace("#uploadDes", textBox_des.Text);
            uploadString = uploadString.Replace("#createTime", strCreateTime);
            uploadString = uploadString.Replace("#fileDir", filename);

            try
            {
                ADOHelper db = new ADOHelper();
                //for (int i = 0; i < 800; i++ )//for test
                    db.ExecuteUpdate(uploadString);
            }
            catch (Exception ex)
            {
                ErrorLog.WriteLog(ex);
                CValidateTools.showError(ex.Message);
                return false;
            }

            return true;
        }
Example #15
0
 private void FormUploadFile_Load(object sender, EventArgs e)
 {
     //给combobox赋值并绑定id
     string strQuery = @" select * from userInfo where depCID = "+DevTools.getDepartmentId();
     ADOHelper db = new ADOHelper();
     comboBox_uid1.DataSource = db.ExecuteGet(strQuery).Tables[0];
     comboBox_uid1.DisplayMember = "cName";
     comboBox_uid1.ValueMember = "userNumber";
 }