public static TEmpresa GetTEmpresa(SqlCeConnection conn) { TEmpresa empresa = null; using (SqlCeCommand cmd = conn.CreateCommand()) { cmd.CommandType = System.Data.CommandType.Text; cmd.CommandText = String.Format("SELECT * FROM Empresa"); using (SqlCeDataReader dr = cmd.ExecuteReader()) { while (dr.Read()) { empresa = new TEmpresa(); empresa.EmpresaId = dr.GetInt32(0); empresa.Nombre = dr.GetString(1); empresa.Abm = dr.GetByte(2); break; } if (!dr.IsClosed) { dr.Close(); } } } return(empresa); }
public static void TSave(TEmpresa tr, SqlCeConnection conn) { string sql = ""; sql = @"INSERT INTO Empresa(empresa_id, nombre) VALUES({0},'{1}')"; sql = String.Format(sql, tr.EmpresaId, tr.Nombre); using (SqlCeCommand cmd = conn.CreateCommand()) { cmd.CommandText = sql; cmd.ExecuteNonQuery(); } }
public static TEmpresa GetTEmpresa(string nombre, SqlCeConnection conn) { TEmpresa ta = null; string sql = String.Format("SELECT * FROM Empresa WHERE nombre='{0}'", nombre); using (SqlCeCommand cmd = conn.CreateCommand()) { cmd.CommandText = sql; SqlCeDataReader dr = cmd.ExecuteReader(); while (dr.Read()) { ta = new TEmpresa(); ta.EmpresaId = dr.GetInt32(0); ta.Nombre = dr.GetString(1); ta.Abm = dr.GetByte(2); } if (!dr.IsClosed) { dr.Close(); } } return(ta); }
public static TEmpresa GetTEmpresa(int id, SqlCeConnection conn) { TEmpresa empresa = null; using (SqlCeCommand cmd = conn.CreateCommand()) { cmd.CommandType = System.Data.CommandType.Text; cmd.CommandText = String.Format("SELECT * FROM Empresa WHERE empresa_id = {0}", id); using (SqlCeDataReader dr = cmd.ExecuteReader()) { while (dr.Read()) { empresa = new TEmpresa(); empresa.EmpresaId = id; empresa.Nombre = dr.GetString(1); } if (!dr.IsClosed) { dr.Close(); } } } return(empresa); }