Exemplo n.º 1
0
        public JsonResult CreateOrUpDate(NguoiDungEntities Option)
        {
            var result = new HttpResponseMessage {
                StatusCode = HttpStatusCode.OK
            };

            try
            {
                if (_nguoidungService.GetByAccount(Option.username) != null)
                {
                    Option.Date_Edited = DateTime.Now;
                    _nguoidungService.Update(Option);
                }
                else
                {
                    Option.Date_Created = DateTime.Now;
                    _nguoidungService.Create(Option);
                }
            }
            catch (Exception ex)
            {
                result.StatusCode   = HttpStatusCode.InternalServerError;
                result.ReasonPhrase = ex.Message;
            }
            return(Json(result, JsonRequestBehavior.AllowGet));
        }
        public int update(NguoiDungEntities obj)
        {
            int        result   = 0;
            string     strQuery = "update dbo.NguoiDung set pass='******' where username='******'";
            DataConfig config   = new DataConfig();

            result = config.excuteNonquery(strQuery);
            return(result);
        }
Exemplo n.º 3
0
 public String Create(NguoiDungEntities Option)
 {
     using (var scope = new TransactionScope())
     {
         Mapper.CreateMap <NguoiDungEntities, NguoiDung>();
         var o = Mapper.Map <NguoiDungEntities, NguoiDung>(Option);
         o.IsDelete     = false;
         o.Date_Created = DateTime.Now;
         _unitOfWork.NguoiDungRepository.Insert(o);
         _unitOfWork.Save();
         scope.Complete();
         return(o.username);
     }
 }
Exemplo n.º 4
0
        public bool Update(NguoiDungEntities Option)
        {
            var success = false;

            if (Option != null)
            {
                using (var scope = new TransactionScope())
                {
                    var o = _unitOfWork.NguoiDungRepository.Get(x => x.username == Option.username);
                    if (o != null)
                    {
                        Mapper.CreateMap <NguoiDungEntities, NguoiDung>();
                        o = Mapper.Map <NguoiDungEntities, NguoiDung>(Option);
                    }
                    _unitOfWork.NguoiDungRepository.Update(o);
                    _unitOfWork.Save();
                    scope.Complete();
                }
            }
            return(success);
        }
Exemplo n.º 5
0
        private void btXacNhan_Click(object sender, EventArgs e)
        {
            NguoiDungBLL      nguoidungbll  = new NguoiDungBLL();
            string            username      = tbTenDangNhap.Text.Trim();
            string            pass          = tbMatKhauCu.Text.Trim();
            string            passnew       = tbMatKhauMoi.Text.Trim();
            string            xacnhanpass   = bXacNhanMK.Text.Trim();
            NguoiDungEntities nguoidungenti = new NguoiDungEntities();

            nguoidungenti.Username = tbTenDangNhap.Text.Trim();
            nguoidungenti.Pass     = tbMatKhauCu.Text.Trim();
            nguoidungenti.Pass     = tbMatKhauMoi.Text.Trim();
            nguoidungenti.Pass     = bXacNhanMK.Text.Trim();
            if (nguoidungbll.DangNhap(username, pass))
            {
                nguoidungbll.update(nguoidungenti);
                MessageBox.Show("thay doi thanh cong", "thong bao", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            else
            {
                MessageBox.Show("thay doi that bai", "thong bao", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }