Exemple #1
0
        public void ProcessRequest(HttpContext context)
        {
            page  = (context.Request["page"] == null) ? 1 : int.Parse(context.Request["page"].ToString());
            rows  = (context.Request["rows"] == null) ? 20 : int.Parse(context.Request["rows"].ToString());
            sort  = (context.Request["sort"] == null) ? "processnumber desc" : context.Request["sort"].ToString();
            order = (context.Request["order"] == null) ? "desc" : context.Request["order"].ToString();
            string strUser = ((FormsIdentity)context.User.Identity).Ticket.UserData;

            user = JsonConvert.DeserializeObject <TBL_USER>(strUser);
            string action = context.Request["action"];

            switch (action)
            {
            //获取列表
            case "getPageList": getPageList(context); break;

            //获取列表
            case "getList": getList(context); break;

            //删除
            case "delete": delete(context); break;

            //个数
            case "getCount": GetCount(context); break;

            //出入库操作
            case "GetInoroutStock":  GetInoroutStock(context); break;
            }
        }
Exemple #2
0
        private void getLoginUser(HttpContext context)
        {
            string json = "";


            try
            {
                string   strUser = ((FormsIdentity)context.User.Identity).Ticket.UserData;
                TBL_USER user    = JsonConvert.DeserializeObject <TBL_USER>(strUser);

                List <TBL_USER> userList = userBLL.GetList(" and a.userid='" + user.userid + "'  ").ToList <TBL_USER>();
                if (userList.Count > 0)
                {
                    user = userList[0];
                    json = "{IsSuccess:'true',Message:'" + JsonConvert.SerializeObject(user) + "'}";
                }
                else
                {
                    json = "{IsSuccess:'false',Message:'无此用户!'}";
                }
            }
            catch (Exception ex)
            {
                logger.Error(ex.Message);
                json = "{IsSuccess:'false',Message:'操作失败!'}";
            }

            json = JsonConvert.SerializeObject(json);
            context.Response.ContentType = "application/json";
            //返回JSON结果
            context.Response.Write(json);
            context.Response.End();
        }
 public ActionResult editUser(HttpPostedFile filename, TBL_USER model)
 {
     if (ModelState.IsValid)
     {
         try {
             var OldModel = db.TBL_USER.Where(X => X.USER_ID == model.USER_ID).FirstOrDefault();
             OldModel.NAME    = model.NAME;
             OldModel.ADDRESS = model.ADDRESS;
             OldModel.GENDER  = model.GENDER;
             OldModel.DOB     = model.DOB;
             OldModel.CONTACT = model.CONTACT;
             OldModel.IMAGE   = model.IMAGE;
             if (filename != null)
             {
                 string pic  = System.IO.Path.GetExtension(filename.FileName);
                 string name = Guid.NewGuid().ToString() + pic;
                 string path = System.IO.Path.Combine(
                     Server.MapPath("~/Contents/upload/Doctor"), name);
                 // file is uploaded
                 filename.SaveAs(path);
                 OldModel.IMAGE = name;
             }
             db.SaveChanges();
             return(Json(new { title = "Success", successMessage = "Successfully Updated !" }));
         }
         catch (Exception ex)
         {
             return(Json(new { title = "Error", errorMessage = ex.ToString() }));
         }
     }
     else
     {
         return(PartialView(model));
     }
 }
        public ActionResult Verify()
        {
            var      id = Session["id"].ToString();
            TBL_USER tu = new TBL_USER();

            return(View(tu));
        }
 /// <summary>
 /// 修改TBL_USER表的数据
 /// </summary>
 /// <param name="whereLambda"> (u=>u.userId == info.userId, info) == true </param>
 /// 判断有无userId
 /// <param name="info"> info是需要修改的信息 </param>
 /// <notice>权限信息的修改需要判断用户身份</notice>
 /// <notice>修改密码用专门的方法来修改,这里只管资料</notice>
 public static Boolean UpdateUserInfo(Expression <Func <TBL_USER, bool> > whereLambda, TBL_USER info)
 {
     try
     {
         using (LampNetEntities db = new LampNetEntities())
         {
             DbQuery <TBL_USER> dataObject = db.TBL_USER.Where(whereLambda) as DbQuery <TBL_USER>;
             TBL_USER           oldInfo    = dataObject.FirstOrDefault();
             oldInfo.userName     = info.userName;
             oldInfo.userSex      = info.userSex;
             oldInfo.userPhone    = info.userPhone;
             oldInfo.userWechat   = info.userWechat;
             oldInfo.userStatus   = info.userStatus;
             oldInfo.userLlogtime = info.userLlogtime;
             oldInfo.userExptime  = info.userExptime;
             oldInfo.userAut      = info.userAut;
             oldInfo.userNote     = info.userNote;
             db.SaveChanges();
             return(true);
         }
     }
     catch
     {
         return(false);
     }
 }
        public ActionResult addUser(TBL_USER model)
        {
            if (ModelState.IsValid)
            {
                //var result = db.TBL_DISEASE.Create(model)
                model.USER_ID  = db.TBL_USER.Add(model).USER_ID;
                model.PASSWORD = com.EncodePass(model.PASSWORD, "shpud");
                db.SaveChanges();


                if (model.USER_ID > 0)
                {
                    return(Json(new { successMessage = "Successfully Registered!" }));
                }
                else
                {
                    Response.StatusCode = (int)HttpStatusCode.SeeOther;
                    return(Json(new { errorMessage = "Something went wrong!" }));
                }
            }
            else
            {
                return(PartialView(model));
            }
        }
        public IHttpActionResult Put(int id, TBL_USER tBL_USER)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != tBL_USER.ID)
            {
                return(BadRequest());
            }

            db.Entry(tBL_USER).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!Exists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Exemple #8
