Exemplo n.º 1
0
 /// <summary>
 /// 添加新用户,初始密码默认123456
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void button1_Click(object sender, EventArgs e)
 {
     try
     {
         UFSM_UserInfo user = new UFSM_UserInfo();
         user.Name      = textBox1.Text.Trim();
         user.Account   = textBox2.Text.Trim();
         user.Authority = comboBox1.SelectedIndex == 0 ? "normal" : "admin";
         if (user.Authority == "admin")
         {
             user.AreaNum = 0;
         }
         else
         {
             user.AreaNum = (int)numericUpDown1.Value;
         }
         user.Password = "******";
         if (new UserInfoService().AddUserInfo(user))
         {
             MessageBox.Show("添加成功!");
             UpdateDGV();
         }
         else
         {
             MessageBox.Show("添加失败!");
         }
     }
     catch
     {
         MessageBox.Show("添加失败,请检查注册内容合法性后重试!");
     }
 }
Exemplo n.º 2
0
 public bool ChangeUserInfo(UFSM_UserInfo user)
 {
     using (xs373431671Entities db = new xs373431671Entities())
     {
         try
         {
             var userInfoList = from u in db.UFSM_UserInfo where u.ID == user.ID select u;
             var userInfo     = userInfoList.FirstOrDefault();
             userInfo.Name       = user.Name;
             userInfo.Account    = user.Account;
             userInfo.Password   = user.Password;
             userInfo.Telephone  = user.Telephone;
             userInfo.Department = user.Department;
             userInfo.AreaNum    = user.AreaNum;
             userInfo.Authority  = user.Authority;
             db.Entry <UFSM_UserInfo>(userInfo).State = System.Data.Entity.EntityState.Modified;
             db.SaveChanges();
             return(true);
         }
         catch
         {
             return(false);
         }
     }
 }
Exemplo n.º 3
0
 private void dataGridView1_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
 {
     user                    = (UFSM_UserInfo)dataGridView1.Rows[e.RowIndex].DataBoundItem;
     textBox3.Text           = user.Name;
     textBox4.Text           = user.Account;
     textBox5.Text           = user.Password;
     textBox6.Text           = user.Department;
     textBox7.Text           = user.Email;
     textBox8.Text           = user.Telephone;
     numericUpDown2.Value    = user.AreaNum;
     comboBox2.SelectedIndex = user.Authority == "normal" ? 0 : 1;
     label14.Text            = user.ID.ToString();
 }
        public bool CheckUserInfo(string account, string pwd, out string returnMessage)
        {
            UserInfoDal   userInfoDal = new UserInfoDal();
            UFSM_UserInfo user        = userInfoDal.CheckUserInfo(account, pwd, out returnMessage);

            if (user != null)
            {
                StaticObject.user = user;
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemplo n.º 5
0
 public bool AddUserInfo(UFSM_UserInfo user)
 {
     using (xs373431671Entities db = new xs373431671Entities())
     {
         try
         {
             db.UFSM_UserInfo.Add(user);
             db.SaveChanges();
             return(true);
         }
         catch
         {
             return(false);
         }
     }
 }
Exemplo n.º 6
0
        /// <summary>
        /// 修改用户信息
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button2_Click(object sender, EventArgs e)
        {
            try
            {
                user            = new UFSM_UserInfo();
                user.Name       = textBox3.Text;
                user.Account    = textBox4.Text;
                user.Password   = textBox5.Text;
                user.Department = textBox6.Text;
                user.Email      = textBox7.Text;
                user.Telephone  = textBox8.Text;
                user.Authority  = comboBox2.SelectedIndex == 0 ? "normal" : "admin";
                if (user.Authority == "admin")
                {
                    user.AreaNum = 0;
                }
                else
                {
                    user.AreaNum = (int)numericUpDown2.Value;
                }
                user.ID = Convert.ToInt32(label14.Text.Trim());

                DialogResult result = MessageBox.Show("确定要进行修改吗?", "敏感操作提示", MessageBoxButtons.YesNo);
                if (result == DialogResult.Yes)
                {
                    if (new UserInfoService().ChangeUserInfo(user))
                    {
                        UpdateDGV();
                        MessageBox.Show("修改成功");
                    }
                    else
                    {
                        MessageBox.Show("修改失败!");
                    }
                }
                else
                {
                    return;
                }
            }
            catch
            {
                MessageBox.Show("执行异常,请稍后再试!");
            }
        }
Exemplo n.º 7
0
 public bool DeleteUserInfo(UFSM_UserInfo user)
 {
     using (xs373431671Entities db = new xs373431671Entities())
     {
         try
         {
             UFSM_UserInfo u = new UFSM_UserInfo()
             {
                 ID = user.ID
             };
             db.Entry <UFSM_UserInfo>(u).State = System.Data.Entity.EntityState.Deleted;
             db.SaveChanges();
             return(true);
         }
         catch
         {
             return(false);
         }
     }
 }
 public bool DeleteUserInfo(UFSM_UserInfo user)
 {
     return(new UserInfoDal().DeleteUserInfo(user));
 }
 public bool ChangeUserInfo(UFSM_UserInfo user)
 {
     return(new UserInfoDal().ChangeUserInfo(user));
 }
 public bool AddUserInfo(UFSM_UserInfo user)
 {
     return(new UserInfoDal().AddUserInfo(user));
 }