public static void Update(int id, StudentFines studentfines)
 {
     try
     {
         db.cmd.CommandText = @"update tblStudentFines set Fine = @fine, 
             DateTime=@datetime,
         Note=@note,
         Student_ID=@student_id,
         AddedByEmployee_ID=@addedbyemployeeid,
         FineStatus_ID=@finestatusid
             where Id=@id";
         db.cmd.Parameters.AddWithValue("@fine", studentfines.Fine);
         db.cmd.Parameters.AddWithValue("@datetime", studentfines.DateTime);
         db.cmd.Parameters.AddWithValue("@note", studentfines.Note);
         db.cmd.Parameters.AddWithValue("@student_id", studentfines.StudentsId);
         db.cmd.Parameters.AddWithValue("@addedbyemployeeid", studentfines.AddedByEmployeesId);
         db.cmd.Parameters.AddWithValue("@finestatusid", studentfines.FineStatusesId);
         db.cmd.Parameters.AddWithValue("@id", id);
         db.con.Open();
         db.cmd.ExecuteNonQuery();
     }
     catch (SqlException sqlex)
     {
         SqlExceptionErrorHandling rh = new SqlExceptionErrorHandling();
         rh.GetError(sqlex);
     }
     finally
     {
         db.CloseDb(db.con, db.cmd);
     }
 }
        private static List <ClassTimings> _GetListOfClassTimings()
        {
            List <ClassTimings> classTimings = new List <ClassTimings>();

            try
            {
                Command            = @"select * from tblClassTimings";
                db.cmd.CommandText = Command;
                db.con.Open();

                SqlDataReader rdr = db.cmd.ExecuteReader();
                while (rdr.Read())
                {
                    ClassTimings singleClassTimings = new ClassTimings();
                    singleClassTimings.Id        = (int)rdr[0];
                    singleClassTimings.StartTime = Convert.ToDateTime(rdr[1].ToString());
                    singleClassTimings.EndTime   = Convert.ToDateTime(rdr[2].ToString());
                    singleClassTimings.Name      = rdr[3].ToString();
                    classTimings.Add(singleClassTimings);
                }
            }
            catch (SqlException sqlex)
            {
                SqlExceptionErrorHandling rh = new SqlExceptionErrorHandling();
                rh.GetError(sqlex);
            }
            finally
            {
                db.con.Close();
            }

            return(classTimings);
        }
        public static void Update(int id, StudentAttendanceRecords stdattrecord)
        {
            try
            {
                db.cmd.CommandText = @"UPDATE [dbo].[tblStudentAttendanceRecords]
   SET [Date] =@dte
      ,[Student_ID] = @stdid
      ,[StudentAttendanceStatus_ID] = @stdstatid
 WHERE Id=id";

                db.cmd.Parameters.AddWithValue("@dte", stdattrecord.Date);
                db.cmd.Parameters.AddWithValue("@stdid", stdattrecord.StudentsId);
                db.cmd.Parameters.AddWithValue("@stdstatid", stdattrecord.StudentAttendanceStatusesId);
                db.cmd.Parameters.AddWithValue("@id", id);
                db.con.Open();
                db.cmd.ExecuteNonQuery();
            }

            catch (SqlException sqlex)
            {
                SqlExceptionErrorHandling rh = new SqlExceptionErrorHandling();
                rh.GetError(sqlex);
            }
            finally
            {
                db.CloseDb(db.con, db.cmd);
            }
        }
        private static List <LoginDetails> _GetListOfLoginDetails()
        {
            List <LoginDetails> loginDetails = new List <LoginDetails>();

            try
            {
                Command            = @"select * from tblLoginDetails";
                db.cmd.CommandText = Command;
                db.con.Open();

                SqlDataReader rdr = db.cmd.ExecuteReader();
                while (rdr.Read())
                {
                    LoginDetails singleLoginDetails = new LoginDetails();
                    singleLoginDetails.Id          = (int)rdr[0];
                    singleLoginDetails.Username    = rdr[1].ToString();
                    singleLoginDetails.Password    = rdr[2].ToString();
                    singleLoginDetails.AllowAccess = Convert.ToBoolean(rdr[3]);

                    loginDetails.Add(singleLoginDetails);
                }
            }
            catch (SqlException sqlex)
            {
                SqlExceptionErrorHandling rh = new SqlExceptionErrorHandling();
                rh.GetError(sqlex);
            }
            finally
            {
                db.con.Close();
            }

            return(loginDetails);
        }
