コード例 #1
0
        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);
        }
コード例 #2
0
        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);
        }
コード例 #3
0
        //public ClassSchedules()
        //{
        //    Subjects = new Subjects();
        //    Classes = new Classes();
        //    ClassTimings = new ClassTimings();
        //}

        private static List <ClassSchedules> _GetListOfClassSchedules()
        {
            List <ClassSchedules> classSchedules = new List <ClassSchedules>();

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

                SqlDataReader rdr = db.cmd.ExecuteReader();
                while (rdr.Read())
                {
                    ClassSchedules singleClassSchedules = new ClassSchedules();
                    singleClassSchedules.Id             = (int)rdr[0];
                    singleClassSchedules.WeekDay        = rdr[1].ToString();
                    singleClassSchedules.SubjectsId     = (int)rdr[2];
                    singleClassSchedules.ClassesId      = (int)rdr[3];
                    singleClassSchedules.ClassTimingsId = (int)rdr[4];

                    var subject = new Subjects();
                    singleClassSchedules.Subjects = Subjects.ListOfSubjects.SingleOrDefault(sub => sub.Id == singleClassSchedules.SubjectsId);
                    var classes = new Classes();
                    singleClassSchedules.Classes = Classes.ListOfClasses.SingleOrDefault(cls => cls.Id == singleClassSchedules.ClassesId);
                    var classtiming = new ClassTimings();
                    singleClassSchedules.ClassTimings = ClassTimings.ListOfClassTimings.SingleOrDefault(ct => ct.Id == singleClassSchedules.ClassTimingsId);

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

            return(classSchedules);
        }
コード例 #4
0
        public static void Update(int id, ClassTimings classtimings)
        {
            try
            {
                db.cmd.CommandText = "update tblClassTimings set StartTime = @StartTime,Endtime=@Endtime,Name=@Name where Id=@id";
                db.cmd.Parameters.AddWithValue("@StartTime", classtimings.StartTime);
                db.cmd.Parameters.AddWithValue("@Endtime", classtimings.EndTime);
                db.cmd.Parameters.AddWithValue("@Name", classtimings.Name);
                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);
            }
        }