Exemple #1
0
        public void updateUserInfo(String userName)
        {
            if (tb_username.Text != null && tb_up_password.Text != null && tb_company.Text != null)
            {
                hailyEntities db = new hailyEntities();

                //查询要获取的对象
                var userInfo = from u in db.user
                               where u.username == userName
                               select u;
                //获得具体对象
                var userInfoObject = userInfo.FirstOrDefault();

                //修改密码
                userInfoObject.password = EncodeMD5.getMD5(tb_up_password.Text.Trim());

                ////如果用户名与原始用户名不同,则修改用户名
                //if (userName != tb_username.Text)
                //{
                //    //用户信息表中的用户名
                //    userInfoObject.username = tb_username.Text;

                //    //软件授权记录表中的用户名,也应修改
                //    var permissionInfo = from u in db.permission
                //                         where u.username == userName
                //                         select u;
                //    var softwareInfoObject = permissionInfo.FirstOrDefault();


                //    softwareInfoObject.username = tb_username.Text;
                //    db.Entry<permission>(softwareInfoObject).State = System.Data.Entity.EntityState.Modified;
                //}
                userInfoObject.company = tb_company.Text;

                userInfoObject.permission = cb_new_permission.SelectedIndex;

                //指定状态。
                db.Entry <user>(userInfoObject).State = System.Data.Entity.EntityState.Modified;
                db.SaveChanges();

                MessageBox.Show("用户信息已更新!");

                FormMain formMain = new FormMain("userControlPage");
                formMain.Show();

                this.Hide();
            }
            else if (tb_username.Text == null)
            {
                MessageBox.Show("请输入用户名!", "缺少参数", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            else if (tb_up_password == null && tb_username != null)
            {
                MessageBox.Show("请输入密码!", "缺少参数", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            else
            {
                MessageBox.Show("请重新输入用户信息!", "缺少参数", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
Exemple #2
0
        public void updateSoftwareInfo()
        {
            if (tb_up_software.Text != null && tb_up_model.Text != null && tb_up_version.Text != null)
            {
                hailyEntities db = new hailyEntities();

                //查询要获取的对象
                var softwareInfo = from u in db.software
                                   where (u.name == soft_main.name && u.model == soft_main.model && u.version == soft_main.version)
                                   select u;
                //获得具体对象
                var softwareInfoObject = softwareInfo.FirstOrDefault();

                //修改软件名
                softwareInfoObject.name    = tb_up_software.Text.Trim();
                softwareInfoObject.model   = tb_up_model.Text.Trim();
                softwareInfoObject.version = tb_up_version.Text.Trim();

                //指定状态。
                db.Entry <software>(softwareInfoObject).State = System.Data.Entity.EntityState.Modified;
                db.SaveChanges();

                MessageBox.Show("软件信息已更新!");

                this.Close();
            }
            else if (tb_up_software.Text == null)
            {
                MessageBox.Show("请输入软件名!", "缺少参数", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            else if (tb_up_model == null && tb_up_software != null)
            {
                MessageBox.Show("请输入模块名!", "缺少参数", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            else if (tb_up_software.Text != null && tb_up_model.Text != null && tb_up_version.Text == null)
            {
                MessageBox.Show("请输入软件版本号!", "缺少参数", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
Exemple #3
0
        void DataGridViewX_SendList_CellContentClick(object sender, DataGridViewCellEventArgs e)  //申请列表 点击事件
        {
            int column = dgv_send_list.CurrentCell.ColumnIndex;
            int row    = dgv_send_list.CurrentCell.RowIndex;

            shenpi _shenpi = new shenpi();

            _shenpi = (shenpi)shenpi_read_list[row];

            //通过
            if (column == 7)
            {
                //修改 审批表(审批状态)、软件权限表(用户拥有软件权限)
                //修改审批表
                var shenpiList = from u in db.shenpi
                                 where u.Id == _shenpi.Id
                                 select u;
                var shenpiListObject = shenpiList.FirstOrDefault();
                shenpiListObject.is_read    = 1;
                shenpiListObject.is_through = 1;
                shenpiListObject.read_time  = DateTime.Now;

                //软件权限表添加一条记录
                permission _permission = new permission();
                _permission.username = _shenpi.username;
                _permission.software = _shenpi.software;
                _permission.model    = _shenpi.model;
                _permission.version  = _shenpi.version;
                db.permission.Add(_permission);

                //指定状态。
                db.Entry <shenpi>(shenpiListObject).State = System.Data.Entity.EntityState.Modified;
                db.SaveChanges();

                //更新 前端显示 -> 申请列表 和 授权记录;

                //清空前端数据
                dgv_send_list.Rows.Clear();
                shenpi_read_list.Clear();
                dgv_read_list.Rows.Clear();

                //同时更新 用户管理页面 -> 用户列表数据
                dgv_user_control.Rows.Clear();
                list_user_control.Clear();

                //重新载入 权限审批页面 -> 申请列表
                initSendListData();
                initReadListData();
                //刷新 用户管理页面
                data_user_initialize();
            }
            //拒绝
            if (column == 8)
            {
                //修改 审批表(审批状态)
                var shenpiList = from u in db.shenpi
                                 where u.Id == _shenpi.Id
                                 select u;
                var shenpiListObject = shenpiList.FirstOrDefault();
                shenpiListObject.is_read    = 1;
                shenpiListObject.is_through = 0;
                shenpiListObject.read_time  = DateTime.Now;

                db.Entry <shenpi>(shenpiListObject).State = System.Data.Entity.EntityState.Modified;
                db.SaveChanges();

                //更新 前端显示 -> 申请列表 和 授权记录
                //清空前端数据
                dgv_send_list.Rows.Clear();
                shenpi_read_list.Clear();
                dgv_read_list.Rows.Clear();
                //重新载入 权限审批页面 -> 申请列表
                initSendListData();
                initReadListData();
            }
        }