// GET: Exam/Edit/5 public ActionResult Edit() { Exam.Models.Exam ex = new Models.Exam(); SqlConnection con = new SqlConnection(); con.ConnectionString = @"Data Source=(localdb)\MsSqlLocalDb;Initial Catalog=Exam;Integrated Security=True;Pooling=False"; con.Open(); SqlCommand cmd = new SqlCommand(); cmd.Connection = con; cmd.CommandType = System.Data.CommandType.Text; cmd.CommandText = "select * from Exam where UserName=@UserName"; cmd.Parameters.AddWithValue("@UserName", Session["UserName"]); SqlDataReader dr = cmd.ExecuteReader(); if (dr.Read()) { ex.UserName = (string)dr["UserName"]; ex.Password = (string)dr["PassWord"]; } return(View(ex)); }
private SelectList GetAllExams(string AYID = "", string SchoolId = "", string ClassID = "", string AssessmentType = "") { Models.Exam obj = new Models.Exam(); obj.AYID = AYID; obj.SchoolID = SchoolId; obj.ExamType = "UnitTest"; obj.AssessmentType = AssessmentType; obj.ClassID = ClassID; SelectList retList = null; List<Models.Exam> ObjList = _ExamService.GetAllForLookup(obj).ToList(); if (retList == null) retList = new SelectList(ObjList, ExamMst_Constant.EXAM_ID, ExamMst_Constant.EXAM_NAME); return retList; }