//SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["constr"].ToString());
        public int AddStudent(EEP_Models.Models.Student s)
        {
            SqlConnection con = new SqlConnection("user id=sa;password=abc;database=demo;data source=.");

            con.Open();
            SqlCommand cmd = new SqlCommand("proc_add", con);

            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.AddWithValue("@RollNo", s.RollNo);
            cmd.Parameters.AddWithValue("@Fname", s.Fname);
            cmd.Parameters.AddWithValue("@Lname", s.Lname);
            cmd.Parameters.AddWithValue("@Fathername", s.FatherName);
            cmd.Parameters.AddWithValue("@Mothername", s.MotherName);
            cmd.Parameters.AddWithValue("@Phno", s.Phno);
            cmd.Parameters.AddWithValue("@ParentPhno", s.ParentsPhno);
            cmd.Parameters.AddWithValue("@Email", s.Email);
            cmd.Parameters.AddWithValue("@Aadhar", s.Aadhar);
            cmd.Parameters.AddWithValue("@AId", s.StudentAddress.AddressID);
            cmd.Parameters.AddWithValue("@Bloodgroup", s.Bloodgroup);
            cmd.Parameters.AddWithValue("@Photo", s.Photo);
            cmd.Parameters.AddWithValue("@DeptId", s.studentDepartment.DeptId);
            cmd.Parameters.AddWithValue("@Bcert", s.btechDetails.BCertificate);
            cmd.Parameters.AddWithValue("@Bcollegename", s.btechDetails.BCollegeName);
            cmd.Parameters.AddWithValue("@Bmarks", s.btechDetails.BMarks);
            cmd.Parameters.AddWithValue("@Firstline", s.StudentAddress.Firstline);
            cmd.Parameters.AddWithValue("@Bper", s.btechDetails.BPercentage);
            cmd.Parameters.AddWithValue("@BRollno", s.btechDetails.BtechRollNo);
            cmd.Parameters.AddWithValue("@Dcert", s.degreeDetails.DCertificate);
            cmd.Parameters.AddWithValue("@Dcollegename", s.degreeDetails.DCollegeName);
            cmd.Parameters.AddWithValue("@District", s.StudentAddress.District);
            cmd.Parameters.AddWithValue("@Dmarks", s.degreeDetails.DMarks);
            cmd.Parameters.AddWithValue("@Dno", s.StudentAddress.Dno);
            cmd.Parameters.AddWithValue("@Dper", s.degreeDetails.DPercentage);
            cmd.Parameters.AddWithValue("@DRollno", s.degreeDetails.DRollNo);
            cmd.Parameters.AddWithValue("@Incert", s.interDetails.ICertificate);
            cmd.Parameters.AddWithValue("@Incollegename", s.interDetails.ICollegeName);
            cmd.Parameters.AddWithValue("@Inmarks", s.interDetails.IMarks);
            cmd.Parameters.AddWithValue("@Inper", s.interDetails.IPercentage);
            cmd.Parameters.AddWithValue("@IRollno", s.interDetails.IRollNo);
            cmd.Parameters.AddWithValue("@Mandal", s.StudentAddress.Mandal);
            cmd.Parameters.AddWithValue("@PTcert", s.polytechnicDetails.PCertificate);
            cmd.Parameters.AddWithValue("@PTcollegename", s.polytechnicDetails.PCollegeName);
            cmd.Parameters.AddWithValue("@Pincode", s.StudentAddress.Pincode);
            cmd.Parameters.AddWithValue("@PTmarks", s.polytechnicDetails.PMarks);
            cmd.Parameters.AddWithValue("@PTper", s.polytechnicDetails.PPercentage);
            cmd.Parameters.AddWithValue("@PTRollno", s.polytechnicDetails.PRollNo);
            cmd.Parameters.AddWithValue("@State", s.StudentAddress.State);
            cmd.Parameters.AddWithValue("@Tcert", s.tenthDetails.TCertificate);
            cmd.Parameters.AddWithValue("@Tmarks", s.tenthDetails.TMarks);
            cmd.Parameters.AddWithValue("@Tper", s.tenthDetails.TPercentage);
            cmd.Parameters.AddWithValue("@TRollno", s.tenthDetails.TRollNo);
            cmd.Parameters.AddWithValue("@Schoolname", s.tenthDetails.TSchoolName);
            cmd.Parameters.AddWithValue("@Village", s.StudentAddress.Village);
            cmd.Parameters.AddWithValue("@Secondline", s.StudentAddress.Secondline);

            int i = cmd.ExecuteNonQuery();

            return(i);
        }
        public ActionResult AddStudent(EEP_Models.Models.Student s)
        {
            if (s.btechDetails.BtechRollNo == null || s.degreeDetails.DRollNo == null)
            {
                //adding photo
                string filename = Path.GetFileName(s.image.FileName);
                string filexe   = Path.GetExtension(s.image.FileName);
                s.Photo  = "~/StudentImages/" + s.RollNo + filename;
                filename = Path.Combine(Server.MapPath("~/StudentImages/"), filename);
                s.image.SaveAs(filename);
                //adding tenth certiicate
                string filename1 = Path.GetFileName(s.tenthDetails.Timage.FileName);
                string filexe1   = Path.GetExtension(s.tenthDetails.Timage.FileName);
                s.tenthDetails.TCertificate = "~/StudentCertificate/Tenth/" + s.RollNo + filename1;
                //string a1 = filename1 + s.RollNo + filexe1;
                filename1 = Path.Combine(Server.MapPath("~/StudentCertificate/Tenth/"), filename1);
                s.image.SaveAs(filename1);
                //adding inter certificate
                string filename2 = Path.GetFileName(s.interDetails.Iimage.FileName);
                string filexe2   = Path.GetExtension(s.interDetails.Iimage.FileName);
                s.tenthDetails.TCertificate = "~/StudentCertificate/Inter/" + s.RollNo + filename2;
                // string a2 = filename2 + s.RollNo + filexe2;
                filename2 = Path.Combine(Server.MapPath("~/StudentCertificate/Inter/"), filename2);
                s.image.SaveAs(filename2);
            }


            EEP_Services.ServiceStudent obj = new ServiceStudent();
            int i = obj.addstudent(s);

            if (i == 1)
            {
                ViewData["message"] = "Add Successfully";
            }
            return(View());
        }
Exemple #3
0
        public int addstudent(EEP_Models.Models.Student s)
        {
            int i = objrepstudent.AddStudent(s);

            return(i);
        }