public ActionResult InsertId(Results_Information_viewmodel model, string classname)
        {
            if (classname == "5")
            {
                MvcDatabase1Entities2 rd5       = new MvcDatabase1Entities2();
                ResultDatabaseClass5  stdresult = new ResultDatabaseClass5();
                stdresult.StudentId = model.StudentId;
                stdresult.Term      = model.Term;
                rd5.ResultDatabaseClass5.Add(stdresult);

                try
                {
                    rd5.SaveChanges();
                }
                catch (Exception ex)
                {
                    throw ex;
                }
                // ViewData.sid = new List<int>();



                return(RedirectToAction("Insertresultdb", model));
            }
            else if (classname == "6")
            {
                MvcDatabase1Entities3 rd6  = new MvcDatabase1Entities3();
                ResultDatabaseClass6  std6 = new ResultDatabaseClass6();
                std6.StudentId = model.StudentId;
                std6.Term      = model.Term;
                rd6.ResultDatabaseClass6.Add(std6);
                rd6.SaveChanges();
                //stdresult.StudentId = model.StudentId;
                //stdresult.Term = model.Term;
                //rd5.ResultDatabaseClass5.Add(stdresult);

                //try
                //{
                //    rd5.SaveChanges();
                //}
                //catch (Exception ex)
                //{
                //    throw ex;
                //}
                //// ViewData.sid = new List<int>();



                return(RedirectToAction("Insertresultdb6", "ResultsDb6", model));
            }

            else
            {
                return(View());
            }
        }
        public ActionResult Insertresultdb(Results_Information_viewmodel model, string subject, string marks)
        {
            //double begin ,total=0 ;


            s = model.StudentId;

            SqlConnection con = new SqlConnection(@"Data Source=(LocalDB)\v11.0;AttachDbFilename= C:\Users\HP\Documents\Visual Studio 2013\Projects\MvcApplication1\MvcApplication1\App_Data\MvcDatabase1.mdf;Integrated Security=True");

            con.Open();


            MvcDatabase1Entities2 db  = new MvcDatabase1Entities2();
            ResultDatabaseClass5  rd5 = new ResultDatabaseClass5();
            int    m = Convert.ToInt32(marks);
            double b = Convert.ToDouble(m);

            ViewBag.Subject = subject + " " + marks;
            ViewBag.x       = MARKS;
            MARKS++;
            ViewBag.gpa_ = gpa;
            ViewBag.sid  = model.StudentId;
            List <ResultDatabaseClass5> l = new List <ResultDatabaseClass5>();

            begin = grading(b);
            if (subject == "Bengali")
            {
                model.Bengali = m;
                rd5.Bengali   = m;
                l.Add(rd5);
                SqlCommand cmd = new SqlCommand(" UPDATE ResultDatabaseClass5 set Bengali = '" + rd5.Bengali + "' where (StudentId = '" + model.StudentId + "')", con);
                cmd.ExecuteNonQuery();
            }

            if (subject == "English")
            {
                //  int m = Convert.ToInt32(marks);
                model.English = m;
                rd5.English   = m;
                l.Add(rd5);
                SqlCommand cmd = new SqlCommand(" UPDATE ResultDatabaseClass5 set English = '" + rd5.English + "' where (StudentId = '" + model.StudentId + "')", con);
                cmd.ExecuteNonQuery();
            }

            if (subject == "Mathematics")
            {
                model.Mathematics = m;
                rd5.Mathematics   = m;
                l.Add(rd5);
                SqlCommand cmd = new SqlCommand(" UPDATE ResultDatabaseClass5 set Mathematics = '" + rd5.Mathematics + "' where (StudentId = '" + model.StudentId + "')", con);
                cmd.ExecuteNonQuery();
            }
            if (subject == "Science")
            {
                model.Science = m;
                rd5.Science   = m;
                l.Add(rd5);
                SqlCommand cmd = new SqlCommand(" UPDATE ResultDatabaseClass5 set Science = '" + rd5.Science + "' where (StudentId = '" + model.StudentId + "')", con);
                cmd.ExecuteNonQuery();
            }
            if (subject == "Religion")
            {
                model.Religion = m;
                rd5.Religion   = m;
                l.Add(rd5);
                SqlCommand cmd = new SqlCommand(" UPDATE ResultDatabaseClass5 set Religion = '" + rd5.Religion + "' where (StudentId = '" + model.StudentId + "')", con);
                cmd.ExecuteNonQuery();
            }
            if (subject == "Bangladesh_and_Global_Studies")
            {
                model.Bangladesh_and_Global_Studies = m;
                rd5.Bangladesh_and_Global_Studies   = m;
                l.Add(rd5);
                SqlCommand cmd = new SqlCommand(" UPDATE ResultDatabaseClass5 set Bangladesh_and_Global_Studies = '" + rd5.Bangladesh_and_Global_Studies + "' where (StudentId = '" + model.StudentId + "')", con);
                cmd.ExecuteNonQuery();
            }
            //begin = b;
            total = total + begin;
            //string connectionstring = ConfigurationManager.ConnectionStrings["MvcDatabase1Entities2"].ConnectionString;


            //cmd.ExecuteNonQuery();
            con.Close();


            //db.Entry(rd5).State = EntityState.Modified;
            try
            {
                db.SaveChanges();
            }
            catch (Exception ex)
            {
                //throw ex;
            }

            // db.ResultDatabaseClass5.ToList<l
            return(View(model));
        }