示例#5
0
        private static List <Grades> _getListOfGrades()
        {
            List <Grades> grades = new List <Grades>();

            try
            {
                Command            = "select * from tblGrades;";
                db.cmd.CommandText = Command;
                db.con.Open();

                SqlDataReader rdr = db.cmd.ExecuteReader();
                while (rdr.Read())
                {
                    Grades singlegrade = new Grades();
                    singlegrade.Id        = (int)rdr[0];
                    singlegrade.GradeName = rdr[1].ToString();
                    grades.Add(singlegrade);
                }
            }
            catch (SqlException sqlex)
            {
                SqlExceptionErrorHandling rh = new SqlExceptionErrorHandling();
                rh.GetError(sqlex);
            }
            finally
            {
                db.con.Close();
            }
            return(grades);
        }
示例#6
0
        private static List <Qualifications> _GetQualifications()
        {
            List <Qualifications> Qualifications = new List <Qualifications>();


            try
            {
                Command            = "select * from tblQualifications";
                db.cmd.CommandText = Command;
                db.con.Open();

                SqlDataReader rdr = db.cmd.ExecuteReader();
                while (rdr.Read())
                {
                    Qualifications singleQualifications = new Qualifications();
                    singleQualifications.Id = (int)rdr[0];
                    singleQualifications.QualificationName = rdr[1].ToString();


                    Qualifications.Add(singleQualifications);
                }
            }
            catch (SqlException sqlex)
            {
                SqlExceptionErrorHandling rh = new SqlExceptionErrorHandling();
                rh.GetError(sqlex);
            }
            finally
            {
                db.con.Close();
            }
            return(Qualifications);
        }
示例#7
0
        private List <StudentAttendanceStatuses> _GetStudentAttendanceStatuses()
        {
            List <StudentAttendanceStatuses> StudentAttendanceStatuses = new List <StudentAttendanceStatuses>();


            try
            {
                Command            = "select * from tblStudentAttendanceStatuses";
                db.cmd.CommandText = Command;
                db.con.Open();

                SqlDataReader rdr = db.cmd.ExecuteReader();
                while (rdr.Read())
                {
                    StudentAttendanceStatuses singleStudentAttendanceStatuses = new StudentAttendanceStatuses();
                    singleStudentAttendanceStatuses.Id         = (int)rdr[0];
                    singleStudentAttendanceStatuses.StatusName = rdr[1].ToString();


                    StudentAttendanceStatuses.Add(singleStudentAttendanceStatuses);
                }
            }
            catch (SqlException sqlex)
            {
                SqlExceptionErrorHandling rh = new SqlExceptionErrorHandling();
                rh.GetError(sqlex);
            }
            finally
            {
                db.con.Close();
            }
            return(StudentAttendanceStatuses);
        }
        public static void Update(int id, FeeSchedules feeschedules)
        {
            try
            {
                db.cmd.CommandText = @"update tblFeeSchedules set FEE = @fee, 
                    Grade_ID=@gradeid,
                FeeType_ID=@feetypeid
                 where Id=@id; ";

                db.cmd.Parameters.AddWithValue("@fee", feeschedules.Fee);
                db.cmd.Parameters.AddWithValue("@gradeid", feeschedules.GradesId);
                db.cmd.Parameters.AddWithValue("@feetypeid", feeschedules.FeeTypesId);
                db.cmd.Parameters.AddWithValue("@id", id);
                db.con.Open();
                db.cmd.ExecuteNonQuery();
            }

            catch (SqlException sqlex)
            {
                SqlExceptionErrorHandling rh = new SqlExceptionErrorHandling();
                rh.GetError(sqlex);
            }
            finally
            {
                db.CloseDb(db.con, db.cmd);
            }
        }
        private static List <ExpenseTypes> _GetExpenseTypes()
        {
            List <ExpenseTypes> ExpenseTypes = new List <ExpenseTypes>();


            try
            {
                Command            = "select * from tblExamTypes";
                db.cmd.CommandText = Command;
                db.con.Open();

                SqlDataReader rdr = db.cmd.ExecuteReader();
                while (rdr.Read())
                {
                    ExpenseTypes singleExpenseTypes = new ExpenseTypes();
                    singleExpenseTypes.Id = (int)rdr[0];
                    singleExpenseTypes.ExpenseTypeName = rdr[1].ToString();



                    ExpenseTypes.Add(singleExpenseTypes);
                }
            }
            catch (SqlException sqlex)
            {
                SqlExceptionErrorHandling rh = new SqlExceptionErrorHandling();
                rh.GetError(sqlex);
            }
            finally
            {
                db.con.Close();
            }
            return(ExpenseTypes);
        }
