示例#1
0
        public ActionResult Login(SMS_User model)
        {
            int    UserId   = model.UserId == null ? 0 : model.UserId;
            string Password = model.Password == null ? "" : model.Password;

            var UserInfo = dbSms.SMS_User.Where(x => x.UserId == UserId && x.Password == Password).ToList();

            if (UserInfo.Count != 0)
            {
                Session["UserInfo"] = UserInfo.First();
                Session["UserName"] = UserInfo.First().FirstName + " " + UserInfo.First().LastName;
                Session["Picture"]  = UserInfo.First().Picture == "" ? "../Images/defaultImg.png" : UserInfo.First().Picture;
            }
            else
            {
                Session["UserInfo"] = null;
                Session["UserName"] = null;
                Session["Picture"]  = null;
            }
            return(RedirectToAction("Index"));

            //ObjUser.UserId = model.UserId == null ? 0 : model.UserId;
            //ObjUser.Password = model.Password == null ? "" : model.Password;
            //DataSet dsUserInfo = ObjUser.CRUD_User(ObjUser);

            //if (dsUserInfo.Tables != null && dsUserInfo.Tables[0].Rows.Count > 0)
            //{
            //    Sms_User UserInfoList = (Sms_User)ObjUser.GetUserList(dsUserInfo.Tables[0]);
            //    Session["UserInfo"] = UserInfoList;
            //    Session["UserName"] = UserInfoList.FirstName + " " + UserInfoList.LastName;
            //    Session["Picture"] = UserInfoList.Picture == "" ? "../Images/defaultImg.png" : UserInfoList.Picture;
            //}
            //else
            //{
            //    Session["UserInfo"] = null;
            //    Session["UserName"] = null;
            //    Session["Picture"] = null;
            //}
        }
示例#2
0
        // Get Tree Menu
        public JsonResult GetTreeMenu()
        {
            objUser = (SMS_User)Session["UserInfo"];
            object List = new object();


            var _ParentList = dbSms.SMS_Menu.ToList();

            if (objUser != null && objUser.SMS_Group.Type == 1)
            {
                //var _ParentList = dbSms.SMS_Menu.ToList();
                List = _ParentList
                       .Where(c => c.ChildId == 0)
                       .Select(c => new SMS_Menu()
                {
                    MenuId      = c.MenuId,
                    ParentId    = c.ParentId,
                    ChildId     = c.ChildId,
                    MenuName    = c.MenuName,
                    Icon        = c.Icon,
                    Action      = c.Action,
                    Status      = c.Status,
                    CreatedBy   = c.CreatedBy,
                    CreatedDate = c.CreatedDate,
                    UpdatedBy   = c.UpdatedBy,
                    UpdatedDate = c.UpdatedDate,
                    MenuList    = GetChildren(_ParentList, c.ParentId)
                })
                       .ToList();
            }
            else
            {
                List <SMS_Menu> menu = new List <SMS_Menu>();
                var             LIST = from m in dbSms.SMS_Menu
                                       from d in dbSms.SMS_UserRole.Where(x => x.Status == true && x.GroupId == objUser.GroupId && x.MenuId == m.MenuId)
                                       select new { m };

                foreach (var item in LIST)
                {
                    menu.Add(new SMS_Menu()
                    {
                        MenuId      = item.m.MenuId,
                        ParentId    = item.m.ParentId,
                        ChildId     = item.m.ChildId,
                        Action      = item.m.Action,
                        Status      = item.m.Status,
                        MenuName    = item.m.MenuName,
                        Icon        = item.m.Icon,
                        CreatedBy   = item.m.CreatedBy,
                        CreatedDate = item.m.CreatedDate,
                        UpdatedBy   = item.m.UpdatedBy,
                        UpdatedDate = item.m.UpdatedDate
                    });
                }

                _ParentList = menu;
                List        = _ParentList
                              .Where(c => c.ChildId == 0)
                              .Select(c => new SMS_Menu()
                {
                    MenuId      = c.MenuId,
                    ParentId    = c.ParentId,
                    ChildId     = c.ChildId,
                    MenuName    = c.MenuName,
                    Icon        = c.Icon,
                    Action      = c.Action,
                    Status      = c.Status,
                    CreatedBy   = c.CreatedBy,
                    CreatedDate = c.CreatedDate,
                    UpdatedBy   = c.UpdatedBy,
                    UpdatedDate = c.UpdatedDate,
                    MenuList    = GetChildren(_ParentList, c.ParentId)
                })
                              .ToList();
            }
            return(Json(List));
        }
    private string add_user()
    {
        db = new SMSDataClassesDataContext();
        SMS_User u = new SMS_User();
        u.admin = txtUsername.Text;
        u.password = config.encrypt(txtPassword.Text);
        u.email = txtEmail.Text;
        u.role = ddlRole.SelectedValue;
        u.date_added = config.current_DateTime();
        u.added_by = Session["user"].ToString();

        try
        {
            db.SMS_Users.InsertOnSubmit(u);
            db.SubmitChanges();
            config.send_email("User Account",
                    config.email_UsernameAndPassword("User Account", txtUsername.Text, txtPassword.Text),
                    txtEmail.Text);
            return txtUsername .Text + " was successfully added!";
        }
        catch (Exception ex)
        { }
        return txtUsername.Text + " wasn't successfully added!";
    }
 partial void DeleteSMS_User(SMS_User instance);
 partial void UpdateSMS_User(SMS_User instance);
 partial void InsertSMS_User(SMS_User instance);