using System; using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.Data; using System.IO; using System.Configuration; using System.Data.SqlClient; using System.ServiceModel; using nmsSetup; using KMASchoolERP; public partial class Default : System.Web.UI.Page { static Int32 gType = 0; static string meCoursID = ""; static string meCourse = ""; string stuid = ""; SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["cn"].ConnectionString); protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { if (Session["officeWebUser"] != null) { try { string getlist = Session["officeWebUser"] as string; string[] getval = getlist.Split(','); gType = Convert.ToInt32(getval[7]); stuid = getval[1]; string welcome = "Welcome"; if (welcome != "") { // return "some text"; } mprofile.InnerText = getval[2]; getcourseid(getval[1]); bindCourse(); } catch(Exception ex) { Response.Redirect("../loginstu.aspx?log=student"); } } // ExamDetail(); //if (Session["WebSess"] == null) //{ // bind_Theory(); // bind_Video(); //} } } public void bindCourse() { if (gType <= 0) { mCourse.InnerText = "No Course Assigned Yet!"; string getlist = Session["WebSess"] as string; ; string[] getval = getlist.Split(','); string[] getphoto = getval[6].Split('.'); if (getphoto[2] == "/icon/default_img") { //Image1.ImageUrl = "assets/images/user.png"; } //meData.Visible = false; } else { mCourse.InnerText = "My Course : " + meCourse; string getlist = Session["officeWebUser"] as string; ; string[] getval = getlist.Split(','); //string[] getphoto = getval[6].Split('.'); //if(getphoto[2]!=null && getphoto[2]!="") //{ //if (getphoto[2] == "/icon/default_img") //{ // Image1.ImageUrl = "assets/images/user.png"; //} //} //Image1.ImageUrl = "assets/images/user.png"; //meData.Visible = true; //bind_Theory(); // bind_Video(); } } //-----------Getting All Data----------------// public void getcourseid(string UserCode) { SqlDataAdapter adp = new SqlDataAdapter("select*from studentdetail where studentcode=" + UserCode + "", con); adp.SelectCommand.CommandType = CommandType.Text; DataTable dt = new DataTable(); adp.Fill(dt); if (dt.Rows.Count > 0) { meCoursID = dt.Rows[0]["courseId"].ToString(); meCourse = dt.Rows[0]["courseName"].ToString(); } } public class clsprp { public string id { get; set; } public string title { get; set; } public string description { get; set; } public string urlPath { get; set; } public string subtitle { get; set; } public string name { get; set; } public string catID { get; set; } public string courseName { get; set; } public string courseId { get; set; } } public List ViewData(clsprp p) { if (con.State == ConnectionState.Closed) con.Open(); List lst = new List(); SqlCommand cmd = new SqlCommand(); cmd.CommandText = "View_TopicFileDetail"; cmd.Connection = con; cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@topicid", p.catID); cmd.Parameters.AddWithValue("@id", p.id); SqlDataReader dr = cmd.ExecuteReader(); clsprp obj; if (dr.HasRows) { while (dr.Read()) { obj = new clsprp(); obj.id = dr["mtfid"].ToString(); obj.title = dr["mtftitles"].ToString(); obj.description = dr["mtfDescription"].ToString(); obj.urlPath = dr["mtfFilePath"].ToString(); obj.subtitle = dr["mtfExtenstion"].ToString(); obj.name = dr["mftName"].ToString(); obj.catID = dr["mtfType"].ToString(); obj.courseName = dr["courseName"].ToString(); obj.courseId = dr["mtfTopicid"].ToString(); lst.Add(obj); } } dr.Close(); cmd.Dispose(); con.Close(); return lst; } public void bind_Theory() { List lst = new List(); clsprp obj = new clsprp(); obj.catID = meCoursID; obj.id = ""; lst = ViewData(obj); string str = ""; if (lst.Count > 0) { str += "
"; foreach (clsprp p in lst) { if (p.catID == "1") { str += "
"; if (p.urlPath != null && p.urlPath != "") { str += "
"; str += "

"; str += "" + p.title + ""; str += "

"; str += "
"; //-------Now Content-----------// str += "
"; str += "
" + p.description + "
 View Full Detail
"; str += "
"; str += "
"; } else { str += "
"; str += "

"; str += "" + p.title + ""; str += "

"; str += "
"; //-------Now Content-----------// str += "
"; str += "
" + p.description + "
"; str += "
"; str += "
"; } } } str += ""; //get_Theory.InnerHtml = str; } else { // get_Theory.InnerHtml = "No Results Founds!"; } //else //{ // get_home.InnerHtml = "No Results Founds!"; //} } //-----------Bind Video--------------// public void bind_Video() { List lst = new List(); clsprp obj = new clsprp(); obj.catID = meCoursID; obj.id = ""; lst = ViewData(obj); string str = ""; if (lst.Count > 0) { foreach (clsprp p in lst) { if (p.catID == "3") { str += "
"; str += "
"; str += ""; str += "
" + p.title + "
"; str += "
"; str += "
"; } } //get_video.InnerHtml = str; } else { // get_video.InnerHtml = "No Results Founds!"; } //else //{ // get_home.InnerHtml = "No Results Founds!"; //} } //-------------------Getting Test Detail--------------------// public void ExamDetail() { Service b = new Service(); System.Web.Script.Serialization.JavaScriptSerializer srl1 = new System.Web.Script.Serialization.JavaScriptSerializer(); List lst1 = new List(); //------------for Getting User Test Type------------// //if (Session["WebSess"] != null) //{ // string getstr = Request.QueryString["log"].ToString();//Session["WebSess"].ToString(); //string[] getval = getstr.Split(','); //stuid = Request.QueryString["log"].ToString();//getval[1]; //Session["officeWebUser"] = stuid; string data1 = b.viewTestDetail(stuid); lst1 = srl1.Deserialize>(data1); string str = ""; string testStatus = ""; testActive.InnerText = "Test Not Assigned"; if (lst1.Count > 0) { foreach (clsExam p in lst1) { var tmint = p.mint; var zero = "0"; if(tmint.Length < 10 ) { tmint = zero.ToString() + tmint.ToString(); } else { tmint = 0+tmint; } cName.InnerText = p.name; tName.InnerText = p.testname; toQuestion.InnerText = p.totle_Quest; toTime.InnerText = p.testSdate;//p.hour + " : " + tmint + " " + p.accountId; // testStatus = p.isactive; DateTime now = DateTime.Now; string todate = now.ToString(); if (p.status == "0" && testStatus=="0") { testActive.InnerText = "Enabled"; str += ""; } else { testActive.InnerText = "Completed"; str += ""; } } STest.InnerHtml = str; //} } } }