示例#10
0
        public static int Add(FeeRecords feeRecords)
        {
            int retvalue = -1;

            try
            {
                db.cmd.CommandType = CommandType.StoredProcedure;
                db.cmd.CommandText = "procFeeRecords_AddFeeRecords";
                db.cmd.Parameters.AddWithValue("@DateTime", feeRecords.DateTime);
                db.cmd.Parameters.AddWithValue("@Paid", feeRecords.Paid);
                db.cmd.Parameters.AddWithValue("@AddedByEmployee_ID", feeRecords.AddedByEmployeesId);
                db.cmd.Parameters.AddWithValue("@Student_ID", feeRecords.StudentsId);
                db.cmd.Parameters.AddWithValue("@FeeSchedule_ID", feeRecords.FeeSchedulesId);
                db.cmd.Parameters.Add("@id", SqlDbType.Int);
                db.cmd.Parameters["@id"].Direction = ParameterDirection.Output;
                db.con.Open();
                db.cmd.ExecuteNonQuery();
                retvalue = Convert.ToInt32(db.cmd.Parameters["@id"].Value);
            }

            catch (SqlException sqlex)
            {
                SqlExceptionErrorHandling rh = new SqlExceptionErrorHandling();
                rh.GetError(sqlex);
            }
            finally
            {
                db.CloseDb(db.con, db.cmd);
            }

            return(retvalue);
        }
示例#11
0
        public static void Update(int id, FeeRecords feerecords)
        {
            try
            {
                db.cmd.CommandText = @"update tblFeeRecords set DateTime=@dt,Paid=@pd,AddedByEmployee_ID=@abid,
                                       Student_ID=@sid,FeeSchedule_ID=@fsid where Id=@id;";

                db.cmd.Parameters.AddWithValue("@dt", feerecords.DateTime);
                db.cmd.Parameters.AddWithValue("@pd", feerecords.Paid);
                db.cmd.Parameters.AddWithValue("@abid", feerecords.AddedByEmployeesId);
                db.cmd.Parameters.AddWithValue("@sid", feerecords.StudentsId);
                db.cmd.Parameters.AddWithValue("@fsid", feerecords.FeeSchedulesId);
                db.cmd.Parameters.AddWithValue("@id", id);
                db.con.Open();
                db.cmd.ExecuteNonQuery();
            }

            catch (SqlException sqlex)
            {
                SqlExceptionErrorHandling rh = new SqlExceptionErrorHandling();
                rh.GetError(sqlex);
            }
            finally
            {
                db.CloseDb(db.con, db.cmd);
            }
        }
