Esempio n. 1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            CQGJPassportEntities cqgj = new CQGJPassportEntities();
            if (Request.QueryString["ID"] != null)
            {
                if (Request.QueryString["userID"] != null)
                {
                    int iID = int.Parse(Request.QueryString["userID"].ToString());
                    User usertemp = (from u in cqgj.User where u.UserID == iID select u).First();
                    Session["userobject"] = usertemp;
                }
                if (Request.QueryString["orgID"] != null)
                {
                    string orgID = (Request.QueryString["orgID"].ToString());
                    b01 orgtemp = (from b in cqgj.b01 where b.b0111 == orgID select b).First();
                    Session["Org"] = orgtemp;
                }
                try
                {
                    if (Session["userobject"] != null || Session["Org"] != null)
                    {
                        int iID = int.Parse(Request.QueryString["ID"].ToString());
                        User user;
                        user = new User();

                        user = (from u in cqgj.User where u.UserID == iID select u).First();
                        Response.ContentType = user.PhotoType;
                        Response.BinaryWrite((byte[])user.Photo);
                    }
                    else
                    {
                        System.Configuration.AppSettingsSection apsetting = new AppSettingsSection();
                        string str = apsetting.Settings["ssologin"].ToString();
                        Response.Redirect(str + "?url=" + System.Web.HttpUtility.UrlEncode(Request.Url.ToString()));
                    }
                }
                catch
                {
                }

            }
        }
Esempio n. 2
0
        /// <summary>
        /// 添加用户-负责数据库保存
        /// </summary>
        /// <param name="id"></param>
        public ActionResult CreateUser(string id)
        {
            CQGJUserViewData viewData = new CQGJUserViewData();
            User user = new User();
            //user.UserID = Request.Form["UserID"].ToString();
            user.Username = Request.Form["UserName"].ToString();
            user.Remark = Request.Form["AdminRemark"].ToString();
            try
            {
                user.Status = int.Parse(Request.Form["AdminStatus"].ToString());
            }
            catch { }
            user.Birthday = DateTime.Parse(Request.Form["Birthday"].ToString());
            user.Cellphone = Request.Form["Cellphone"].ToString();
            //user.COUPost = Request.Form["COUPost"].ToString();
            //user.Degree = Request.Form["Degree"].ToString();
            //user.Description = Request.Form["Description"].ToString();
            //user.Edu = Request.Form["Edu"].ToString();
            //user.Email = Request.Form["Email"].ToString();
            user.Gender = Request.Form["Gender"].ToString();
            user.IDCard = Request.Form["IDCard"].ToString();
            if (HttpContext.Session["Photo"] != null && HttpContext.Session["PhotoType"] != null)
            {
                user.PhotoType = HttpContext.Session["PhotoType"].ToString();
                user.Photo = (byte[])HttpContext.Session["Photo"];

            }
            user.Password = Security.MD5Encrypt(Request.Form["userPassword"].ToString());
            try
            {
                user.JoinWorkDate = DateTime.Parse(Request.Form["JoinWorkDate"].ToString());
            }
            catch { }
            user.Nation = Request.Form["Nation"].ToString();
            //user.OtherLink = Request.Form["OtherLink"].ToString();
            //user.Password = Request.Form["OtherLink"].ToString();
            user.Politics = Request.Form["Politics"].ToString();
            user.Position = Request.Form["Position"].ToString();

            user.WorkTel = Request.Form["WorkTel"].ToString();
            user.RelationsName = Request.Form["OrgName"].ToString();
            user.RelationsCode = Request.Form["OrgCode"].ToString();
            try
            {
                user.Class = (Request.Form["Level"].ToString());
            }
            catch { }

            CQGJ.AddToUser(user);
            CQGJ.SaveChanges(true);
            viewData.User = user;
            viewData.ActionSuccess = true;

            viewData.JavaScriptPage = "添加人员:" + user.Username;
            //调用webservers
            CQGJAP.CQGJWebServices ap = new CQGJ.Passport.CQGJAP.CQGJWebServices();
            ap.AddUser(user.UserID);

            var querry = from b in CQGJ.b01 where b.b0111 == id select b;
            b01 Org = new b01();
            try
            {
                Org = querry.First();
            }
            catch
            {
                //错误
            }
            UsersInOrgs userinorg = new UsersInOrgs();
            userinorg.User = viewData.User;
            userinorg.b0111 = Org.b0111;

            CQGJ.AddToUsersInOrgs(userinorg);
            CQGJ.SaveChanges(true);
            viewData.HtmlPage = user.Username + "添加功,请添加" + Org.b0104 + "中的职务信息";
            viewData.JavaScriptPage = "/admin/OrgUserAdd/" + user.UserID + "/" + Org.b0111;
            return View("MessagePage", viewData);
        }
Esempio n. 3
0
        public bool SavaUserChange(User user)
        {
            try
            {
                int userID = user.UserID;
                CQGJPassportEntities CQGJ = new CQGJPassportEntities();
                User localUser = (from c in CQGJ.User
                                  where c.UserID == userID
                                  select c).First();

                localUser.Username = user.Username;
                localUser.Gender = user.Gender;
                localUser.Nation = user.Nation;
                localUser.Birthday = user.Birthday;
                localUser.Politics = user.Politics;
                localUser.IDCard = user.IDCard;
                localUser.WorkTel = user.WorkTel;
                localUser.Cellphone = user.Cellphone;
                localUser.Position = user.Position;
                localUser.JoinWorkDate = user.JoinWorkDate;
                localUser.Remark = user.Remark;
                localUser.Status = user.Status;
                localUser.Class = user.Class;
                localUser.RelationsCode = user.RelationsCode;
                localUser.RelationsName = user.RelationsName;
                localUser.Photo = user.Photo;
                localUser.PhotoType = user.PhotoType;
                CQGJ.SaveChanges();
                return true;
            }
            catch
            {
                return false;
            }
        }
Esempio n. 4
0
 public User ValidateUser(string username, string password)
 {
     CQGJPassportEntities CQGJ = new CQGJPassportEntities();
     User Querry = new User();
     try
     {
         Querry = (from u in CQGJ.User where u.Username == username && u.Password == password select u).First();
     }
     catch
     {
         Querry = null;
     }
     return Querry;
 }
Esempio n. 5
0
        public List<User> GetUserListOwnRole()
        {
            CQGJPassportEntities CQGJPassport = new CQGJPassportEntities();
            List<int> usersID = (from u in CQGJPassport.UsersInRoles select (int)u.User.UserID).Distinct().ToList();
            List<User> users = new List<User>();

            foreach (int id in usersID)
            {
                User user = new User();

                user = GetCQGJUser(id);

                users.Add(user);
            }

            return users;
        }