Пример #1
0
        public static IList <TResponsable> GetTResponsables(SqlCeConnection conn)
        {
            IList <TResponsable> ltr = new List <TResponsable>();
            string sql = "SELECT * FROM Responsable";

            using (SqlCeCommand cmd = conn.CreateCommand())
            {
                cmd.CommandText = sql;
                SqlCeDataReader dr = cmd.ExecuteReader();
                while (dr.Read())
                {
                    TResponsable tr = GetTResponsable(dr.GetInt32(0), conn);
                    ltr.Add(tr);
                }
            }
            return(ltr);
        }
Пример #2
0
        public static IList <TResponsable> GetTResponsables(SqlCeConnection conn)
        {
            IList <TResponsable> l = new List <TResponsable>();

            using (SqlCeCommand cmd = conn.CreateCommand())
            {
                cmd.CommandText = String.Format("SELECT * FROM Responsable");
                SqlCeDataReader dr = cmd.ExecuteReader();
                while (dr.Read())
                {
                    TResponsable tusu = GetTResponsable(dr.GetInt32(0), conn);
                    if (tusu != null)
                    {
                        l.Add(tusu);
                    }
                }
            }
            return(l);
        }
Пример #3
0
        public static void TSave(TResponsable tu, SqlCeConnection conn)
        {
            string sql = "";
            // primero verificamos que si el elemento está
            // TResponsable tusu = GetTResponsable(tu.ResponsableId, conn);
            TResponsable tusu = null;

            if (tusu == null)
            {
                sql = "INSERT INTO Responsable(responsable_id, nombre) VALUES({0},'{1}')";
            }
            else
            {
                sql = "UPDATE Responsable SET nombre='{1}' WHERE responsable_id={0}";
            }
            sql = String.Format(sql, tu.ResponsableId, tu.Nombre);
            using (SqlCeCommand cmd = conn.CreateCommand())
            {
                cmd.CommandText = sql;
                int nrec = cmd.ExecuteNonQuery();
            }
        }
Пример #4
0
        public static TResponsable GetTResponsable(string nombre, SqlCeConnection conn)
        {
            TResponsable tr  = null;
            string       sql = String.Format("SELECT * FROM Responsable WHERE nombre='{0}'", nombre);

            using (SqlCeCommand cmd = conn.CreateCommand())
            {
                cmd.CommandText = sql;
                SqlCeDataReader dr = cmd.ExecuteReader();
                while (dr.Read())
                {
                    tr = new TResponsable();
                    tr.ResponsableId = dr.GetInt32(0);
                    tr.Nombre        = dr.GetString(1);
                    tr.Abm           = dr.GetByte(2);
                }
                if (!dr.IsClosed)
                {
                    dr.Close();
                }
            }
            return(tr);
        }
Пример #5
0
        public static TResponsable GetTResponsable(int id, SqlCeConnection conn)
        {
            TResponsable Responsable = null;

            using (SqlCeCommand cmd = conn.CreateCommand())
            {
                cmd.CommandText = String.Format("SELECT * FROM Responsable WHERE responsable_id = {0}", id);
                SqlCeDataReader dr = cmd.ExecuteReader();
                while (dr.Read())
                {
                    Responsable = new TResponsable()
                    {
                        ResponsableId = dr.GetInt32(0),
                        Nombre        = dr.GetString(1),
                        Abm           = dr.GetByte(2)
                    };
                }
                if (!dr.IsClosed)
                {
                    dr.Close();
                }
            }
            return(Responsable);
        }