示例#12
0
        public static int Add(Teachers teachers)
        {
            int retvalue = -1;

            try
            {
                db.cmd.CommandType = CommandType.StoredProcedure;
                db.cmd.CommandText = "procTeachers_AddTeachers";
                db.cmd.Parameters.AddWithValue("@Employee_ID", teachers.EmployeesId);
                db.cmd.Parameters.Add("@id", SqlDbType.Int);
                db.cmd.Parameters["@id"].Direction = ParameterDirection.Output;
                db.con.Open();
                db.cmd.ExecuteNonQuery();
                retvalue = Convert.ToInt32(db.cmd.Parameters["@id"].Value);
            }

            catch (SqlException sqlex)
            {
                SqlExceptionErrorHandling rh = new SqlExceptionErrorHandling();
                rh.GetError(sqlex);
            }
            finally
            {
                db.CloseDb(db.con, db.cmd);
            }

            return(retvalue);
        }
示例#13
0
        public static void Update(int id, Subjects subjects)
        {
            try
            {
                db.cmd.CommandText = @" update tblSubjects set SubjectName = @subjectname, 
                    Teacher_ID=@teacherid,
					Class_ID=@classid
                    where Id=@id; ";

                db.cmd.Parameters.AddWithValue("@subjectname", subjects.SubjectName);
                db.cmd.Parameters.AddWithValue("@teacherid", subjects.TeachersId);
                db.cmd.Parameters.AddWithValue("@classid", subjects.ClassesId);
                db.cmd.Parameters.AddWithValue("@id", id);
                db.con.Open();
                db.cmd.ExecuteNonQuery();
            }

            catch (SqlException sqlex)
            {
                SqlExceptionErrorHandling rh = new SqlExceptionErrorHandling();
                rh.GetError(sqlex);
            }
            finally
            {
                db.CloseDb(db.con, db.cmd);
            }
        }
示例#14
0
        public static void Update(int id, EmployeeQualifications empQual)
        {
            try
            {
                db.cmd.CommandText = @"update tblEmployeeQualifications 
                                     set Employee_ID = @eid,
                                     Qualification_ID = @qid
                                  where id = @cid";
                db.cmd.Parameters.AddWithValue("@eid", empQual.EmployeesId);
                db.cmd.Parameters.AddWithValue("@qid", empQual.QualificationsId);
                db.cmd.Parameters.AddWithValue("@cid", empQual.Id);
                db.con.Open();
                db.cmd.ExecuteNonQuery();
            }

            catch (SqlException sqlex)
            {
                SqlExceptionErrorHandling rh = new SqlExceptionErrorHandling();
                rh.GetError(sqlex);
            }
            finally
            {
                db.CloseDb(db.con, db.cmd);
            }
        }
示例#15
0
        public static int Add(Exams exams)
        {
            int retvalue = -1;

            try
            {
                db.cmd.CommandType = CommandType.StoredProcedure;
                db.cmd.CommandText = "procExams_AddExams";
                db.cmd.Parameters.AddWithValue("@TotalMarks", exams.TotalMarks);
                db.cmd.Parameters.AddWithValue("@ObtainedMarks", exams.ObtainedMarks);
                db.cmd.Parameters.AddWithValue("@DateTime ", exams.DateTime);
                db.cmd.Parameters.AddWithValue("@Student_ID", exams.StudentsId);
                db.cmd.Parameters.AddWithValue("@Subject_ID", exams.SubjectsId);
                db.cmd.Parameters.AddWithValue("@ExamType_ID", exams.ExamTypesId);
                db.cmd.Parameters.Add("@id", SqlDbType.Int);
                db.cmd.Parameters["@id"].Direction = ParameterDirection.Output;
                db.con.Open();
                db.cmd.ExecuteNonQuery();
                retvalue = Convert.ToInt32(db.cmd.Parameters["@id"].Value);
            }

            catch (SqlException sqlex)
            {
                SqlExceptionErrorHandling rh = new SqlExceptionErrorHandling();
                rh.GetError(sqlex);
            }
            finally
            {
                db.CloseDb(db.con, db.cmd);
            }

            return(retvalue);
        }
        public static void Update(int id, StudentDocuments studoc)
        {
            try
            {
                db.cmd.CommandText = @"   update tblStudentDocuments set Student_ID = @studentid, 
                   DocumentUrl_ID=@docurlid
                    where Id=@id;";

                db.cmd.Parameters.AddWithValue("@studentid", studoc.StudentsId);
                db.cmd.Parameters.AddWithValue("@docurlid", studoc.DocumentUrls_Id);
                db.cmd.Parameters.AddWithValue("@id", id);
                db.con.Open();
                db.cmd.ExecuteNonQuery();
            }

            catch (SqlException sqlex)
            {
                SqlExceptionErrorHandling rh = new SqlExceptionErrorHandling();
                rh.GetError(sqlex);
            }
            finally
            {
                db.CloseDb(db.con, db.cmd);
            }
        }
