Example #1
0
        public ActionResult Savestudent(Student student)
        {
            string msg = "";

            if (ModelState.IsValid)
            {
                SqlConnection con = new SqlConnection("Data Source=DESKTOP-EF9DLAS;Initial Catalog=Studentmvc;Integrated Security=True");
                con.Open();
                string     querry   = "INSERT INTO student_table (student_name,reg_no,email,address,dept_id) VALUES('" + student.student_name + "','" + student.reg_no + "','" + student.email + "','" + student.address + "','" + student.dept_name + "')";
                SqlCommand cmd      = new SqlCommand(querry, con);
                int        rowcount = cmd.ExecuteNonQuery();
                if (rowcount > 0)
                {
                    msg = "successfully added on database . ";
                }
                else
                {
                    msg = "not saved.";
                }
            }
            gatewayManager gManager = new gatewayManager();

            ViewBag.vb = gManager.GetDepartments();

            ViewBag.gatewayview = gManager.GetStudentGetStudentInfo();
            ViewBag.viewbag     = msg;
            return(View());
        }
Example #2
0
        public ActionResult Savestudent()
        {
            gatewayManager gManager = new gatewayManager();

            ViewBag.vb          = gManager.GetDepartments();
            ViewBag.gatewayview = gManager.GetStudentGetStudentInfo();
            return(View());
        }