public partial class Test : Window
{
public Test()
{
InitializeComponent();
dataGrid.ItemsSource = buildDataGrid();
}
private List<Pago> buildDataGrid()
{
DataSet ds = Dao.getListadoPago();
List<Pago> pagos = new List<Pago>();
for (int i = 0; i <= ds.Tables[0].Rows.Count - 1; i++)
{
pagos.Add(new Pago
{
id = Convert.ToInt32(ds.Tables[0].Rows[i]["id"].ToString()),
cuota = Convert.ToInt32(ds.Tables[0].Rows[i]["cuota"].ToString()),
apartamento = Convert.ToInt32(ds.Tables[0].Rows[i]["apto"].ToString()),
edificio = Convert.ToInt32(ds.Tables[0].Rows[i]["edificio"].ToString()),
fechaPago = Convert.ToDateTime(ds.Tables[0].Rows[i]["fecha_pago"].ToString()),
fechaInsertado = Convert.ToDateTime(ds.Tables[0].Rows[i]["fecha_act"].ToString())
});
}
return pagos;
}
}
public static class Dao
{
public static DataSet getListadoPago()
{
DataSet ds = new DataSet();
string s = "select id,cuota,fecha_pago,apto,fecha_act, getedificio(apto) as edificio ";
s += "from T_PAGO order by apto asc";
ds = executeQuery(s);
if (ds == null)
return null;
return ds;
}
}
public class Pago
{
public int id { get; set; }
public int cuota { get; set; }
public int meses
{
get
{
return cuota / 5;
}
}
public DateTime fechaPago { get; set; }
public int apartamento { get; set; }
public int edificio { get; set; }
public DateTime fechaInsertado { get; set; }
public string resumen
{
get
{
return String.Format("Fecha de actualización {0}/{1}/{2} {3}:{4}:{5}", fechaInsertado.Day, fechaInsertado.Month, fechaInsertado.Year, fechaInsertado.Hour, fechaInsertado.Minute, fechaInsertado.Second);
}
}
}