示例#17
0
        public static void Update(int id, Exams exams)
        {
            try
            {
                db.cmd.CommandText = @"  update tblExams set TotalMarks = @totalmarks, 
                   ObtainedMarks=@obtmarks,
					DateTime=@datetime,
					Student_ID=@stuid,
					Subject_ID=@subid,
					ExamType_ID=@examtid
                    where Id=@id;";

                db.cmd.Parameters.AddWithValue("@totalmarks", exams.TotalMarks);
                db.cmd.Parameters.AddWithValue("@obtmarks", exams.ObtainedMarks);
                db.cmd.Parameters.AddWithValue("@datetime", exams.DateTime);
                db.cmd.Parameters.AddWithValue("@stuid", exams.StudentsId);
                db.cmd.Parameters.AddWithValue("@subid", exams.SubjectsId);
                db.cmd.Parameters.AddWithValue("@examtid", exams.ExamTypesId);

                db.cmd.Parameters.AddWithValue("@id", id);
                db.con.Open();
                db.cmd.ExecuteNonQuery();
            }

            catch (SqlException sqlex)
            {
                SqlExceptionErrorHandling rh = new SqlExceptionErrorHandling();
                rh.GetError(sqlex);
            }
            finally
            {
                db.CloseDb(db.con, db.cmd);
            }
        }
示例#18
0
        public static void Update(int parentId, Parents parents)
        {
            try
            {
                Persons.PersonUpdate(parents.PersonId, parents);
                LoginDetails.Update(parents.LoginDetailsId, parents.LoginDetails);

                db.cmd.CommandText = @"UPDATE [dbo].[tblParents]
                            SET [Person_ID] = @pid
                             ,[LoginDetail_ID] = @lid
                                WHERE Id=id";
                db.cmd.Parameters.AddWithValue("@pid", parents.PersonId);
                db.cmd.Parameters.AddWithValue("@lid", parents.LoginDetailsId);


                db.cmd.Parameters.AddWithValue("@id", parents.Id);

                db.con.Open();
                db.cmd.ExecuteNonQuery();
            }

            catch (SqlException sqlex)
            {
                SqlExceptionErrorHandling rh = new SqlExceptionErrorHandling();
                rh.GetError(sqlex);
            }
            finally
            {
                db.CloseDb(db.con, db.cmd);
            }
        }
示例#19
0
        private static List <Skills> _GetSkills()
        {
            List <Skills> Skills = new List <Skills>();


            try
            {
                Command            = "select * from tblSkills";
                db.cmd.CommandText = Command;
                db.con.Open();

                SqlDataReader rdr = db.cmd.ExecuteReader();
                while (rdr.Read())
                {
                    Skills singleSkills = new Skills();
                    singleSkills.Id        = (int)rdr[0];
                    singleSkills.SkillName = rdr[1].ToString();



                    Skills.Add(singleSkills);
                }
            }
            catch (SqlException sqlex)
            {
                SqlExceptionErrorHandling rh = new SqlExceptionErrorHandling();
                rh.GetError(sqlex);
            }
            finally
            {
                db.con.Close();
            }
            return(Skills);
        }
