/// <summary>
        /// 个人信息
        /// </summary>
        /// <returns></returns>
        public ActionResult AddPerIntroduce()
        {
            string jsonTxt = "";

            try
            {
                string datasize            = Request["perInfoJson"];
                JavaScriptSerializer jss   = new JavaScriptSerializer();
                PerInfo    perInfoSize     = jss.Deserialize <PerInfo>(datasize);
                HttpCookie loginUserCookie = Request.Cookies["loginUserInfo"];
                int        userId          = Convert.ToInt32(loginUserCookie.Values["loginUserId"]);//用户的ID
                var        userInfo        = UserService.LoadEntities(u => u.ID == userId).FirstOrDefault();
                userInfo.vcNickName = perInfoSize.nickName;
                if (UserService.EditEntity(userInfo))
                {
                    var per = PersonalinformationService.LoadEntities(p => p.iUserID == userId).FirstOrDefault();
                    //把个人信息添加到数据库中
                    per.vcName              = perInfoSize.name;
                    per.cPhone              = perInfoSize.phone;
                    per.vcGender            = perInfoSize.gender;
                    per.dBirthday           = perInfoSize.birthday;
                    per.vcWeChat            = perInfoSize.wechat;
                    per.vcEmail             = perInfoSize.Email;
                    per.vcQQ                = perInfoSize.QQ;
                    per.vcHobby             = perInfoSize.hobby;
                    per.vcPersonalIntroduce = perInfoSize.introduce;
                    per.vcAddress           = perInfoSize.address;
                    per.vcMajor             = perInfoSize.major;
                    per.vcGrade             = perInfoSize.grade;
                    per.IsDel               = false;
                    if (PersonalinformationService.EditEntity(per))
                    {
                        status  = "ok";
                        result  = "添加成功";
                        jsonTxt = "{" + "\"" + "status" + "\"" + ":" + "\"" + status + "\"" + "," + "\"" + "result" + "\"" + ":" + "\"" + result + "\"" + "}";
                    }
                    else
                    {
                        status  = "no";
                        result  = "添加失败";
                        jsonTxt = "{" + "\"" + "status" + "\"" + ":" + "\"" + status + "\"" + "," + "\"" + "result" + "\"" + ":" + "\"" + result + "\"" + "}";
                    }
                }
                else
                {
                    status  = "no";
                    result  = "请先登录";
                    jsonTxt = "{" + "\"" + "status" + "\"" + ":" + "\"" + status + "\"" + "," + "\"" + "result" + "\"" + ":" + "\"" + result + "\"" + "}";
                }
            }
            catch (Exception ex)
            {
                status  = "no";
                result  = "添加失败";
                jsonTxt = "{" + "\"" + "status" + "\"" + ":" + "\"" + status + "\"" + "," + "\"" + "result" + "\"" + ":" + "\"" + result + "\"" + "}";
            }
            return(Content(jsonTxt));
        }
Esempio n. 2
0
        /// <summary>
        /// 获取一个人的全部个人信息
        /// </summary>
        /// <returns></returns>
        public ActionResult ManagePersonPageHead()
        {
            string jsonTxt = "";
            string id      = Request["personId"];

            if (id != null)
            {
                try
                {
                    int            perId   = Convert.ToInt32(id);
                    var            persons = PersonalinformationService.LoadEntities(p => p.ID == perId).FirstOrDefault();
                    BackPersonInfo perInfo = new BackPersonInfo();
                    //perInfo.TeamName = "BAR团队";
                    var team = TeamService.LoadEntities(t => t.ID == persons.iUserID).FirstOrDefault();
                    perInfo.TeamName = team.vcTeamName;
                    perInfo.Name     = persons.vcName;
                    var user1 = UserService.LoadEntities(u => u.ID == persons.iUserID).FirstOrDefault();
                    perInfo.ProfilePhotoAddress = user1.vcProfilePhotoAddress;
                    perInfo.UserAccount         = user1.vcUserAccount;
                    perInfo.UserName            = user1.vcNickName;
                    perInfo.Gender            = persons.vcGender;
                    perInfo.Grade             = persons.vcGrade;
                    perInfo.Birthday          = (DateTime)persons.dBirthday;
                    perInfo.Major             = persons.vcMajor;
                    perInfo.WeChat            = persons.vcWeChat;
                    perInfo.QQ                = persons.vcQQ;
                    perInfo.Email             = persons.vcEmail;
                    perInfo.Phone             = persons.cPhone;
                    perInfo.PersonalIntroduce = persons.vcPersonalIntroduce;
                    perInfo.Hobby             = persons.vcHobby;
                    perInfo.Address           = persons.vcAddress;
                    BackPersonModel model = new BackPersonModel();
                    model.PersonInfoList = perInfoList;
                    var timerConverter = new IsoDateTimeConverter {
                        DateTimeFormat = "yyyy-MM-dd"
                    };
                    jsonTxt = JsonConvert.SerializeObject(model, Newtonsoft.Json.Formatting.Indented);
                }
                catch (Exception ex)
                {
                    jsonTxt = "no";
                }
            }
            else
            {
                jsonTxt = "no";
            }
            return(Content(jsonTxt));
        }
        /// <summary>
        /// 获取个人信息  get请求
        /// </summary>
        /// <returns></returns>
        public ActionResult GetPerInfo()
        {
            string     jsonTxt         = "";
            HttpCookie loginUserCookie = Request.Cookies["loginUserInfo"];

            if (loginUserCookie != null)
            {
                int userId = Convert.ToInt32(loginUserCookie.Values["loginUserId"]);
                var per    = PersonalinformationService.LoadEntities(p => p.iUserID == userId).FirstOrDefault();
                var user   = UserService.LoadEntities(u => u.ID == userId).FirstOrDefault();
                if (per != null && user != null)
                {
                    Per perInfo = new Per();
                    if (!String.IsNullOrEmpty(user.vcNickName))
                    {
                        perInfo.nickName = user.vcNickName;
                    }
                    if (!String.IsNullOrEmpty(per.vcName))
                    {
                        perInfo.name = per.vcName;
                    }
                    if (!String.IsNullOrEmpty(user.vcProfilePhotoAddress))
                    {
                        perInfo.perLogo = user.vcProfilePhotoAddress;
                    }
                    if (!String.IsNullOrEmpty(per.vcGender))
                    {
                        perInfo.gender = per.vcGender;
                    }
                    if (!String.IsNullOrEmpty(per.vcGrade))
                    {
                        perInfo.grade = per.vcGrade;
                    }
                    if (!String.IsNullOrEmpty(per.vcMajor))
                    {
                        perInfo.major = per.vcMajor;
                    }
                    if (per.dBirthday != null)
                    {
                        perInfo.birthday = (DateTime)per.dBirthday;
                    }
                    if (!String.IsNullOrEmpty(per.cPhone))
                    {
                        perInfo.phone = per.cPhone;
                    }
                    if (!String.IsNullOrEmpty(per.vcWeChat))
                    {
                        perInfo.wechat = per.vcWeChat;
                    }
                    if (!String.IsNullOrEmpty(per.vcQQ))
                    {
                        perInfo.QQ = per.vcQQ;
                    }
                    if (!String.IsNullOrEmpty(per.vcEmail))
                    {
                        perInfo.Email = per.vcEmail;
                    }
                    if (!String.IsNullOrEmpty(per.vcHobby))
                    {
                        perInfo.hobby = per.vcHobby;
                    }
                    if (!String.IsNullOrEmpty(per.vcAddress))
                    {
                        perInfo.address = per.vcAddress;
                    }
                    if (!String.IsNullOrEmpty(per.vcPersonalIntroduce))
                    {
                        perInfo.introduce = per.vcPersonalIntroduce;
                    }
                    var timerConverter = new IsoDateTimeConverter {
                        DateTimeFormat = "yyyy-MM-dd"
                    };
                    jsonTxt = JsonConvert.SerializeObject(perInfo, Newtonsoft.Json.Formatting.Indented);
                }
                else  //未找到数据
                {
                    status  = "no";
                    result  = "未找到数据";
                    jsonTxt = "{" + "\"" + "status" + "\"" + ":" + "\"" + status + "\"" + "," + "\"" + "result" + "\"" + ":" + "\"" + result + "\"" + "}";
                }
            }
            else //未登录
            {
                status  = "no";
                result  = "未登录";
                jsonTxt = "{" + "\"" + "status" + "\"" + ":" + "\"" + status + "\"" + "," + "\"" + "result" + "\"" + ":" + "\"" + result + "\"" + "}";
            }
            return(Content(jsonTxt));
        }
Esempio n. 4
0
        /// <summary>
        /// 个人信息展示
        /// </summary>
        /// <returns></returns>
        public ActionResult ShowPerson()
        {
            string jsonTxt = "";
            /// <summary>
            /// 根据Cookie拿到UserID
            /// </summary>
            HttpCookie loginUserCookie = Request.Cookies["loginUserInfo"];
            string     strId           = Request["userId"];

            if (loginUserCookie != null && strId != null)
            {
                Model.ViewModel.PerStripModel.PerInfo perInfo = new Model.ViewModel.PerStripModel.PerInfo();
                int userId = Convert.ToInt32(strId);
                /// <summary>
                /// 根据UserId拿到所有与UserId对应的HonorId
                /// </summary>
                try
                {
                    var per  = PersonalinformationService.LoadEntities(p => p.iUserID == userId).FirstOrDefault();
                    var user = UserService.LoadEntities(u => u.ID == userId).FirstOrDefault();
                    if (per != null && user != null)
                    {
                        perInfo.perEmail        = per.vcEmail;
                        perInfo.perGrade        = per.vcGrade;
                        perInfo.perMajor        = per.vcMajor;
                        perInfo.perName         = per.vcName;
                        perInfo.perNickName     = user.vcNickName;
                        perInfo.perPhone        = per.cPhone;
                        perInfo.perPhotoAddress = user.vcProfilePhotoAddress;
                        perInfo.perQQ           = per.vcQQ;
                        perInfo.perWechat       = per.vcWeChat;
                        perInfo.perIntroduce    = per.vcPersonalIntroduce;
                        perInfo.perHobby        = per.vcHobby;
                        Model.ViewModel.PerStripModel.PerHonorModel model = new Model.ViewModel.PerStripModel.PerHonorModel();
                        model.perInfo = perInfo;
                        jsonTxt       = JsonConvert.SerializeObject(model, Newtonsoft.Json.Formatting.Indented);
                    }
                    var teamapplicant = TeamapplicantService.LoadEntities(ta => ta.iUserID == userId).FirstOrDefault();
                    var team          = TeamService.LoadEntities(t => t.ID == teamapplicant.iTeamID).FirstOrDefault();
                    perInfo.perTeamLogo = team.vcTeamLogoAddress;
                    List <Model.ViewModel.PerStripModel.PerHonor> perHonorList = new List <Model.ViewModel.PerStripModel.PerHonor>();
                    var honorPer = HonorparticipantmemberService.LoadEntities(hp => hp.iUserID == userId).ToList();
                    if (honorPer != null)
                    {
                        foreach (var honorper in honorPer)
                        {
                            Model.ViewModel.PerStripModel.PerHonor perHonor = new Model.ViewModel.PerStripModel.PerHonor();
                            var honorInfo = HonorService.LoadEntities(h => h.ID == honorper.iHonorID).FirstOrDefault();
                            perHonor.honorFell   = honorper.vcHonorFeel;
                            perHonor.honorAdvice = honorper.vcHonorAdvice;
                            if (honorInfo != null)
                            {
                                perHonor.honorId      = honorInfo.ID;
                                perHonor.honorLogo    = honorInfo.vcPreviewAddress;
                                perHonor.honorName    = honorInfo.vcHonorName;
                                perHonor.honorSubmit  = (DateTime)honorInfo.dSubmitTime;
                                perHonor.honorTeacher = honorInfo.vcGuideTeacher;
                                var teamInfo = TeamService.LoadEntities(t => t.ID == honorInfo.iTeamID).FirstOrDefault();
                                if (teamInfo != null)
                                {
                                    perHonor.teamName = teamInfo.vcTeamName;
                                }
                                else
                                {
                                    perHonor.teamName = "数据库无此荣耀团队数据";
                                }
                            }
                            else
                            {
                                perHonor.honorId     = 0;
                                perHonor.honorLogo   = "../img/aboutUs/large/cover.jpg";
                                perHonor.honorName   = "数据库无此荣耀名称数据";
                                perHonor.honorSubmit = DateTime.Now.Date;
                            }
                            perHonorList.Add(perHonor);
                        }
                        Model.ViewModel.PerStripModel.PerHonorModel model = new Model.ViewModel.PerStripModel.PerHonorModel();
                        model.perInfo      = perInfo;
                        model.perHonorList = perHonorList;
                        var timerConverter = new IsoDateTimeConverter {
                            DateTimeFormat = "yyyy-MM-dd"
                        };
                        jsonTxt = JsonConvert.SerializeObject(model, Newtonsoft.Json.Formatting.Indented);
                    }
                    else  //查询数据失败
                    {
                        status  = "no";
                        jsonTxt = "{" + "\"" + "status" + "\"" + ":" + "\"" + status + "\"" + "}";
                    }
                }
                catch (Exception ex)  //网络连接故障
                {
                    if (jsonTxt != null)
                    {
                        return(Content(jsonTxt));
                    }
                    else
                    {
                        status  = "no";
                        jsonTxt = "{" + "\"" + "status" + "\"" + ":" + "\"" + status + "\"" + "}";
                    }
                }
            }
            else //未登录
            {
                status  = "no";
                jsonTxt = "{" + "\"" + "status" + "\"" + ":" + "\"" + status + "\"" + "}";
            }
            return(Content(jsonTxt));
        }
        public ActionResult GetHonorInfo()
        {
            string jsonTxt = "";
            int    HonorId = Request["HonorId"] != null?int.Parse(Request["HonorId"]) : 1;

            try
            {
                var           honorinfo = HonorService.LoadEntities(h => h.ID == HonorId && h.IsDel == false).FirstOrDefault();
                BackHonorInfo honorInfo = new BackHonorInfo();
                honorInfo.honorName     = honorinfo.vcHonorName;
                honorInfo.guidTeacher   = honorinfo.vcGuideTeacher;
                honorInfo.technicalType = honorinfo.vcTechnicalType;
                if ((bool)honorinfo.bReviewOfWorks)
                {
                    honorInfo.isChecked = "已审核";
                }
                else
                {
                    honorInfo.isChecked = "未审核";
                }
                honorInfo.honorSubmit    = (DateTime)honorinfo.dSubmitTime;
                honorInfo.honorIntroduce = honorinfo.vcHonorIntroduce;
                List <int> UserId = new List <int>();
                List <BackHonorInfoPer> HonorInfoPer = new List <BackHonorInfoPer>();
                var honorPer = HonorparticipantmemberService.LoadEntities(hp => hp.iHonorID == honorinfo.ID && hp.IsDel == false).ToList();
                foreach (var honorper in honorPer)
                {
                    UserId.Add((int)honorper.iUserID);
                    honorInfo.NonTeamMember = honorper.vcNonTeamMember;
                }
                foreach (int userId in UserId)
                {
                    BackHonorInfoPer honorInfoPer = new BackHonorInfoPer();
                    var per = PersonalinformationService.LoadEntities(p => p.iUserID == userId && p.IsDel == false).FirstOrDefault();
                    honorInfoPer.Name   = per.vcName;
                    honorInfoPer.Gender = per.vcGender;
                    honorInfoPer.Grade  = per.vcGrade;
                    honorInfoPer.Major  = per.vcMajor;
                    var reg = RegisterloginService.LoadEntities(r => r.iUserID == userId && r.IsDel == false).FirstOrDefault();
                    if (reg.iIdentity == (int)Model.EnumType.IdentityEnumType.Captain)
                    {
                        honorInfoPer.Identity = "队长";
                    }
                    else if (reg.iIdentity == (int)Model.EnumType.IdentityEnumType.Member)
                    {
                        honorInfoPer.Identity = "队员";
                    }
                    else
                    {
                        honorInfoPer.Identity = "身份出错";
                    }
                    var user = UserService.LoadEntities(u => u.ID == userId && u.IsDel == false).FirstOrDefault();
                    honorInfoPer.Account = user.vcUserAccount;
                    HonorInfoPer.Add(honorInfoPer);
                }
                BackHonorInfoModel HonorInfoModel = new BackHonorInfoModel();
                HonorInfoModel.HonorInfo    = honorInfo;
                HonorInfoModel.HonorInfoPer = HonorInfoPer;
                var timerConverter = new IsoDateTimeConverter {
                    DateTimeFormat = "yyyy-MM-dd"
                };
                jsonTxt = JsonConvert.SerializeObject(HonorInfoModel, Newtonsoft.Json.Formatting.Indented);
            }
            catch (Exception ex)
            {
                jsonTxt = "no" + ex.ToString();
            }
            return(Content(jsonTxt));
        }