Ejemplo n.º 1
0
 public async Task<ActionResult> Edit(EM_User_Account model)
 {
     if (userAccountRepo.IsEmailRepeat(model.LoginEmail, model.UserId))
     {
         return Json(new { code = 0, message = "邮箱已存在,请重新输入" });
     }
     var entity=userAccountRepo.GetById(model.UserId);
     model.Password = DESEncrypt.Encrypt(model.Password);
     entity = Mapper.Map<EM_User_Account, EM_User_Account>(model, entity);
     entity.CreateTime = entity.CreateTime == DateTime.MinValue ? DateTime.Now : entity.CreateTime;
     entity.ModifyTime = DateTime.Now;
    var result= userAccountRepo.SaveChanges();
    if (result > 0)
        return Json(new { code = 1 });
    else
        return Json(new { code = 0,message="保存失败,请重试" });
 }
Ejemplo n.º 2
0
        public async Task<ActionResult> Add(EM_User_Account model)
        {
            if(userAccountRepo.IsEmailRepeat(model.LoginEmail,0))
            {
                return Json(new { code = 0, message = "邮箱已存在,请重新输入" });
            }


            model.Password = DESEncrypt.Encrypt(model.Password);
            model.CreateTime = DateTime.Now;
            model.ModifyTime = DateTime.Now;
            userAccountRepo.Add(model);
            var result = userAccountRepo.SaveChanges();
            if (result > 0)
                return Json(new { code = 1 });
            else
                return Json(new { code = 0, message = "保存失败,请重试" });
        }
Ejemplo n.º 3
0
Archivo: Form1.cs Proyecto: LuoSven/EM
        private void button1_Click(object sender, EventArgs e)
        {
            var Msg = "";
            Msg = textBox1.Text == "" ? "账号为空,请重新输入" : "";
            Msg = textBox2.Text == "" ? "密码为空,请重新输入" : "";
            Msg = textBox3.Text == "" ? "手机为空,请重新输入" : "";
            Msg = textBox4.Text == "" ? "用户名为空,请重新输入" : "";

            if (Msg != "")
            {
                MessageBox.Show(Msg);
                return;
            }
            var Account = new EM_User_Account()
            {
                LoginEmail = textBox1.Text,
                Password = textBox2.Text,
                Mobile = textBox3.Text,
                UserName = textBox4.Text
            };
            var IsRepeat = userAccountrepo.IsRepeat(Account);
            if (IsRepeat.Item1)
            {
                Account.Password = DESEncrypt.Encrypt(Account.Password);
                Account.ModifyTime = DateTime.Now;
                Account.CreateTime = DateTime.Now;
                Account.Status = (int)AccountStatus.Allow;
                Account.RoleId = Convert.ToInt32(RoleId.SelectedValue);
                userAccountrepo.Add(Account);

                var result = userAccountrepo.SaveChanges();
                if (result > 0)
                    MessageBox.Show("保存成功");
                else
                    MessageBox.Show("保存失败");
            }
            else
                MessageBox.Show(IsRepeat.Item2);
        }
Ejemplo n.º 4
0
 public async Task<ActionResult> Add()
 {
     var model = new EM_User_Account();
     InitSelect(model.RoleId, model.Status);
     return View("AddOrEdit", model);
 }