示例#20
0
        public static void Delete(int id)
        {
            Parents parents = new Parents();
            Persons person  = new Persons();
            var     parent  = Parents.ListOfParents.SingleOrDefault(p => p.Id == id);

            Persons.PersonDelete(parent.PersonsId);
            LoginDetails.Delete(parents.LoginDetailsId);
            try
            {
                db.cmd.CommandText = "delete from tblParents  where Id=@id";
                db.cmd.Parameters.AddWithValue("@id", id);
                db.con.Open();
                db.cmd.ExecuteNonQuery();
            }

            catch (SqlException sqlex)
            {
                SqlExceptionErrorHandling rh = new SqlExceptionErrorHandling();
                rh.GetError(sqlex);
            }
            finally
            {
                db.CloseDb(db.con, db.cmd);
            }
        }
示例#21
0
        public static int PersonAdd(Persons persons)
        {
            int retvalue = -1;

            try
            {
                db.cmd.CommandType = CommandType.StoredProcedure;
                db.cmd.CommandText = "procPersons_Persons";
                db.cmd.Parameters.AddWithValue("@FirstName", persons.FirstName);
                db.cmd.Parameters.AddWithValue("@LastName", persons.LastName);
                db.cmd.Parameters.AddWithValue("@DateOfBirth", persons.DateOfBirth);
                db.cmd.Parameters.AddWithValue("@CNIC", persons.CNIC);
                db.cmd.Parameters.AddWithValue("@ImageUrlPath", persons.ImageUrlPath);
                db.cmd.Parameters.AddWithValue("@Phone1", persons.Phone1);
                db.cmd.Parameters.AddWithValue("@Phone2", persons.Phone2);
                db.cmd.Parameters.AddWithValue("@Gender_ID", persons.GendersId);
                db.cmd.Parameters.Add("@id", SqlDbType.Int);
                db.cmd.Parameters["@id"].Direction = ParameterDirection.Output;
                db.con.Open();
                db.cmd.ExecuteNonQuery();
                retvalue = Convert.ToInt32(db.cmd.Parameters["@id"].Value);
            }

            catch (SqlException sqlex)
            {
                SqlExceptionErrorHandling rh = new SqlExceptionErrorHandling();
                rh.GetError(sqlex);
            }
            finally
            {
                db.CloseDb(db.con, db.cmd);
            }

            return(retvalue);
        }
