public static ENTEquipo buscarId(Int32 id) { ENTEquipo equi = null; ObjConnection.Open(); SQLiteCommand ObjCommand = new SQLiteCommand("SELECT * FROM equipo where id=" + id + "", ObjConnection); ObjCommand.CommandType = CommandType.Text; SQLiteDataAdapter ObjDataAdapter = new SQLiteDataAdapter(ObjCommand); DataTable dt = new DataTable("equipo"); ObjDataAdapter.Fill(dt); ObjConnection.Close(); foreach (DataRow dr in dt.Rows) { equi = new ENTEquipo ( Convert.ToInt32(dr["id"].ToString()), dr["marca"].ToString(), dr["modelo"].ToString(), dr["color"].ToString(), dr["foto"].ToString(), dr["fechaIng"].ToString(), dr["fechaEnt"].ToString(), pag = (Convert.ToInt32(dr["pagado"].ToString()) == 1) ? true : false, pag = (Convert.ToInt32(dr["arreglado"].ToString()) == 1) ? true : false, pag = (Convert.ToInt32(dr["entregado"].ToString()) == 1) ? true : false, float.Parse(dr["precio"].ToString()), dr["obser"].ToString(), Convert.ToInt32(dr["id_cliente"].ToString()) ); } return equi; }
public static void actualizarEquipo(ENTEquipo equi) { int pagado = (equi.pagado) ? 1 : 0; int arreglado = (equi.arreglado) ? 1 : 0; int entregado = (equi.entregado) ? 1 : 0; ObjConnection.Open(); string sql = "UPDATE equipo SET " + "marca='" + equi.marca + "'," + "modelo='" + equi.modelo + "'," + "color='" + equi.color + "'," + "foto='" + equi.foto + "'," + "fechaIng='" + equi.fechaIng + "'," + "fechaEnt='" + equi.fechaEnt + "'," + "pagado=" + pagado + "," + "arreglado=" + arreglado + "," + "entregado=" + entregado + "," + "precio=" + equi.precio + "," + "obser='" + equi.obser + "'" + "where id=" + equi.id; SQLiteCommand command = new SQLiteCommand(sql, ObjConnection); command.ExecuteNonQuery(); ObjConnection.Close(); }
public static void nuevo(ENTEquipo equi) { ObjConnection.Open(); int pagado = (equi.pagado) ? 1 : 0; int arreglado = (equi.arreglado) ? 1 : 0; int entregado = (equi.entregado) ? 1 : 0; string sql = "insert into equipo values (null,'" + equi.marca + "','" + equi.modelo + "','" + equi.color + "','" + equi.foto + "'," + "'" + equi.fechaIng + "'," + "null" + "," + pagado + "," + arreglado + "," + entregado + "," + equi.precio + ",'" + equi.obser + "'," + equi.id_cliente + ");"; SQLiteCommand command = new SQLiteCommand(sql, ObjConnection); command.ExecuteNonQuery(); ObjConnection.Close(); }