0
        public string Login(TBL_USER user)
        {
            try
            {
                //从数据库中查找数据
                TBL_USER[] users_array = Areas.ToolsHelper.SelectTools.SelectUserInfo(u => u.userId == user.userId, u => u.userId);
                //string MD5Pwd = Areas.MD5Helper.MD5Helper.encrypt(user.userPwd.Trim());
                if (users_array == null)
                {
                    Response.Write("<script>alert('用户名错误!');</script>");
                    Response.Redirect(Url.Action("Index", "Login", new { area = "" }));
                }
                //取密码
                string Pwd = users_array[0].userPwd.ToString();
                if (Pwd != null && Pwd == users_array[0].userPwd)
                {
                    HttpCookie cookieName = new HttpCookie("userId");
                    cookieName.Value   = users_array[0].userName;
                    cookieName.Expires = DateTime.Now.AddHours(1);

                    System.Web.HttpContext.Current.Response.Cookies.Add(Areas.CookiesHelper.CookiesHelper.creatCookieHours("userId", users_array[0].ToString(), 1));
                    System.Web.HttpContext.Current.Response.Cookies.Add(cookieName);
                    Response.Redirect(Url.Action("Index", "MainIndex", new { area = "" }));
                    return("登录成功");
                }
                else
                {
                    return("密码错误");
                }
            }
            catch (Exception ex)
            {
                return(ex.ToString());
            }
        }
