Beispiel #1
0
        private void addStudentToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Student_Details std = new Student_Details();

            std.MdiParent = Form1.ActiveForm;
            std.Show();
        }
        public async Task InsertStudent()
        {
            //In order to create or insert new date we first instantiate a new type. We then update the values of the properties. Next we add it to the underlying set of the context and then save that back to the database.


            using (var context = new collegestudentsEntities())
            {
                var contact = new Student_Details();
                contact.Name       = Name;
                contact.Address    = Address;
                contact.Phone      = Phone;
                contact.CourseIDFK = CourseIDFK;
                //Add to entity set of context
                context.Student_Details.Add(contact);


                // add new marks to cascade up the student details.

                var marks = new Mark();
                marks.Marks1   = 0;
                marks.marks2   = 0;
                marks.Marks3   = 0;
                marks.Marks4   = 0;
                marks.StudIDFK = contact.StudID;
                context.Marks.Add(marks);

                await context.SaveChangesAsync();

                //      ClearTextBoxes();
            }
        }
        public ActionResult DeleteConfirmed(int id)
        {
            Student_Details student_Details = db.Student_Details.Find(id);

            db.Student_Details.Remove(student_Details);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
 public ActionResult Edit([Bind(Include = "Id,SName,AddressLine1,AddressLine2,emailID,DOB")] Student_Details student_Details)
 {
     if (ModelState.IsValid)
     {
         db.Entry(student_Details).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(student_Details));
 }
 public ActionResult CreatStudent(Student_Details emp)
 {
     if (ModelState.IsValid)
     {
         context.Student_Details.Add(emp);
         context.SaveChanges();
         return(RedirectToAction("Student_Details"));
     }
     return(View());
 }
        public ActionResult Create([Bind(Include = "Id,SName,AddressLine1,AddressLine2,emailID,DOB")] Student_Details student_Details)
        {
            if (ModelState.IsValid)
            {
                db.Student_Details.Add(student_Details);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(student_Details));
        }
        // GET: Student_Details/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Student_Details student_Details = db.Student_Details.Find(id);

            if (student_Details == null)
            {
                return(HttpNotFound());
            }
            return(View(student_Details));
        }
        //Given FSID
        public List<Student_Details> Student_Summary(int id)
        {   
            //i did not put this in appsetting as this is a merged project and this function is only used by our project's win service
            //String File_Output = "D:\\IPT\\Project";
            List<Student_Details> SDs = new List<Student_Details>();
            string query = "select  Student.StudentID,Student.SName,Student.Email " +
                           "from FacultySections,CourseEnrollment,Student " +
                           "where FacultySections.FSID=CourseEnrollment.FSID and Student.StudentID=CourseEnrollment.StudentID and FacultySections.FSID=" + id.ToString();

            string connectionString = ConfigurationManager.AppSettings["SqlDBConn"].ToString();

            using (SqlConnection connection = new SqlConnection(connectionString))
            {
                SqlCommand command = new SqlCommand(query, connection);
                command.Parameters.AddWithValue("@tPatSName", "Your-Parm-Value");
                connection.Open();
                SqlDataReader reader = command.ExecuteReader();
                try
                {
                    while (reader.Read())
                    {
                        Student_Details sds = new Student_Details();
                        sds.StudentID = reader.GetInt32(reader.GetOrdinal("StudentID"));
                        sds.StudentName = reader.GetString(reader.GetOrdinal("SName"));
                        sds.Email = reader.GetString(reader.GetOrdinal("Email"));

                        SDs.Add(sds);
                    }
                }
                finally
                {
                    reader.Close();
                }
            }
            for (int i=0;i<SDs.Count;i++)
            {
                Dist_list.assign = 0; Dist_list.fyp = 0; Dist_list.pro = 0; Dist_list.lab = 0; Dist_list.pres = 0; Dist_list.quiz = 0;

                query = "select Course.CourseName " +
                "from FacultySections, CourseFaculty, CourseOffered, Course " +
                "where FacultySections.CFID = CourseFaculty.CFID and CourseFaculty.CourseOfferedID = CourseOffered.CourseOfferedID and CourseOffered.CourseID = Course.CourseID "
                + "and FacultySections.FSID = " + id.ToString();
                using (SqlConnection connection = new SqlConnection(connectionString))
                {
                    SqlCommand command = new SqlCommand(query, connection);
                    command.Parameters.AddWithValue("@tPatSName", "Your-Parm-Value");
                    connection.Open();
                    SqlDataReader reader = command.ExecuteReader();
                    try
                    {
                        while (reader.Read())
                        {
                            SDs[i].CourseName = reader.GetString(reader.GetOrdinal("CourseName"));
                        }
                    }
                    finally
                    {
                        reader.Close();
                    }
                }

                query = "select MarksDistribution.MDID,MarksDistribution.Weigtage,MarksDistribution.TotalMarks,MarksDistribution.Title,MarksRecord.ObtainedMarks"+
                        " from MarksDistribution, MarksRecord"+
                        " where MarksDistribution.MDID = MarksRecord.MDID and MarksDistribution.FSID = "+id.ToString()+"  and MarksRecord.StudentID = " + SDs[i].StudentID.ToString();
                using (SqlConnection connection = new SqlConnection(connectionString))
                {
                    SqlCommand command = new SqlCommand(query, connection);
                    command.Parameters.AddWithValue("@tPatSName", "Your-Parm-Value");
                    connection.Open();
                    SqlDataReader reader = command.ExecuteReader();
                    try
                    {
                        while (reader.Read())
                        {
                            Dist_list temp = new Dist_list();
                            temp.MDID = (reader.GetInt32(reader.GetOrdinal("MDID")));
                            temp.title_setter(reader.GetInt32(reader.GetOrdinal("Title")));
                            temp.currentmarks = reader.GetDouble(reader.GetOrdinal("ObtainedMarks"));
                            temp.totalmarks= reader.GetDouble(reader.GetOrdinal("TotalMarks"));
                            temp.weightage= reader.GetDouble(reader.GetOrdinal("Weigtage"));
                            SDs[i].DL.Add(temp);
                        }

                    }
                    finally
                    {
                        reader.Close();
                    }
                }
            }
            //JavaScriptSerializer serializer = new JavaScriptSerializer();
            //var data = serializer.Serialize(SDs);
            //File.WriteAllText(File_Output + "\\Summary.json", data);
            //File.WriteAllText(File_Output + "\\Check", "New Data");
            return SDs;
        }