Пример #1
0
        private void buttonOk_Click(object sender, EventArgs e)
        {
            if (this.textBoxCode.Text == "")
            {
                MessageBox.Show("请填写账号。", "提示信息");
                this.textBoxCode.Focus();
                return;
            }
            if (this.textBoxPassword.Text == "")
            {
                MessageBox.Show("请填写密码。", "提示信息");
                this.textBoxPassword.Focus();
                return;
            }
            try
            {
                Response          res  = new Response();
                Artifact.Api.User user = new Api.User();
                user.user_code     = this.textBoxCode.Text;
                user.user_name     = this.textBoxName.Text;
                user.user_password = this.textBoxPassword.Text;
                user.user_remark   = this.richTextBoxRemark.Text;
                user.role_id       = this.comboBoxRole.SelectedIndex.ToString();
                user.user_expire   = this.dateTimePickerExpire.Text;
                user.user_email    = "";
                user.user_mobile   = "";

                if (this.radioButtonService.Checked == true)
                {
                    user.user_is_service = "1";
                }

                Artifact.Api.User user_add = res.UserCreate(user);
                if (user_add != null)
                {
                    MessageBox.Show("添加成功!");
                    this.textBoxCode.Text = "";
                }
                else
                {
                    MessageBox.Show("添加失败!" + res.message);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("获取信息出错!" + ex.Message);
            }
        }
Пример #2
0
        private void buttonOk_Click(object sender, EventArgs e)
        {
            if (this.textBoxCode.Text == "")
            {
                MessageBox.Show("请填写账号。", "提示信息");
                this.textBoxCode.Focus();
                return;
            }
            if (this.textBoxPassword.Text == "")
            {
                MessageBox.Show("请填写密码。", "提示信息");
                this.textBoxPassword.Focus();
                return;
            }
            try
            {
                Response res = new Response();
                Artifact.Api.User user = new Api.User();
                user.user_code = this.textBoxCode.Text;
                user.user_name = this.textBoxName.Text;
                user.user_password = this.textBoxPassword.Text;
                user.user_remark = this.richTextBoxRemark.Text;
                user.role_id = this.comboBoxRole.SelectedIndex.ToString();
                user.user_expire = this.dateTimePickerExpire.Text;
                user.user_email = "";
                user.user_mobile = "";

                if (this.radioButtonService.Checked == true)
                    user.user_is_service = "1";

                Artifact.Api.User user_add = res.UserCreate(user);
                if (user_add != null)
                {
                    MessageBox.Show("添加成功!");
                    this.textBoxCode.Text = "";
                }
                else
                    MessageBox.Show("添加失败!" + res.message);

            }
            catch (Exception ex)
            {
                MessageBox.Show("获取信息出错!" + ex.Message);
            }
        }
Пример #3
0
        private User selectUser()
        {
            User user = new User();
            if (this.listBoxService.Items.Count > 0 && this.listBoxService.SelectedIndex>=0)
            {
                user = (User)this.listBoxService.SelectedItem;

            }

            return user;
        }
Пример #4
0
        private void dataGridViewUserList_CellValueChanged(object sender, DataGridViewCellEventArgs e)
        {
            try
            {
                if (this.dataGridViewUserList.DataSource == null || this.dataGridViewUserList.CurrentRow == null)
                {
                    return;
                }
                else
                {
                    if (this.dataGridViewUserList.SelectedRows.Count > 0)
                    {
                        DialogResult dr = MessageBox.Show("数据有更改,是否保存? ", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
                        if (dr == DialogResult.OK)
                        {
                            try
                            {
                                Response res = new Response();
                                DataGridViewRow row = this.dataGridViewUserList.CurrentRow;
                                User user = new User();
                                user.user_id = row.Cells[0].Value.ToString();
                                user.role_id = row.Cells[1].Value.ToString();
                                user.user_code = row.Cells[2].Value.ToString();
                                user.user_password = row.Cells[3].Value.ToString();
                                user.user_expire = row.Cells[4].Value.ToString();
                                user.user_name = row.Cells[5].Value.ToString();
                                user.user_mobile = row.Cells[6].Value.ToString();
                                user.user_email = row.Cells[7].Value.ToString();
                                user.user_remark = row.Cells[8].Value.ToString();
                                user.user_is_service = row.Cells[9].Value.ToString();

                                if (res.UserUpdate(user) != null)
                                    MessageBox.Show("保存成功", "提示");

                            }
                            catch (Exception ex)
                            {
                                MessageBox.Show(ex.ToString(), "提示");
                            }
                            //删除后执行刷新操作
                        }
                    }
                }
            }
            catch (Exception )
            {
            }
        }
Пример #5
0
        public User UserUpdate(User user)
        {
            User manageUser = Program.user;
            this.SendApi(this.apiUserUpdate + "token=" + manageUser.token + "&id=" + user.user_id + "&code=" + user.user_code + "&pwd=" + user.user_password + "&role=" + user.role_id + "&name=" + user.user_name + "&expire=" + user.user_expire + "&mobile=" + user.user_mobile + "&email=" + user.user_email + "&remark=" + user.user_remark + "&pcode=" + user.user_parent_code + "&service=" + user.user_is_service);

            try
            {
                if (this.items != "")
                {
                    return (User)JsonConvert.DeserializeObject(this.items, typeof(User));
                }
                return null;
            }
            catch (Exception ex)
            {
                Console.WriteLine(" API update 出错 " + ex.Message);
                return null;
            }
        }