示例#1
0
        public List <AssistanceListDto> GetLessons(Int32 schoolID, Int32 programmingID, Boolean active)
        {
            SqlConnection conn = null;
            SqlDataReader reader;
            String        sql;
            SqlCommand    command;
            SqlParameter  prmschoolID      = null;
            SqlParameter  prmprogrammingID = null;
            SqlParameter  prmactive        = null;

            try
            {
                AssistanceListDto        assistance;
                List <AssistanceListDto> lstAssistances;

                conn = new SqlConnection(Functions.GetConnectionString());

                sql = "GetAssistanceByschoolIDByprogrammingIDByactive";

                command             = new SqlCommand(sql, conn);
                command.CommandType = CommandType.StoredProcedure;

                prmschoolID = new SqlParameter();
                prmschoolID.ParameterName = "@schoolID";
                prmschoolID.SqlDbType     = SqlDbType.Int;
                prmschoolID.Value         = schoolID;
                command.Parameters.Add(prmschoolID);

                prmprogrammingID = new SqlParameter();
                prmprogrammingID.ParameterName = "@programmingID";
                prmprogrammingID.SqlDbType     = SqlDbType.Int;
                prmprogrammingID.Value         = programmingID;
                command.Parameters.Add(prmprogrammingID);

                prmactive = new SqlParameter();
                prmactive.ParameterName = "@active";
                prmactive.SqlDbType     = SqlDbType.Bit;
                prmactive.Value         = active;
                command.Parameters.Add(prmactive);

                command.Connection.Open();
                reader = command.ExecuteReader();

                lstAssistances = new List <AssistanceListDto>();

                while (reader.Read())
                {
                    assistance = new AssistanceListDto();
                    assistance.assistanceID  = reader.GetInt32(reader.GetOrdinal("assistanceID"));
                    assistance.classTheme    = reader.GetString(reader.GetOrdinal("classTheme"));
                    assistance.dateClass     = reader.GetDateTime(reader.GetOrdinal("dateClass"));
                    assistance.dateClassShow = TimerAgo.TimeShow(assistance.dateClass, Formater.SortableDateTime());
                    assistance.dateClassAgo  = assistance.dateClass.Day + " " + Formater.getShortName(assistance.dateClass.Month.ToString());
                    lstAssistances.Add(assistance);
                }

                command.Connection.Close();
                conn.Dispose();

                return(lstAssistances);
            }
            catch (Exception ex)
            {
                conn.Dispose();
                throw ex;
            }
        }
示例#2
0
        public TeacherDto Obtain(int TeacherID)
        {
            SqlConnection conn = null;
            SqlDataReader drTeachers;
            String        strSqlTeacher;
            SqlCommand    cmdTeacher;
            SqlParameter  prmTeacherID = null;

            try
            {
                TeacherDto objTeacherBe;
                objTeacherBe = new TeacherDto();
                conn         = new SqlConnection(Functions.GetConnectionString());

                strSqlTeacher = "GetTeacherByTeacherID";

                cmdTeacher             = new SqlCommand(strSqlTeacher, conn);
                cmdTeacher.CommandType = CommandType.StoredProcedure;

                prmTeacherID = new SqlParameter();
                prmTeacherID.ParameterName = "@TeacherID";
                prmTeacherID.SqlDbType     = SqlDbType.Int;
                prmTeacherID.Value         = TeacherID;
                cmdTeacher.Parameters.Add(prmTeacherID);

                cmdTeacher.Connection.Open();
                drTeachers = cmdTeacher.ExecuteReader();

                AmazonS3 s3 = new AmazonS3();
                s3 = AmazonS3Factory.setAmazonS3();

                if (drTeachers.Read())
                {
                    //Instancio el objeto y le agrego cada uno de sus campos
                    objTeacherBe           = new TeacherDto();
                    objTeacherBe.TeacherID = drTeachers.GetInt32(drTeachers.GetOrdinal("TeacherID"));
                    objTeacherBe.Name      = drTeachers.GetString(drTeachers.GetOrdinal("Name"));
                    objTeacherBe.ShortName = drTeachers.GetString(drTeachers.GetOrdinal("ShortName"));

                    objTeacherBe.Gender    = drTeachers.GetString(drTeachers.GetOrdinal("Gender"));
                    objTeacherBe.SchoolID  = drTeachers.GetInt32(drTeachers.GetOrdinal("SchoolID"));
                    objTeacherBe.Active    = drTeachers.GetBoolean(drTeachers.GetOrdinal("Active"));
                    objTeacherBe.Role_Name = drTeachers.GetString(drTeachers.GetOrdinal("Role_Name"));

                    objTeacherBe.Email           = drTeachers.GetString(drTeachers.GetOrdinal("Email"));
                    objTeacherBe.AlternativeMail = drTeachers.GetString(drTeachers.GetOrdinal("AlternativeMail"));
                    objTeacherBe.HomeAddress     = drTeachers.GetString(drTeachers.GetOrdinal("HomeAddress"));
                    objTeacherBe.Phone           = drTeachers.GetString(drTeachers.GetOrdinal("Phone"));

                    objTeacherBe.LastLoginDate           = drTeachers.GetDateTime(drTeachers.GetOrdinal("LastLoginDate"));
                    objTeacherBe.LastPasswordChangedDate = drTeachers.GetDateTime(drTeachers.GetOrdinal("LastPasswordChangedDate"));

                    objTeacherBe.LastLoginDateShow           = TimerAgo.TimeShow(objTeacherBe.LastLoginDate, Formater.ShortDateTime());
                    objTeacherBe.LastPasswordChangedDateShow = TimerAgo.TimeShow(objTeacherBe.LastPasswordChangedDate, Formater.ShortDateTime());
                    objTeacherBe.LastLogoutDateShow          = TimerAgo.TimeShow(objTeacherBe.LastLogoutDate, Formater.ShortDateTime());

                    objTeacherBe.LastLoginDateAgo           = TimerAgo.TimeAgo(objTeacherBe.LastLoginDate);
                    objTeacherBe.LastPasswordChangedDateAgo = TimerAgo.TimeAgo(objTeacherBe.LastPasswordChangedDate);
                    objTeacherBe.LastLogoutDateAgo          = TimerAgo.TimeAgo(objTeacherBe.LastLogoutDate);

                    objTeacherBe.School_Name = drTeachers.GetString(drTeachers.GetOrdinal("School_Name"));
                    objTeacherBe.ImageKey    = drTeachers.GetString(drTeachers.GetOrdinal("ImageKey"));
                    objTeacherBe.EndPoint    = s3.getTeacherEndPoint(objTeacherBe.SchoolID, objTeacherBe.ImageKey);
                }

                cmdTeacher.Connection.Close();
                conn.Dispose();

                return(objTeacherBe);
            }
            catch (Exception ex)
            {
                conn.Dispose();
                throw ex;
            }
        }