示例#22
0
        public static void Update(int id, EmployeeAttendanceRecords empattrecord)
        {
            try
            {
                db.cmd.CommandText = @"update tblEmployeeAttendanceReords set Date=@dt,
                                       Employee_ID=@eid,EmployeeAttendanceSatus_ID=@easid where Id=@id; ";

                db.cmd.Parameters.AddWithValue("@dt", empattrecord.Date);
                db.cmd.Parameters.AddWithValue("@eid", empattrecord.EmployeesId);
                db.cmd.Parameters.AddWithValue("@easid", empattrecord.EmployeesAttendanceStatusesId);
                db.cmd.Parameters.AddWithValue("@id", id);
                db.con.Open();
                db.cmd.ExecuteNonQuery();
            }

            catch (SqlException sqlex)
            {
                SqlExceptionErrorHandling rh = new SqlExceptionErrorHandling();
                rh.GetError(sqlex);
            }
            finally
            {
                db.CloseDb(db.con, db.cmd);
            }
        }
        public static int Add(LoginDetails logindetails)
        {
            int retvalue = -1;

            try
            {
                db.cmd.CommandType = CommandType.StoredProcedure;
                db.cmd.CommandText = "procLoginDetails_LoginDetails";
                db.cmd.Parameters.AddWithValue("@Username", logindetails.Username);
                db.cmd.Parameters.AddWithValue("@Password", logindetails.Password);
                db.cmd.Parameters.AddWithValue("@AllowAccess", logindetails.AllowAccess);
                db.cmd.Parameters.Add("@id", SqlDbType.Int);
                db.cmd.Parameters["@id"].Direction = ParameterDirection.Output;
                db.con.Open();
                db.cmd.ExecuteNonQuery();
                retvalue = Convert.ToInt32(db.cmd.Parameters["@id"].Value);
            }

            catch (SqlException sqlex)
            {
                SqlExceptionErrorHandling rh = new SqlExceptionErrorHandling();
                rh.GetError(sqlex);
            }
            finally
            {
                db.CloseDb(db.con, db.cmd);
            }

            return(retvalue);
        }
        public static int Add(ClassSchedules classSchedules)
        {
            int retvalue = -1;

            try
            {
                db.cmd.CommandType = CommandType.StoredProcedure;
                db.cmd.CommandText = "procClassSchedules_AddClassSchedules";
                db.cmd.Parameters.AddWithValue("@WeekDay", classSchedules.WeekDay);
                db.cmd.Parameters.AddWithValue("@Subject_ID", classSchedules.SubjectsId);
                db.cmd.Parameters.AddWithValue("@Class_ID", classSchedules.ClassesId);
                db.cmd.Parameters.AddWithValue("@ClassTiming_ID", classSchedules.ClassTimingsId);
                db.cmd.Parameters.Add("@id", SqlDbType.Int);
                db.cmd.Parameters["@id"].Direction = ParameterDirection.Output;
                db.con.Open();
                db.cmd.ExecuteNonQuery();
                retvalue = Convert.ToInt32(db.cmd.Parameters["@id"].Value);
            }

            catch (SqlException sqlex)
            {
                SqlExceptionErrorHandling rh = new SqlExceptionErrorHandling();
                rh.GetError(sqlex);
            }
            finally
            {
                db.CloseDb(db.con, db.cmd);
            }

            return(retvalue);
        }
示例#25
0
        public static int Add(Grades grades)
        {
            int retvalue = -1;

            try
            {
                db.cmd.CommandType = CommandType.StoredProcedure;
                db.cmd.CommandText = "procGrades_Grades";
                db.cmd.Parameters.AddWithValue("@GradeName", grades.GradeName);
                db.cmd.Parameters.Add("@Id", SqlDbType.Int);
                db.cmd.Parameters["@Id"].Direction = ParameterDirection.Output;
                db.con.Open();
                db.cmd.ExecuteNonQuery();
                retvalue = Convert.ToInt32(db.cmd.Parameters["@Id"].Value);
            }

            catch (SqlException sqlex)
            {
                SqlExceptionErrorHandling rh = new SqlExceptionErrorHandling();
                rh.GetError(sqlex);
            }
            finally
            {
                db.CloseDb(db.con, db.cmd);
            }

            return(retvalue);
        }
        public static void Update(int id, ClassSchedules classschedules)
        {
            try
            {
                db.cmd.CommandText = @"update tblClassSchedules set WeekDay = @weekday, 
                    Subject_ID = @subjectid,
                Class_ID = @classid,
                ClassTiming_ID = @classtimingid
                 where Id = @id; ";

                db.cmd.Parameters.AddWithValue("@weekday", classschedules.WeekDay);
                db.cmd.Parameters.AddWithValue("@subjectid", classschedules.SubjectsId);
                db.cmd.Parameters.AddWithValue("@classid", classschedules.ClassesId);
                db.cmd.Parameters.AddWithValue("@classtimingid", classschedules.ClassTimingsId);
                db.cmd.Parameters.AddWithValue("@id", id);
                db.con.Open();
                db.cmd.ExecuteNonQuery();
            }

            catch (SqlException sqlex)
            {
                SqlExceptionErrorHandling rh = new SqlExceptionErrorHandling();
                rh.GetError(sqlex);
            }
            finally
            {
                db.CloseDb(db.con, db.cmd);
            }
        }
        public static int Add(ClassTimings classtimings)
        {
            int retvalue = -1;

            try
            {
                db.cmd.CommandType = CommandType.StoredProcedure;
                db.cmd.CommandText = "procClassTimings_ClassTimings";
                db.cmd.Parameters.AddWithValue("@StartTime", classtimings.StartTime);
                db.cmd.Parameters.AddWithValue("@Endtime", classtimings.EndTime);
                db.cmd.Parameters.AddWithValue("@Name", classtimings.Name);
                db.cmd.Parameters.Add("@id", SqlDbType.Int);
                db.cmd.Parameters["@id"].Direction = ParameterDirection.Output;
                db.con.Open();
                db.cmd.ExecuteNonQuery();
                return(Convert.ToInt32(db.cmd.Parameters["@id"].Value));
            }

            catch (SqlException sqlex)
            {
                SqlExceptionErrorHandling rh = new SqlExceptionErrorHandling();
                rh.GetError(sqlex);
            }
            finally
            {
                db.CloseDb(db.con, db.cmd);
            }
            return(retvalue);
        }