Exemple #9
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            conn.Open();
            SqlCommand command   = new SqlCommand("SELECT USER_USERNAME FROM TBL_USERS WHERE USER_USERNAME LIKE'" + txtUsername.Text + "'", conn);
            string     get_uname = Convert.ToString(command.ExecuteScalar());

            conn.Close();
            if (txtLastname.Text == "" || txtFirstname.Text == "" || txtMiddlename.Text == "" || txtUsername.Text == "" || txtPassword.Text == "" || txtContactNo.Text == "" || PB_image.ImageLocation == null)
            {
                MessageBox.Show("Information Required! Please fill out the necessary fields", "Ooops !", MessageBoxButtons.OK, MessageBoxIcon.Hand);
            }
            else if (txtUsername.Text == get_uname)
            {
                MessageBox.Show("Username exist already", "Ooops !", MessageBoxButtons.OK, MessageBoxIcon.Hand);
            }
            else
            {
                Control_variables.type = "Administrator";
                TBL_USER u       = new TBL_USER();
                string   dateNow = DateTime.Now.ToShortDateString();
                u.USER_IMAGE = Control_variables.img;
                Image im = Image.FromFile(Control_variables.img);
                u.USER_IMAGE = Photo.byteArrayToBase64String(Photo.imageToByteArray(im));
                db.SP_USERSAVE(txtLastname.Text, txtFirstname.Text, txtMiddlename.Text, txtUsername.Text, txtPassword.Text, txtContactNo.Text, Control_variables.type, int.Parse(cmbutype.SelectedValue.ToString()), Control_variables.img);
                MessageBox.Show("Successfully Saved!", "", MessageBoxButtons.OK, MessageBoxIcon.Information);
                ClearAll();
            }
        }
 private void btnSave_Click(object sender, EventArgs e)
 {
     if (!Invalid())
     {
         try
         {
             using (TBL_USER_DATA_ACCESS uda = new TBL_USER_DATA_ACCESS())
             {
                 TBL_USER user = new TBL_USER();
                 user.USERNAME  = txtUsername.Text.Trim();
                 user.PASSWORD  = uda.Encrypt(txtPassword.Text.Trim(), true);
                 user.IS_ACTIVE = true;
                 uda.SaveUser(user);
                 this.Close();
             }
         }
         catch (Exception ex)
         {
             MessageBox.Show(ex.ToString(), "Error", MessageBoxButtons.OKCancel, MessageBoxIcon.Error);
         }
     }
     else
     {
     }
 }
 private void btnDelete_Click(object sender, EventArgs e)
 {
     USER_ID = 0;
     try
     {
         foreach (DataGridViewRow row in dataGridViewUser.SelectedRows)
         {
             USER_ID = Convert.ToInt32(row.Cells[0].Value);
         }
         //MessageBox.Show(SEASON_ID.ToString());
         if (USER_ID != 0)
         {
             using (LicenseDataContext _context = new LicenseDataContext())
             {
                 TBL_USER user = (from u in _context.TBL_USERs
                                  where u.USER_ID == USER_ID
                                  select u).FirstOrDefault();
                 user.IS_ACTIVE = false;
                 _context.SubmitChanges();
             };
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString(), "Error", MessageBoxButtons.OKCancel, MessageBoxIcon.Error);
     }
     finally
     {
         using (TBL_USER_DATA_ACCESS uda = new TBL_USER_DATA_ACCESS())
         {
             dataGridViewUser.DataSource = uda.ShowUserAllIncludeInActive();
         }
         GC.Collect();
     }
 }
Exemple #12
0
 private void btnSave_Click(object sender, EventArgs e)
 {
     if (!Invalid())
     {
         try
         {
             using (TBL_USER_DATA_ACCESS uda = new TBL_USER_DATA_ACCESS())
             {
                 using (_contex = new LicenseDataContext())
                 {
                     TBL_USER user = (from u in _contex.TBL_USERs
                                      where u.USER_ID == ControlUser.USER_ID
                                      select u).FirstOrDefault();
                     user.PASSWORD = user_data.Encrypt(txtPwdNew.Text.Trim(), true);
                     _contex.SubmitChanges();
                 }
             }
             this.Close();
         }
         catch (Exception ex)
         {
             MessageBox.Show(ex.ToString(), "Error", MessageBoxButtons.OKCancel, MessageBoxIcon.Error);
         }
     }
     else
     {
     }
 }
Exemple #13
0
        private void updatepaw(HttpContext context)
        {
            string   userid   = context.Request["userid"];
            string   password = context.Request["password"];
            string   json     = "";
            TBL_USER user     = new TBL_USER();

            user.userid   = userid;
            user.password = FormsAuthentication.HashPasswordForStoringInConfigFile(password, "MD5");

            try
            {
                if (userBLL.UpdatePwd(user))
                {
                    json = "{IsSuccess:'false',Message:'操作成功!'}";
                }
                else
                {
                    json = "{IsSuccess:'false',Message:'操作失败!'}";
                }
            }
            catch (Exception ex)
            {
                logger.Error(ex.Message);
                json = "{IsSuccess:'false',Message:'操作失败!'}";
                //json = JsonConvert.SerializeObject("{IsSuccess:'false',Message:'保存失败!'}");
            }
            json = JsonConvert.SerializeObject(json);
            context.Response.ContentType = "application/json";
            //返回JSON结果
            context.Response.Write(json);
            context.Response.End();
        }
Exemple #14
0
        public bool RemoveUser(long userID)
        {
            return(m_Locker.Synchronized(userID, () =>
            {
                var deleted = TBL_USER.Remove(userID);
                if (!deleted)
                {
                    return false;
                }

                var posts = TBL_USERPOST.Get(userID) as List <long>;
                if (posts == null)
                {
                    return true;
                }
                TBL_USERPOST.Remove(userID); //todo  Rewrite with table.RemoveReturning()

                foreach (var postID in posts)
                {
                    TBL_POST.Remove(postID);
                }

                return true;
            }));
        }
        public IHttpActionResult Post(TBL_USER tBL_USER)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.TBL_USER.Add(tBL_USER);

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateException)
            {
                if (Exists(tBL_USER.ID))
                {
                    return(Conflict());
                }
                else
                {
                    throw;
                }
            }

            return(CreatedAtRoute("DefaultApi", new { id = tBL_USER.ID }, tBL_USER));
        }
Exemple #16
0
        /// <summary>
        /// 获取当前登陆人的部门id
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        public static string getOrgId(HttpContext context)
        {
            string   strUser = ((FormsIdentity)context.User.Identity).Ticket.UserData;
            TBL_USER user    = JsonConvert.DeserializeObject <TBL_USER>(strUser); //获取当前用户信息

            return(user.organizationid);
        }
Exemple #17
0
        //获取图标需要的数据
        private void getContainer(HttpContext context)
        {
            string json = "";

            //1.获取当前登录用户数据
            string   strUser = ((FormsIdentity)context.User.Identity).Ticket.UserData;
            TBL_USER user    = JsonConvert.DeserializeObject <TBL_USER>(strUser);
            //2.获取则线图时间
            string Data = context.Request["Date"].ToString() == "" ? DateTime.Now.ToString("yyyy-MM") : context.Request["Date"].ToString();
            //string Data = "2016-12";
            //出入账sql语句.
            string sql  = "select SUM(amount) amount,CONVERT(varchar(10),appeardate,120) appeardate from tbl_capitalaccount_flowrecord  where flowrecordtype='入账' and organizationid='" + user.organizationid + "' and CONVERT(varchar(7),appeardate,120)='" + Data + "'  group by CONVERT(varchar(10),appeardate,120) ORDER BY appeardate";
            string sql1 = " select SUM(amount) amount,CONVERT(varchar(10),appeardate,120) appeardate from tbl_capitalaccount_flowrecord  where flowrecordtype='出账' and organizationid='" + user.organizationid + "' and CONVERT(varchar(7),appeardate,120)='" + Data + "' group by CONVERT(varchar(10),appeardate,120) ORDER BY appeardate";
            IList <MODEL.Capital.TBL_CAPITALACCOUNT_FLOWRECORD> flowList  = flowBll.GetListByOrgan(sql);
            IList <MODEL.Capital.TBL_CAPITALACCOUNT_FLOWRECORD> flowList1 = flowBll.GetListByOrgan(sql1);
            Dictionary <string, object> obj = new Dictionary <string, object>();
            int days = DateTime.DaysInMonth(DateTime.Now.Year, DateTime.Now.Month);

            obj.Add("total", days);
            obj.Add("rows", flowList);
            obj.Add("total1", days);
            obj.Add("rows1", flowList1);
            json = JsonConvert.SerializeObject(obj);
            context.Response.ContentType = "application/json";
            context.Response.Write(json);
            context.ApplicationInstance.CompleteRequest();
        }
Exemple #18
0
        private void getCount(HttpContext context)
        {
            //1. 获取前端参数
            string flowrecordtype = context.Request["flowrecordtype"].ToString();
            string source         = context.Request["source"].ToString();
            string organization   = "";

            if (context.Request["Oneself"].ToString() == "1")
            {
                string   strUser = ((FormsIdentity)context.User.Identity).Ticket.UserData;
                TBL_USER user    = JsonConvert.DeserializeObject <TBL_USER>(strUser);
                organization = user.organizationid;
            }
            else
            {
                organization = context.Request["Organization"].ToString();
            }

            string appeardate = context.Request["StartTime"].ToString();
            string endDate    = context.Request["EndTime"].ToString();
            string sql        = "";
            string json       = "";

            if (!string.IsNullOrEmpty(flowrecordtype) && flowrecordtype != "全部")
            {
                sql += " and  flowrecordtype='" + flowrecordtype + "'";
            }
            if (!string.IsNullOrEmpty(source) && source != "全部")
            {
                sql += " and  source='" + source + "'";
            }
            if (!string.IsNullOrEmpty(organization) && organization != "全部")
            {
                organization = CFunctions.getChildByParentId(organization);
                sql         += " and organizationid in(" + organization + ")";
            }
            if (!string.IsNullOrEmpty(appeardate))
            {
                sql += " and  Convert(varchar(10),appeardate,120)>='" + Convert.ToDateTime(appeardate) + "'";
            }
            if (!string.IsNullOrEmpty(endDate))
            {
                sql += " and  Convert(varchar(10),appeardate,120)<='" + Convert.ToDateTime(endDate) + "'";
            }
            try
            {
                int count = flowBll.GetCount(sql);
                json = "{\"IsSuccess\":\"true\",\"Count\":" + count + "}";
            }
            catch
            {
                json = "{\"IsSuccess\":\"false\",\"Count\":0}";
            }

            context.Response.ContentType = "application/json";
            //返回JSON结果
            context.Response.Write(json);
            context.Response.End();
        }
