コード例 #1
0
ファイル: Competidor.cs プロジェクト: rickyasg/ProyectoX
        //public int SaveCompetidor()
        //{
        //    string procedimiento="";
        //    List<SqlParameter> ps = new List<SqlParameter>();
        //    ps = LoadParameters();
        //    if (this.PersonaId==0)
        //    {
        //        procedimiento = "acre.pInsPersonas";

        //    }
        //    ExecuteTransaction(procedimiento, ps);
        //    return PersonaId;
        //}
        #endregion

        #region Members
        public static Competidor ConvertToCompetidor(DataRow dr, bool constructComponentes = false)
        {
            Competidor cp = new Competidor();

            if (dr != null)
            {
                cp.CompetidorId       = Convert.ToInt32(dr["CompetidorId"]);
                cp.EquipoId           = dr.Table.Columns.Contains("EquipoId")? string.IsNullOrEmpty(dr["EquipoId"].ToString())? 0 : Convert.ToInt32(dr["EquipoId"]) : 0;
                cp.PersonaId          = dr.Table.Columns.Contains("PersonaId") ? string.IsNullOrEmpty(dr["PersonaId"].ToString())?  0: Convert.ToInt32(dr["PersonaId"]) : 0;
                cp.PruebaEventoId     = Convert.ToInt32(dr["PruebaEventoId"]);
                cp.Activo             = Convert.ToBoolean(dr["Activo"]);
                cp.MarcaTiempoInicial = dr.Table.Columns.Contains("MarcaTiempoInicial") ? Convert.ToString(dr["MarcaTiempoInicial"]): "";

                if (constructComponentes)
                {
                    cp.Persona = cp.PersonaId != 0? Persona.GetPersona(cp.PersonaId): new Persona();
                    cp.Equipo  = cp.EquipoId != 0 ? Equipo.GetEquipo(cp.EquipoId, true): new Equipo();
                }
            }
            return(cp);
        }