示例#1
0
        public DataSet GetStudentInfo(WebApplication5.Models.StudentInformation_Result std)
        {
            List <StudentInformation_Result> students = new List <StudentInformation_Result>();

            using (SqlConnection myCon = new SqlConnection("Data Source=DESKTOP-50L3KE8\\SQLEXPRESS;Initial Catalog=DB_Class;Integrated Security=True"))
            {
                try
                {
                    SqlCommand cmd = new SqlCommand("GetStudentDetails", myCon);
                    cmd.CommandType = System.Data.CommandType.StoredProcedure;

                    cmd.Parameters.Add("@ClassId", SqlDbType.Int).Value = Int32.Parse(std.ClassTypeId.ToString());


                    DataSet dt = new DataSet();
                    using (SqlDataAdapter sda = new SqlDataAdapter(cmd))
                    {
                        //DataSet dt = new DataSet();
                        sda.Fill(dt);
                    }
                    return(dt);
                }

                catch (Exception ex)
                {
                    throw ex;
                }
                finally
                {
                    myCon.Close();
                    myCon.Dispose();
                }
            }
        }
示例#2
0
        public DataSet GetStudentRecord(WebApplication5.Models.StudentInformation_Result std)
        {
            List <StudentInformation_Result> students = new List <StudentInformation_Result>();

            using (SqlConnection myCon = new SqlConnection("Data Source=DESKTOP-50L3KE8\\SQLEXPRESS;Initial Catalog=DB_Class;Integrated Security=True"))
            {
                DataSet dsCustomers = new DataSet();
                using (SqlCommand cmd = new SqlCommand("SELECT * FROM Student where StudentID = " + std.StudentID))
                {
                    cmd.Connection = myCon;
                    myCon.Open();
                    using (SqlDataReader sdr = cmd.ExecuteReader())
                    {
                        //Create a new DataSet.

                        dsCustomers.Tables.Add("Customers");

                        //Load DataReader into the DataTable.
                        dsCustomers.Tables[0].Load(sdr);
                    }
                    myCon.Close();
                }
                return(dsCustomers);
            }
        }
示例#3
0
        public ActionResult Contact(string text)
        {
            BusinessLayer businesslayer = new BusinessLayer();

            WebApplication5.Models.StudentInformation_Result std = new WebApplication5.Models.StudentInformation_Result();
            std.ClassTypeId = text;
            DataSet dt = businesslayer.GetStudentInfo(std);

            var plist = dt.Tables[0].AsEnumerable().Select(x => new WebApplication5.Models.StudentInformation_Result
            {
                StudentID        = x.Field <int>("StudentID"),
                first_names      = x.Field <string>("first_name"),
                last_names       = x.Field <string>("last_name"),
                birthdate        = x.Field <DateTime>("birthdate"),
                contact          = x.Field <string>("contact"),
                contact_emails   = x.Field <string>("contact_email"),
                Gender           = x.Field <string>("Gender"),
                AdharNumber      = x.Field <Int64>("Adharcard"),
                middle_names     = x.Field <string>("middle_name"),
                LocalAddress     = x.Field <string>("LocalAddress"),
                PermanentAddress = x.Field <string>("PermanentAddress"),
                ClassTypeId      = x.Field <string>("ClassTypeId"),
            });

            return(View(plist));
        }
示例#4
0
        ///////////////////////////////////////////////////////////edit////////////////////////////////////////////////

        public ActionResult Edit()
        {
            string           studentId = Request.QueryString["stuId"].ToString();
            DB_ClassEntities objentity = new DB_ClassEntities();

            WebApplication5.Models.StudentInformation_Result objstudentdetail = new WebApplication5.Models.StudentInformation_Result();
            objstudentdetail.StudentID = Int32.Parse(studentId.ToString());
            BusinessLayer bl = new BusinessLayer();
            DataSet       dt = bl.GetStudentRecord(objstudentdetail);


            foreach (DataRow dr in dt.Tables[0].Rows)
            {
                objstudentdetail.StudentID        = Int32.Parse(dr["StudentID"].ToString());
                objstudentdetail.first_names      = dr["first_name"].ToString();
                objstudentdetail.last_names       = dr["last_name"].ToString();
                objstudentdetail.birthdate        = dr.Field <System.DateTime>("birthdate");
                objstudentdetail.contact          = dr["contact"].ToString();
                objstudentdetail.contact_emails   = dr["contact_email"].ToString();
                objstudentdetail.Gender           = dr["Gender"].ToString();
                objstudentdetail.AdharNumber      = Int32.Parse(dr["Adharcard"].ToString());
                objstudentdetail.middle_names     = dr["middle_name"].ToString();
                objstudentdetail.LocalAddress     = dr["LocalAddress"].ToString();
                objstudentdetail.PermanentAddress = dr["PermanentAddress"].ToString();
                objstudentdetail.ClassTypeId      = dr["ClassTypeId"].ToString();
            }
            DataSet dt2       = bl.GetParentId(objstudentdetail.StudentID);
            int     ContactId = 0;

            foreach (DataRow dr in dt2.Tables[0].Rows)
            {
                ContactId = Int32.Parse(dr["Contact_PersonID"].ToString());
            }
            DataSet dt3 = bl.GetParentRecord(ContactId);

            foreach (DataRow dr in dt3.Tables[0].Rows)
            {
                objstudentdetail.Contact_PersonID     = Int32.Parse(dr["Contact_PersonID"].ToString());
                objstudentdetail.first_name           = dr["first_name"].ToString();
                objstudentdetail.last_name            = dr["last_name"].ToString();
                objstudentdetail.contact_number1      = (dr["contact_number1"].ToString());
                objstudentdetail.contact_number2      = dr["contact_number2"].ToString();
                objstudentdetail.contact_email        = dr["contact_email"].ToString();
                objstudentdetail.RelationWith_Student = dr["RelationWith_Student"].ToString();
                objstudentdetail.middle_name          = dr["middle_name"].ToString();
                objstudentdetail.Address = dr["Address"].ToString();
            }
            return(View(objstudentdetail));
        }
示例#5
0
        public ActionResult Delete()
        {
            string           studentId = Request.QueryString["stuId"].ToString();
            DB_ClassEntities objentity = new DB_ClassEntities();

            WebApplication5.Models.StudentInformation_Result objstudentdetail = new WebApplication5.Models.StudentInformation_Result();
            objstudentdetail.StudentID = Int32.Parse(studentId.ToString());
            BusinessLayer bl        = new BusinessLayer();
            DataSet       dt2       = bl.GetParentId(objstudentdetail.StudentID);
            int           ContactId = 0;

            foreach (DataRow dr in dt2.Tables[0].Rows)
            {
                ContactId = Int32.Parse(dr["Contact_PersonID"].ToString());
            }
            bl.DeleteParentRecord(ContactId);
            bl.DeleteStudentRecord(objstudentdetail);
            return(Redirect("/Home/Student_registrar"));
        }