Exemple #19
0
 public void SaveUser(TBL_USER user)
 {
     using (_context = new LicenseDataContext())
     {
         _context.TBL_USERs.InsertOnSubmit(user);
         _context.SubmitChanges();
     }
 }
Exemple #20
0
        //获取登录人的经办
        public static string getMyHandledTask(HttpContext context)
        {
            TBL_USER user = getUser(context);
            List <WorkFlow.Model.FLOW_TASK> taskList = WorkFlow.BLL.Operate.getMyHandledTask(user.userid, "", "", "");
            List <WorkFlow.Model.FLOW_TASK> fiveList = (from p in taskList select p).Take(4).ToList();
            string json = JsonConvert.SerializeObject(fiveList);

            return(json);
        }
Exemple #21
0
        public ActionResult UserSelect(TBL_USER user)
        {
            try
            {
                if (user.userId != 0)
                {
                    int        sumPage = GetSumPage(30);
                    int        nowPage = 1;
                    TBL_USER[] allInfo = GetPagedList(1, 30, u => u.userId == u.userId, u => u.userId);
                    ViewBag.nowPage = nowPage;
                    ViewBag.sumPage = sumPage;
                    TBL_USER[] info = SelectTools.SelectUserInfo(u => u.userId == user.userId, u => u.userId);
                    if (info == null || info.Length == 0)
                    {
                        return(Content("没有此展示!"));
                    }
                    ViewBag.allInfo = allInfo;
                    ViewBag.info    = info;

                    HttpCookie cookie = Request.Cookies["userId"];
                    if (cookie.Name != null)
                    {
                        ViewBag.user = cookie.Value;
                    }

                    return(View());
                }
                else
                {
                    int        sumPage = GetSumPage(30);
                    int        nowPage = 1;
                    TBL_USER[] allInfo = GetPagedList(1, 30, u => u.userId == u.userId, u => u.userId);
                    ViewBag.nowPage = nowPage;
                    ViewBag.sumPage = sumPage;
                    TBL_USER[] info = SelectTools.SelectUserInfo(u => u.userName == user.userName, u => u.userId);
                    if (info == null || info.Length == 0)
                    {
                        return(Content("没有此展示!"));
                    }
                    ViewBag.allInfo = allInfo;
                    ViewBag.info    = info;

                    HttpCookie cookie = Request.Cookies["userId"];
                    if (cookie.Name != null)
                    {
                        ViewBag.user = cookie.Value;
                    }

                    return(View());
                }
            }
            catch
            {
                return(Content("查询失败!(ERROR)"));
            }
        }
