protected void loginButton_Click(object sender, EventArgs e) { string adminId = this.adminName.Text.Trim(); string adminpass = this.adminPass.Text; DBUtil db = new DBUtil(); DataSet ds = db.executeSqlQuery("select * from Admins where adminId='" + adminId + "'"); if (ds.Tables[0].Rows.Count > 0) { string adminpassDb = ds.Tables[0].Rows[0]["adminpass"].ToString(); if(adminpassDb.Equals(System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(adminpass, "MD5")) { Session["adminid"] = adminId; Response.Redirect("admin.aspx"); } else { ClientScript.RegisterStartupScript(Page.GetType(), "", "<script>alert('密码错误!')</script>"); } } else { ClientScript.RegisterStartupScript(Page.GetType(), "", "<script>alert('无此用户!')</script>"); } }
protected void submitButton_Click(object sender, EventArgs e) { string username = this.username.Text.Trim(); string userpass = this.userpass.Text; DBUtil db = new DBUtil(); string sql = "select * from Admins where adminId='" + username + "'"; DataSet ds = db.executeSqlQuery(sql); if (ds.Tables[0].Rows.Count > 0) { string userpassdb = ds.Tables[0].Rows[0]["adminpass"].ToString(); string md5pass = System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(userpass, "MD5"); if (userpassdb.Equals(md5pass)) { Session["admin"] = username; Response.Redirect("admin-index.aspx"); } else { ClientScript.RegisterStartupScript(Page.GetType(), "", "<script>alert('密码错了');</script>"); } } else { ClientScript.RegisterStartupScript(Page.GetType(), "", "<script>alert('用户名错了');</script>"); } }
protected void deleteToolButton_Click(object sender, EventArgs e) { string sql = "delete from MyTool where Id=" + Request["id"]; DBUtil db = new DBUtil(); db.executeSqlQuery(sql); Response.Redirect("way-tool.aspx?userid=" + Request["userid"]); }
protected void addTopic_Click(object sender, EventArgs e) { string title = this.title.Text.Trim(); string introduction = this.introduction.Text.Trim(); DateTime dt = DateTime.Now; string img = dt.Year+"_"+dt.Month+"_"+dt.Day+"_"+dt.Hour+"_"+dt.Minute+"_"+dt.Second; this.img.SaveAs(Server.MapPath("/img/"+img+this.img.FileName.Substring(this.img.FileName.LastIndexOf('.')+1))); string imgPath = Server.MapPath("/img/"+img+this.img.FileName.Substring(this.img.FileName.LastIndexOf('.')+1)); int totalOptions = Convert.ToInt32(this.totalOptions.Text.Trim()); int totalChooseItems = Convert.ToInt32(this.totalChooseItems.Text.Trim()); string sql = string.Format("insert into Topics(title,introduction,introductionImage,Topictype,TotalOptions,TotalChooseItem,CreateDateTime,resulttype) " + "values('{0}','{1}','{2}',{3},{4},{5},'{6}',{7})",title,introduction,imgPath,1,totalOptions,totalChooseItems,dt.ToString(),1); DBUtil db = new DBUtil(); db.executeSqlNonQuery(sql); sql = "select max(Id) as maxid from Topics"; DataSet ds = db.executeSqlQuery(sql); if (ds.Tables[0].Rows.Count > 0) { int newid = Convert.ToInt32(ds.Tables[0].Rows[0][0].ToString()); Response.Redirect("admin-add-choose-item.aspx?id="+newid +"&totalChooseItem="+totalChooseItems+"&totalOptions="+totalOptions); } }
protected void editToolButton_Click(object sender, EventArgs e) { string title = this.itemName.Text.Trim(); string frequency = this.frequencyField.Value; string sql = string.Format("update MyTool set toolName='{0}',frequency={1} where Id={2}", title, frequency, Request["id"]); DBUtil db = new DBUtil(); db.executeSqlNonQuery(sql); Response.Redirect("way-tool.aspx?userid=" + Request["userid"]); }
protected void Page_Load(object sender, EventArgs e) { string sql = "select * from Topics where ID=" + Request["id"]; DBUtil db = new DBUtil(); DataSet ds = db.executeSqlQuery(sql); if(ds.Tables[0].Rows.Count > 0 ) { infoTitleImage = ds.Tables[0].Rows[0]["infoTitleImage"].ToString(); } }
protected void Page_Load(object sender, EventArgs e) { string userid = Request["userid"]; if (userid == null) { userid = "om8uZt7fajggMH8vqjFb1afiE8y4"; } JObject obj = WeixinUtil.getUserInfo(userid); userImageUrl = obj.GetValue("headimgurl").ToString(); userNickName = obj.GetValue("nickname").ToString(); DBUtil db = new DBUtil(); DataSet ds = db.executeSqlQuery("select * from Users where userName='******'"); if (ds.Tables[0].Rows.Count > 0) { age = ds.Tables[0].Rows[0]["age"].ToString(); industry = ds.Tables[0].Rows[0]["industry"].ToString(); region = ds.Tables[0].Rows[0]["region"].ToString(); } string sql = "select count(Id) as total from measureScores where userId='" + userid + "' and topicId in (2,5)"; ds = db.executeSqlQuery(sql); if (ds.Tables[0].Rows.Count > 0) { testTimes = Convert.ToInt32(ds.Tables[0].Rows[0][0]) / 4; } int personalTimes = 0; sql = "select * from Votes where userId='" + userid + "' and topicId=1"; ds = db.executeSqlQuery(sql); if (ds.Tables[0].Rows.Count > 0) { personalTimes++; } sql = "select * from Votes where userId='" + userid + "' and topicId=8"; ds = db.executeSqlQuery(sql); if (ds.Tables[0].Rows.Count > 0) { personalTimes++; } selfPercent = personalTimes * 100 / 6; if (!IsPostBack) { sql = "select * from MyTool where Id=" + Request["id"]; ds = db.executeSqlQuery(sql); if (ds.Tables[0].Rows.Count > 0) { this.itemName.Text = ds.Tables[0].Rows[0]["toolName"].ToString(); this.frequencyField.Value = ds.Tables[0].Rows[0]["frequency"].ToString(); } } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { string code = Request["code"]; string userid = Request["userid"]; if (userid == null) { if (code == null) { Response.Redirect("https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxe29e41d979d25872&redirect_uri=http%3A%2F%2Fwww.ihappyabc.com%2Fperson.aspx&response_type=code&scope=snsapi_base#wechat_redirect"); } else { userid = WeixinUtil.getUserAuthorizedId(code); } } openid = userid; JObject obj = WeixinUtil.getUserInfo(userid); userImageUrl = obj.GetValue("headimgurl").ToString(); userNickName = obj.GetValue("nickname").ToString(); string sql = "select * from Users where userName='******'"; DBUtil db = new DBUtil(); DataSet ds = db.executeSqlQuery(sql); if (ds.Tables[0].Rows.Count <= 0) { string province = obj.GetValue("province").ToString(); this.gender.Value = province; } else { string dbregion = ds.Tables[0].Rows[0]["region"].ToString(); this.gender.Value = dbregion; string dbdegree = ds.Tables[0].Rows[0]["degree"].ToString(); this.degree.Value = dbdegree; string dbmarriage = ds.Tables[0].Rows[0]["marriage"].ToString(); this.marriage.Value = dbmarriage; string dbincome = ds.Tables[0].Rows[0]["income"].ToString(); this.income.Value = dbincome; string dbage = ds.Tables[0].Rows[0]["age"].ToString(); this.age.Value = dbage; string dbindustry = ds.Tables[0].Rows[0]["industry"].ToString(); this.industry.Value = dbindustry; } } }
protected void start_Click(object sender, EventArgs e) { string marriage = this.marriage.Value; string income = this.income.Value; string degree = this.degree.Value; string userid = Request["userid"].ToString(); string type = Request["type"].ToString(); string id = Request["id"].ToString(); DBUtil db = new DBUtil(); string sql = "update Users set marriage='" + marriage + "',income='" + income + "',degree='" + degree + "' where userName='******'"; db.executeSqlNonQuery(sql); Response.Redirect("result.aspx?id=" + id + "&userid=" + userid + "&type=" + type); }
protected void Page_Load(object sender, EventArgs e) { string userid = Request["userid"]; string sql = "select * from Users where userName='******'"; DBUtil db = new DBUtil(); DataSet ds = db.executeSqlQuery(sql); if (ds.Tables[0].Rows.Count > 0) { Response.Redirect("vote.aspx?id=" + Request["id"] + "&userid=" + userid); } else { Response.Redirect("person.aspx?userid=" + userid + "&backId=" + Request["id"]); } }
protected void createToolButton_Click(object sender, EventArgs e) { string toolTitle = this.itemName.Text.Trim(); string frequency = this.frequencyField.Value; string userid = Request["userid"]; if (userid == null) { userid = "om8uZt7fajggMH8vqjFb1afiE8y4"; } string sql = "select * from MyTool where userId='" + userid + "'"; DBUtil db = new DBUtil(); DataSet ds = db.executeSqlQuery(sql); if (ds.Tables[0].Rows.Count >=0 && ds.Tables[0].Rows.Count<3 ) { sql = string.Format("insert into MyTool(userId,toolName,frequency,postDateTime) values('{0}','{1}',{2},'{3}')", userid, toolTitle, frequency, DateTime.Now.ToString()); db.executeSqlNonQuery(sql); Response.Redirect("way-tool.aspx?userid=" + userid); } }
protected void noneFinishButton_Click(object sender, EventArgs e) { string userid = Request["userid"]; string toolId = Request["id"]; string dateTime = this.checkRecordIndex.Value; string sql = string.Format("select * from MyToolRecord where userId='{0}' and toolId={1} and recordDateTime='{2}'", userid, toolId, dateTime); DBUtil db = new DBUtil(); DataSet ds = db.executeSqlQuery(sql); if (ds.Tables[0].Rows.Count == 0) { sql = string.Format("insert into MyToolRecord(userId,toolId,recordDateTime,status) values('{0}',{1},'{2}',{3})", userid, toolId, dateTime, 0); } else { sql = string.Format("update MyToolRecord set status=0 where userId='{0}' and toolId={1} and recordDateTime='{2}'", userid, toolId, dateTime); } db.executeSqlNonQuery(sql); Response.Redirect("tool-record.aspx?userid=" + Request["userid"] + "&id=" + Request["id"]); }
protected void start_Click(object sender, EventArgs e) { string userid = Request["userid"].ToString(); string age = this.age.Value; string gender = this.gender.Value; string industry = this.industry.Value; string sql = "select * from Users where userName='******'"; DBUtil db = new DBUtil(); DataSet ds = db.executeSqlQuery(sql); if (ds.Tables[0].Rows.Count > 0) { sql = string.Format("update Users set age='{0}',gender='{1}',industry='{2}'", age, gender, industry); db.executeSqlNonQuery(sql); } else { sql = string.Format("insert into Users(userName,regDateTime,age,gender,industry) values('{0}','{1}','{2}','{3}','{4}')",userid,DateTime.Now.ToString(), age, gender, industry); db.executeSqlNonQuery(sql); } Response.Redirect("vote.aspx?id="+Request["id"]+"&userid="+userid); }
protected void start_Click(object sender, EventArgs e) { string userid = Request["userid"]; if (userid == null) { userid = "om8uZt7fajggMH8vqjFb1afiE8y4"; } string age = this.age.Value; string region = this.gender.Value; string industry = this.industry.Value; string income = this.income.Value; string degree = this.degree.Value; string marriage = this.marriage.Value; string sql = "select * from Users where userName='******'"; DBUtil db = new DBUtil(); DataSet ds = db.executeSqlQuery(sql); if (ds.Tables[0].Rows.Count > 0) { sql = string.Format("update Users set age='{0}',region='{1}',industry='{2}',degree='{3}',income='{4}',marriage='{5}' where userName='******'", age, region, industry,degree,income,marriage,userid); db.executeSqlNonQuery(sql); } else { sql = string.Format("insert into Users(userName,regDateTime,age,gender,industry,income,degree,marriage) values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}')", userid, DateTime.Now.ToString(), age, region, industry,income,degree,marriage); db.executeSqlNonQuery(sql); } Response.Redirect("person.aspx?userid=" + userid); }
protected void Page_Load(object sender, EventArgs e) { string userid = Request["userid"]; if (userid == null) { userid = "om8uZt7fajggMH8vqjFb1afiE8y4"; } JObject obj = WeixinUtil.getUserInfo(userid); userImageUrl = obj.GetValue("headimgurl").ToString(); userNickName = obj.GetValue("nickname").ToString(); DBUtil db = new DBUtil(); DataSet ds = db.executeSqlQuery("select * from Users where userName='******'"); if (ds.Tables[0].Rows.Count > 0) { age = ds.Tables[0].Rows[0]["age"].ToString(); industry = ds.Tables[0].Rows[0]["industry"].ToString(); region = ds.Tables[0].Rows[0]["region"].ToString(); } string sql = "select count(Id) as total from measureScores where userId='" + userid + "' and topicId in (2,5)"; ds = db.executeSqlQuery(sql); if (ds.Tables[0].Rows.Count > 0) { testTimes = Convert.ToInt32(ds.Tables[0].Rows[0][0]) / 4; } int personalTimes = 0; sql = "select * from Votes where userId='" + userid + "' and topicId=1"; ds = db.executeSqlQuery(sql); if (ds.Tables[0].Rows.Count > 0) { personalTimes++; } sql = "select * from Votes where userId='" + userid + "' and topicId=8"; ds = db.executeSqlQuery(sql); if (ds.Tables[0].Rows.Count > 0) { personalTimes++; } selfPercent = personalTimes * 100 / 6; string id = Request["id"]; sql = "select * from MyTool where Id=" + id; ds = db.executeSqlQuery(sql); if (ds.Tables[0].Rows.Count > 0) { toolName = ds.Tables[0].Rows[0]["toolName"].ToString(); frequency = ds.Tables[0].Rows[0]["frequency"].ToString(); if (frequency.Equals("0")) frequency = "每天"; else frequency = "每周"; DateTime dt = DateTime.Parse(ds.Tables[0].Rows[0]["postDateTime"].ToString()); createDateTime = dt.Year + "年" + dt.Month + "月" + dt.Day + "日"; DateTime now = DateTime.Now; if( frequency.Equals("每天")) { int showTimes = 0; while(!sameDay(dt,now)) { showTimes++; string currentString = now.Year + "-" + now.Month + "-" + now.Day; sql = string.Format("select * from MyToolRecord where userId='{0}' and toolId={1} and recordDateTime='{2}'", userid, id, currentString); ds = db.executeSqlQuery(sql); if (ds.Tables[0].Rows.Count > 0) { string status = ds.Tables[0].Rows[0]["status"].ToString(); if(status.Equals("0")) { status = "未完成"; listColors.Add("#c9302c"); } else { status = "已完成"; listColors.Add("#5cb85c"); } listDays.Add(currentString); listStatus.Add(status); } else { listDays.Add(currentString); listStatus.Add("未打卡"); listColors.Add("rgba(117,197,240,1)"); } if (showTimes == 7) { break; } now = now.AddDays(-1); } if(sameDay(dt,now)) { string currentString = now.Year + "-" + now.Month + "-" + now.Day; sql = string.Format("select * from MyToolRecord where userId='{0}' and toolId={1} and recordDateTime='{2}'", userid, id, currentString); ds = db.executeSqlQuery(sql); if (ds.Tables[0].Rows.Count > 0) { string status = ds.Tables[0].Rows[0]["status"].ToString(); if (status.Equals("0")) { status = "未完成"; listColors.Add("#c9302c"); } else { status = "已完成"; listColors.Add("#5cb85c"); } listDays.Add(currentString); listStatus.Add(status); } else { listDays.Add(currentString); listStatus.Add("未打卡"); listColors.Add("rgba(117,197,240,1)"); } } if(listDays.Count<7) { int leftDays = 7 - listDays.Count; now = DateTime.Now; for( int i=0;i<leftDays;i++) { now = now.AddDays(1); string currentString = now.Year + "-" + now.Month + "-" + now.Day; listDays.Insert(0,currentString); listStatus.Insert(0, "未打卡"); listColors.Insert(0, "rgba(117,197,240,1)"); } } } else if (frequency.Equals("每周")) { int showTimes = 0; while (!sameWeek(dt, now)) { showTimes++; string currentString = now.Year + "-" + now.Month + "-" + now.Day; sql = string.Format("select * from MyToolRecord where userId='{0}' and toolId={1} and recordDateTime='{2}'", userid, id, currentString); ds = db.executeSqlQuery(sql); if (ds.Tables[0].Rows.Count > 0) { string status = ds.Tables[0].Rows[0]["status"].ToString(); if (status.Equals("0")) { status = "未完成"; listColors.Add("#c9302c"); } else { status = "已完成"; listColors.Add("#5cb85c"); } listDays.Add(currentString); listStatus.Add(status); } else { listDays.Add(currentString); listStatus.Add("未打卡"); listColors.Add("rgba(117,197,240,1)"); } if (showTimes == 7) { break; } now = now.AddDays(-7); } if (sameWeek(dt, now)) { string currentString = now.Year + "-" + now.Month + "-" + now.Day; sql = string.Format("select * from MyToolRecord where userId='{0}' and toolId={1} and recordDateTime='{2}'", userid, id, currentString); ds = db.executeSqlQuery(sql); if (ds.Tables[0].Rows.Count > 0) { string status = ds.Tables[0].Rows[0]["status"].ToString(); if (status.Equals("0")) { status = "未完成"; listColors.Add("#c9302c"); } else { status = "已完成"; listColors.Add("#5cb85c"); } listDays.Add(currentString); listStatus.Add(status); } else { listDays.Add(currentString); listStatus.Add("未打卡"); listColors.Add("rgba(117,197,240,1)"); } } if (listDays.Count < 7) { int leftDays = 7 - listDays.Count; now = DateTime.Now; for (int i = 0; i < leftDays; i++) { now = now.AddDays(7); string currentString = now.Year + "-" + now.Month + "-" + now.Day; listDays.Insert(0, currentString); listStatus.Insert(0, "未打卡"); listColors.Insert(0, "rgba(117,197,240,1)"); } } } } }
protected void Page_Load(object sender, EventArgs e) { string topicId = Request["id"].ToString(); string userId = Request["userid"].ToString(); string type = Request["type"].ToString(); fromSource = Request["from"]; DBUtil db = new DBUtil(); int resultType = 1; DataSet dst = db.executeSqlQuery("select * from Topics where Id=" + topicId); int maxOptionScore = -1; int totalChooseItem = -1; string resultChart = ""; if (dst.Tables[0].Rows.Count > 0) { resultType = Convert.ToInt32(dst.Tables[0].Rows[0]["resulttype"].ToString()); string introductionTitle = dst.Tables[0].Rows[0]["introductionTitleImage"].ToString(); string resultImage = dst.Tables[0].Rows[0]["resultPageImage"].ToString(); totalChooseItem = Convert.ToInt32(dst.Tables[0].Rows[0]["TotalChooseItem"]); resultChart = dst.Tables[0].Rows[0]["resultChartIntroductionImage"].ToString(); topicTitle = dst.Tables[0].Rows[0]["title"].ToString(); try { maxOptionScore = Convert.ToInt32(dst.Tables[0].Rows[0]["optionMaxScore"]); } catch (Exception ex) { maxOptionScore = totalChooseItem; } Panel titlePanel = new Panel(); Image titleImage = new Image(); titleImage.ImageUrl = "assets/" + introductionTitle; titlePanel.CssClass = "test-option-page-title-img"; titlePanel.Controls.Add(titleImage); this.titleDiv.Controls.Add(titlePanel); if (!topicId.Equals("8")) { Panel imgPanel = new Panel(); Image image = new Image(); image.ImageUrl = "assets/" + resultImage; imgPanel.CssClass = "test-img"; imgPanel.Controls.Add(image); this.titleDiv.Controls.Add(imgPanel); } } if (type.Equals("1")) { DataSet ds = db.executeSqlQuery("select * from ChooseItem where topicId=" + topicId); Dictionary<int, int> scores = new Dictionary<int, int>(); if (ds.Tables[0].Rows.Count > 0) { for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { int position = Convert.ToInt32(ds.Tables[0].Rows[i]["itemPosition"].ToString()); int score = Convert.ToInt32(ds.Tables[0].Rows[i]["ItemScore"].ToString()); scores.Add(position, score); } ds = db.executeSqlQuery("select * from Votes where userId='" + userId + "' and TopicId=" + topicId); if (ds.Tables[0].Rows.Count > 0) { int totalScore = 0; Dictionary<int, int> choosePositionMap = new Dictionary<int, int>(); for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { int optionId = Convert.ToInt32(ds.Tables[0].Rows[i]["OptionId"].ToString()); int choosePosition = Convert.ToInt32(ds.Tables[0].Rows[i]["ChooseItemPosition"].ToString()); totalScore += scores[choosePosition]; choosePositionMap.Add(optionId, choosePosition); } /*总分板块*/ ds = db.executeSqlQuery("select * from Dimensions where TopicId=" + topicId); if (ds.Tables[0].Rows.Count > 1) { int dimensionCount = ds.Tables[0].Rows.Count; Dictionary<int, int> dimensionScores = new Dictionary<int, int>(); Dictionary<int, string> dimensionNames = new Dictionary<int, string>(); Dictionary<int, string> dimensionDescs = new Dictionary<int, string>(); Dictionary<int, string> dimensionImages = new Dictionary<int, string>(); Dictionary<int, int> dimensionOptionCount = new Dictionary<int, int>(); string chartLabelString = "" ; string chartScoreRaderString = ""; List<string> chartScoreString = new List<string>(); StringBuilder strBuilder = new StringBuilder(); StringBuilder strBuilder2 = new StringBuilder(); for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { int dimensionId = Convert.ToInt32(ds.Tables[0].Rows[i]["id"]); string dimensionName = ds.Tables[0].Rows[i]["DimensionName"].ToString(); string dimensionDesc = ds.Tables[0].Rows[i]["DimensionDesc"].ToString(); string optionIdList = ds.Tables[0].Rows[i]["OptionIdList"].ToString(); string dimensionImage = ds.Tables[0].Rows[i]["DimensionImage"].ToString(); string[] options = optionIdList.Split(','); int[] optionIDInt = new int[options.Length]; int dimensionScore = 0; for (int j = 0; j < options.Length; j++) { optionIDInt[j] = Convert.ToInt32(options[j]); dimensionScore += scores[choosePositionMap[optionIDInt[j]]]; } dimensionScores.Add(dimensionId, dimensionScore); dimensionNames.Add(dimensionId, dimensionName); dimensionDescs.Add(dimensionId, dimensionDesc); dimensionImages.Add(dimensionId, dimensionImage); dimensionOptionCount.Add(dimensionId, options.Length); int chartScore = (dimensionScore * 100) / (options.Length * maxOptionScore); if (ds.Tables[0].Rows.Count == 3) { if (i % 3 == 0) { strBuilder.Append("\"").Append(dimensionName).Append(" "); chartScoreString.Add(chartScore.ToString()); } else if ( i % 3 == 1 ) { strBuilder.Append(dimensionName).Append(" "); chartScoreString.Add(chartScore.ToString()); } else { strBuilder.Append(dimensionName).Append("\""); chartScoreString.Add(chartScore.ToString()); } } if (ds.Tables[0].Rows.Count > 4) { strBuilder.Append("\"").Append(dimensionName).Append("\","); strBuilder2.Append(chartScore).Append(","); } } chartLabelString = strBuilder.ToString(); chartScoreRaderString = strBuilder2.ToString(); if(resultType == 2) { StringBuilder chartJs = new StringBuilder(); chartJs.Append("<script>").Append("\r\n") .Append("var barChartData = {").Append("\r\n") .Append("labels : [").Append("\" \"").Append("],").Append("\r\n") .Append("datasets : [").Append("\r\n"); if (dimensionNames.Keys.Count == 3) { chartJs.Append("{").Append("\r\n") .Append("fillColor : \"rgba(217,179,242,0.5)\",").Append("\r\n") .Append("strokeColor : \"rgba(217,179,242,0.8)\",").Append("\r\n") .Append("highlightFill: \"rgba(217,179,242,0.75)\",").Append("\r\n") .Append("highlightStroke: \"rgba(217,179,242,,1)\",").Append("\r\n") .Append("data : [").Append(chartScoreString[0]).Append("]").Append("\r\n") .Append("},").Append("\r\n"); chartJs.Append("{").Append("\r\n") .Append("fillColor : \"rgba(108,198,232,0.5)\",").Append("\r\n") .Append("strokeColor : \"rgba(108,198,232,0.8)\",").Append("\r\n") .Append("highlightFill: \"rgba(108,198,232,0.75)\",").Append("\r\n") .Append("highlightStroke: \"rgba(108,198,232,1)\",").Append("\r\n") .Append("data : [").Append(chartScoreString[1]).Append("]").Append("\r\n") .Append("},").Append("\r\n"); chartJs.Append("{").Append("\r\n") .Append("fillColor : \"rgba(238,159,102,0.5)\",").Append("\r\n") .Append("strokeColor : \"rgba(238,159,102,0.8)\",").Append("\r\n") .Append("highlightFill: \"rgba(238,159,102,0.75)\",").Append("\r\n") .Append("highlightStroke: \"rgba(238,159,102,1)\",").Append("\r\n") .Append("data : [").Append(chartScoreString[2]).Append("]").Append("\r\n") .Append("}").Append("\r\n"); } chartJs.Append("]").Append("\r\n") .Append("}").Append("\r\n") .Append("window.onload = function(){").Append("\r\n") .Append("var ctx = document.getElementById(\"canvas\").getContext(\"2d\");").Append("\r\n") .Append("window.myBar = new Chart(ctx).Bar(barChartData, {").Append("\r\n") .Append("responsive : true,").Append("\r\n") .Append("scaleGridLineColor : \"lightgrey\",").Append("\r\n") .Append("scaleGridLineWidth : 1").Append("\r\n") .Append("});").Append("\r\n") .Append("}").Append("\r\n") .Append("</script>").Append("\r\n"); chartJsString = chartJs.ToString(); } else if(resultType == 3 || resultType==1) { StringBuilder chartJs = new StringBuilder(); chartJs.Append("<script>").Append("\r\n") .Append("var radarChartData = {").Append("\r\n") .Append("labels: [").Append(chartLabelString.Substring(0, chartLabelString.Length - 1)).Append("],").Append("\r\n") .Append("datasets: [").Append("\r\n") .Append("{").Append("\r\n") .Append("label: \"My First dataset\",").Append("\r\n") .Append("fillColor: \"rgba(217,179,242,0.5)\",").Append("\r\n") .Append("strokeColor: \"rgba(217,179,242,0.8)\",").Append("\r\n") .Append("pointColor: \"rgba(217,179,242,1)\",").Append("\r\n") .Append("pointStrokeColor: \"#fff\",").Append("\r\n") .Append("pointHighlightFill: \"#fff\",").Append("\r\n") .Append("pointHighlightStroke: \"rgba(220,220,220,1)\",").Append("\r\n") .Append("data: [").Append(chartScoreRaderString.Substring(0, chartScoreRaderString.Length - 1)).Append("]").Append("\r\n") .Append("}").Append("\r\n") .Append("]").Append("\r\n") .Append("};").Append("\r\n") .Append("window.onload = function(){") .Append("window.myRadar = new Chart(document.getElementById(\"canvas\").getContext(\"2d\")).Radar(radarChartData, {").Append("\r\n") .Append("responsive: true").Append("\r\n") .Append("});").Append("\r\n") .Append("}").Append("\r\n") .Append("</script>").Append("\r\n"); chartJsString = chartJs.ToString(); } if (resultType == 2) { Panel resultChartTipImagePanel = new Panel(); Image resultChartTipImage = new Image(); resultChartTipImage.ImageUrl = "assets/" + resultChart; resultChartTipImagePanel.CssClass = "result-chart-tip-Image-panel"; resultChartTipImagePanel.Controls.Add(resultChartTipImage); this.titleDiv.Controls.Add(resultChartTipImagePanel); } Panel dimensionTipImagePanel = new Panel(); Image dimensionTipImage = new Image(); dimensionTipImage.ImageUrl = "assets/result-tip.jpg"; dimensionTipImagePanel.CssClass = "result-tip-Image-panel"; dimensionTipImagePanel.Controls.Add(dimensionTipImage); this.form1.Controls.Add(dimensionTipImagePanel); if (resultType == 3) { Panel dimensionScorePanel = new Panel(); dimensionScorePanel.CssClass = "dimension-score-panel"; Panel dimensionImagePanel = new Panel(); Image tempImg = new Image(); tempImg.ImageUrl = "assets/totalScore.jpg"; dimensionImagePanel.CssClass = "dimension-Image-panel"; dimensionImagePanel.Controls.Add(tempImg); dimensionScorePanel.Controls.Add(dimensionImagePanel); Panel totalScorePanel = new Panel(); totalScorePanel.CssClass = "dimension-score-panel-score"; Label weightTitle = new Label(); weightTitle.Text = "得分:"; weightTitle.CssClass = "bold-text"; Label label = new Label(); label.Text = totalScore + "分"; totalScorePanel.Controls.Add(weightTitle); totalScorePanel.Controls.Add(label); if (resultType != 2) { dimensionScorePanel.Controls.Add(totalScorePanel); } /*总分板块*/ ds = db.executeSqlQuery("select * from UserTopicScore where userId='" + userId + "' and topicId=" + topicId); if (ds.Tables[0].Rows.Count > 0) { db.executeSqlNonQuery("update UserTopicScore set score=" + totalScore + " where userId='" + userId + "' and topicId=" + topicId); } else { db.executeSqlNonQuery("insert into UserTopicScore(userId,topicId,Score) values('" + userId + "'," + topicId + "," + totalScore + ")"); } ds = db.executeSqlQuery("select count(Id) as totalCount from UserTopicScore where topicId=" + topicId); if (ds.Tables[0].Rows.Count > 0) { int totalPersons = Convert.ToInt32(ds.Tables[0].Rows[0][0]); ds = db.executeSqlQuery("select count(Id) as totalCount from UserTopicScore where topicId=" + topicId + " and Score<" + totalScore); if (ds.Tables[0].Rows.Count > 0) { int lessScorePersons = Convert.ToInt32(ds.Tables[0].Rows[0][0]); int beat = lessScorePersons * 100 / (totalPersons); if (totalPersons == 1) beat = 100; Panel totalScoreBeatPanel = new Panel(); totalScoreBeatPanel.CssClass = "result-dimension-score-beat-panel"; weightTitle = new Label(); weightTitle.Text = "比较:"; weightTitle.CssClass = "bold-text"; Label temp = new Label(); temp.Text = "击败了全国" + beat + "%的选手!"; totalScoreBeatPanel.Controls.Add(weightTitle); totalScoreBeatPanel.Controls.Add(temp); if (resultType != 2) { dimensionScorePanel.Controls.Add(totalScoreBeatPanel); } } } this.form1.Controls.Add(dimensionScorePanel); } List<string> maxScoresDimensions = new List<string>(); int maxScore = -9999; foreach(KeyValuePair<int,int> pair in dimensionScores) { int dimensionId = pair.Key; int dimensionScore = pair.Value; if (dimensionScore > maxScore) { maxScore = dimensionScore; } ds = db.executeSqlQuery("select * from TopicDimensionScores where dimensionId=" + dimensionId + " and TopicId=" + topicId + " and minScore<=" + dimensionScore + " and maxScore>=" + dimensionScore); if (ds.Tables[0].Rows.Count > 0) { string dimensionName = dimensionNames[dimensionId]; string dimensionDesc = dimensionDescs[dimensionId]; string dimensionScoreDesc = ds.Tables[0].Rows[0]["ScoreDesc"].ToString(); Panel dimensionScorePanel = new Panel(); dimensionScorePanel.CssClass = "dimension-score-panel"; Panel dimensionImagePanel = new Panel(); Image tempImg = new Image(); tempImg.ImageUrl = "assets/"+dimensionImages[dimensionId]; dimensionImagePanel.CssClass = "dimension-Image-panel"; dimensionImagePanel.Controls.Add(tempImg); dimensionScorePanel.Controls.Add(dimensionImagePanel); Panel dimensionDescPanel = new Panel(); Label temp = new Label(); temp.Text = dimensionDesc; dimensionDescPanel.CssClass = "dimension-score-panel-desc"; dimensionDescPanel.Controls.Add(temp); dimensionScorePanel.Controls.Add(dimensionDescPanel); Panel dimensionScoreDescPanel = new Panel(); temp = new Label(); temp.Text = dimensionScoreDesc; dimensionScoreDescPanel.Controls.Add(temp); dimensionScorePanel.Controls.Add(dimensionScoreDescPanel); this.form1.Controls.Add(dimensionScorePanel); } else { string dimensionName = dimensionNames[dimensionId]; string dimensionDesc = dimensionDescs[dimensionId]; Panel dimensionScorePanel = new Panel(); dimensionScorePanel.CssClass = "dimension-score-panel"; /* Panel dimensionImagePanel = new Panel(); Image tempImg = new Image(); tempImg.ImageUrl = "assets/" + dimensionImages[dimensionId]; dimensionImagePanel.CssClass = "dimension-Image-panel"; dimensionImagePanel.Controls.Add(tempImg); dimensionScorePanel.Controls.Add(dimensionImagePanel); */ if (!topicId.Equals("8")) { Panel dimensionNamePanel = new Panel(); dimensionNamePanel.CssClass = "dimension-score-panel-score"; Label weightTitle1 = new Label(); weightTitle1.Text = dimensionName; weightTitle1.CssClass = "bold-text"; dimensionNamePanel.Controls.Add(weightTitle1); dimensionScorePanel.Controls.Add(dimensionNamePanel); Panel dimensionScoreTempPanel = new Panel(); dimensionScoreTempPanel.CssClass = "dimension-score-panel-score"; Label weightTitle = new Label(); weightTitle.Text = "得分:"; weightTitle.CssClass = "bold-text"; Label temp = new Label(); temp.Text = (dimensionScores[dimensionId] * 100) / (dimensionOptionCount[dimensionId] * maxOptionScore) + "分"; dimensionScoreTempPanel.Controls.Add(weightTitle); dimensionScoreTempPanel.Controls.Add(temp); dimensionScorePanel.Controls.Add(dimensionScoreTempPanel); } if (resultType == 3 || resultType == 2) { ds = db.executeSqlQuery("select * from UserTopicDimensionScore where userId='" + userId + "' and topicId=" + topicId + " and dimensionId=" + dimensionId); if (ds.Tables[0].Rows.Count > 0) { db.executeSqlNonQuery("update UserTopicDimensionScore set score=" + totalScore + " where userId='" + userId + "' and topicId=" + topicId + " and dimensionId=" + dimensionId); } else { db.executeSqlNonQuery("insert into UserTopicDimensionScore(userId,topicId,dimensionId,Score) values('" + userId + "'," + topicId + "," + dimensionId + "," + totalScore + ")"); } ds = db.executeSqlQuery("select count(Id) as totalCount from UserTopicDimensionScore where topicId=" + topicId + " and dimensionId=" + dimensionId); if (ds.Tables[0].Rows.Count > 0) { int totalPersons = Convert.ToInt32(ds.Tables[0].Rows[0][0]); ds = db.executeSqlQuery("select count(Id) as totalCount from UserTopicDimensionScore where topicId=" + topicId + " and Score<" + totalScore + " and dimensionId=" + dimensionId); if (ds.Tables[0].Rows.Count > 0) { int lessScorePersons = Convert.ToInt32(ds.Tables[0].Rows[0][0]); int beat = lessScorePersons * 100 / (totalPersons); if (totalPersons == 1) beat = 100; Panel totalScoreBeatPanel = new Panel(); totalScoreBeatPanel.CssClass = "result-dimension-score-beat-panel"; Label temp = new Label(); temp.Text = "击败了全国" + beat + "%的选手!"; Label weightTitle = new Label(); weightTitle.Text = "比较:"; weightTitle.CssClass = "bold-text"; totalScoreBeatPanel.Controls.Add(weightTitle); totalScoreBeatPanel.Controls.Add(temp); dimensionScorePanel.Controls.Add(totalScoreBeatPanel); } } } if(resultType !=3 && !topicId.Equals("8")) { Panel dimensionDescPanel = new Panel(); dimensionDescPanel.CssClass = "dimension-score-panel-desc"; Label temp = new Label(); temp.Text = dimensionDesc; Label weightTitle = new Label(); weightTitle.Text = "解释:"; weightTitle.CssClass = "bold-text"; dimensionDescPanel.Controls.Add(weightTitle); dimensionDescPanel.Controls.Add(temp); dimensionScorePanel.Controls.Add(dimensionDescPanel); } if (topicId.Equals("8") && (!added)) { string resultString = ""; if (dimensionScores[21] > 0) { resultString += "E"; } else { resultString += "I"; } if (dimensionScores[22] > 0) { resultString += "S"; } else { resultString += "N"; } if (dimensionScores[23] > 0) { resultString += "T"; } else { resultString += "F"; } if (dimensionScores[24] > 0) { resultString += "J"; } else { resultString += "P"; } Panel dimensionScoreTempPanel = new Panel(); dimensionScoreTempPanel.CssClass = "dimension-score-panel-score"; Label weightTitle = new Label(); weightTitle.Text = "人格类型:"; weightTitle.CssClass = "bold-text"; Label temp = new Label(); temp.Text = resultString; dimensionScoreTempPanel.Controls.Add(weightTitle); dimensionScoreTempPanel.Controls.Add(temp); dimensionScorePanel.Controls.Add(dimensionScoreTempPanel); string descString =""; if(resultString.Equals("ISTJ")) { descString= "安静、严肃,通过全面性和可靠性获得成功。实际,有责任感。决定有逻辑性,并一步步地朝着目标前进,不易分心。喜欢将工作、家庭和生活都安排得井井有条。重视传统和忠诚。";} else if(resultString.Equals("ISFJ")) {descString= "安静、友好、有责任感和良知。坚定地致力于完成他们的义务。全面、勤勉、精确,忠诚、体贴,留心和记得他们重视的人的小细节,关心他人的感受。努力把工作和家庭环境营造得有序而温馨。"; } else if(resultString.Equals("INFJ")) { descString= "寻求思想、关系、物质等之间的意义和联系。希望了解什么能够激励人,对人有很强的洞察力。有责任心,坚持自己的价值观。对于怎样更好的服务大众有清晰的远景。在对于目标的实现过程中有计划而且果断坚定。"; } else if(resultString.Equals("INTJ")) { descString = "在实现自己的想法和达成自己的目标时有创新的想法和非凡的动力。能很快洞察到外界事物间的规律并形成长期的远景计划。一旦决定做一件事就会开始规划并直到完成为止。多疑、独立,对于自己和他人能力和表现的要求都非常高。"; } else if(resultString.Equals("ISTP")) { descString = "灵活、忍耐力强,是个安静的观察者直到有问题发生,就会马上行动,找到实用的解决方法。分析事物运作的原理,能从大量的信息中很快的找到关键的症结所在。对于原因和结果感兴趣,用逻辑的方式处理问题,重视效率。"; } else if(resultString.Equals("ISFP")) { descString = "安静、友好、敏感、和善。享受当前。喜欢有自己的空间,喜欢能按照自己的时间表工作。对于自己的价值观和自己觉得重要的人非常忠诚,有责任心。不喜欢争论和冲突。不会将自己的观念和价值观强加到别人身上。"; } else if(resultString.Equals("INFP")) { descString = "理想主义,对于自己的价值观和自己觉得重要的人非常忠诚。希望外部的生活和自己内心的价值观是统一的。好奇心重,很快能看到事情的可能性,能成为实现想法的催化剂。寻求理解别人和帮助他们实现潜能。适应力强,灵活,善于接受,除非是有悖于自己的价值观的。"; } else if(resultString.Equals("INTP")) { descString = "对于自己感兴趣的任何事物都寻求找到合理的解释。喜欢理论性的和抽象的事物,热衷于思考而非社交活动。安静、内向、灵活、适应力强。对于自己感兴趣的领域有超凡的集中精力深度解决问题的能力。多疑,有时会有点挑剔,喜欢分析。"; } else if(resultString.Equals("ESTP")) { descString= "灵活、忍耐力强,实际,注重结果。觉得理论和抽象的解释非常无趣。喜欢积极地采取行动解决问题。注重当前,自然不做作,享受和他人在一起的时刻。喜欢物质享受和时尚。学习新事物最有效的方式是通过亲身感受和练习。"; } else if(resultString.Equals("ESFP")) { descString = "外向、友好、接受力强。热爱生活、人类和物质上的享受。喜欢和别人一起将事情做成功。在工作中讲究常识和实用性,并使工作显得有趣。灵活、自然不做作,对于新的任何事物都能很快地适应。学习新事物最有效的方式是和他人一起尝试。"; } else if(resultString.Equals("ENFP")) { descString= "热情洋溢、富有想象力。认为人生有很多的可能性。能很快地将事情和信息联系起来,然后很自信地根据自己的判断解决问题。总是需要得到别人的认可,也总是准备着给与他人赏识和帮助。灵活、自然不做作,有很强的即兴发挥的能力,言语流畅。"; } else if(resultString.Equals("ENTP")) { descString = "反应快、睿智,有激励别人的能力,警觉性强、直言不讳。在解决新的、具有挑战性的问题时机智而有策略。善于找出理论上的可能性,然后再用战略的眼光分析。善于理解别人。不喜欢例行公事,很少会用相同的方法做相同的事情,倾向于一个接一个的发展新的爱好。"; } else if(resultString.Equals("ESTJ")) { descString = "实际、现实主义。果断,一旦下决心就会马上行动。善于将项目和人组织起来将事情完成,并尽可能用最有效率的方法得到结果。注重日常的细节。有一套非常清晰的逻辑标准,有系统性地遵循,并希望他人也同样遵循。在实施计划时强而有力。"; } else if(resultString.Equals("ESFJ")) { descString = "热心肠、有责任心、合作。希望周边的环境温馨而和谐,并为此果断地执行。喜欢和他人一起精确并及时地完成任务。事无巨细都会保持忠诚。能体察到他人在日常生活中的所需并竭尽全力帮助。希望自己和自己的所为能受到他人的认可和赏识。"; } else if(resultString.Equals("ENFJ")) { descString="热情、为他人着想、易感应、有责任心。非常注重他人的感情、需求和动机。善于发现他人的潜能,并希望能帮助他们实现。能成为个人或群体成长和进步的催化剂。忠诚,对于赞扬和批评都会积极地回应。友善、好社交。在团体中能很好地帮助他人,并有鼓舞他人的领导能力。"; } else if (resultString.Equals("ENTJ")) { descString = "坦诚、果断,有天生的领导能力。能很快看到公司/组织程序和政策中的不合理性和低效能性,发展并实施有效和全面的系统来解决问题。善于做长期的计划和目标的设定。通常见多识广,博览群书,喜欢拓广自己的知识面并将此分享给他人。在陈述自己的想法时非常强而有力。"; } Panel dimensionDescPanel = new Panel(); dimensionDescPanel.CssClass = "dimension-score-panel-desc"; temp = new Label(); temp.Text = descString; weightTitle = new Label(); weightTitle.Text = "解释:"; weightTitle.CssClass = "bold-text"; dimensionDescPanel.Controls.Add(weightTitle); dimensionDescPanel.Controls.Add(temp); dimensionScorePanel.Controls.Add(dimensionDescPanel); added = true; } this.form1.Controls.Add(dimensionScorePanel); } } /*if (resultType == 2) { string maxScoreDimensions = ""; foreach (KeyValuePair<int, int> pair in dimensionScores) { int dimensionId = pair.Key; int dimensionScore = pair.Value; if (dimensionScore == maxScore) { maxScoreDimensions += dimensionNames[dimensionId] + " "; } } Panel dimensionTotalPanel = new Panel(); dimensionTotalPanel.CssClass = "dimension-head-panel"; Label dimensionTotalLabel = new Label(); dimensionTotalLabel.Text = "总体说明"; dimensionTotalPanel.Controls.Add(dimensionTotalLabel); this.form1.Controls.Add(dimensionTotalPanel); Panel tempPanel = new Panel(); Label totalScoreDesc = new Label(); tempPanel.CssClass = "dimension-total-desc"; totalScoreDesc.Text = "总体上你状态处于:" + maxScoreDimensions; tempPanel.Controls.Add(totalScoreDesc); this.form1.Controls.Add(tempPanel); }*/ } /*if (resultType != 2) { Panel totalHeaderPanel = new Panel(); totalHeaderPanel.CssClass = "dimension-head-panel"; Label totalHeaderLabel = new Label(); totalHeaderLabel.Text = "总体说明"; totalHeaderPanel.Controls.Add(totalHeaderLabel); this.form1.Controls.Add(totalHeaderPanel); }*/ if (resultType != 3) {/* Panel totalScorePanel = new Panel(); totalScorePanel.CssClass = "result-total-score-panel"; Label label = new Label(); label.Text = "您的总分是:" + totalScore + "分"; totalScorePanel.Controls.Add(label); if (resultType != 2) { this.form1.Controls.Add(totalScorePanel); } ds = db.executeSqlQuery("select * from UserTopicScore where userId='" + userId + "' and topicId=" + topicId); if (ds.Tables[0].Rows.Count > 0) { db.executeSqlNonQuery("update UserTopicScore set score=" + totalScore + " where userId='" + userId + "' and topicId=" + topicId); } else { db.executeSqlNonQuery("insert into UserTopicScore(userId,topicId,Score) values('" + userId + "'," + topicId + "," + totalScore + ")"); } ds = db.executeSqlQuery("select count(Id) as totalCount from UserTopicScore where topicId=" + topicId); if (ds.Tables[0].Rows.Count > 0) { int totalPersons = Convert.ToInt32(ds.Tables[0].Rows[0][0]); ds = db.executeSqlQuery("select count(Id) as totalCount from UserTopicScore where topicId=" + topicId + " and Score<" + totalScore); if (ds.Tables[0].Rows.Count > 0) { int lessScorePersons = Convert.ToInt32(ds.Tables[0].Rows[0][0]); int beat = lessScorePersons * 100 / (totalPersons); if (totalPersons == 1) beat = 100; Panel totalScoreBeatPanel = new Panel(); totalScoreBeatPanel.CssClass = "result-total-score-beat-panel"; Label temp = new Label(); temp.Text = "您的总分打败了全国" + beat + "%的选手!"; totalScoreBeatPanel.Controls.Add(temp); if (resultType != 2) { this.form1.Controls.Add(totalScoreBeatPanel); } } }*/ } if (resultType != 3) { ds = db.executeSqlQuery("select * from TopicScores where TopicId=" + topicId + " and minScore<=" + totalScore + " and maxScore>=" + totalScore); if (ds.Tables[0].Rows.Count > 0) { Panel totalScoreDescPanel = new Panel(); totalScoreDescPanel.CssClass = "result-total-score-desc-panel"; Label totalScoreDesc = new Label(); if (resultType == 3) { totalScoreDesc.Text = "您的生活满意度为:" + ds.Tables[0].Rows[0]["ScoreDesc"].ToString(); } else { totalScoreDesc.Text = ds.Tables[0].Rows[0]["ScoreDesc"].ToString(); } totalScoreDescPanel.Controls.Add(totalScoreDesc); this.form1.Controls.Add(totalScoreDescPanel); } } } } } }
protected void startTest(object sender, EventArgs e) { Button button = (Button)sender; string[] ids = button.ID.Split('_'); int id = Convert.ToInt32(ids[0].Replace("RadioGroup", "")); int checkedindex = Convert.ToInt32(ids[1].Replace("RadioOption", "")); int totalChooseItem = Convert.ToInt32(Request["totalChooseItem"].ToString()); int totalOptions = Convert.ToInt32(Request["totalOptions"].ToString()); if (ViewState[id.ToString()] == null) { ViewState.Add(id.ToString(), checkedindex); } else { ViewState[id.ToString()] = checkedindex; } /*for (int i = 1; i <= totalChooseItem; i++) { if (((RadioButton)form1.FindControl("RadioGroup" + id + "_RadioOption" + i)).Checked) { ViewState.Add(id.ToString(), i); } }*/ form1.FindControl("OptionOrder" + id).Visible = false; if (id< totalOptions) { form1.FindControl("OptionOrder" + (id+ 1)).Visible = true; } else { string userid=Request["userId"].ToString(); DBUtil db = new DBUtil(); db.executeSqlNonQuery("delete from Votes where userId='" + userid + "' and TopicId=" + Request["id"].ToString()); for (int i = 1; i <= totalOptions; i++) { int chooseItem = Convert.ToInt32(ViewState[i.ToString()]); db.executeSqlNonQuery("insert into Votes(userId,TopicId,OptionId,ChooseItemPosition) values('" + userid + "'," + Request["id"].ToString() + "," + i+","+chooseItem+")"); } if ("9".Equals(Request["id"].ToString())) { Response.Redirect("world-result.aspx?id=" + Request["id"].ToString() + "&userid=" + userid + "&type=" + Request["type"].ToString()); } else if("10".Equals(Request["id"].ToString())) { Response.Redirect("perfect-result.aspx?id=" + Request["id"].ToString() + "&userid=" + userid + "&type=" + Request["type"].ToString()); } else if( "2".Equals(Request["id"].ToString())) { Response.Redirect("happy-feeling-result.aspx?id=" + Request["id"].ToString() + "&userid=" + userid + "&type=" + Request["type"].ToString()); } else if ("5".Equals(Request["id"].ToString())) { Response.Redirect("work-result.aspx?id=" + Request["id"].ToString() + "&userid=" + userid + "&type=" + Request["type"].ToString()); } else if ("3".Equals(Request["id"].ToString())) { Response.Redirect("life-result.aspx?id=" + Request["id"].ToString() + "&userid=" + userid + "&type=" + Request["type"].ToString()); } else { Response.Redirect("result.aspx?id=" + Request["id"].ToString() + "&userid=" + userid + "&type=" + Request["type"].ToString()); } } }
protected void Page_Load(object sender, EventArgs e) { string topicId = Request["id"].ToString(); string userId = Request["userid"].ToString(); if (userId == null || userId.Equals("")) { userId = "om8uZt7fajggMH8vqjFb1afiE8y4"; } JObject obj = WeixinUtil.getUserInfo(userId); userImageUrl = obj.GetValue("headimgurl").ToString(); userNickName = obj.GetValue("nickname").ToString(); string type = Request["type"].ToString(); fromSource = Request["from"]; DBUtil db = new DBUtil(); int resultType = 1; DataSet dst = db.executeSqlQuery("select * from Topics where Id=" + topicId); int maxOptionScore = -1; int totalChooseItem = -1; string resultChart = ""; if (dst.Tables[0].Rows.Count > 0) { resultType = Convert.ToInt32(dst.Tables[0].Rows[0]["resulttype"].ToString()); string introductionTitle = dst.Tables[0].Rows[0]["introductionTitleImage"].ToString(); string resultImage = dst.Tables[0].Rows[0]["resultPageImage"].ToString(); totalChooseItem = Convert.ToInt32(dst.Tables[0].Rows[0]["TotalChooseItem"]); resultChart = dst.Tables[0].Rows[0]["resultChartIntroductionImage"].ToString(); topicTitle = dst.Tables[0].Rows[0]["title"].ToString(); try { maxOptionScore = Convert.ToInt32(dst.Tables[0].Rows[0]["optionMaxScore"]); } catch (Exception ex) { maxOptionScore = totalChooseItem; } Panel titlePanel = new Panel(); /*Label titleImage = new Label(); titleImage.Text = ""; titlePanel.CssClass = "glyphicon glyphicon-user"; titlePanel.Controls.Add(titleImage);*/ Label titleTT = new Label(); titlePanel.CssClass = "title-TT"; if (topicId.Equals("2")) titleTT.Text = "生活状态大数据"; else if (topicId.Equals("5")) titleTT.Text = "工作状态大数据"; else if (topicId.Equals("1")) titleTT.Text = "性格分析"; titlePanel.Controls.Add(titleTT); this.titleDiv.Controls.Add(titlePanel); Panel imgPanel = new Panel(); Image image = new Image(); image.ImageUrl = "assets/" + resultImage; imgPanel.CssClass = "test-img"; imgPanel.Controls.Add(image); this.titleDiv.Controls.Add(imgPanel); } if (type.Equals("1")) { DataSet ds = db.executeSqlQuery("select * from ChooseItem where topicId=" + topicId); Dictionary<int, int> scores = new Dictionary<int, int>(); if (ds.Tables[0].Rows.Count > 0) { for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { int position = Convert.ToInt32(ds.Tables[0].Rows[i]["itemPosition"].ToString()); int score = Convert.ToInt32(ds.Tables[0].Rows[i]["ItemScore"].ToString()); scores.Add(position, score); } ds = db.executeSqlQuery("select * from Votes where userId='" + userId + "' and TopicId=" + topicId); if (ds.Tables[0].Rows.Count > 0) { int totalScore = 0; Dictionary<int, int> choosePositionMap = new Dictionary<int, int>(); for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { int optionId = Convert.ToInt32(ds.Tables[0].Rows[i]["OptionId"].ToString()); int choosePosition = Convert.ToInt32(ds.Tables[0].Rows[i]["ChooseItemPosition"].ToString()); totalScore += scores[choosePosition]; choosePositionMap.Add(optionId, choosePosition); } /*总分板块*/ ds = db.executeSqlQuery("select * from Dimensions where TopicId=" + topicId); if (ds.Tables[0].Rows.Count > 1) { int dimensionCount = ds.Tables[0].Rows.Count; Dictionary<int, int> dimensionScores = new Dictionary<int, int>(); Dictionary<int, string> dimensionNames = new Dictionary<int, string>(); Dictionary<int, string> dimensionDescs = new Dictionary<int, string>(); Dictionary<int, string> dimensionImages = new Dictionary<int, string>(); Dictionary<int, int> dimensionOptionCount = new Dictionary<int, int>(); string chartLabelString = "" ; string chartScoreRaderString = ""; List<string> chartScoreString = new List<string>(); StringBuilder strBuilder = new StringBuilder(); StringBuilder strBuilder2 = new StringBuilder(); for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { int dimensionId = Convert.ToInt32(ds.Tables[0].Rows[i]["id"]); string dimensionName = ds.Tables[0].Rows[i]["DimensionName"].ToString(); string dimensionDesc = ds.Tables[0].Rows[i]["DimensionDesc"].ToString(); string optionIdList = ds.Tables[0].Rows[i]["OptionIdList"].ToString(); string dimensionImage = ds.Tables[0].Rows[i]["DimensionImage"].ToString(); string[] options = optionIdList.Split(','); int[] optionIDInt = new int[options.Length]; int dimensionScore = 0; for (int j = 0; j < options.Length; j++) { optionIDInt[j] = Convert.ToInt32(options[j]); if (choosePositionMap.ContainsKey(optionIDInt[j])) { dimensionScore += scores[choosePositionMap[optionIDInt[j]]]; } } dimensionScores.Add(dimensionId, dimensionScore); dimensionNames.Add(dimensionId, dimensionName); dimensionDescs.Add(dimensionId, dimensionDesc); dimensionImages.Add(dimensionId, dimensionImage); dimensionOptionCount.Add(dimensionId, options.Length); int chartScore = (dimensionScore * 100) / (2 * maxOptionScore); if (ds.Tables[0].Rows.Count > 4) { strBuilder.Append("\"").Append(dimensionName).Append("\","); strBuilder2.Append(chartScore).Append(","); } } chartLabelString = strBuilder.ToString(); chartScoreRaderString = strBuilder2.ToString(); if (topicId.Equals("2") || topicId.Equals("5") || topicId.Equals("1")) { StringBuilder chartJs = new StringBuilder(); chartJs.Append("<script>").Append("\r\n") .Append("var radarChartData = {").Append("\r\n") .Append("labels: [").Append(chartLabelString.Substring(0, chartLabelString.Length - 1)).Append("],").Append("\r\n") .Append("datasets: [").Append("\r\n") .Append("{").Append("\r\n") .Append("label: \"My First dataset\",").Append("\r\n") .Append("fillColor: \"rgba(217,179,242,0.5)\",").Append("\r\n") .Append("strokeColor: \"rgba(217,179,242,0.8)\",").Append("\r\n") .Append("pointColor: \"rgba(217,179,242,1)\",").Append("\r\n") .Append("pointStrokeColor: \"#fff\",").Append("\r\n") .Append("pointHighlightFill: \"#fff\",").Append("\r\n") .Append("pointHighlightStroke: \"rgba(220,220,220,1)\",").Append("\r\n") .Append("data: [").Append(chartScoreRaderString.Substring(0, chartScoreRaderString.Length - 1)).Append("]").Append("\r\n") .Append("}").Append("\r\n") .Append("]").Append("\r\n") .Append("};").Append("\r\n") .Append("window.onload = function(){") .Append("window.myRadar = new Chart(document.getElementById(\"canvas\").getContext(\"2d\")).Radar(radarChartData, {").Append("\r\n") .Append("responsive: true").Append("\r\n") .Append("});").Append("\r\n") .Append("}").Append("\r\n") .Append("</script>").Append("\r\n"); chartJsString = chartJs.ToString(); } Panel dimensionTipImagePanel = new Panel(); Image dimensionTipImage = new Image(); dimensionTipImage.ImageUrl = "assets/result-tip.jpg"; dimensionTipImagePanel.CssClass = "result-tip-Image-panel"; dimensionTipImagePanel.Controls.Add(dimensionTipImage); this.form1.Controls.Add(dimensionTipImagePanel); if (topicId.Equals("2") || topicId.Equals("5")) { Panel dimensionScorePanel = new Panel(); dimensionScorePanel.CssClass = "dimension-score-panel"; DataSet p = db.executeSqlQuery("select * from Users where userName='******'"); string industry = "--"; string age = "--"; string region = "--"; bool showCompare = false; if(p.Tables[0].Rows.Count>0) { region = p.Tables[0].Rows[0]["region"].ToString(); age = p.Tables[0].Rows[0]["age"].ToString(); industry = p.Tables[0].Rows[0]["industry"].ToString(); showCompare = true; } Panel personalInfoPanel = new Panel(); personalInfoPanel.CssClass = "dimension-score-panel-score"; Label personalInfo = new Label(); personalInfo.Text = "您目前的地区为:" + region + ",年龄为:" + age + ",行业为:" + industry + "。如果不准确,请到个人中心设置。"; personalInfoPanel.Controls.Add(personalInfo); dimensionScorePanel.Controls.Add(personalInfoPanel); ds = db.executeSqlQuery("select * from UserTopicScore where userId='" + userId + "' and topicId=" + topicId); if (ds.Tables[0].Rows.Count > 0) { db.executeSqlNonQuery("update UserTopicScore set score=" + totalScore + " where userId='" + userId + "' and topicId=" + topicId); } else { db.executeSqlNonQuery("insert into UserTopicScore(userId,topicId,Score) values('" + userId + "'," + topicId + "," + totalScore + ")"); } ds = db.executeSqlQuery("select count(Id) as totalCount from UserTopicScore where topicId=" + topicId); if (ds.Tables[0].Rows.Count > 0) { int totalPersons = Convert.ToInt32(ds.Tables[0].Rows[0][0]); ds = db.executeSqlQuery("select count(Id) as totalCount from UserTopicScore where topicId=" + topicId + " and Score<" + totalScore); if (ds.Tables[0].Rows.Count > 0) { int lessScorePersons = Convert.ToInt32(ds.Tables[0].Rows[0][0]); int beat = lessScorePersons * 100 / (totalPersons); if (totalPersons == 1) beat = 100; Panel totalScoreBeatPanel = new Panel(); totalScoreBeatPanel.CssClass = "result-dimension-score-beat-panel"; // weightTitle = new Label(); //weightTitle.Text = "结果:"; //weightTitle.CssClass = "bold-text"; Label temp = new Label(); string resultWord = ""; if( topicId.Equals("2") ) { resultWord = "整体幸福指数"; } else if (topicId.Equals("5")) { resultWord = "工作满意度"; } temp.Text = "您的" + resultWord + "为:"+totalScore+"分,击败了全国"+beat+"%的网友!"; //totalScoreBeatPanel.Controls.Add(weightTitle); totalScoreBeatPanel.Controls.Add(temp); if (resultType != 2) { dimensionScorePanel.Controls.Add(totalScoreBeatPanel); } } if(showCompare) { // 同地区 ds = db.executeSqlQuery("select count(UserTopicScore.Id) as totalCount from UserTopicScore, Users where Users.userName = UserTopicScore.userId and topicId=" + topicId + " and Score<" + totalScore +" and Users.region='"+region +"'"); if (ds.Tables[0].Rows.Count > 0) { int lessScorePersons = Convert.ToInt32(ds.Tables[0].Rows[0][0]); int beat = lessScorePersons * 100 / (totalPersons); if (totalPersons == 1) beat = 100; Panel totalScoreBeatPanel = new Panel(); totalScoreBeatPanel.CssClass = "result-category-score-beat-panel"; Label temp = new Label(); temp.Text = "按照地区:击败了" + beat + "%的老乡!"; totalScoreBeatPanel.Controls.Add(temp); if (resultType != 2) { dimensionScorePanel.Controls.Add(totalScoreBeatPanel); } } // 同年龄 ds = db.executeSqlQuery("select count(UserTopicScore.Id) as totalCount from UserTopicScore, Users where Users.userName = UserTopicScore.userId and topicId=" + topicId + " and Score<" + totalScore + " and Users.age='" + age + "'"); if (ds.Tables[0].Rows.Count > 0) { int lessScorePersons = Convert.ToInt32(ds.Tables[0].Rows[0][0]); int beat = lessScorePersons * 100 / (totalPersons); if (totalPersons == 1) beat = 100; Panel totalScoreBeatPanel = new Panel(); totalScoreBeatPanel.CssClass = "result-category-score-beat-panel"; Label temp = new Label(); temp.Text = "按照年龄:击败了" + beat + "%的同龄人!"; totalScoreBeatPanel.Controls.Add(temp); if (resultType != 2) { dimensionScorePanel.Controls.Add(totalScoreBeatPanel); } } // 同行业 ds = db.executeSqlQuery("select count(UserTopicScore.Id) as totalCount from UserTopicScore, Users where Users.userName = UserTopicScore.userId and topicId=" + topicId + " and Score<" + totalScore + " and Users.industry='" + industry + "'"); if (ds.Tables[0].Rows.Count > 0) { int lessScorePersons = Convert.ToInt32(ds.Tables[0].Rows[0][0]); int beat = lessScorePersons * 100 / (totalPersons); if (totalPersons == 1) beat = 100; Panel totalScoreBeatPanel = new Panel(); totalScoreBeatPanel.CssClass = "result-category-score-beat-panel"; Label temp = new Label(); temp.Text = "按照行业:击败了" + beat + "%的同行!"; totalScoreBeatPanel.Controls.Add(temp); if (resultType != 2) { dimensionScorePanel.Controls.Add(totalScoreBeatPanel); } } } } this.form1.Controls.Add(dimensionScorePanel); } Dictionary<int, string> measureMap = new Dictionary<int, string>(); ds = db.executeSqlQuery("select * from Measures where TopicId=" + topicId); for( int i = 0;i<ds.Tables[0].Rows.Count;i++) { int id = Convert.ToInt32(ds.Tables[0].Rows[i]["Id"]); string measureName = ds.Tables[0].Rows[i]["measureName"].ToString(); measureMap.Add(id, measureName); } Dictionary<int, int> measureScores = new Dictionary<int, int>(); if (topicId.Equals("2")) { measureScores.Add(1, totalScore); measureScores.Add(2, 100 - totalScore); measureScores.Add(3, dimensionScores[4]); measureScores.Add(4, (dimensionScores[7] + dimensionScores[15]) / 2); } else if (topicId.Equals("5")) { measureScores.Add(5,totalScore); measureScores.Add(6,100-totalScore); measureScores.Add(7,(dimensionScores[17] + dimensionScores[18]) / 2); measureScores.Add(8, dimensionScores[20]); } int year = DateTime.Now.Year; int month = DateTime.Now.Month; Dictionary<int, int> measureBeats = new Dictionary<int, int>(); if(topicId.Equals("2")) { ds = db.executeSqlQuery("select * from MeasureScores where measureId = 1 and YEAR(testDateTime)=" + year + " and MONTH(testDateTime)=" + month + " and topicId=" + topicId); int totalPersons = ds.Tables[0].Rows.Count; ds = db.executeSqlQuery("select * from MeasureScores where measureId = 1 and YEAR(testDateTime)=" + year + " and MONTH(testDateTime)=" + month + " and topicId=" + topicId + " and score<" + measureScores[1]); int lessPersons = ds.Tables[0].Rows.Count; if(totalPersons == 0) { measureBeats.Add(1, 100); } else { measureBeats.Add(1, lessPersons * 100 / totalPersons); } ds = db.executeSqlQuery("select * from MeasureScores where measureId = 2 and YEAR(testDateTime)=" + year + " and MONTH(testDateTime)=" + month + " and topicId=" + topicId); totalPersons = ds.Tables[0].Rows.Count; ds = db.executeSqlQuery("select * from MeasureScores where measureId = 2 and YEAR(testDateTime)=" + year + " and MONTH(testDateTime)=" + month + " and topicId=" + topicId + " and score<" + measureScores[2]); lessPersons = ds.Tables[0].Rows.Count; if (totalPersons == 0) { measureBeats.Add(2, 100); } else { measureBeats.Add(2, lessPersons * 100 / totalPersons); } ds = db.executeSqlQuery("select * from MeasureScores where measureId = 3 and YEAR(testDateTime)=" + year + " and MONTH(testDateTime)=" + month + " and topicId=" + topicId); totalPersons = ds.Tables[0].Rows.Count; ds = db.executeSqlQuery("select * from MeasureScores where measureId = 3 and YEAR(testDateTime)=" + year + " and MONTH(testDateTime)=" + month + " and topicId=" + topicId + " and score<" + measureScores[3]); lessPersons = ds.Tables[0].Rows.Count; if (totalPersons == 0) { measureBeats.Add(3, 100); } else { measureBeats.Add(3, lessPersons * 100 / totalPersons); } ds = db.executeSqlQuery("select * from MeasureScores where measureId = 4 and YEAR(testDateTime)=" + year + " and MONTH(testDateTime)=" + month + " and topicId=" + topicId); totalPersons = ds.Tables[0].Rows.Count; ds = db.executeSqlQuery("select * from MeasureScores where measureId = 4 and YEAR(testDateTime)=" + year + " and MONTH(testDateTime)=" + month + " and topicId=" + topicId + " and score<" + measureScores[4]); lessPersons = ds.Tables[0].Rows.Count; if (totalPersons == 0) { measureBeats.Add(4, 100); } else { measureBeats.Add(4, lessPersons * 100 / totalPersons); } } else if (topicId.Equals("5")) { ds = db.executeSqlQuery("select * from MeasureScores where measureId = 5 and YEAR(testDateTime)=" + year + " and MONTH(testDateTime)=" + month + " and topicId=" + topicId); int totalPersons = ds.Tables[0].Rows.Count; ds = db.executeSqlQuery("select * from MeasureScores where measureId = 5 and YEAR(testDateTime)=" + year + " and MONTH(testDateTime)=" + month + " and topicId=" + topicId + " and score<" + measureScores[5]); int lessPersons = ds.Tables[0].Rows.Count; if (totalPersons == 0) { measureBeats.Add(5, 100); } else { measureBeats.Add(5, lessPersons * 100 / totalPersons); } ds = db.executeSqlQuery("select * from MeasureScores where measureId = 6 and YEAR(testDateTime)=" + year + " and MONTH(testDateTime)=" + month + " and topicId=" + topicId); totalPersons = ds.Tables[0].Rows.Count; ds = db.executeSqlQuery("select * from MeasureScores where measureId = 6 and YEAR(testDateTime)=" + year + " and MONTH(testDateTime)=" + month + " and topicId=" + topicId + " and score<" + measureScores[6]); lessPersons = ds.Tables[0].Rows.Count; if (totalPersons == 0) { measureBeats.Add(6, 100); } else { measureBeats.Add(6, lessPersons * 100 / totalPersons); } ds = db.executeSqlQuery("select * from MeasureScores where measureId = 7 and YEAR(testDateTime)=" + year + " and MONTH(testDateTime)=" + month + " and topicId=" + topicId); totalPersons = ds.Tables[0].Rows.Count; ds = db.executeSqlQuery("select * from MeasureScores where measureId = 7 and YEAR(testDateTime)=" + year + " and MONTH(testDateTime)=" + month + " and topicId=" + topicId + " and score<" + measureScores[7]); lessPersons = ds.Tables[0].Rows.Count; if (totalPersons == 0) { measureBeats.Add(7, 100); } else { measureBeats.Add(7, lessPersons * 100 / totalPersons); } ds = db.executeSqlQuery("select * from MeasureScores where measureId = 8 and YEAR(testDateTime)=" + year + " and MONTH(testDateTime)=" + month + " and topicId=" + topicId); totalPersons = ds.Tables[0].Rows.Count; ds = db.executeSqlQuery("select * from MeasureScores where measureId = 8 and YEAR(testDateTime)=" + year + " and MONTH(testDateTime)=" + month + " and topicId=" + topicId + " and score<" + measureScores[8]); lessPersons = ds.Tables[0].Rows.Count; if (totalPersons == 0) { measureBeats.Add(8, 100); } else { measureBeats.Add(8, lessPersons * 100 / totalPersons); } } ds = db.executeSqlQuery("select * from MeasureScores where YEAR(testDateTime)=" + year + " and MONTH(testDateTime)=" + month + " and userId='" + userId + "' and topicId=" + topicId); if ( ds.Tables[0].Rows.Count > 0) { string deleteSql = "delete from MeasureScores where YEAR(testDateTime)=" + year + " and MONTH(testDateTime)=" + month + " and userId='" + userId + "' and topicId=" + topicId; db.executeSqlNonQuery(deleteSql); } foreach (KeyValuePair<int, int> pair in measureScores) { string insertSql = string.Format("insert into MeasureScores(topicId,measureId,userId,score,beats,testDateTime) values({0},{1},'{2}',{3},{4},'{5}')", topicId, pair.Key, userId, pair.Value,measureBeats[pair.Key],DateTime.Now.ToString()); db.executeSqlNonQuery(insertSql); } /* //List<string> maxScoresDimensions = new List<string>(); //int maxScore = -9999; foreach (KeyValuePair<int, int> pair in dimensionScores) { int dimensionId = pair.Key; int dimensionScore = pair.Value; string dimensionName = dimensionNames[dimensionId]; /* if (dimensionScore > maxScore) { maxScore = dimensionScore; } ds = db.executeSqlQuery("select * from TopicDimensionScores where dimensionId=" + dimensionId + " and TopicId=" + topicId + " and minScore<=" + dimensionScore + " and maxScore>=" + dimensionScore); if (ds.Tables[0].Rows.Count > 0) { } else { string dimensionName = dimensionNames[dimensionId]; string dimensionDesc = dimensionDescs[dimensionId]; Panel dimensionScorePanel = new Panel(); dimensionScorePanel.CssClass = "dimension-score-panel"; /*Panel dimensionImagePanel = new Panel(); Image tempImg = new Image(); tempImg.ImageUrl = "assets/" + dimensionImages[dimensionId]; dimensionImagePanel.CssClass = "dimension-Image-panel"; dimensionImagePanel.Controls.Add(tempImg); dimensionScorePanel.Controls.Add(dimensionImagePanel); Panel dimensionScoreTempPanel = new Panel(); dimensionScoreTempPanel.CssClass = "dimension-score-panel-score"; Label weightTitle = new Label(); weightTitle.Text = "得分:"; weightTitle.CssClass = "bold-text"; Label temp = new Label(); int dimensionTotalScore = (dimensionScores[dimensionId] * 100) / (2 * maxOptionScore); temp.Text = dimensionTotalScore + "分"; dimensionScoreTempPanel.Controls.Add(weightTitle); dimensionScoreTempPanel.Controls.Add(temp); dimensionScorePanel.Controls.Add(dimensionScoreTempPanel);*/ /*if (topicId.Equals("2") || topicId.Equals("5")) { ds = db.executeSqlQuery("select * from UserTopicDimensionScore where userId='" + userId + "' and topicId=" + topicId + " and dimensionId=" + dimensionId); if (ds.Tables[0].Rows.Count > 0) { db.executeSqlNonQuery("update UserTopicDimensionScore set score=" + totalScore + " where userId='" + userId + "' and topicId=" + topicId + " and dimensionId=" + dimensionId); } else { db.executeSqlNonQuery("insert into UserTopicDimensionScore(userId,topicId,dimensionId,Score) values('" + userId + "'," + topicId + "," + dimensionId + "," + totalScore + ")"); } ds = db.executeSqlQuery("select count(Id) as totalCount from UserTopicDimensionScore where topicId=" + topicId + " and dimensionId=" + dimensionId); if (ds.Tables[0].Rows.Count > 0) { int totalPersons = Convert.ToInt32(ds.Tables[0].Rows[0][0]); ds = db.executeSqlQuery("select count(Id) as totalCount from UserTopicDimensionScore where topicId=" + topicId + " and Score<" + totalScore + " and dimensionId=" + dimensionId); if (ds.Tables[0].Rows.Count > 0) { int lessScorePersons = Convert.ToInt32(ds.Tables[0].Rows[0][0]); int beat = lessScorePersons * 100 / (totalPersons); if (totalPersons == 1) beat = 100; Panel totalScoreBeatPanel = new Panel(); totalScoreBeatPanel.CssClass = "result-dimension-score-beat-panel"; temp = new Label(); temp.Text = "击败了全国" + beat + "%的选手!"; weightTitle = new Label(); weightTitle.Text = "比较:"; weightTitle.CssClass = "bold-text"; totalScoreBeatPanel.Controls.Add(weightTitle); totalScoreBeatPanel.Controls.Add(temp); dimensionScorePanel.Controls.Add(totalScoreBeatPanel); } } }*/ //this.form1.Controls.Add(dimensionScorePanel); //} } } } } }
protected void Page_Load(object sender, EventArgs e) { string code = Request["code"]; string userid = Request["userid"]; if (userid == null) { if (code == null) { Response.Redirect("https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxe29e41d979d25872&redirect_uri=http%3A%2F%2Fwww.ihappyabc.com%2Ffind-life.aspx&response_type=code&scope=snsapi_base#wechat_redirect"); } else { userid = WeixinUtil.getUserAuthorizedId(code); } } openid = userid; JObject obj = WeixinUtil.getUserInfo(userid); userImageUrl = obj.GetValue("headimgurl").ToString(); userNickName = obj.GetValue("nickname").ToString(); DBUtil db = new DBUtil(); DataSet ds = db.executeSqlQuery("select * from Users where userName='******'"); if (ds.Tables[0].Rows.Count > 0) { age = ds.Tables[0].Rows[0]["age"].ToString(); industry = ds.Tables[0].Rows[0]["industry"].ToString(); region = ds.Tables[0].Rows[0]["region"].ToString(); } string sql = "select count(Id) as total from measureScores where userId='" + userid + "' and topicId in (2,5)"; ds = db.executeSqlQuery(sql); if (ds.Tables[0].Rows.Count > 0) { testTimes = Convert.ToInt32(ds.Tables[0].Rows[0][0]) / 4; } int personalTimes = 0; sql = "select * from Votes where userId='" + userid + "' and topicId=1"; ds = db.executeSqlQuery(sql); if (ds.Tables[0].Rows.Count > 0) { personalTimes++; } sql = "select * from Votes where userId='" + userid + "' and topicId=8"; ds = db.executeSqlQuery(sql); if (ds.Tables[0].Rows.Count > 0) { personalTimes++; } selfPercent = personalTimes * 100 / 6; ds = db.executeSqlQuery("select * from Votes where userid='" + userid + "' and topicId=2"); if (ds.Tables[0].Rows.Count > 0) happyfeeling = true; ds = db.executeSqlQuery("select * from Votes where userid='" + userid + "' and topicId=5"); if (ds.Tables[0].Rows.Count > 0) work = true; ds = db.executeSqlQuery("select * from Votes where userid='" + userid + "' and topicId=3"); if (ds.Tables[0].Rows.Count > 0) life = true; ds = db.executeSqlQuery("select * from Badges where userId='" + userid + "' and topicId=2"); if (ds.Tables[0].Rows.Count > 0) { badgeNames.Add(ds.Tables[0].Rows[0]["badgeName"].ToString()); badgeCategory.Add(1); } ds = db.executeSqlQuery("select * from Badges where userId='" + userid + "' and topicId=5"); if (ds.Tables[0].Rows.Count > 0) { badgeNames.Add(ds.Tables[0].Rows[0]["badgeName"].ToString()); badgeCategory.Add(2); } ds = db.executeSqlQuery("select * from Badges where userId='" + userid + "' and topicId=3"); if (ds.Tables[0].Rows.Count > 0) { badgeNames.Add(ds.Tables[0].Rows[0]["badgeName"].ToString()); badgeCategory.Add(3); } badgeColor.Add("orangered"); badgeColor.Add("skyblue"); badgeColor.Add("orange"); badgeClass.Add("glyphicon-inbox"); badgeClass.Add("glyphicon-tower"); badgeClass.Add("glyphicon-globe"); ds = db.executeSqlQuery("select count(userId) from badges where topicId=2"); int totalPerson = 0; if (ds.Tables[0].Rows.Count > 0) { totalPerson = Convert.ToInt32(ds.Tables[0].Rows[0][0]); } ds = db.executeSqlQuery("select count(userId) from badges where topicId=2 and badgeName='非常幸福'"); int person = 0; if (ds.Tables[0].Rows.Count > 0) { person = Convert.ToInt32(ds.Tables[0].Rows[0][0]); } happy_1 = person * 100 / totalPerson; ds = db.executeSqlQuery("select count(userId) from badges where topicId=2 and badgeName='比较幸福'"); person = 0; if (ds.Tables[0].Rows.Count > 0) { person = Convert.ToInt32(ds.Tables[0].Rows[0][0]); } happy_2 = person * 100 / totalPerson; ds = db.executeSqlQuery("select count(userId) from badges where topicId=2 and badgeName='不太幸福'"); person = 0; if (ds.Tables[0].Rows.Count > 0) { person = Convert.ToInt32(ds.Tables[0].Rows[0][0]); } happy_3 = person * 100 / totalPerson; ds = db.executeSqlQuery("select count(userId) from badges where topicId=2 and badgeName='很不幸福'"); person = 0; if (ds.Tables[0].Rows.Count > 0) { person = Convert.ToInt32(ds.Tables[0].Rows[0][0]); } happy_4 = person * 100 / totalPerson; ds = db.executeSqlQuery("select count(userId) from badges where topicId=5"); totalPerson = 0; if (ds.Tables[0].Rows.Count > 0) { totalPerson = Convert.ToInt32(ds.Tables[0].Rows[0][0]); } ds = db.executeSqlQuery("select count(userId) from badges where topicId=5 and badgeName='对工作非常满意'"); person = 0; if (ds.Tables[0].Rows.Count > 0) { person = Convert.ToInt32(ds.Tables[0].Rows[0][0]); } work_1 = person * 100 / totalPerson; ds = db.executeSqlQuery("select count(userId) from badges where topicId=5 and badgeName='对工作比较满意'"); person = 0; if (ds.Tables[0].Rows.Count > 0) { person = Convert.ToInt32(ds.Tables[0].Rows[0][0]); } work_2 = person * 100 / totalPerson; ds = db.executeSqlQuery("select count(userId) from badges where topicId=5 and badgeName='对工作不太满意'"); person = 0; if (ds.Tables[0].Rows.Count > 0) { person = Convert.ToInt32(ds.Tables[0].Rows[0][0]); } work_3 = person * 100 / totalPerson; ds = db.executeSqlQuery("select count(userId) from badges where topicId=5 and badgeName='对工作很不满意'"); person = 0; if (ds.Tables[0].Rows.Count > 0) { person = Convert.ToInt32(ds.Tables[0].Rows[0][0]); } work_4 = person * 100 / totalPerson; ds = db.executeSqlQuery("select count(userId) from badges where topicId=3"); totalPerson = 0; if (ds.Tables[0].Rows.Count > 0) { totalPerson = Convert.ToInt32(ds.Tables[0].Rows[0][0]); } ds = db.executeSqlQuery("select count(userId) from badges where topicId=3 and badgeName='舒适区'"); person = 0; if (ds.Tables[0].Rows.Count > 0) { person = Convert.ToInt32(ds.Tables[0].Rows[0][0]); } life_1 = person * 100 / totalPerson; ds = db.executeSqlQuery("select count(userId) from badges where topicId=3 and badgeName='学习区'"); person = 0; if (ds.Tables[0].Rows.Count > 0) { person = Convert.ToInt32(ds.Tables[0].Rows[0][0]); } life_2 = person * 100 / totalPerson; ds = db.executeSqlQuery("select count(userId) from badges where topicId=3 and badgeName='恐慌区'"); person = 0; if (ds.Tables[0].Rows.Count > 0) { person = Convert.ToInt32(ds.Tables[0].Rows[0][0]); } life_3 = person * 100 / totalPerson; }
protected void Page_Load(object sender, EventArgs e) { string userid = Request["userid"]; if (userid == null) { userid = "om8uZt7fajggMH8vqjFb1afiE8y4"; } this.userId.Text = userid; JObject obj = WeixinUtil.getUserInfo(userid); userImageUrl = obj.GetValue("headimgurl").ToString(); userNickName = obj.GetValue("nickname").ToString(); DBUtil db = new DBUtil(); DataSet ds = db.executeSqlQuery("select * from Users where userName='******'"); if (ds.Tables[0].Rows.Count > 0) { age = ds.Tables[0].Rows[0]["age"].ToString(); industry = ds.Tables[0].Rows[0]["industry"].ToString(); region = ds.Tables[0].Rows[0]["region"].ToString(); } ds = db.executeSqlQuery("select * from Topics where Id="+Request["id"]); if (ds.Tables[0].Rows.Count > 0) { string id = ds.Tables[0].Rows[0]["Id"].ToString(); string title = ds.Tables[0].Rows[0]["title"].ToString(); string contentText = ds.Tables[0].Rows[0]["introduction"].ToString(); string introductionImg = ds.Tables[0].Rows[0]["introductionImage"].ToString(); string topicType = ds.Tables[0].Rows[0]["topictype"].ToString(); string totalChooseItems = ds.Tables[0].Rows[0]["totalChooseItem"].ToString().Trim(); string totalOptions = ds.Tables[0].Rows[0]["totalOptions"].ToString(); string introductionTitle = ds.Tables[0].Rows[0]["introductionTitleImage"].ToString(); string introductionContent =ds.Tables[0].Rows[0]["introductionContentImage"].ToString(); Panel panel = new Panel(); panel.CssClass = "content"; Panel titlePanel = new Panel(); /*Image titleImage = new Image(); titleImage.ImageUrl = "assets/" + introductionTitle; titlePanel.CssClass = "test-option-page-title-img"; titlePanel.Controls.Add(titleImage);*/ Label titleLabel = new Label(); titleLabel.Text = title; titlePanel.CssClass = "test-option-page-title-text"; titlePanel.Controls.Add(titleLabel); /* Panel introductionPanel = new Panel(); Image introduction = new Image(); introduction.ImageUrl = "assets/" + introductionContent; introductionPanel.CssClass = "test-option-page-title-img"; introductionPanel.Controls.Add(introduction); Panel imgPanel = new Panel(); Image image = new Image(); image.ImageUrl = "assets/" + introductionImg; imgPanel.CssClass = "test-img"; imgPanel.Controls.Add(image);*/ Panel tempPanel = new Panel(); tempPanel.ID = "custom-panel"; Panel buttonPanel = new Panel(); DateTime now = DateTime.Now; ds = db.executeSqlQuery("select * from MeasureScores where YEAR(testDateTime)=" + now.Year + " and MONTH(testDateTime)=" + now.Month + " and topicId=" + Request["id"] + " and userId='" + Request["userid"].ToString() + "'"); if (ds.Tables[0].Rows.Count > 0) { Panel temp = new Panel(); Label tempLabel = new Label(); tempLabel.Text = "您本月已经测试过了,每月建议只测试一次,是否还要再测一次?"; temp.Controls.Add(tempLabel); buttonPanel.Controls.Add(temp); } buttonPanel.CssClass = "test-button-div"; Button button = new Button(); button.CssClass = "test-button"; button.Click += new EventHandler(startTest); buttonPanel.Controls.Add(button); panel.Controls.Add(titlePanel); panel.Controls.Add(tempPanel); // panel.Controls.Add(imgPanel); // panel.Controls.Add(introductionPanel); panel.Controls.Add(buttonPanel); this.topicId.Text = id; this.topicType.Text = topicType; this.totalChooseItems.Text = totalChooseItems; this.totalOptions.Text = totalOptions; this.form1.Controls.Add(panel); } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { randomOptionIds = new List<int>(); } //if (!IsPostBack) // { string id = Request["id"].ToString(); string type = Request["type"].ToString(); string sql = "select * from Options where topicId=" + id + " order by OptionOrder asc"; DBUtil db = new DBUtil(); string TopicSql = "select * from Topics where Id=" + id; DataSet ds = db.executeSqlQuery(TopicSql); if (ds.Tables[0].Rows.Count > 0) { string introductionTitle = ds.Tables[0].Rows[0]["introductionTitleImage"].ToString(); string title = ds.Tables[0].Rows[0]["title"].ToString(); Panel titlePanel = new Panel(); /*Image titleImage = new Image(); titleImage.ImageUrl = "assets/" + introductionTitle; titlePanel.CssClass = "test-option-page-title-img"; titlePanel.Controls.Add(titleImage); this.form1.Controls.Add(titlePanel);*/ Label titleLabel = new Label(); titleLabel.Text = title; titlePanel.CssClass = "test-option-page-title-text"; titlePanel.Controls.Add(titleLabel); this.form1.Controls.Add(titlePanel); } TopicSql = "select * from Dimensions where TopicId=" + id; ds = db.executeSqlQuery(TopicSql); if (randomOptionIds.Count == 0) { for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { string optionList = ds.Tables[0].Rows[i]["optionIdList"].ToString(); string[] list = optionList.Split(','); List<int> integerValues = new List<int>(); for (int j = 0; j < list.Length; j++) { integerValues.Add(Convert.ToInt32(list[j])); } Random ran = new Random(); int first = ran.Next(1, integerValues.Count); int second = ran.Next(1, integerValues.Count); if (first == second) { if (first == integerValues.Count) second = 1; else second = first + 1; } randomOptionIds.Add(integerValues[first - 1]); randomOptionIds.Add(integerValues[second - 1]); } } ds = db.executeSqlQuery(sql); if (ds.Tables[0].Rows.Count > 0) { int currentOrder = 1; for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { int order = Convert.ToInt32(ds.Tables[0].Rows[i]["OptionOrder"].ToString()); if (!randomOptionIds.Contains(order)) { continue; } string optionText = ds.Tables[0].Rows[i]["OptionText"].ToString(); Panel panel = new Panel(); panel.CssClass = "content"; panel.ID = "OptionOrder" + currentOrder; Panel titlePanel = new Panel(); Label titleLabel = new Label(); titleLabel.Text = currentOrder + ": " + optionText; titlePanel.CssClass = "test-title-sub"; titlePanel.Controls.Add(titleLabel); Panel titleTotalPanel = new Panel(); Label titleTotalLabel = new Label(); titleTotalLabel.Text = "本测试共 "; Label temp1 = new Label(); temp1.Text = ds.Tables[0].Rows.Count.ToString(); temp1.CssClass = "test-title-total-span"; Label temp2 = new Label(); temp2.Text = " 题"; titleTotalPanel.CssClass = "test-title-total"; titleTotalPanel.Controls.Add(titleTotalLabel); titleTotalPanel.Controls.Add(temp1); titleTotalPanel.Controls.Add(temp2); Panel chooseItemPanel = new Panel(); chooseItemPanel.CssClass = "test-choose-item-day"; DataSet itemDs = null; if (type.Equals("1")) { itemDs = db.executeSqlQuery("select * from ChooseItem where TopicId=" + id + " order by ItemPosition asc"); } else { itemDs = db.executeSqlQuery("select * from ChooseItem where TopicId=" + id + " and OptionId=" + order + " order by ItemPosition asc"); } for (int j = 0; j < itemDs.Tables[0].Rows.Count; j++) { Panel chooseItemRadioPanel = new Panel(); /* RadioButton bt = new RadioButton(); bt.GroupName = "RadioGroup" + order; bt.ID = "RadioGroup" + order+"_RadioOption" + itemDs.Tables[0].Rows[j]["ItemPosition"].ToString(); bt.Text = itemDs.Tables[0].Rows[j]["ItemText"].ToString(); bt.AutoPostBack = true; bt.CheckedChanged += new EventHandler(startTest); chooseItemRadioPanel.Controls.Add(bt);*/ //chooseItemRadioPanel.ID = "RadioGroup" + order + "_RadioOption" + itemDs.Tables[0].Rows[j]["ItemPosition"].ToString(); //chooseItemRadioPanel. Button bt = new Button(); bt.ID = "RadioGroup" + currentOrder + "_RadioOption" + itemDs.Tables[0].Rows[j]["ItemPosition"].ToString() + "_Original" + order; bt.Text = itemDs.Tables[0].Rows[j]["ItemText"].ToString(); bt.Click += new EventHandler(startTest); bt.CssClass = "test-option-button"; bt.OnClientClick = "$('#RadioGroup" + currentOrder + "_RadioOption" + itemDs.Tables[0].Rows[j]["ItemPosition"].ToString() + "_Original" + order + "').addClass('test-option-button-click')"; chooseItemRadioPanel.Controls.Add(bt); chooseItemPanel.Controls.Add(chooseItemRadioPanel); } panel.Controls.Add(titleTotalPanel); panel.Controls.Add(titlePanel); panel.Controls.Add(chooseItemPanel); if (currentOrder == 1) { panel.Visible = true; } else { Button last = new Button(); last.ID = currentOrder.ToString(); last.CssClass = "last-option-button"; last.Click += new EventHandler(lastButtonClick); panel.Controls.Add(last); panel.Visible = false; } this.form1.Controls.Add(panel); currentOrder++; } } // } }
protected void Page_Load(object sender, EventArgs e) { string code = Request["code"]; string userid = Request["userid"]; if (userid == null) { if (code == null) { Response.Redirect("https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxe29e41d979d25872&redirect_uri=http%3A%2F%2Fwww.ihappyabc.com%2Flearn-self.aspx&response_type=code&scope=snsapi_base#wechat_redirect"); } else { userid = WeixinUtil.getUserAuthorizedId(code); } } if (userid == null || userid.Equals("")) { Response.Redirect("https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxe29e41d979d25872&redirect_uri=http%3A%2F%2Fwww.ihappyabc.com%2Flearn-self.aspx&response_type=code&scope=snsapi_base#wechat_redirect"); } openid = userid; JObject obj = WeixinUtil.getUserInfo(userid); userImageUrl = obj.GetValue("headimgurl").ToString(); userNickName = obj.GetValue("nickname").ToString(); DBUtil db = new DBUtil(); DataSet ds = db.executeSqlQuery("select * from Users where userName='******'"); if (ds.Tables[0].Rows.Count > 0) { age = ds.Tables[0].Rows[0]["age"].ToString(); industry = ds.Tables[0].Rows[0]["industry"].ToString(); region = ds.Tables[0].Rows[0]["region"].ToString(); } string sql = "select count(Id) as total from measureScores where userId='" + userid + "' and topicId in (2,5)"; ds = db.executeSqlQuery(sql); if (ds.Tables[0].Rows.Count > 0) { testTimes = Convert.ToInt32(ds.Tables[0].Rows[0][0]) / 4; } int personalTimes = 0; sql = "select * from Votes where userId='" + userid + "' and topicId=1"; ds = db.executeSqlQuery(sql); if (ds.Tables[0].Rows.Count > 0) { personalTimes++; } sql = "select * from Votes where userId='" + userid + "' and topicId=8"; ds = db.executeSqlQuery(sql); if (ds.Tables[0].Rows.Count > 0) { personalTimes++; } selfPercent = personalTimes * 100 / 6; ds = db.executeSqlQuery("select * from Votes where userid='" + userid + "' and topicId=1"); if (ds.Tables[0].Rows.Count > 0) bigfive = true; ds = db.executeSqlQuery("select * from Votes where userid='" + userid + "' and topicId=9"); if (ds.Tables[0].Rows.Count > 0) world = true; ds = db.executeSqlQuery("select * from Votes where userid='" + userid + "' and topicId=10"); if (ds.Tables[0].Rows.Count > 0) perfect = true; ds = db.executeSqlQuery("select * from Badges where userId='" + userid + "' and topicId=9"); if (ds.Tables[0].Rows.Count > 0) { badgeNames.Add(ds.Tables[0].Rows[0]["badgeName"].ToString()); badgeCategory.Add(1); } ds = db.executeSqlQuery("select * from Badges where userId='" + userid + "' and topicId=10"); if (ds.Tables[0].Rows.Count > 0) { badgeNames.Add(ds.Tables[0].Rows[0]["badgeName"].ToString()); badgeCategory.Add(2); } ds = db.executeSqlQuery("select * from Badges where userId='" + userid + "' and topicId=1"); if (ds.Tables[0].Rows.Count > 0) { for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { badgeNames.Add(ds.Tables[0].Rows[i]["badgeName"].ToString()); badgeCategory.Add(3); } } badgeColor.Add("orangered"); badgeColor.Add("skyblue"); badgeColor.Add("orange"); badgeColor.Add("lightgreen"); badgeColor.Add("#6d3353"); badgeColor.Add("#3071a9"); badgeColor.Add("#c9302c"); badgeColor.Add("#398439"); badgeClass.Add("glyphicon-inbox"); badgeClass.Add("glyphicon-tower"); badgeClass.Add("glyphicon-globe"); badgeClass.Add("glyphicon-stats"); badgeClass.Add("glyphicon-send"); badgeClass.Add("glyphicon-hdd"); badgeClass.Add("glyphicon-eye-open"); ds = db.executeSqlQuery("select count(userId) from badges where topicId=9"); int totalPerson = 0; if (ds.Tables[0].Rows.Count > 0) { totalPerson = Convert.ToInt32(ds.Tables[0].Rows[0][0]); } ds = db.executeSqlQuery("select count(userId) from badges where topicId=9 and badgeName='重度入世'"); int person = 0; if (ds.Tables[0].Rows.Count > 0) { person = Convert.ToInt32(ds.Tables[0].Rows[0][0]); } world_1 = person * 100 / totalPerson; ds = db.executeSqlQuery("select count(userId) from badges where topicId=9 and badgeName='轻度入世'"); person = 0; if (ds.Tables[0].Rows.Count > 0) { person = Convert.ToInt32(ds.Tables[0].Rows[0][0]); } world_2 = person * 100 / totalPerson; ds = db.executeSqlQuery("select count(userId) from badges where topicId=9 and badgeName='轻度出世'"); person = 0; if (ds.Tables[0].Rows.Count > 0) { person = Convert.ToInt32(ds.Tables[0].Rows[0][0]); } world_3 = person * 100 / totalPerson; ds = db.executeSqlQuery("select count(userId) from badges where topicId=9 and badgeName='重度出世'"); person = 0; if (ds.Tables[0].Rows.Count > 0) { person = Convert.ToInt32(ds.Tables[0].Rows[0][0]); } world_4 = person * 100 / totalPerson; ds = db.executeSqlQuery("select count(userId) from badges where topicId=10"); totalPerson = 0; if (ds.Tables[0].Rows.Count > 0) { totalPerson = Convert.ToInt32(ds.Tables[0].Rows[0][0]); } ds = db.executeSqlQuery("select count(userId) from badges where topicId=10 and badgeName='顺其自然主义'"); person = 0; if (ds.Tables[0].Rows.Count > 0) { person = Convert.ToInt32(ds.Tables[0].Rows[0][0]); } perfect_1 = person * 100 / totalPerson; ds = db.executeSqlQuery("select count(userId) from badges where topicId=10 and badgeName='神经质完美主义'"); person = 0; if (ds.Tables[0].Rows.Count > 0) { person = Convert.ToInt32(ds.Tables[0].Rows[0][0]); } perfect_2 = person * 100 / totalPerson; ds = db.executeSqlQuery("select count(userId) from badges where topicId=10 and badgeName='积极完美主义'"); person = 0; if (ds.Tables[0].Rows.Count > 0) { person = Convert.ToInt32(ds.Tables[0].Rows[0][0]); } perfect_3 = person * 100 / totalPerson; ds = db.executeSqlQuery("select count(userId) from badges where topicId=1"); totalPerson = 0; if (ds.Tables[0].Rows.Count > 0) { totalPerson = Convert.ToInt32(ds.Tables[0].Rows[0][0]); } ds = db.executeSqlQuery("select count(userId) from badges where topicId=1 and badgeName='神经质低'"); person = 0; if (ds.Tables[0].Rows.Count > 0) { person = Convert.ToInt32(ds.Tables[0].Rows[0][0]); } bigfive_1 = person * 500 / totalPerson; ds = db.executeSqlQuery("select count(userId) from badges where topicId=1 and badgeName='神经质高'"); person = 0; if (ds.Tables[0].Rows.Count > 0) { person = Convert.ToInt32(ds.Tables[0].Rows[0][0]); } bigfive_2 = person * 500 / totalPerson; ds = db.executeSqlQuery("select count(userId) from badges where topicId=1 and badgeName='内向'"); person = 0; if (ds.Tables[0].Rows.Count > 0) { person = Convert.ToInt32(ds.Tables[0].Rows[0][0]); } bigfive_3 = person * 500 / totalPerson; ds = db.executeSqlQuery("select count(userId) from badges where topicId=1 and badgeName='外向'"); person = 0; if (ds.Tables[0].Rows.Count > 0) { person = Convert.ToInt32(ds.Tables[0].Rows[0][0]); } bigfive_4 = person * 500 / totalPerson; ds = db.executeSqlQuery("select count(userId) from badges where topicId=1 and badgeName='保守'"); person = 0; if (ds.Tables[0].Rows.Count > 0) { person = Convert.ToInt32(ds.Tables[0].Rows[0][0]); } bigfive_5 = person * 500 / totalPerson; ds = db.executeSqlQuery("select count(userId) from badges where topicId=1 and badgeName='开放'"); person = 0; if (ds.Tables[0].Rows.Count > 0) { person = Convert.ToInt32(ds.Tables[0].Rows[0][0]); } bigfive_6 = person * 500 / totalPerson; ds = db.executeSqlQuery("select count(userId) from badges where topicId=1 and badgeName='宜人性低'"); person = 0; if (ds.Tables[0].Rows.Count > 0) { person = Convert.ToInt32(ds.Tables[0].Rows[0][0]); } bigfive_7 = person * 500 / totalPerson; ds = db.executeSqlQuery("select count(userId) from badges where topicId=1 and badgeName='宜人性高'"); person = 0; if (ds.Tables[0].Rows.Count > 0) { person = Convert.ToInt32(ds.Tables[0].Rows[0][0]); } bigfive_8 = person * 500 / totalPerson; ds = db.executeSqlQuery("select count(userId) from badges where topicId=1 and badgeName='严谨性低'"); person = 0; if (ds.Tables[0].Rows.Count > 0) { person = Convert.ToInt32(ds.Tables[0].Rows[0][0]); } bigfive_9 = person * 500 / totalPerson; ds = db.executeSqlQuery("select count(userId) from badges where topicId=1 and badgeName='严谨性高'"); person = 0; if (ds.Tables[0].Rows.Count > 0) { person = Convert.ToInt32(ds.Tables[0].Rows[0][0]); } bigfive_10 = person * 500 / totalPerson; }
protected void Page_Load(object sender, EventArgs e) { string userid = Request["userid"]; if (userid == null) { userid = "om8uZt7fajggMH8vqjFb1afiE8y4"; } JObject obj = WeixinUtil.getUserInfo(userid); userImageUrl = obj.GetValue("headimgurl").ToString(); userNickName = obj.GetValue("nickname").ToString(); DBUtil db = new DBUtil(); DataSet ds = db.executeSqlQuery("select * from Users where userName='******'"); if (ds.Tables[0].Rows.Count > 0) { age = ds.Tables[0].Rows[0]["age"].ToString(); industry = ds.Tables[0].Rows[0]["industry"].ToString(); region = ds.Tables[0].Rows[0]["region"].ToString(); } string sql = "select count(Id) as total from measureScores where userId='" + userid + "' and topicId in (2,5)"; ds = db.executeSqlQuery(sql); if (ds.Tables[0].Rows.Count > 0) { testTimes = Convert.ToInt32(ds.Tables[0].Rows[0][0]) / 4; } int personalTimes = 0; sql = "select * from Votes where userId='" + userid + "' and topicId=1"; ds = db.executeSqlQuery(sql); if (ds.Tables[0].Rows.Count > 0) { personalTimes++; } sql = "select * from Votes where userId='" + userid + "' and topicId=8"; ds = db.executeSqlQuery(sql); if (ds.Tables[0].Rows.Count > 0) { personalTimes++; } selfPercent = personalTimes * 100 / 6; ds = db.executeSqlQuery("select * from ChooseItem where topicId=1"); Dictionary<int, int> scores = new Dictionary<int, int>(); if (ds.Tables[0].Rows.Count > 0) { for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { int position = Convert.ToInt32(ds.Tables[0].Rows[i]["itemPosition"].ToString()); int score = Convert.ToInt32(ds.Tables[0].Rows[i]["ItemScore"].ToString()); scores.Add(position, score); } ds = db.executeSqlQuery("select * from Votes where userId='" + userid + "' and TopicId=1"); if (ds.Tables[0].Rows.Count > 0) { int totalScore = 0; Dictionary<int, int> choosePositionMap = new Dictionary<int, int>(); for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { int optionId = Convert.ToInt32(ds.Tables[0].Rows[i]["OptionId"].ToString()); int choosePosition = Convert.ToInt32(ds.Tables[0].Rows[i]["ChooseItemPosition"].ToString()); totalScore += scores[choosePosition]; choosePositionMap.Add(optionId, choosePosition); } /*总分板块*/ ds = db.executeSqlQuery("select * from Dimensions where TopicId=1"); if (ds.Tables[0].Rows.Count > 1) { int dimensionCount = ds.Tables[0].Rows.Count; Dictionary<int, int> dimensionScores = new Dictionary<int, int>(); Dictionary<int, string> dimensionNames = new Dictionary<int, string>(); Dictionary<int, string> dimensionDescs = new Dictionary<int, string>(); Dictionary<int, string> dimensionImages = new Dictionary<int, string>(); Dictionary<int, int> dimensionOptionCount = new Dictionary<int, int>(); List<string> chartScoreString = new List<string>(); for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { int dimensionId = Convert.ToInt32(ds.Tables[0].Rows[i]["id"]); string dimensionName = ds.Tables[0].Rows[i]["DimensionName"].ToString(); string dimensionDesc = ds.Tables[0].Rows[i]["DimensionDesc"].ToString(); string optionIdList = ds.Tables[0].Rows[i]["OptionIdList"].ToString(); string dimensionImage = ds.Tables[0].Rows[i]["DimensionImage"].ToString(); string[] options = optionIdList.Split(','); int[] optionIDInt = new int[options.Length]; int dimensionScore = 0; for (int j = 0; j < options.Length; j++) { optionIDInt[j] = Convert.ToInt32(options[j]); if (choosePositionMap.ContainsKey(optionIDInt[j])) { dimensionScore += scores[choosePositionMap[optionIDInt[j]]]; } } dimensionScores.Add(dimensionId, dimensionScore); dimensionNames.Add(dimensionId, dimensionName); dimensionDescs.Add(dimensionId, dimensionDesc); dimensionImages.Add(dimensionId, dimensionImage); dimensionOptionCount.Add(dimensionId, options.Length); } sql = "select * from TotalAverage where topicId = 1"; ds = db.executeSqlQuery(sql); Dictionary<int, float> dimensionCompare = new Dictionary<int, float>(); for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { int dimId = Convert.ToInt32(ds.Tables[0].Rows[i]["dimensionId"]); int totalScoreCompare = Convert.ToInt32(ds.Tables[0].Rows[i]["totalScore"]); int totalPersonCompare = Convert.ToInt32(ds.Tables[0].Rows[i]["totalPerson"]); dimensionCompare.Add(dimId, ((float)totalScoreCompare) / totalPersonCompare); } foreach (KeyValuePair<int, int> pair in dimensionScores) { radarDimNames.Add(dimensionNames[pair.Key]); radarDimScores.Add((float)(pair.Value / 6.0)); radarAveScores.Add(dimensionCompare[pair.Key] / 10); } } } } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { string userid = Request["userid"]; if (userid == null) { userid = "om8uZt7fajggMH8vqjFb1afiE8y4"; } JObject obj = WeixinUtil.getUserInfo(userid); userImageUrl = obj.GetValue("headimgurl").ToString(); userNickName = obj.GetValue("nickname").ToString(); DBUtil db = new DBUtil(); DataSet ds = db.executeSqlQuery("select * from Users where userName='******'"); if (ds.Tables[0].Rows.Count > 0) { age = ds.Tables[0].Rows[0]["age"].ToString(); industry = ds.Tables[0].Rows[0]["industry"].ToString(); region = ds.Tables[0].Rows[0]["region"].ToString(); } string sql = "select count(Id) as total from measureScores where userId='" + userid + "' and topicId in (2,5)"; ds = db.executeSqlQuery(sql); if (ds.Tables[0].Rows.Count > 0) { testTimes = Convert.ToInt32(ds.Tables[0].Rows[0][0])/4; } int personalTimes = 0; sql = "select * from Votes where userId='" + userid + "' and topicId=1"; ds = db.executeSqlQuery(sql); if (ds.Tables[0].Rows.Count > 0) { personalTimes++; } sql = "select * from Votes where userId='" + userid + "' and topicId=8"; ds = db.executeSqlQuery(sql); if (ds.Tables[0].Rows.Count > 0) { personalTimes++; } selfPercent = personalTimes * 100 / 6; sql = "select * from measures where TopicId=5"; ds = db.executeSqlQuery(sql); int minYear = 0; int minMonth = 0; Dictionary<int, string> mNames = new Dictionary<int, string>(); for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { string measureName = ds.Tables[0].Rows[i]["measureName"].ToString(); string measureId = ds.Tables[0].Rows[i]["Id"].ToString(); measureNames.Add(measureName); mNames.Add(Convert.ToInt32(ds.Tables[0].Rows[i]["Id"]), measureName); DataSet ds1 = db.executeSqlQuery("select * from MeasureScores where measureId=" + measureId + " and userId='" + userid + "' order by testDateTime desc"); if (ds1.Tables[0].Rows.Count > 0) { string score = ds1.Tables[0].Rows[0]["score"].ToString(); string beats = ds1.Tables[0].Rows[0]["beats"].ToString(); measureScores.Add(score); measureBeats.Add(beats); } } if (measureScores.Count == 0) { for (int i = 0; i < 4; i++) { measureScores.Add("--"); measureBeats.Add("--"); } } ds = db.executeSqlQuery("select * from MeasureScores where topicId=5 and userId='" + userid + "' order by testDateTime desc"); Dictionary<string, Dictionary<string, int>> measureAllScores = new Dictionary<string, Dictionary<string, int>>(); if (ds.Tables[0].Rows.Count > 0) { int stars = 1; string tempDate = ""; for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { string dt = ds.Tables[0].Rows[i]["testDateTime"].ToString(); if (!dt.Equals(tempDate)) { tempDate = dt; stars++; } DateTime datetime = DateTime.Parse(dt); string timeStr = datetime.Month +"月"; if (minYear == 0) { minYear = datetime.Year; minMonth = datetime.Month; } if (!measureAllScores.ContainsKey(timeStr)) { measureAllScores.Add(timeStr, new Dictionary<string, int>()); } int measureId = Convert.ToInt32(ds.Tables[0].Rows[i]["measureId"]); int score = Convert.ToInt32(ds.Tables[0].Rows[i]["score"].ToString()); measureAllScores[timeStr].Add(mNames[measureId], score); } if (stars > 5) { totalStars = 5; } else { totalStars = stars; } } string labelNames = ""; Dictionary<string, Dictionary<string, int>> nullScores = new Dictionary<string, Dictionary<string, int>>(); if (measureAllScores.Keys.Count < 6) { int calTimes = 6 - measureAllScores.Keys.Count; if (minYear == 0) { minYear = DateTime.Now.Year; minMonth = DateTime.Now.Month; } for (int i = calTimes; i > 0; i--) { DateTime dt = new DateTime(minYear, minMonth, 1); dt = dt.AddMonths(-i); string timeStr = dt.Month + "月"; nullScores.Add(timeStr, new Dictionary<string, int>()); nullScores[timeStr].Add("工作满意度", 0); nullScores[timeStr].Add("离职指数", 0); nullScores[timeStr].Add("投入指数", 0); nullScores[timeStr].Add("压力指数", 0); } } foreach (KeyValuePair<string, Dictionary<string, int>> pair in nullScores) { labelNames += "\"" + pair.Key + "\","; string temp = ""; foreach (KeyValuePair<string, int> pair2 in pair.Value) { string dName = pair2.Key; if (!dimName.Contains(dName)) { dimName.Add(dName); scoreLabels.Add(dName, ""); } scoreLabels[dName] += pair2.Value + ","; } } foreach (KeyValuePair<string, Dictionary<string, int>> pair in measureAllScores) { labelNames += "\"" + pair.Key + "\","; string temp = ""; foreach (KeyValuePair<string, int> pair2 in pair.Value) { string dName = pair2.Key; if (!dimName.Contains(dName)) { dimName.Add(dName); scoreLabels.Add(dName, ""); } scoreLabels[dName] += pair2.Value + ","; } } if(!labelNames.Equals("")) toolBar = labelNames.Substring(0, labelNames.Length - 1); ds = db.executeSqlQuery("select * from ChooseItem where topicId=5"); Dictionary<int, int> scores = new Dictionary<int, int>(); if (ds.Tables[0].Rows.Count > 0) { for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { int position = Convert.ToInt32(ds.Tables[0].Rows[i]["itemPosition"].ToString()); int score = Convert.ToInt32(ds.Tables[0].Rows[i]["ItemScore"].ToString()); scores.Add(position, score); } ds = db.executeSqlQuery("select * from Votes where userId='" + userid + "' and TopicId=5"); if (ds.Tables[0].Rows.Count > 0) { int totalScore = 0; Dictionary<int, int> choosePositionMap = new Dictionary<int, int>(); for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { int optionId = Convert.ToInt32(ds.Tables[0].Rows[i]["OptionId"].ToString()); int choosePosition = Convert.ToInt32(ds.Tables[0].Rows[i]["ChooseItemPosition"].ToString()); totalScore += scores[choosePosition]; choosePositionMap.Add(optionId, choosePosition); } /*总分板块*/ ds = db.executeSqlQuery("select * from Dimensions where TopicId=5"); if (ds.Tables[0].Rows.Count > 1) { int dimensionCount = ds.Tables[0].Rows.Count; Dictionary<int, int> dimensionScores = new Dictionary<int, int>(); Dictionary<int, string> dimensionNames = new Dictionary<int, string>(); Dictionary<int, string> dimensionDescs = new Dictionary<int, string>(); Dictionary<int, string> dimensionImages = new Dictionary<int, string>(); Dictionary<int, int> dimensionOptionCount = new Dictionary<int, int>(); List<string> chartScoreString = new List<string>(); for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { int dimensionId = Convert.ToInt32(ds.Tables[0].Rows[i]["id"]); string dimensionName = ds.Tables[0].Rows[i]["DimensionName"].ToString(); string dimensionDesc = ds.Tables[0].Rows[i]["DimensionDesc"].ToString(); string optionIdList = ds.Tables[0].Rows[i]["OptionIdList"].ToString(); string dimensionImage = ds.Tables[0].Rows[i]["DimensionImage"].ToString(); string[] options = optionIdList.Split(','); int[] optionIDInt = new int[options.Length]; int dimensionScore = 0; for (int j = 0; j < options.Length; j++) { optionIDInt[j] = Convert.ToInt32(options[j]); if (choosePositionMap.ContainsKey(optionIDInt[j])) { dimensionScore += scores[choosePositionMap[optionIDInt[j]]]; } } dimensionScores.Add(dimensionId, dimensionScore); dimensionNames.Add(dimensionId, dimensionName); dimensionDescs.Add(dimensionId, dimensionDesc); dimensionImages.Add(dimensionId, dimensionImage); dimensionOptionCount.Add(dimensionId, options.Length); } sql = "select * from TotalAverage where topicId = 5"; ds = db.executeSqlQuery(sql); Dictionary<int, float> dimensionCompare = new Dictionary<int, float>(); for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { int dimId = Convert.ToInt32(ds.Tables[0].Rows[i]["dimensionId"]); int totalScoreCompare = Convert.ToInt32(ds.Tables[0].Rows[i]["totalScore"]); int totalPersonCompare = Convert.ToInt32(ds.Tables[0].Rows[i]["totalPerson"]); dimensionCompare.Add(dimId, ((float)totalScoreCompare) / totalPersonCompare); } foreach (KeyValuePair<int, int> pair in dimensionScores) { radarDimNames.Add(dimensionNames[pair.Key]); radarDimScores.Add((float)(pair.Value / 2.0)); radarAveScores.Add(dimensionCompare[pair.Key] / 10); } } } } } }
protected void Page_Load(object sender, EventArgs e) { string id = Request["id"].ToString(); string type = Request["type"].ToString(); string sql = "select * from Options where topicId=" + id + " order by OptionOrder asc"; DBUtil db = new DBUtil(); string TopicSql = "select * from Topics where Id=" + id; DataSet ds = db.executeSqlQuery(TopicSql); if (ds.Tables[0].Rows.Count > 0) { string introductionTitle = ds.Tables[0].Rows[0]["introductionTitleImage"].ToString(); string title = ds.Tables[0].Rows[0]["title"].ToString(); Panel titlePanel = new Panel(); /*Image titleImage = new Image(); titleImage.ImageUrl = "assets/" + introductionTitle; titlePanel.CssClass = "test-option-page-title-img"; titlePanel.Controls.Add(titleImage);*/ Label titleLabel = new Label(); titleLabel.Text = title; titlePanel.CssClass = "test-option-page-title-text"; titlePanel.Controls.Add(titleLabel); this.form1.Controls.Add(titlePanel); } ds = db.executeSqlQuery(sql); if (ds.Tables[0].Rows.Count > 0) { for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { int order = Convert.ToInt32(ds.Tables[0].Rows[i]["OptionOrder"].ToString()); string optionText = ds.Tables[0].Rows[i]["OptionText"].ToString(); string topEdge = ds.Tables[0].Rows[i]["EdgeTop"].ToString(); string bottomEdge = ds.Tables[0].Rows[i]["EdgeBottom"].ToString(); Panel panel = new Panel(); panel.CssClass = "content"; panel.ID = "OptionOrder" + order; Panel titlePanel = new Panel(); Label titleLabel = new Label(); titleLabel.Text = order + ": " + optionText; titlePanel.CssClass = "test-title-sub"; titlePanel.Controls.Add(titleLabel); Panel titleTotalPanel = new Panel(); Label titleTotalLabel = new Label(); titleTotalLabel.Text = "本测试共 "; Label temp1 = new Label(); temp1.Text = ds.Tables[0].Rows.Count.ToString(); temp1.CssClass = "test-title-total-span"; Label temp2 = new Label(); temp2.Text = " 题"; titleTotalPanel.CssClass = "test-title-total"; titleTotalPanel.Controls.Add(titleTotalLabel); titleTotalPanel.Controls.Add(temp1); titleTotalPanel.Controls.Add(temp2); Panel chooseItemPanel = new Panel(); chooseItemPanel.CssClass = "test-choose-item test-choose-item-left"; Panel chooseItemPanelRight = new Panel(); chooseItemPanelRight.CssClass = "test-choose-item test-choose-item-right"; DataSet itemDs = null; if (type.Equals("1")) { itemDs = db.executeSqlQuery("select * from ChooseItem where TopicId=" + id + " order by ItemPosition asc"); } else { itemDs = db.executeSqlQuery("select * from ChooseItem where TopicId=" + id + " and OptionId=" + order + " order by ItemPosition asc"); } Panel topEdgePanel = new Panel(); topEdgePanel.CssClass = "edge"; Label topLabel = new Label(); topLabel.Text = "▪ " + topEdge; topLabel.CssClass = "edge-left"; topEdgePanel.Controls.Add(topLabel); Label middleLabel = new Label(); middleLabel.Text = "V.S."; middleLabel.CssClass = "edge-middle"; topEdgePanel.Controls.Add(middleLabel); Label rightLabel = new Label(); rightLabel.Text = bottomEdge + " ▪" ; rightLabel.CssClass = "edge-right"; topEdgePanel.Controls.Add(rightLabel); for (int j = 0; j < itemDs.Tables[0].Rows.Count; j++) { Panel chooseItemRadioPanel = new Panel(); if (j < 3) { chooseItemRadioPanel.CssClass = "test-option-left"; } else { chooseItemRadioPanel.CssClass = "test-option-right"; } Button bt = new Button(); bt.ID = "RadioGroup" + order + "_RadioOption" + itemDs.Tables[0].Rows[j]["ItemPosition"].ToString(); bt.Text = itemDs.Tables[0].Rows[j]["ItemText"].ToString(); bt.Click += new EventHandler(startTest); bt.CssClass = "test-option-button"; bt.OnClientClick = "$('#RadioGroup" + order + "_RadioOption" + itemDs.Tables[0].Rows[j]["ItemPosition"].ToString() + "').addClass('test-option-button-click')"; chooseItemRadioPanel.Controls.Add(bt); if (j < 3) { chooseItemPanel.Controls.Add(chooseItemRadioPanel); } else { chooseItemPanelRight.Controls.Add(chooseItemRadioPanel); } } panel.Controls.Add(titleTotalPanel); panel.Controls.Add(titlePanel); Panel rightPanel = new Panel(); rightPanel.Controls.Add(topEdgePanel); rightPanel.Controls.Add(chooseItemPanel); rightPanel.Controls.Add(chooseItemPanelRight); panel.Controls.Add(rightPanel); if (i == 0) { panel.Visible = true; } else { Button last = new Button(); last.ID = order.ToString(); last.CssClass = "last-option-button"; last.Click += new EventHandler(lastButtonClick); panel.Controls.Add(last); panel.Visible = false; } this.form1.Controls.Add(panel); } } }
protected void startTest(object sender, EventArgs e) { Button button = (Button)sender; string[] ids = button.ID.Split('_'); int id = Convert.ToInt32(ids[0].Replace("RadioGroup", "")); int checkedindex = Convert.ToInt32(ids[1].Replace("RadioOption", "")); int originalId = Convert.ToInt32(ids[2].Replace("Original", "")); int totalChooseItem = Convert.ToInt32(Request["totalChooseItem"].ToString()); int totalOptions = Convert.ToInt32(Request["totalOptions"].ToString()); //totalOptions = 10; if (ViewState[originalId.ToString()] == null) { ViewState.Add(originalId.ToString(), checkedindex); } else { ViewState[originalId.ToString()] = checkedindex; } /*for (int i = 1; i <= totalChooseItem; i++) { if (((RadioButton)form1.FindControl("RadioGroup" + id + "_RadioOption" + i)).Checked) { ViewState.Add(id.ToString(), i); } }*/ form1.FindControl("OptionOrder" + id).Visible = false; if (id < 10)//totalOptions) { form1.FindControl("OptionOrder" + (id+ 1)).Visible = true; } else { string userid=Request["userId"].ToString(); DBUtil db = new DBUtil(); db.executeSqlNonQuery("delete from Votes where userId='" + userid + "' and TopicId=" + Request["id"].ToString()); //foreach(KeyValuePair<string, for (int i = 1; i <= totalOptions; i++) { if (ViewState[i.ToString()] != null) { int chooseItem = Convert.ToInt32(ViewState[i.ToString()]); db.executeSqlNonQuery("insert into Votes(userId,TopicId,OptionId,ChooseItemPosition) values('" + userid + "'," + Request["id"].ToString() + "," + i + "," + chooseItem + ")"); } } Response.Redirect("result-day.aspx?id=" + Request["id"].ToString() + "&userid=" + userid+"&type="+Request["type"].ToString()); } }
protected void Page_Load(object sender, EventArgs e) { string userid = Request["userid"]; if (userid == null) { userid = "om8uZt7fajggMH8vqjFb1afiE8y4"; } JObject obj = WeixinUtil.getUserInfo(userid); userImageUrl = obj.GetValue("headimgurl").ToString(); userNickName = obj.GetValue("nickname").ToString(); DBUtil db = new DBUtil(); DataSet ds = db.executeSqlQuery("select * from Users where userName='******'"); if (ds.Tables[0].Rows.Count > 0) { age = ds.Tables[0].Rows[0]["age"].ToString(); industry = ds.Tables[0].Rows[0]["industry"].ToString(); region = ds.Tables[0].Rows[0]["region"].ToString(); } string sql = "select count(Id) as total from measureScores where userId='" + userid + "' and topicId in (2,5)"; ds = db.executeSqlQuery(sql); if (ds.Tables[0].Rows.Count > 0) { testTimes = Convert.ToInt32(ds.Tables[0].Rows[0][0]) / 4; } int personalTimes = 0; sql = "select * from Votes where userId='" + userid + "' and topicId=1"; ds = db.executeSqlQuery(sql); if (ds.Tables[0].Rows.Count > 0) { personalTimes++; } sql = "select * from Votes where userId='" + userid + "' and topicId=8"; ds = db.executeSqlQuery(sql); if (ds.Tables[0].Rows.Count > 0) { personalTimes++; } selfPercent = personalTimes * 100 / 6; sql = "select * from MyTool where userId='" + userid + "'"; ds = db.executeSqlQuery(sql); for( int i = 0 ;i<ds.Tables[0].Rows.Count;i++) { toolNames.Add(ds.Tables[0].Rows[i]["toolName"].ToString()); toolIds.Add(ds.Tables[0].Rows[i]["Id"].ToString()); string id = ds.Tables[0].Rows[i]["Id"].ToString(); List<string> listStatus = new List<string>(); sql = "select * from MyTool where Id=" + id; DataSet ds2 = db.executeSqlQuery(sql); if (ds2.Tables[0].Rows.Count > 0) { string toolName = ds2.Tables[0].Rows[0]["toolName"].ToString(); string frequency = ds2.Tables[0].Rows[0]["frequency"].ToString(); if (frequency.Equals("0")) frequency = "每天"; else frequency = "每周"; DateTime dt = DateTime.Parse(ds2.Tables[0].Rows[0]["postDateTime"].ToString()); string createDateTime = dt.Year + "年" + dt.Month + "月" + dt.Day + "日"; DateTime now = DateTime.Now; if (frequency.Equals("每天")) { int showTimes = 0; while (!sameDay(dt, now)) { showTimes++; string currentString = now.Year + "-" + now.Month + "-" + now.Day; sql = string.Format("select * from MyToolRecord where userId='{0}' and toolId={1} and recordDateTime='{2}'", userid, id, currentString); ds2 = db.executeSqlQuery(sql); if (ds2.Tables[0].Rows.Count > 0) { string status = ds2.Tables[0].Rows[0]["status"].ToString(); if (status.Equals("0")) { status = "未完成"; } else { status = "已完成"; } listStatus.Add(status); } else { listStatus.Add("未打卡"); } if (showTimes == 7) { break; } now = now.AddDays(-1); } if (sameDay(dt, now)) { string currentString = now.Year + "-" + now.Month + "-" + now.Day; sql = string.Format("select * from MyToolRecord where userId='{0}' and toolId={1} and recordDateTime='{2}'", userid, id, currentString); ds2 = db.executeSqlQuery(sql); if (ds2.Tables[0].Rows.Count > 0) { string status = ds2.Tables[0].Rows[0]["status"].ToString(); if (status.Equals("0")) { status = "未完成"; } else { status = "已完成"; } listStatus.Add(status); } else { listStatus.Add("未打卡"); } } if (listStatus.Count < 7) { int leftDays = 7 - listStatus.Count; now = DateTime.Now; for (int j = 0; j < leftDays; j++) { now = now.AddDays(1); string currentString = now.Year + "-" + now.Month + "-" + now.Day; listStatus.Insert(0, "未打卡"); } } string signs = ""; for( int j = 0;j<listStatus.Count;j++) { string sign = ""; if (listStatus[j].Equals("未打卡")) sign = "<span class='glyphicon glyphicon-ban-circle' aria-hidden='true' style='color:white;margin-right:10px'></span>"; else if (listStatus[j].Equals("已完成")) sign = "<span class='glyphicon glyphicon-ok-circle' aria-hidden='true' style='color:#5cb85c;margin-right:10px'></span>"; else if (listStatus[j].Equals("未完成")) sign = "<span class='glyphicon glyphicon-remove-circle' aria-hidden='true' style='color:#c9302c;margin-right:10px'></span>"; signs += sign; } toolSigns.Add(signs); } else if (frequency.Equals("每周")) { int showTimes = 0; while (!sameWeek(dt, now)) { showTimes++; string currentString = now.Year + "-" + now.Month + "-" + now.Day; sql = string.Format("select * from MyToolRecord where userId='{0}' and toolId={1} and recordDateTime='{2}'", userid, id, currentString); ds2 = db.executeSqlQuery(sql); if (ds2.Tables[0].Rows.Count > 0) { string status = ds2.Tables[0].Rows[0]["status"].ToString(); if (status.Equals("0")) { status = "未完成"; } else { status = "已完成"; } listStatus.Add(status); } else { listStatus.Add("未打卡"); } if (showTimes == 7) { break; } now = now.AddDays(-7); } if (sameWeek(dt, now)) { string currentString = now.Year + "-" + now.Month + "-" + now.Day; sql = string.Format("select * from MyToolRecord where userId='{0}' and toolId={1} and recordDateTime='{2}'", userid, id, currentString); ds2 = db.executeSqlQuery(sql); if (ds2.Tables[0].Rows.Count > 0) { string status = ds2.Tables[0].Rows[0]["status"].ToString(); if (status.Equals("0")) { status = "未完成"; } else { status = "已完成"; } listStatus.Add(status); } else { listStatus.Add("未打卡"); } } if (listStatus.Count < 7) { int leftDays = 7 - listStatus.Count; now = DateTime.Now; for (int j = 0; j < leftDays; j++) { now = now.AddDays(7); string currentString = now.Year + "-" + now.Month + "-" + now.Day; listStatus.Insert(0, "未打卡"); } } string signs = ""; for (int j = 0; j < listStatus.Count; j++) { string sign = ""; if (listStatus[j].Equals("未打卡")) sign = "<span class='glyphicon glyphicon-ban-circle' aria-hidden='true' style='color:white;margin-right:10px'></span>"; else if (listStatus[j].Equals("已完成")) sign = "<span class='glyphicon glyphicon-ok-circle' aria-hidden='true' style='color:#5cb85c;margin-right:10px'></span>"; else if (listStatus[j].Equals("未完成")) sign = "<span class='glyphicon glyphicon-remove-circle' aria-hidden='true' style='color:#c9302c;margin-right:10px'></span>"; signs += sign; } toolSigns.Add(signs); } } } }