private void _BindData() { try { double percentage = 0.0; DataTable dsStud = objStudent.GetStudentInfo(Convert.ToInt32(Session["UserId"])); int classId = Convert.ToInt32(dsStud.Rows[0]["ClassId"].ToString()); int CompleteLegs = objStudent.GetCompleteLegCount(classId); DataTable dsPrevStage = objStudent.GetLastCompleteLeg(classId); int showOld = 0; DataSet ds = objStudent.GetCurrentStageInfo(Convert.ToInt32(Session["UserId"].ToString()), Convert.ToInt32(Session["UserRoleId"].ToString()), classId); if ((ds != null && ds.Tables[0].Rows.Count > 0) || (CompleteLegs > 0)) { divForumBlog.Style.Add("Width", "700px"); DataTable dtm = new DataTable(); dtm = objStudent.GetVisitedCity(classId.ToString()); if (dtm.Rows.Count > 0) { ddlcity.DataSource = dtm; ddlcity.DataTextField = "CityName"; ddlcity.DataValueField = "CityId"; ddlcity.DataBind(); ddlcity.Items.Insert(0, new ListItem(" Stadt", "0")); } else { ddlcity.Items.Add(new ListItem(" Stadt", "0")); } if (dtm.Rows.Count > 0) { ddlcity.SelectedValue = dtm.Rows[dtm.Rows.Count - 1]["CityId"].ToString(); } lblCongratulations1.Visible = false; lblCongratulations3.Visible = false; if ((ds.Tables[0] != null && ds.Tables[0].Rows.Count > 0)) { //lblCurrentStage.Text = (string)GetLocalResourceObject("CurrentStage") + "<br/>" + ds.Tables[0].Rows[0]["StartCity"].ToString() + // " => " + ds.Tables[0].Rows[0]["EndCity"].ToString(); hdn_StartCity.Value = ds.Tables[0].Rows[0]["StartCityId"].ToString(); hdn_EndCity.Value = ds.Tables[0].Rows[0]["EndCityId"].ToString(); // QuizTest(Convert.ToInt32(hdn_StartCity.Value)); string FromCity = "../CityImages/" + ds.Tables[0].Rows[0]["FromCityimage"].ToString(); string ToCity = "../CityImages/" + ds.Tables[0].Rows[0]["ToCityimage"].ToString(); if (ds.Tables[0].Rows[0]["FromCityimage"].ToString() != "") { imgFromCity.ImageUrl = FromCity; } else { imgFromCity.ImageUrl = "../CityImages/noImageBig.png"; } imgFromCity.ToolTip = ds.Tables[0].Rows[0]["StartCity"].ToString(); if (ds.Tables[0].Rows[0]["ToCityimage"].ToString() != "") { imgToCity.ImageUrl = ToCity; } else { imgToCity.ImageUrl = "../CityImages/noImageBig.png"; } imgToCity.ToolTip = ds.Tables[0].Rows[0]["EndCity"].ToString(); if (hdn_StartCity.Value.ToString() != "0" || CompleteLegs == 0) { // QuizTest(Convert.ToInt32(hdn_StartCity.Value)); Session["StartCity"] = hdn_StartCity.Value.ToString(); Session["CurrentClass"] = classId.ToString(); DataTable dt = objStudent.GetQuizResult(classId, Convert.ToInt32(hdn_StartCity.Value)); dt.DefaultView.RowFilter = " IsPassed =1"; int isPassed = dt.DefaultView.Count; dt.DefaultView.RowFilter = string.Empty; if ((isPassed == 1 || dt.Rows.Count > 5) || CompleteLegs == 0) { if (objStudent.GetNextStageFiles(classId) == 0 && CompleteLegs != 0) { lbl_TestResult.Text = (string)GetLocalResourceObject("PassedTest") + "<br/>" + (string)GetLocalResourceObject("ContinueToNextStage") + "<br/>"; lbl_TestResult.Visible = true; div_Congrats.Visible = false; } } else { #region Change : Show Old Leg till Quiz passed try { showOld = 1; if (dsPrevStage.Rows.Count > 0) { lblCurrentStage.Text = (string)GetLocalResourceObject("CurrentStage") + "<br/>" + dsPrevStage.Rows[0]["StartCity"].ToString() + " => " + dsPrevStage.Rows[0]["EndCity"].ToString(); hdn_StartCity.Value = dsPrevStage.Rows[0]["FromCityId"].ToString(); hdn_EndCity.Value = dsPrevStage.Rows[0]["ToCityId"].ToString(); FromCity = "../CityImages/" + dsPrevStage.Rows[0]["FromCityimage"].ToString(); ToCity = "../CityImages/" + dsPrevStage.Rows[0]["ToCityimage"].ToString(); if (dsPrevStage.Rows[0]["FromCityimage"].ToString() != "") { imgFromCity.ImageUrl = FromCity; } else { imgFromCity.ImageUrl = "../CityImages/noImageBig.png"; } imgFromCity.ToolTip = dsPrevStage.Rows[0]["StartCity"].ToString(); if (dsPrevStage.Rows[0]["ToCityimage"].ToString() != "") { imgToCity.ImageUrl = ToCity; } else { imgToCity.ImageUrl = "../CityImages/noImageBig.png"; } imgToCity.ToolTip = dsPrevStage.Rows[0]["EndCity"].ToString(); } } catch { showOld = 0; } #endregion div_NextStage.Visible = true; div_RightCol.Visible = false; } } else { div_QuizTest.Visible = false; } if (ds.Tables[0].Rows[0]["lastreachedcity"].ToString() != "") { lblCongratulations2.Text = ds.Tables[0].Rows[0]["lastreachedcity"].ToString(); lblCongratulations1.Visible = true; lblCongratulations3.Visible = true; //lblFromCityName.Text = ds.Tables[0].Rows[0]["lastreachedcity"].ToString(); } else { //lblFromCityName.Text = ds.Tables[0].Rows[0]["StartCity"].ToString(); } try { double sm2 = 0; double sm3 = 0; if (showOld == 0) { sm2 = double.Parse(ds.Tables[0].Rows[0]["Distance_Covered"].ToString().Replace(@",", "."), System.Globalization.CultureInfo.InvariantCulture); sm3 = double.Parse(ds.Tables[0].Rows[0]["Distance"].ToString(), System.Globalization.CultureInfo.InvariantCulture); percentage = ((sm2 * 100) / Convert.ToDouble(ds.Tables[0].Rows[0]["Distance"])); } else { sm2 = double.Parse(dsPrevStage.Rows[0]["Distance_Covered"].ToString().Replace(@",", "."), System.Globalization.CultureInfo.InvariantCulture); sm3 = double.Parse(dsPrevStage.Rows[0]["Distance"].ToString(), System.Globalization.CultureInfo.InvariantCulture); percentage = ((sm2 * 100) / Convert.ToDouble(dsPrevStage.Rows[0]["Distance"])); } lblDistanceCovered.Text = (Math.Round(sm2, 2).ToString() + " km " + (string)GetLocalResourceObject("From") + " " + Math.Round(sm3, 2).ToString() + " km " + (string)GetLocalResourceObject("driven") + "").Replace(",", ".").ToString(); } catch (Exception ex) { } //Remove(); //if (showOld == 0) //{ // _BindMap(ds.Tables[0].Rows[0]["StartCity"].ToString(), ds.Tables[0].Rows[0]["EndCity"].ToString(), percentage, Convert.ToDouble(ds.Tables[0].Rows[0]["FromCityLat"].ToString()), Convert.ToDouble(ds.Tables[0].Rows[0]["FromCityLong"].ToString()), Convert.ToDouble(ds.Tables[0].Rows[0]["ToCityLat"].ToString()), Convert.ToDouble(ds.Tables[0].Rows[0]["ToCityLong"].ToString())); //} //else //{ // _BindMap(dsPrevStage.Rows[0]["StartCity"].ToString(), dsPrevStage.Rows[0]["EndCity"].ToString(), percentage, Convert.ToDouble(dsPrevStage.Rows[0]["FromCityLat"].ToString()), Convert.ToDouble(dsPrevStage.Rows[0]["FromCityLong"].ToString()), Convert.ToDouble(dsPrevStage.Rows[0]["ToCityLat"].ToString()), Convert.ToDouble(dsPrevStage.Rows[0]["ToCityLong"].ToString())); //} } else { if (CompleteLegs > 0) { DataTable dtLStage = objStudent.GetLastCompleteStageInfo(Convert.ToInt32(Session["UserId"].ToString()), Convert.ToInt32(Session["UserRoleId"].ToString()), classId); if (dtLStage.Rows.Count > 0) { // lblCurrentStage.Text = (string)GetLocalResourceObject("LastStage") + "<br/>" + dtLStage.Rows[0]["StartCity"].ToString() + //" => " + dtLStage.Rows[0]["EndCity"].ToString(); hdn_StartCity.Value = dtLStage.Rows[0]["StartCityId"].ToString(); hdn_EndCity.Value = dtLStage.Rows[0]["EndCityId"].ToString(); string FromCity = "../CityImages/" + dtLStage.Rows[0]["FromCityimage"].ToString(); string ToCity = "../CityImages/" + dtLStage.Rows[0]["ToCityimage"].ToString(); if (dtLStage.Rows[0]["FromCityimage"].ToString() != "") { imgFromCity.ImageUrl = FromCity; } else { imgFromCity.ImageUrl = "../CityImages/noImageBig.png"; } imgFromCity.ToolTip = dtLStage.Rows[0]["FromCityimage"].ToString(); if (dtLStage.Rows[0]["ToCityimage"].ToString() != "") { imgToCity.ImageUrl = ToCity; } else { imgToCity.ImageUrl = "../CityImages/noImageBig.png"; } imgToCity.ToolTip = dtLStage.Rows[0]["ToCityimage"].ToString(); div_QuizTest.Visible = false; //lblFromCityName.Text = dtLStage.Rows[0]["StartCity"].ToString(); try { double sm2 = double.Parse(dtLStage.Rows[0]["Distance_Covered"].ToString().Replace(@",", "."), System.Globalization.CultureInfo.InvariantCulture); double sm3 = double.Parse(dtLStage.Rows[0]["Distance"].ToString(), System.Globalization.CultureInfo.InvariantCulture); percentage = ((sm2 * 100) / Convert.ToDouble(dtLStage.Rows[0]["Distance"])); lblDistanceCovered.Text = (Math.Round(sm2, 2).ToString() + " km von " + Math.Round(sm3, 2).ToString() + " km " + (string)GetLocalResourceObject("driven") + "").Replace(",", ".").ToString(); } catch (Exception ex) { } //Remove(); //_BindMap(dtLStage.Rows[0]["StartCity"].ToString(), dtLStage.Rows[0]["EndCity"].ToString(), percentage, Convert.ToDouble(dtLStage.Rows[0]["FromCityLat"].ToString()), Convert.ToDouble(dtLStage.Rows[0]["FromCityLong"].ToString()), Convert.ToDouble(dtLStage.Rows[0]["ToCityLat"].ToString()), Convert.ToDouble(dtLStage.Rows[0]["ToCityLong"].ToString())); } } } if (ds.Tables[1] != null && ds.Tables[1].Rows.Count > 0) { ltlClassForum.Text += " - " + ds.Tables[1].Rows[0]["School"].ToString(); //h1_ClassForum.InnerHtml += " - " + ds.Tables[1].Rows[0]["School"].ToString(); // BindGermanyMap(); } if (ds.Tables[2] != null && ds.Tables[2].Rows.Count > 0) { div_RightCol.Visible = true; lbtnCityInfo.Visible = true; div_QuizTest.Visible = true; lbtnCityInfo.PostBackUrl = "~/Student/CityInfo.aspx?cityid=" + ds.Tables[2].Rows[0]["cityInfoCityId"].ToString() + "&cityname=" + ds.Tables[2].Rows[0]["cityname"].ToString() + "&parent=student"; } } else { // BindGermanyMap(); div_NoStagePlan.Visible = true; div_Content.Visible = false; divForumBlog.Style.Add("Width", "100%"); } } catch (Exception ex) { } }