Exemple #22
0
        private void getList(HttpContext context)
        {
            //1. 获取前端参数
            string flowrecordtype = context.Request["flowrecordtype"].ToString();
            string source         = context.Request["source"].ToString();
            string organization   = "";

            if (context.Request["Oneself"].ToString() == "1")
            {
                string   strUser = ((FormsIdentity)context.User.Identity).Ticket.UserData;
                TBL_USER user    = JsonConvert.DeserializeObject <TBL_USER>(strUser);
                organization = user.organizationid;
            }
            else
            {
                organization = context.Request["Organization"].ToString();
            }
            string appeardate = context.Request["StartTime"].ToString();
            string endDate    = context.Request["EndTime"].ToString();
            string json       = "";

            string sql = " select A.flowrecordid,A.organizationid,A.capitalaccountid,A.flowrecordtype,A.amount,convert(varchar(11),A.appeardate,120) appeardate,A.processnumber,A.source,B.organizationname from tbl_capitalaccount_flowrecord A inner join  TBL_ORGANIZATION B ON(A.organizationid=B.organizationid)";

            if (!string.IsNullOrEmpty(flowrecordtype) && flowrecordtype != "全部")
            {
                sql += " and  flowrecordtype='" + flowrecordtype + "'";
            }
            if (!string.IsNullOrEmpty(source) && source != "全部")
            {
                sql += " and  source='" + source + "'";
            }
            if (!string.IsNullOrEmpty(organization) && organization != "全部")
            {
                organization = CFunctions.getChildByParentId(organization);
                sql         += " and A.organizationid in(" + organization + ")";
            }
            if (!string.IsNullOrEmpty(appeardate))
            {
                sql += " and  Convert(varchar(10),A.appeardate,120)>='" + Convert.ToDateTime(appeardate) + "'";
            }
            if (!string.IsNullOrEmpty(endDate))
            {
                sql += " and  Convert(varchar(10),A.appeardate,120)<='" + Convert.ToDateTime(endDate) + "'";
            }
            int count   = 0;
            int tocount = 0;
            IList <MODEL.Capital.TBL_CAPITALACCOUNT_FLOWRECORD> obj = flowBll.GetPageList(sql, sort + " " + order, page, rows, out count, out tocount);

            if (obj.Count > 0)
            {
                json = JsonConvert.SerializeObject(obj);
            }
            context.Response.ContentType = "application/json";
            context.Response.Write(json);
            context.ApplicationInstance.CompleteRequest();
        }
Exemple #23
0
        private void getUser(HttpContext context)
        {
            string   strUser = ((FormsIdentity)context.User.Identity).Ticket.UserData;
            TBL_USER user    = JsonConvert.DeserializeObject <TBL_USER>(strUser);
            string   json    = JsonConvert.SerializeObject(user);

            context.Response.ContentType = "application/json";
            context.Response.Write(json);
            context.ApplicationInstance.CompleteRequest();
        }
        public IHttpActionResult Get(int id)
        {
            TBL_USER tBL_USER = db.TBL_USER.Find(id);

            if (tBL_USER == null)
            {
                return(NotFound());
            }

            return(Ok(tBL_USER));
        }
Exemple #25
0
        public HttpResponseMessage Post(int id, [FromBody] TBL_USER value)
        {
            if (id == 0)
            {
                db.TBL_USER.Add(value);
            }
            else
            {
                db.Entry(value).State = EntityState.Modified;
            }

            return(ToJson(db.SaveChanges()));
        }
        public IHttpActionResult Delete(int id)
        {
            TBL_USER tBL_USER = db.TBL_USER.Find(id);

            if (tBL_USER == null)
            {
                return(NotFound());
            }

            db.TBL_USER.Remove(tBL_USER);
            db.SaveChanges();

            return(Ok(tBL_USER));
        }
Exemple #27
0
        public List <TBL_USER> Search(TBL_USER e, DateTime?startDatetime = null, DateTime?finishDatetime = null, int?userGroupId = 0)
        {
            userGroupId    = userGroupId ?? 0;
            finishDatetime = finishDatetime == null ? (DateTime?)null : finishDatetime.Value.AddHours(23).AddMinutes(59).AddSeconds(59);

            var q = _dal.Get(k => k.STATUS &&
                             (string.IsNullOrEmpty(e.NAME) || (k.NAME == null || k.NAME.ToUpper().Contains(e.NAME.ToUpper()))) &&
                             (string.IsNullOrEmpty(e.SURNAME) || (k.SURNAME == null || k.SURNAME.ToUpper().Contains(e.SURNAME.ToUpper()))) &&
                             (string.IsNullOrEmpty(e.USERNAME) || (k.USERNAME == null || k.USERNAME.ToUpper().Contains(e.USERNAME.ToUpper()))) &&
                             (string.IsNullOrEmpty(e.EMAIL) || (k.EMAIL == null || k.EMAIL.ToUpper().Contains(e.EMAIL.ToUpper()))) &&
                             (userGroupId == 0 || k.TBL_USER_PERMISSION.Any(a => a.USERGROUP_ID == userGroupId))
                             ).OrderBy(o => o.NAME).ThenBy(t => t.SURNAME).ToList();

            return(q);
        }
        public async Task <TBL_USER> Register(TBL_USER user, string password)
        {
            byte[] passwordHash, passwordSalt;
            CreatePasswordhash(password, out passwordHash, out passwordSalt);
            //out passes a ref of passwordHash

            user.A_PASSWORD_HASH = passwordHash;
            user.A_PASSWORD_SALT = passwordSalt;

            await _context.TBL_USER.AddAsync(user);

            await _context.SaveChangesAsync();

            return(user);
        }
