Esempio n. 1
0
        private void LoadUserInfo()
        {
            //如果是修改加载user信息  用户账号不允许修改
            if (this.Owner is UserManager)
            {
                UserManager userManager = (UserManager)this.Owner;
                if (userManager.flag.Equals("2"))
                {
                    ScanDataSet scandataset = new Business.UserInfo().GetUserByID(userManager.userID);
                    if (scandataset.UserInfo.Rows.Count > 0)
                    {
                        this.tbUserCode.ReadOnly = true;


                        userTable = scandataset.UserInfo;
                        userRow   = scandataset.UserInfo.Rows[0];

                        this.tbUserCode.Text     = userRow["usercode"].ToString();
                        this.tbUserName.Text     = userRow["username"].ToString();
                        this.tbUserPassWord.Text = userRow["password"].ToString();
                        this.tbSite.Text         = userRow["site"].ToString();
                        string status = userRow["status"].ToString();
                        switch (status)
                        {
                        case "1":
                            this.startRadioButton.Checked = true;
                            break;

                        case "0":
                            this.forbidRadioButton.Checked = true;
                            break;

                        default:
                            this.startRadioButton.Checked = true;
                            break;
                        }
                    }
                    else
                    {
                        MessageBox.Show("获取用户信息错误!");
                        return;
                    }
                }
            }
        }
Esempio n. 2
0
 private void btnUpdateStatus_Click(object sender, EventArgs e)
 {
     //判断选中几行
     try
     {
         int  count  = 0;
         bool result = false;
         for (int i = 0; i < this.dgvUserInfo.Rows.Count; i++)
         {
             if (this.dgvUserInfo.Rows[i].Cells[this.dgvUserInfo.Columns["SelectCheck"].Index].EditedFormattedValue.ToString() == "True")
             {
                 count++;
                 this.userID = this.dgvUserInfo.Rows[i].Cells["id"].Value.ToString();
                 string      status      = this.dgvUserInfo.Rows[i].Cells["status"].Value.ToString();
                 ScanDataSet scanDataSet = new Business.UserInfo().GetUserByID(this.userID);
                 if (scanDataSet.UserInfo.Rows.Count > 0)
                 {
                     ScanDataSet.UserInfoDataTable dt = scanDataSet.UserInfo;
                     dt.Rows[0]["status"] = status == "1" ? "0" : "1";
                     result = new Business.UserInfo().AddUser(dt);
                 }
             }
         }
         if (count == 0)
         {
             MessageBox.Show("请选择要修改的行!");
             return;
         }
         else if (count > 1)
         {
             MessageBox.Show("请选择一行修改记录!");
             return;
         }
         if (result)
         {
             MessageBox.Show("更新成功!");
             return;
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Esempio n. 3
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                //校验数据
                CheckContent();
                bool        result;
                UserManager userManager;
                //判断是新增 or 修改
                if (this.Owner is UserManager)
                {
                    userManager = (UserManager)this.Owner;
                    if (userManager.flag.Equals("1"))
                    {
                        userTable            = new ScanDataSet.UserInfoDataTable();
                        userInfoRow          = userTable.NewUserInfoRow();
                        userInfoRow.usercode = this.tbUserCode.Text.Trim();

                        userInfoRow.username = this.tbUserName.Text.Trim();
                        userInfoRow.password = this.tbUserPassWord.Text.Trim();
                        userInfoRow.forgid   = ((UserManager)this.Owner).orgID;
                        userInfoRow.frcode   = ((UserManager)this.Owner).frcode;
                        userInfoRow.site     = this.tbSite.Text.Trim();
                        string status = "";
                        if (this.startRadioButton.Checked)
                        {
                            status = "1";
                        }

                        if (this.forbidRadioButton.Checked)
                        {
                            status = "0";
                        }
                        userInfoRow.status = status;

                        userTable.AddUserInfoRow(userInfoRow);
                        result = new Business.UserInfo().AddUser(userTable);
                    }
                    else if (userManager.flag.Equals("2"))
                    {
                        ScanDataSet scandataset = new Business.UserInfo().GetUserByID(userManager.userID);
                        if (scandataset.UserInfo.Rows.Count > 0)
                        {
                            userTable = scandataset.UserInfo;
                            userRow   = scandataset.UserInfo.Rows[0];

                            userRow["usercode"] = this.tbUserCode.Text.Trim();
                            userRow["username"] = this.tbUserName.Text.Trim();
                            userRow["password"] = this.tbUserPassWord.Text.Trim();
                            userRow["forgid"]   = ((UserManager)this.Owner).orgID;
                            userRow["frcode"]   = Util.Util.GetAppSetting("rcode").ToString();
                            userRow["site"]     = this.tbSite.Text.Trim();
                            string status = "";
                            if (this.startRadioButton.Checked)
                            {
                                status = "1";
                            }

                            if (this.forbidRadioButton.Checked)
                            {
                                status = "0";
                            }
                            userRow["status"] = status;

                            if (!String.IsNullOrEmpty(((UserManager)this.Owner).userID))
                            {
                                userRow["id"] = ((UserManager)this.Owner).userID;
                            }
                            result = new Business.UserInfo().AddUser(userTable);
                        }
                        else
                        {
                            MessageBox.Show("获取用户信息错误!");
                            return;
                        }
                    }
                    else
                    {
                        MessageBox.Show("获取业务标记错误!");
                        return;
                    }
                }
                else
                {
                    MessageBox.Show("获取父窗口错误!");
                    return;
                }



                if (result)
                {
                    MessageBox.Show("保存成功!");
                    userManager.searchData();
                    this.Close();
                    return;
                }
                else
                {
                    MessageBox.Show("保存失败!");

                    return;
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }