//特定咨询详情页面(用户和专家共用) public ActionResult ConsultDetails() { if (Session["userName"] == null) { return(RedirectToAction("LoginRemind", "Topic")); } LoginStatusConfig();//配置登录状态 string userName = Session["userName"].ToString(); ////获取用户等级名 Rank_bll rank_bll = new Rank_bll(); string rankNameDB = rank_bll.GetRankName(userName); //该用户数据库里的等级名 rankNameDB = rankNameDB.Trim(); //去除空格 //string expertUserName = Request["expertUserName"].ToString(); int specialConsultId = Convert.ToInt32(Request["specialConsultId"]); SpecialConsult_bll specialConsult_bll = new SpecialConsult_bll(); SpecialConsult_model specialConsult_model = specialConsult_bll.GetOneSpecialConsult(specialConsultId);//通过specialConsultId获取用户特定咨询时填写的特定咨询数据 ViewData["specialConsult_model"] = specialConsult_model; ViewData["rankName"] = rankNameDB; SpecialConsultAnswer_bll specialConsultAnswer_bll = new SpecialConsultAnswer_bll(); string expertUserName = Request["expertUserName"].ToString(); User_bll user_bll = new User_bll(); int expertId = user_bll.GetUserId(expertUserName); SpecialConsultAnswer_model specialConsultAnswer_model = specialConsultAnswer_bll.GetOneSpecialAnswerData(specialConsultId, expertId);//通过specialConsultId获取特定咨询的专家解答数据 return(View(specialConsultAnswer_model)); }
/// <summary> /// 遍历我的特定咨询过的帖子 /// Creator:Simple /// </summary> /// <returns></returns> public ActionResult MySpecialConsult() { if (Session["userName"] == null) { return(RedirectToAction("LoginRemind", "Topic")); } LoginStatusConfig();//配置登录状态 string userName = Session["userName"].ToString(); ////判断用户类型是否为普通用户 Rank_bll rank_bll = new Rank_bll(); string rankNameDB = rank_bll.GetRankName(userName); //该用户数据库里的等级名 rankNameDB = rankNameDB.Trim(); //去除空格 if (rankNameDB != "普通用户") { return(Content("错误提示:您不是普通用户")); } User_bll user_bll = new User_bll(); int userId = Convert.ToInt32(user_bll.GetUserId(userName)); //通过用户名获取userId CountUser_model countUser_model = user_bll.GetCountUser(userId, rankNameDB); //获取用户的CountUser_model 数据:点赞数 关注数 粉丝数 收藏数 提问数 回帖数 特定咨询数 等 ViewData["countUser_model"] = countUser_model; ViewData["rankName"] = rankNameDB; ViewData["actionName"] = "MySpecialConsult"; //当前action名 SpecialConsult_bll specialConsult_bll = new SpecialConsult_bll(); List <SpecialConsult_model> specialConsult_modelList = specialConsult_bll.GetMyConsultData(userId); //通过userId获取该用户的特定咨询数据 return(View(specialConsult_modelList)); }
/// <summary> /// 返回特定咨询页面 /// </summary> /// <returns></returns> public ActionResult Consult() { if (Session["username"] == null) { return(View("loginremind")); } string userName = Session["username"].ToString(); LoginStatusConfig();//配置登录状态 User_bll user_bll = new User_bll(); int userId = Convert.ToInt32(user_bll.GetUserId(userName));//通过用户名获取userId ////获取用户等级名 Rank_bll rank_bll = new Rank_bll(); string rankNameDB = rank_bll.GetRankName(userName); //该用户数据库里的等级名 rankNameDB = rankNameDB.Trim(); //去除空格 CountUser_model countUser_model = user_bll.GetCountUser(userId, rankNameDB); //获取用户的CountUser_model 数据:点赞数 关注数 粉丝数 收藏数 提问数 回帖数 特定咨询数 等 ViewData["countUser_model"] = countUser_model; List <ExpertUserConsult_model> expertUserConsult_modelList = user_bll.GetExpertConsult(); //获取专家的ExpertUserConsult_model数据,用户填写特定咨询时,需要选择专家 User_model user_model = new User_model(); try { user_model = user_bll.GetUserDataConsult(userName);//用户的个人数据 } catch (Exception e) { return(Content(e.ToString())); } ViewData["user_model"] = user_model; return(View(expertUserConsult_modelList)); }
/// <summary> /// 遍历我的回答过的帖子,即回帖 /// Creator:Simple /// </summary> /// <returns></returns> public ActionResult myAnsweres() { if (Session["userName"] == null) { return(RedirectToAction("LoginRemind", "Topic")); } LoginStatusConfig();//配置登录状态 string userName = Session["userName"].ToString(); ////获取用户等级名 Rank_bll rank_bll = new Rank_bll(); string rankNameDB = rank_bll.GetRankName(userName); //该用户数据库里的等级名 rankNameDB = rankNameDB.Trim(); //去除空格 User_bll user_bll = new User_bll(); int userId = Convert.ToInt32(user_bll.GetUserId(userName)); //通过用户名获取userId CountUser_model countUser_model = user_bll.GetCountUser(userId, rankNameDB); //获取用户的CountUser_model 数据:点赞数 关注数 粉丝数 收藏数 提问数 回帖数 特定咨询数 等 ViewData["countUser_model"] = countUser_model; ViewData["rankName"] = rankNameDB; ViewData["actionName"] = "myAnsweres";//当前action名 ReplyPost_bll replyPost_bll = new ReplyPost_bll(); List <ReplyPost_model> replyPost_modelList = new List <ReplyPost_model>(); replyPost_modelList = replyPost_bll.GetShortReplyPostData(userId);//获取用户的回帖数据 return(View(replyPost_modelList)); }
/// <summary> /// 判断登录是否成功,登录成功返回1,登录失败返回0,数据库异常返回2,用户类型不一致返回3 /// login /// </summary> /// <returns></returns> public ActionResult ajaxMakeLogin() { People_bll people = new People_bll(); string username = Request["username"].ToString(); string password = Request["password"].ToString(); string rankName = Request["rankName"].ToString(); bool login = false; //true代表账号密码都正确 try { login = people.LoginYes(username, password); } catch (Exception e) { //数据库异常处理,数据库里存在大于两条用户名一样的数据 ErrorMessage_bll errorMessage_bll = new ErrorMessage_bll(); errorMessage_bll.InsertErrorMessage("数据库出错", "数据库里tb_User表存在大于2条用户名一样的数据,用户名为:" + username); return(Content("2")); } if (login) { ////登录成功后,判断用户类型是否与用户填写的一致 Rank_bll rank_bll = new Rank_bll(); string rankNameDB = rank_bll.GetRankName(username); //该用户数据库里的等级名 rankNameDB = rankNameDB.Trim(); //去除空格 if (rankName != rankNameDB) { return(Content("3")); } //,保存用户的用户名,权限等资料到session Session["userName"] = username; Session["rank"] = rankName; User_bll user_bll = new User_bll(); Session["signature"] = user_bll.GetSignature(username); return(Content("1")); } else { return(Content("0")); } }
/// <summary> /// 模板页,查看我的 “回答 提问 收藏 ” 帖子, /// </summary> /// <returns></returns> public ActionResult MyPostTemplate() { LoginStatusConfig();//配置登录状态 if (Session["userName"] == null) { return(RedirectToAction("LoginRemind", "Topic")); } string userName = Session["userName"].ToString(); User_bll user_bll = new User_bll(); int userId = Convert.ToInt32(user_bll.GetUserId(userName));//通过用户名获取userId ////获取用户等级名 Rank_bll rank_bll = new Rank_bll(); string rankNameDB = rank_bll.GetRankName(userName); //该用户数据库里的等级名 rankNameDB = rankNameDB.Trim(); //去除空格 CountUser_model countUser_model = user_bll.GetCountUser(userId, rankNameDB); //获取用户的CountUser_model 数据:点赞数 关注数 粉丝数 收藏数 提问数 回帖数 特定咨询数 等 ViewData["countUser_model"] = countUser_model; return(View()); }
/// <summary> /// 返回专家特定咨询解答页面 /// </summary> /// <returns></returns> public ActionResult ExpertAnswer() { //string expertUserName = Request["expertUserName"].ToString(); string expertUserName = "******"; int specialConsultId = 3; //检查用户是否为专家 Rank_bll rank_bll = new Rank_bll(); string rankName = rank_bll.GetRankName(expertUserName); //获取用户的等级名称 rankName = rankName.Trim(); //去除字符串里的空格 if (rankName != "专家") { return(Content("0")); } //获取specialConsultId的特定咨询的数据 SpecialConsult_bll specialConsult_bll = new SpecialConsult_bll(); SpecialConsult_model specialConsult_model = specialConsult_bll.GetOneSpecialConsult(specialConsultId); return(View(specialConsult_model)); }
/// <summary> /// 返回专家特定咨询解答页面 /// </summary> /// <returns></returns> public ActionResult ExpertAnswer() { if (Session["userName"] == null) { return(RedirectToAction("LoginRemind", "Topic")); } LoginStatusConfig();//配置登录状态 string expertUserName = Request["expertUserName"].ToString(); int specialConsultId = Convert.ToInt32(Request["specialConsultId"]); //检查用户是否为专家 Rank_bll rank_bll = new Rank_bll(); string rankName = rank_bll.GetRankName(expertUserName); //获取用户的等级名称 rankName = rankName.Trim(); //去除字符串里的空格 if (rankName != "专家") { return(Content("0")); } //获取specialConsultId的特定咨询的数据 SpecialConsult_bll specialConsult_bll = new SpecialConsult_bll(); SpecialConsult_model specialConsult_model = specialConsult_bll.GetOneSpecialConsult(specialConsultId); return(View(specialConsult_model)); }
/// <summary> /// 专家对特定咨询的回帖,当点击提交时调用此函数 /// </summary> /// <returns></returns> public ActionResult MakeExpertAnswer() { if (Session["userName"] == null) { return(RedirectToAction("LoginRemind", "Topic")); } LoginStatusConfig();//配置登录状态 string expertUserName = Session["userName"].ToString(); //检查用户是否为专家 Rank_bll rank_bll = new Rank_bll(); string rankName = rank_bll.GetRankName(expertUserName); //获取用户的等级名称 rankName = rankName.Trim(); //去除字符串里的空格 if (rankName != "专家") { return(Content("您不是专家")); } User_bll user_bll = new User_bll(); int expertId = user_bll.GetUserId(expertUserName); ////先把前端传回来的content内容保存为静态页面 byte[] byteData = new byte[Request.InputStream.Length]; //定义一个字节数组保存前端传回来的Post数据全部数据 Request.InputStream.Read(byteData, 0, byteData.Length); //将流读取到byteData,InputStream读取到的是http头里的主体数据 //string postData = System.Text.Encoding.Default.GetString(byteData);//系统的默认编码为gb2312,不适用这种 string postData = System.Text.Encoding.UTF8.GetString(byteData); string[] datas = postData.Split('&'); //对前端传回来的数据进行分割,提取出文本框里的html数据 string contentData = datas[2].ToString(); //data[0]为变量名为content的内容 contentData = contentData.Substring(contentData.IndexOf('=') + 1); //去除变量名,如content=aaa,只取出aaa contentData = Server.UrlDecode(contentData); //对数据进行url解码,这个解码的操作要放在Split('&')之后,因为可能content里会含有&符号 DateTime datetime = DateTime.Now; string fileName = datetime.ToString("yyyyMMddHHmmss_ffff") + ".html"; //定义文件名fileName string fileNamePath = Server.MapPath("~/StaticHtml/ConsultAnswerHtml/") + fileName; //物理路径 while (System.IO.File.Exists(fileNamePath)) //先判断文件是否存在,若存在:更换文件名 { datetime = DateTime.Now; fileName = datetime.ToString("yyyyMMddHHmmss_ffff") + ".html"; fileNamePath = Server.MapPath("~/StaticHtml/ConsultAnswerHtml/") + fileName; } System.IO.FileStream fs = new System.IO.FileStream(fileNamePath, System.IO.FileMode.Create); byte[] contentBytes = System.Text.Encoding.UTF8.GetBytes(contentData); //byte[] contentBytes = System.Text.Encoding.Default.GetBytes(contentData); fs.Write(contentBytes, 0, contentBytes.Length); fs.Close();//保存静态html成功 ////将数据保存到数据库里tb_SpecialConsultAnswer SpecialConsultAnswer_SpecialConsultId SpecialConsultAnswer_HtmlUrl int specialConsultId = Convert.ToInt32(Request["hidSpecialConsultId"]); //用户特定咨询的id string staticConsultAnswerHtml = "/StaticHtml/ConsultAnswerHtml/" + fileName; //相对路径 SpecialConsult_bll specialConsult_bll = new SpecialConsult_bll(); specialConsult_bll.InsertAnswerData(specialConsultId, expertId, staticConsultAnswerHtml, datetime); ////保存购买链接 int specialConsultAnswer_Id = specialConsult_bll.GetConsultAnswerId(staticConsultAnswerHtml); int selectCount = Convert.ToInt32(Request["selectCount"]); //代表购买链接的条数 Dictionary <string, string> selectClothUrlDic = new Dictionary <string, string>(); //服饰类型名:购买链接 for (int i = 1; i <= selectCount; i++) { try { selectClothUrlDic.Add(Request["selectCloth" + i].ToString(), Request["clothShoppingUrl" + i].ToString()); } catch (Exception e) { return(Content("<script type='text/javascript'>alert('请不要出入两种同样的服饰,请重新操作');window.location.href = '../Consult/ExpertAnswer';</script>")); } } SpecialConsultAnswerClothes_bll specialConsultAnswerClothes_bll = new SpecialConsultAnswerClothes_bll(); specialConsultAnswerClothes_bll.InsertConsultAnswerClothes(specialConsultAnswer_Id, selectClothUrlDic); return(RedirectToAction("ConsultDetails", new { specialConsultId = specialConsultId, expertUserName = expertId })); }
public ActionResult Index() { if (Session["userName"] == null) { return(RedirectToAction("LoginRemind", "Topic")); } LoginStatusConfig();//配置登录状态 People_bll user = new People_bll(); string userName = Session["userName"].ToString(); //检测姓名是否为空 if (user.CheckRealName(userName) == null) { ViewData["realName"] = "请输入您的真实姓名"; } else { ViewData["realName"] = user.CheckRealName(userName); } // 检测出生年月是否为空 if (user.CheckBirthDate(userName) == null) { ViewData["BirthDate"] = "请输入您的出生年月"; } else { ViewData["BirthDate"] = user.CheckBirthDate(userName); } //检测职业是否为空 if (user.CheckProfession(userName) == null) { ViewData["Profession"] = "请输入您的职业"; } else { ViewData["Profession"] = user.CheckProfession(userName); } // 检测手机号是否为空 if (user.CheckPhoneNumber(userName) == null) { ViewData["PhoneNumber"] = "请输入您的手机号"; } else { ViewData["PhoneNumber"] = user.CheckPhoneNumber(userName); } //检测学历是否为空 if (user.CheckEducationalBackground(userName) == null) { ViewData["CheckEducationalBackground"] = "请输入您的手机号"; } else { ViewData["CheckEducationalBackground"] = user.CheckEducationalBackground(userName); } //检测爱好是否为空 if (user.CheckInterest(userName) == null) { ViewData["Interest"] = "请输入您的兴趣"; } else { ViewData["Interest"] = user.CheckInterest(userName); } //检测肤色是否为空 if (user.GetSkinColor(userName) == null) { ViewData["SkinColor"] = "请输入您的肤色"; } else { ViewData["SkinColor"] = user.GetSkinColor(userName); } //检测体重是否为空 if (user.GetWeight(userName) == -1) { ViewData["Weight"] = "请输入您的体重"; } else { ViewData["Weight"] = user.GetWeight(userName); } //检测臀围是否为空 if (user.GetTunWei(userName) == -1) { ViewData["TunWei"] = "请输入您的臀围"; } else { ViewData["TunWei"] = user.GetTunWei(userName); } //检测胸围是否为空 if (user.GetXiongWei(userName) == -1) { ViewData["XiongWei"] = "请输入您的胸围"; } else { ViewData["XiongWei"] = user.GetXiongWei(userName); } //检测腰围是否为空 if (user.GetYaoWei(userName) == -1) { ViewData["YaoWei"] = "请输入您的腰围"; } else { ViewData["YaoWei"] = user.GetYaoWei(userName); } //检测身高是否为空 if (user.GetHeight(userName) == -1) { ViewData["Height"] = "请输入您的身高"; } else { ViewData["Height"] = user.GetHeight(userName); } //检测腿长是否为空 if (user.GetThighGirth(userName) == -1) { ViewData["LegLength"] = "请输入您的腿长"; } else { ViewData["LegLength"] = user.GetLegLength(userName); } //检测大腿围是否为空 if (user.GetThighGirth(userName) == -1) { ViewData["ThighGirth"] = "请输入您的大腿围"; } else { ViewData["ThighGirth"] = user.GetThighGirth(userName); } //检测小腿围是否为空 if (user.GetCalfGirth(userName) == -1) { ViewData["CalfGirth"] = "请输入您的小腿围"; } else { ViewData["CalfGirth"] = user.GetCalfGirth(userName); } //检测手臂围是否为空 if (user.GetArmGirth(userName) == -1) { ViewData["ArmGirth"] = "请输入您的手臂围"; } else { ViewData["ArmGirth"] = user.GetArmGirth(userName); } //检测全是照 if (user.GetQuanShenZhao(userName) == "1") { ViewData["QuanShenZhao"] = "请输入您的手臂围"; } else { ViewData["QuanShenZhao"] = user.GetQuanShenZhao(userName); } ////获取用户等级名 Rank_bll rank_bll = new Rank_bll(); string rankNameDB = rank_bll.GetRankName(userName); //该用户数据库里的等级名 rankNameDB = rankNameDB.Trim(); //去除空格 //获取用户的CountUser_model 数据:点赞数 关注数 粉丝数 收藏数 提问数 回帖数 特定咨询数 等 User_bll user_bll = new User_bll(); int userId = user_bll.GetUserId(userName); CountUser_model countUser_model = user_bll.GetCountUser(userId, rankNameDB); ViewData["countUser_model"] = countUser_model; ViewData["rankName"] = rankNameDB; return(View()); }