Exemple #29
0
        public ActionResult Login(TBL_USER model)
        {
            try
            {
                var user = db.TBL_USER.Where(x => x.EMAIL == model.EMAIL).FirstOrDefault();
                if (user != null)
                {
                    var enpas    = com.EncodePass(model.PASSWORD, "shpud");
                    var userpass = db.TBL_USER.Where(x => x.PASSWORD == enpas && x.EMAIL == model.EMAIL).FirstOrDefault();
                    if (userpass != null)
                    {
                        if (user.STATUS == "Unverified")
                        {
                            Session["id"] = user.USER_ID;
                            return(Json(new { success = true, verified = false, error = false, successMessage = "Verification Needed" }));
                        }
                        else
                        {
                            int userid = user.USER_ID;
                            Session["userid"]   = userid;
                            Session["fullname"] = user.NAME;
                            Session["email"]    = user.EMAIL;
                            Session["role"]     = user.ROLE;

                            string[] name = Session["fullname"].ToString().Split(' ');
                            Session["firstname"] = name[0];
                            return(Json(new { success = true, verified = true, error = false, successMessage = "Logged in Successfully", role = Session["role"].ToString() }));
                        }
                        //return RedirectToAction("Dashboard", "Admin", new {userid=user });
                    }
                    else
                    {
                        //Response.StatusCode = (int)HttpStatusCode.SeeOther;
                        return(Json(new { success = false, error = true, title = "Password Incorrect", errorMessage = "Please recheck your password and try again! " }));
                    }
                }
                else
                {
                    //Response.StatusCode = (int)HttpStatusCode.SeeOther;
                    return(Json(new { success = false, error = true, title = "Incorrect Email", errorMessage = "No user found with this email.\n Please rechek your email Address!" }));
                }
            }
            catch (Exception ex)
            {
                Response.StatusCode = (int)HttpStatusCode.SeeOther;
                return(Json(new { success = false, error = true, title = "Server Error", errorMessage = ex.ToString() }));
            }
        }
Exemple #30
0
        private void btnUpdatepass_Click(object sender, EventArgs e)
        {
            DataClasses1DataContext db = new DataClasses1DataContext();
            int count = 0;

            if (txtOldpass.Text == "" || txtNewpass.Text == "" || txtRetypepass.Text == "")
            {
                MessageBox.Show("Please input data", "Ooops !", MessageBoxButtons.OK, MessageBoxIcon.Hand);
            }
            else
            {
                var scan = db.SP_VERIFYPASSWORD(txtUserID.Text, txtOldpass.Text);
                db.SubmitChanges();

                foreach (SP_VERIFYPASSWORDResult user in scan)
                {
                    count++;
                    if (txtNewpass.Text.Length >= 8)
                    {
                        if (txtNewpass.Text == txtRetypepass.Text)
                        {
                            user.USER_PASSWORD = txtNewpass.Text;
                            db.SP_CHANGEPASSWORD(Control_variables.current_id, user.USER_PASSWORD);
                            TBL_USER user2 = new TBL_USER();
                            MessageBox.Show("Password Successfully Changed", "Success !", MessageBoxButtons.OK, MessageBoxIcon.Information);

                            //CLEAR TEXTBOXES
                            txtOldpass.Clear();
                            txtNewpass.Clear();
                            txtRetypepass.Clear();
                            groupChangePass.Visible = false;
                        }
                        else
                        {
                            MessageBox.Show("Password did not match", "Ooops !", MessageBoxButtons.OK, MessageBoxIcon.Hand);
                        }
                    }
                    else
                    {
                        MessageBox.Show("Password must be contain atleast 8 characters long ", "Ooops !", MessageBoxButtons.OK, MessageBoxIcon.Hand);
                    }
                }
                if (count == 0)
                {
                    MessageBox.Show("Old password Incorrect", "Ooops !", MessageBoxButtons.OK, MessageBoxIcon.Hand);
                }
            }
        }