protected void Page_Load(object sender, EventArgs e) { if (!this.Page.IsPostBack) { bool IsCom = false; int ret = 0; if (!string.IsNullOrEmpty(Request.Form["ctl00$MainContent$heUserID"]) && !string.IsNullOrEmpty(Request.Form["ctl00$MainContent$hdTsID"])) { //try //{ int UserId = int.Parse(Request.Form["ctl00$MainContent$heUserID"]); int tsid = int.Parse(Request.Form["ctl00$MainContent$hdTsID"]); //Profile Process //Model_ReportItemResult cr = new Model_ReportItemResult(); Model_UsersAssessment cr = new Model_UsersAssessment(); string resultID = Request.Form["ass_fill_ch_"]; if (!string.IsNullOrEmpty(resultID)) { string[] arrResultID = resultID.Split(','); foreach (string r in arrResultID) { int intTASID = int.Parse(r); int RankVal = int.Parse(Request.Form["ass_fill_ch_sc_" + r]); IsCom = cr.UpdateUserRank(intTASID, RankVal); } } if (IsCom) { ret = CalculationController.CalculateActionStart(tsid); } } string strRet = "True"; switch (ret) { case -1: strRet = "False"; break; case 0: strRet = "True"; break; default: strRet = ret.ToString(); break; } Response.Write(strRet); Response.End(); } }
public List <Model_UsersAssessment> GetUserAss(char code) { Model_UsersAssessment uss = new Model_UsersAssessment(); List <Model_UsersAssessment> ussList = uss.GetUserAssessmentByTsID(this.TransactionID).Where(o => o.Code.Trim().ToLower()[0] == code).ToList(); return(ussList); }
protected void btnDownload_Click(object sender, EventArgs e) { Model_UsersAssChoice choice = new Model_UsersAssChoice(); Model_UsersAssessment assUser = new Model_UsersAssessment(); string ass = Request.Form["TASID"]; if (!string.IsNullOrEmpty(ass)) { string[] arrAss = ass.Split(','); if (arrAss.Length > 0) { foreach (string item in arrAss) { // TASID,int Score, string Code int TASID = int.Parse(item); int Score = int.Parse(Request.Form["TASID_score_" + item]); string Code = Request.Form["TASID_code_" + item].ToString(); assUser.UpdateUserAssbyID(TASID, Score, Code); } } } string ch = Request.Form["TASCID"]; if (!string.IsNullOrEmpty(ch)) { string[] arrCh = ch.Split(','); if (arrCh.Length > 0) { foreach (string item in arrCh) { //TASCID, int Score, string Code int TASCID = int.Parse(item); int Score = int.Parse(Request.Form["TASCID_score_" + item]); string Code = Request.Form["TASCID_code_" + item].ToString(); choice.UpdateUserAssChoicebyID(TASCID, Score, Code); } } } Response.Redirect(Request.Url.ToString()); }
//Get Subsection F and H public List <Model_ReportItemResult> Code_F_SumValueBySubSection() { //Cdoe F = Section 7; List <Model_ReportItemResult> rlist = new List <Model_ReportItemResult>(); Model_ReportSectionItem rss = new Model_ReportSectionItem(); List <Model_ReportSectionItem> rsslist = rss.GetListItemBySectionID(this.ResultSectionID); foreach (Model_ReportSectionItem item in rsslist) { string map = item.SUCID; string[] arrmap = map.Split(','); decimal score = 0; int TASCID = 0; int TASID = 0; string strDetail = string.Empty; foreach (string m in arrmap) { score = score + this.R_UserAss_F.Where(o => o.SUCID == int.Parse(m)).Sum(t => t.Score); } foreach (string m in arrmap) { List <Model_UsersAssChoice> assch = this.R_UserAssChoice_H.Where(o => o.SUCID == int.Parse(m)).ToList(); score = score + this.R_UserAssChoice_H.Where(o => o.SUCID == int.Parse(m)).Sum(t => t.Score); if (assch.Count > 0) { TASCID = assch.Select(r => r.TASCID).Last(); TASID = assch.Select(r => r.TASID).Last(); strDetail = String.Join(",", assch.Select(t => t.Score).ToArray()); } } rlist.Add(new Model_ReportItemResult { ResultSectionID = this.ResultSectionID, ResultItemID = item.ResultItemID, ResultItemTitle = item.Title, TransactionID = this.TransactionID, Score = score, Score_new = score, TASCID = TASCID, TASID = TASID, Detail = strDetail }); } Dictionary <decimal, int> GroupDupRecheck = rlist.GroupBy(x => (decimal)x.Score) .Where(g => g.Count() > 1) .ToDictionary(x => x.Key, y => y.Count()); if (GroupDupRecheck.Count > 0) { Model_UsersAssessment hforcus = this.R_UserAss_H.OrderByDescending(o => o.Priority).FirstOrDefault(); List <Model_UsersAssChoice> chfocus = this.R_UserAssChoice_H.Where(o => o.TASID == hforcus.TASID).OrderByDescending(r => r.Score).ToList(); decimal startfactor = 0.99M; foreach (KeyValuePair <decimal, int> q in GroupDupRecheck) { List <Model_ReportItemResult> dupfocus = rlist.Where(d => d.Score == q.Key).OrderByDescending(r => r.Score).ToList(); //foreach (Model_ReportItemResult item in dupfocus.Where(o => o.IsDup).OrderBy(o => o.UserRank)) //{ // var obj = rlist.FirstOrDefault(o => o.ResultItemID == item.ResultItemID); // if (obj != null) obj.Score_new = obj.Score_new + startfactor; // startfactor = startfactor - (decimal)0.01; //} foreach (Model_UsersAssChoice item in chfocus) { var obj = rlist.FirstOrDefault(o => o.TASCID == item.TASCID); if (obj != null) { obj.Score_new = obj.Score_new + startfactor; } startfactor = startfactor - (decimal)0.01; } } } return(rlist); }
//Get Subsection F and H public List <Model_ReportItemResult> Code_SumValueBySubSection() { //Cdoe F = Section 7; List <Model_ReportItemResult> rlist = new List <Model_ReportItemResult>(); foreach (Model_ReportSectionItem item in this.ReportSectionItem) { string map = item.SUCID; //string[] arrGroup = map.Split('#'); string[] arrmap = map.Split(','); decimal score = 0; decimal score_y = 0; decimal score_c = 0; string group = string.Empty; byte Side_y = 0; byte Side_c = 0; byte frequency_c = 0; byte frequency_y = 0; if (arrmap.Length > 0) { foreach (string m in arrmap) { Model_UsersAssessment F_code = this.R_UserAss_F.Where(o => o.SUCID2 == int.Parse(m)).FirstOrDefault(); Model_UsersAssessment G_code = this.R_UserAss_G.Where(o => o.SUCID2 == int.Parse(m)).FirstOrDefault(); if (F_code != null) { Side_y = F_code.Side; score_y = F_code.Score; group = F_code.GroupName; if (F_code.Score > 0) { switch (F_code.Score) { case 1: case 2: frequency_y = (byte)T5_Frequency.Low; break; case 3: frequency_y = (byte)T5_Frequency.Mid; break; case 4: case 5: frequency_y = (byte)T5_Frequency.High; break; } } } if (G_code != null) { Side_c = G_code.Side; score_c = G_code.Score; group = G_code.GroupName; if (G_code.Score > 0) { switch (G_code.Score) { case 1: case 2: frequency_c = (byte)T5_Frequency.Low; break; case 3: frequency_c = (byte)T5_Frequency.Mid; break; case 4: case 5: frequency_c = (byte)T5_Frequency.High; break; } } } } rlist.Add(new Model_ReportItemResult { ResultSectionID = this.ResultSectionID, ResultItemID = item.ResultItemID, ResultItemTitle = item.Title, TransactionID = this.TransactionID, Score = score, Score_new = score, Score_y = score_y, Score_c = score_c, T5Group = group, Side_c = Side_c, Side_y = Side_y, Frequency_c = frequency_c, Frequency_y = frequency_y }); } } List <Model_ReportItemResult> ListReview = ReviewResult(rlist); return(ListReview.OrderByDescending(o => o.Score_new).ToList()); }
protected void Page_Load(object sender, EventArgs e) { if (!this.Page.IsPostBack) { bool IsCom = false; int ret = 0; if (!string.IsNullOrEmpty(Request.Form["ctl00$MainContent$heUserID"])) { //try //{ int UserId = int.Parse(Request.Form["ctl00$MainContent$heUserID"]); //Profile Process string FirstName = Request.Form["ctl00$MainContent$firstName"]; string LastName = Request.Form["ctl00$MainContent$LastName"]; string bytGender = Request.Form["ctl00$MainContent$dropGender"]; string Nationality = Request.Form["ctl00$MainContent$dropNation"]; string DatBirth = Request.Form["ctl00$MainContent$day"]; string Phone = Request.Form["ctl00$MainContent$txtPhon"]; Model_Users us = new Model_Users { UserID = UserId, FirstName = FirstName, LastName = LastName, DateofBirth = DatBirth.DateSplitYear('-'), Gender = byte.Parse(bytGender), Nationality = int.Parse(Nationality), MobileNumber = Phone }; us.UpdateUserProfileFront(us); //Fuction Competencies string FCCheck = Request.Form["chckFC_form"]; if (!string.IsNullOrEmpty(FCCheck)) { string[] arrfc = FCCheck.Split(','); if (arrfc.Length > 0) { List <Model_UserFC> list = new List <Model_UserFC>(); foreach (string i in arrfc) { list.Add(new Model_UserFC { FCID = int.Parse(i), UserID = UserId }); } Model_UserFC fc = new Model_UserFC(); fc.AddUserFC(list, UserId); } } //Current Job string CJFCheck = Request.Form["chckCJF_form"]; if (!string.IsNullOrEmpty(CJFCheck)) { string[] arrcjf = CJFCheck.Split(','); if (arrcjf.Length > 0) { List <Model_UserCJF> list = new List <Model_UserCJF>(); foreach (string i in arrcjf) { list.Add(new Model_UserCJF { CJFID = int.Parse(i), UserID = UserId }); } Model_UserCJF cjf = new Model_UserCJF(); cjf.AddUserCjf(list, UserId); } } //UserAssessment Transaction Model_UsersTransaction ts = new Model_UsersTransaction { UserID = UserId }; int tsid = ts.InsertUserTsAss(ts); if (tsid > 0) { //Score Process string ass = Request.Form["ass_fill_"]; if (!string.IsNullOrEmpty(Request.Form["ass_fill_"])) { string[] arrAss = ass.Split(','); if (arrAss.Length > 0) { //List<Model_UsersAssessment> uslist = new List<Model_UsersAssessment>(); foreach (string assItem in arrAss) { string assSCore = Request.Form["ass_fill_i_sc_" + assItem]; //if (!string.IsNullOrEmpty(assSCore)) // { int AssID = int.Parse(assItem); int AssScore = 0; if (!string.IsNullOrEmpty(assSCore)) { AssScore = int.Parse(assSCore); } Model_UsersAssessment uass = new Model_UsersAssessment { ASID = AssID, TransactionID = tsid, Score = AssScore }; int intTASID = uass.InsertUserAssessment(uass); string asssChoice = Request.Form["ass_fill_ch_" + assItem]; if (!string.IsNullOrEmpty(asssChoice)) { string[] arrChoice = asssChoice.Split(','); if (arrChoice.Length > 0) { foreach (string choiceItem in arrChoice) { string assChoiceScore = Request.Form["ass_fill_ch_sc_" + assItem + "_" + choiceItem]; if (!string.IsNullOrEmpty(assChoiceScore)) { int AssChoiceID = int.Parse(choiceItem); int AssChoiceScore = int.Parse(assChoiceScore); Model_UsersAssChoice usch = new Model_UsersAssChoice { ASID = AssID, TransactionID = tsid, ASCID = AssChoiceID, TASID = intTASID, Score = AssChoiceScore }; usch.InsertUserAssessmentChoice(usch); //insert choice here } } } } // } } } } } // assessment is recorded! IsCom = true; if (IsCom) { ret = CalculationController.CalculateActionStart(tsid); } //} //catch(Exception ex) //{ // string ee = ex.Message + ex.StackTrace; // IsCom = false; //} } string strRet = "True"; switch (ret) { case -1: strRet = "False"; break; case 0: strRet = "True"; break; default: strRet = ret.ToString(); break; } Response.Write(strRet); Response.End(); } }
protected void Page_Load(object sender, EventArgs e) { this.Page.Title = "KeenProfile Assessment Extra"; if (!this.Page.IsPostBack) { if (!string.IsNullOrEmpty(Request.QueryString["success"])) { main_thanks.Visible = true; main_form.Visible = false; Model_AssesIntro intro = new Model_AssesIntro(); intro = intro.GetIntro(); ThanksTitle.Text = intro.ThanksTitle; ThanksDes.Text = convertcontent(intro.ThanksDes); } else { Model_Users u = this.UserActive; if (u != null) { heUserID.Value = u.UserID.ToString(); if (!string.IsNullOrEmpty(Request.QueryString["ts"])) { int intTs = int.Parse(Request.QueryString["ts"]); hdTsID.Value = intTs.ToString(); Model_ReportItemResult cr = new Model_ReportItemResult(); Model_UsersAssessment us = new Model_UsersAssessment(); List <Model_UsersAssessment> uss = us.GetUserAssessmentByTsID(intTs); List <Model_ReportItemResult> crl = cr.GetItemReportByTransactionID(intTs); List <Model_ReportItemResult> dup = crl.Where(o => o.IsDup > 0).ToList(); Dictionary <decimal, int> GroupDup = dup.GroupBy(x => (decimal)x.Score_new) .Where(g => g.Count() > 1) .ToDictionary(x => x.Key, y => y.Count()); int numStep = GroupDup.Count(); StringBuilder ret = new StringBuilder(); int count = 1; foreach (KeyValuePair <decimal, int> q in GroupDup) { List <Model_ReportItemResult> dupfocus = dup.Where(d => d.Score_new == q.Key).OrderByDescending(r => r.Score_new).ToList(); ret.Append("<h1 class=\"step_count\"></h1>\r\n"); ret.Append("<div class=\"step-content\" data-valid=\"check_choice\" data-count=\"" + (dupfocus.Count < 3 ? 3 : dupfocus.Count) + "\">\r\n"); ret.Append("<input type=\"hidden\" name=\"ass_fill_\" value=\"" + count + "\" />\r\n"); ret.Append("<div class=\"text-center m-t-md\">\r\n"); ret.Append("<h2>โปรดให้ระดับคะแนนความสำคัญของข้อความต่อไปนี้ว่าข้อความใดตรงกับตัวตนของคุณมากที่สุด โดยในแต่ละข้อโปรดเลือกระดับคะแนนของแต่ละข้อความไม่ให้ซ้ำกัน</h2>\r\n"); ret.Append("<div class=\"question-type q-type-rank-scale-choice\">\r\n"); ret.Append("<div class=\"col-md-12 tbl-rank-scale\" >\r\n"); ret.Append("<table>\r\n"); ret.Append("<tr>\r\n"); ret.Append("<td class=\"question\"></td>\r\n"); //ret.Append("<input type=\"hidden\" name=\"ass_fill_i_sc_" + ass.ASID + "\" value=\"0\" />"); for (int i = 1; i <= (dupfocus.Count < 3 ? 3 : dupfocus.Count); i++) { if (i == 1) { ret.Append("<td class=\"choice\">" + i + "<br /><span> เป็นตัวตนของฉัน \"น้อย\" ที่สุด</span></td>\r\n"); } else if (i == (dupfocus.Count < 3 ? 3 : dupfocus.Count)) { ret.Append("<td class=\"choice\">" + i + "<br /> <span> เป็นตัวตนของฉัน \"มาก\" ที่สุด</span></td>\r\n"); } else { ret.Append("<td class=\"choice\">" + i + "</td>\r\n"); } } ret.Append(" </tr>\r\n"); if (dupfocus.Count > 0) { foreach (Model_ReportItemResult ch in dupfocus) { Model_UsersAssessment assuser = uss.FirstOrDefault(o => o.TASID == ch.TASID); if (assuser != null) { ret.Append("<tr>\r\n"); ret.Append("<input type=\"hidden\" name=\"ass_fill_ch_\" value=\"" + ch.TASID + "\" />\r\n"); ret.Append("<td class=\"question\">" + assuser.Questions + "</td>\r\n"); //for (int i = 1; i <= (dupfocus.Count < 3? 3: dupfocus.Count); i++) for (int i = (dupfocus.Count < 3 ? 3 : dupfocus.Count); i >= 1; i--) { //ret.Append("<td class=\"choice\"><input type=\"radio\" name=\"ass_fill_ch_sc_" + ch.ResultID + "\" value=\"" + i + "\" /></td>\r\n"); ret.Append("<td class=\"choice\"><input type=\"radio\" name=\"ass_fill_ch_sc_" + ch.TASID + "\" value=\"" + i + "\" /></td>\r\n"); } ret.Append("</tr>\r\n"); } } if (dupfocus.Count < 3) { List <Model_UsersAssessment> randomlist = new List <Model_UsersAssessment>(); foreach (Model_UsersAssessment i in uss) { foreach (Model_ReportItemResult ch in dupfocus) { if (i.TASID != ch.TASID) { randomlist.Add(i); } } } Model_UsersAssessment rd = randomlist.Where(p => !dupfocus.Any(p2 => p2.TASID == p.TASID)).Skip(3).FirstOrDefault(); ret.Append("<tr>\r\n"); //ret.Append("<input type=\"hidden\" name=\"ass_fill_ch_\" value=\"" + rd.ResultID + "\" />\r\n"); ret.Append("<td class=\"question\">" + rd.Questions + "</td>\r\n"); //for (int i = 1; i <= (dupfocus.Count < 3 ? 3 : dupfocus.Count); i++) for (int i = (dupfocus.Count < 3 ? 3 : dupfocus.Count); i >= 1; i--) { ret.Append("<td class=\"choice\"><input type=\"radio\" name=\"ass_fill_ch_sc_" + rd.TASID + "\" value=\"" + i + "\" /></td>\r\n"); } ret.Append("</tr>\r\n"); } } ret.Append("</table>\r\n"); ret.Append("</div>\r\n"); ret.Append("</div>\r\n"); ret.Append("</div>\r\n"); ret.Append("</div>\r\n"); count = count + 1; } Stepcontent.Text = ret.ToString(); numtopic.Text = (count - 1).ToString(); } } } } else { //Button btn = (Button)sender; //Response.Write(chckCJF.SelectedValue); } }
protected void Page_Load(object sender, EventArgs e) { if (!this.Page.IsPostBack) { if (!string.IsNullOrEmpty(Request.QueryString["ts"])) { int tsID = int.Parse(Request.QueryString["ts"]); Model_UsersAssessment uss = new Model_UsersAssessment(); List <Model_UsersAssessment> ussList = uss.GetUserAssessmentByTsID(tsID); StringBuilder ret = new StringBuilder(); ret.Append("<div class=\"table-responsive\">"); ret.Append("<table class=\"table table-striped\">"); ret.Append("<thead>"); ret.Append("<tr>"); ret.Append("<th>Code</th>"); ret.Append("<th>Question</th>"); ret.Append("<th>Question Type </th>"); ret.Append("<th>Section </th>"); ret.Append("<th>SubSection </th>"); ret.Append("<th>Score </th>"); //ret.Append("<th>Task</th>"); //ret.Append("<th>Date</th>"); //ret.Append("<th>Date</th>"); //ret.Append("<th >Action</th>"); ret.Append("</tr>"); ret.Append("</thead>"); ret.Append("<tbody>"); foreach (Model_UsersAssessment item in ussList) { ret.Append("<tr>"); Model_UsersAssChoice ch = new Model_UsersAssChoice(); List <Model_UsersAssChoice> chlist = ch.GetUserAssessmentChoiceByTsID(item.TASID); ret.Append("<td><input style=\"display:none\" type=\"checkbox\" name=\"TASID\" checked=\"checked\" value=\"" + item.TASID + "\" /><input type=\"text\" class=\"form-control\" style=\"text-align:center;\" readonly=\"true\" name=\"TASID_code_" + item.TASID + "\" value=\"" + item.Code + "\" /></td>"); ret.Append("<td>" + item.Questions + "</td>"); ret.Append("<td>" + item.QuestionTypeTitle + (item.QTID == 5? " <br/><strong>[" + item.GroupName + "][" + (item.Side == 1? "Left":"Right") + "]</strong>" : "") + "</td>"); ret.Append("<td>" + item.SectionTitle + "</td>"); ret.Append("<td>" + item.SubSectionTitle + "</td>"); ret.Append("<td><input type=\"text\" name=\"TASID_score_" + item.TASID + "\" class=\"form-control\" style=\"text-align:center;\" value=\"" + item.Score + "\" /></td>"); ret.Append("</tr>"); if (chlist.Count > 0) { ret.Append("<tr>"); ret.Append("<td colspan=\"6\">"); ret.Append("<table class=\"table \">"); ret.Append("<thead>"); ret.Append("<tr>"); ret.Append("<th>Code</th>"); ret.Append("<th>Question</th>"); ret.Append("<th>SubSection </th>"); ret.Append("<th>Score </th>"); ret.Append("</tr>"); ret.Append("</thead>"); ret.Append("<tbody>"); foreach (Model_UsersAssChoice choice in chlist) { ret.Append("<tr>"); ret.Append("<td><input style=\"display:none\" type=\"checkbox\" name=\"TASCID\" checked=\"checked\" value=\"" + choice.TASCID + "\" /><input type=\"text\" class=\"form-control\" style=\"text-align:center;\" readonly=\"true\" name=\"TASCID_code_" + choice.TASCID + "\" value=\"" + choice.Code + "\" /></td>"); ret.Append("<td>" + choice.Questions + "</td>"); ret.Append("<td>" + choice.SubSectionTitle + "</td>"); ret.Append("<td><input type=\"text\" name=\"TASCID_score_" + choice.TASCID + "\" class=\"form-control\" style=\"text-align:center;\" value=\"" + choice.Score + "\" /></td>"); ; ret.Append("</tr>"); } ret.Append("</tbody>"); ret.Append("</table>"); ret.Append("</td>"); ret.Append("</tr>"); } } ret.Append("</tbody>"); ret.Append("</table>"); ret.Append("</div>"); data.Text = ret.ToString(); } } }