示例#28
0
        private static List <Genders> _GetListOfGenders()
        {
            List <Genders> Genders = new List <Genders>();

            try
            {
                Command            = @"select * from tblGenders";
                db.cmd.CommandText = Command;
                db.con.Open();

                SqlDataReader rdr = db.cmd.ExecuteReader();
                while (rdr.Read())
                {
                    Genders singleGenders = new Genders();
                    singleGenders.Id         = (int)rdr[0];
                    singleGenders.GenderName = rdr[1].ToString();


                    Genders.Add(singleGenders);
                }
            }
            catch (SqlException sqlex)
            {
                SqlExceptionErrorHandling rh = new SqlExceptionErrorHandling();
                rh.GetError(sqlex);
            }
            finally
            {
                db.con.Close();
            }

            return(Genders);
        }
        public static int Add(StudentAttendanceRecords studentAttendanceRecords)
        {
            int retvalue = -1;

            try
            {
                db.cmd.CommandType = CommandType.StoredProcedure;
                db.cmd.CommandText = "procStudentAttendanceRecords_AddStudentAttendanceRecords";
                db.cmd.Parameters.AddWithValue("@Date", studentAttendanceRecords.Date);
                db.cmd.Parameters.AddWithValue("@Student_ID", studentAttendanceRecords.StudentsId);
                db.cmd.Parameters.AddWithValue("@StudentAttendanceStatus_ID", studentAttendanceRecords.StudentAttendanceStatusesId);
                db.cmd.Parameters.Add("@id", SqlDbType.Int);
                db.cmd.Parameters["@id"].Direction = ParameterDirection.Output;
                db.con.Open();
                db.cmd.ExecuteNonQuery();
                retvalue = Convert.ToInt32(db.cmd.Parameters["@id"].Value);
            }

            catch (SqlException sqlex)
            {
                SqlExceptionErrorHandling rh = new SqlExceptionErrorHandling();
                rh.GetError(sqlex);
            }
            finally
            {
                db.CloseDb(db.con, db.cmd);
            }

            return(retvalue);
        }
示例#30
0
        private static List <Classes> _GetClasses()
        {
            List <Classes> classes = new List <Classes>();

            try
            {
                db.cmd.CommandType = CommandType.Text;
                Command            = "select * from tblClasses;";
                db.cmd.CommandText = Command;
                db.con.Open();

                SqlDataReader rdr = db.cmd.ExecuteReader();
                while (rdr.Read())
                {
                    Classes singleclass = new Classes();
                    singleclass.Id          = (int)rdr[0];
                    singleclass.ClassesName = rdr[1].ToString();
                    singleclass.GradesId    = (int)rdr[2];
                    singleclass.Grades      = Grades.ListOfGrades.SingleOrDefault(gr => gr.Id == singleclass.GradesId);
                    classes.Add(singleclass);
                }
            }
            catch (SqlException sqlex)
            {
                SqlExceptionErrorHandling rh = new SqlExceptionErrorHandling();
                rh.GetError(sqlex);
            }
            finally
            {
                db.CloseDb(db.con, db.cmd);
            }
            return(classes);
        }