示例#3
0
        public List <EvaluationExpirationListDto> GetByprogrammingIDByactive(Int32 programmingID, bool active)
        {
            SqlConnection conn = null;
            SqlDataReader reader;
            String        sql;
            SqlCommand    command;
            SqlParameter  prmprogrammingID = null;
            SqlParameter  prmactive        = null;

            try
            {
                EvaluationExpirationListDto        evaluationExpiration;
                List <EvaluationExpirationListDto> lstEvaluationExpirations;

                conn = new SqlConnection(Functions.GetConnectionString());

                sql = "GetEvaluationExpirationByprogrammingIDByactive";

                command             = new SqlCommand(sql, conn);
                command.CommandType = CommandType.StoredProcedure;

                prmprogrammingID = new SqlParameter();
                prmprogrammingID.ParameterName = "@programmingID";
                prmprogrammingID.SqlDbType     = SqlDbType.Int;
                prmprogrammingID.Value         = programmingID;
                command.Parameters.Add(prmprogrammingID);

                prmactive = new SqlParameter();
                prmactive.ParameterName = "@active";
                prmactive.SqlDbType     = SqlDbType.Bit;
                prmactive.Value         = active;
                command.Parameters.Add(prmactive);

                command.Connection.Open();
                reader = command.ExecuteReader();

                lstEvaluationExpirations = new List <EvaluationExpirationListDto>();

                while (reader.Read())
                {
                    evaluationExpiration           = new EvaluationExpirationListDto();
                    evaluationExpiration.startDate = reader.GetDateTime(reader.GetOrdinal("startDate"));
                    evaluationExpiration.endDate   = reader.GetDateTime(reader.GetOrdinal("endDate"));
                    evaluationExpiration.evaluationExpirationID = reader.GetInt32(reader.GetOrdinal("evaluationExpirationID"));
                    evaluationExpiration.startDateShow          = TimerAgo.TimeShow(evaluationExpiration.startDate, Formater.ShortDateTime());
                    evaluationExpiration.startDateAgo           = TimerAgo.TimeAgo(evaluationExpiration.startDate);
                    evaluationExpiration.endDateShow            = TimerAgo.TimeShow(evaluationExpiration.endDate, Formater.ShortDateTime());
                    evaluationExpiration.endDateAgo             = TimerAgo.TimeAgo(evaluationExpiration.endDate);
                    evaluationExpiration.programmingID          = reader.GetInt32(reader.GetOrdinal("programmingID"));
                    evaluationExpiration.evaluationID           = reader.GetInt32(reader.GetOrdinal("evaluationID"));



                    lstEvaluationExpirations.Add(evaluationExpiration);
                }

                command.Connection.Close();
                conn.Dispose();

                return(lstEvaluationExpirations);
            }
            catch (Exception ex)
            {
                conn.Dispose();
                throw ex;
            }
        }