/* * protected void Page_Load(object sender, EventArgs e) * { * SqlConnection con = newSqlConnection("Data Source=sql Server name ;Initial Catalog=ResultDB;Integrated Security=True"); * if (!IsPostBack) * { * string strQuery = "SELECT * FROM tblStudent"; * SqlDataAdapter da = newSqlDataAdapter(strQuery, con); * DataTable dt = newDataTable(); * da.Fill(dt); * RDLC ds = newRDLC(); * ds.Tables["tblStudent"].Merge(dt); * ReportViewer1.ProcessingMode = ProcessingMode.Local; * ReportViewer1.LocalReport.ReportPath = Server.MapPath("Student.rdlc"); * ReportDataSource datasource = newReportDataSource("RDLC", ds.Tables[0]); * ReportViewer1.LocalReport.DataSources.Clear(); * ReportViewer1.LocalReport.DataSources.Add(datasource); * } * } */ protected void Page_Load(object sender, EventArgs e) { //SqlConnection con = new SqlConnection("Data Source=sql Server name ;Initial Catalog=ResultDB;Integrated Security=True"); IDatabase _database = LiteDBDatabase.GetInstance(); if (!IsPostBack) { AutoDataSet ds = new AutoDataSet(); DataTable dt = ds.Tables["AutoDT"]; foreach (var a in _database.GetAutos()) { var r = dt.NewRow(); r["Id"] = a.Id; r["Year"] = a.Year; r["Brand"] = a.Brand; r["Model"] = a.Model; r["Price"] = a.Price; r["Km"] = a.Km; r["ExtColor"] = a.ExtColor; r["IntColor"] = a.IntColor; r["Liters"] = a.Liters; r["Doors"] = a.Doors; dt.Rows.Add(r); } ReportViewer1.ProcessingMode = ProcessingMode.Local; ReportViewer1.LocalReport.ReportPath = Server.MapPath("AutoReporte.rdlc"); ReportDataSource datasource = new ReportDataSource("AutoDataSet", dt); //ReportViewer1.LocalReport.DataSources.Clear(); ReportViewer1.LocalReport.DataSources.Add(datasource); } }
static void Main(string[] args) { IDatabase database = LiteDBDatabase.GetInstance(); /* Auto auto = new Auto(); * auto.Id = 1; * auto.Year = 2017; * auto.Brand = "Volskwagen"; * auto.Model = "Vento"; * auto.Doors = 4; * auto.ExtColor = "Grafito"; * auto.IntColor = "Gris"; * auto.Km = 76000; * auto.Liters = 1.6f; * auto.Price = 173900; * IDatabase database = LiteDBDatabase.GetInstance(); * database.InsertAuto(auto);*/ var autos = database.GetAutos(); foreach (var a in autos) { Console.WriteLine(a._id + " " + a.GetNombre()); } Console.Read(); }
public void LoadData() { IDatabase database = LiteDBDatabase.GetInstance(); var autos = database.GetAutos(); lstAutos.Items.Clear(); foreach (var auto in autos) { ListViewItem lvi = new ListViewItem(); lvi.Text = auto.GetNombre(); lstAutos.Items.Add(lvi); } }
private void LoadCars() { IDatabase db = LiteDBDatabase.GetInstance(Interfaces.IDevice.dir); /*Auto auto = new Auto(); * auto.Id = 1; * auto.Year = 2017; * auto.Brand = "Volskwagen"; * auto.Model = "Vento"; * auto.Doors = 4; * auto.ExtColor = "Grafito"; * auto.IntColor = "Gris"; * auto.Km = 76000; * auto.Liters = 1.6f; * auto.Price = 173900; * db.InsertAuto(auto);*/ Autos = new ObservableCollection <Auto>(db.GetAutos()); }
public HomeController() { _database = LiteDBDatabase.GetInstance(); }
private void evGuardar(object sender, EventArgs e) { var Errores = new List <string>(); var valido = true; if ( string.IsNullOrEmpty(tbDoors.Text) || string.IsNullOrEmpty(tbBrand.Text) || string.IsNullOrEmpty(tbExtColor.Text) || string.IsNullOrEmpty(tbIntColor.Text) || string.IsNullOrEmpty(tbKm.Text) || string.IsNullOrEmpty(tbLiters.Text) || string.IsNullOrEmpty(tbModel.Text) || string.IsNullOrEmpty(tbPrice.Text) || string.IsNullOrEmpty(tbYear.Text) ) { Errores.Add("Todos los campos son requeridos"); valido = false; } if (!int.TryParse(tbDoors.Text, out var doors)) { Errores.Add("Las puertas deben ser un valor entero"); valido = false; } if (!int.TryParse(tbKm.Text, out var km)) { Errores.Add("El Km debe ser un valor entero"); valido = false; } if (!float.TryParse(tbLiters.Text, out var liters)) { Errores.Add("Los litros deben ser un valor decimal"); valido = false; } if (!float.TryParse(tbPrice.Text, out var price)) { Errores.Add("El precio debe ser un valor decimal"); valido = false; } if (!int.TryParse(tbYear.Text, out var year)) { Errores.Add("El año debe ser un valor entero"); valido = false; } if (valido) { var nuevoAuto = new Auto { Brand = tbBrand.Text, Doors = int.Parse(tbDoors.Text), ExtColor = tbExtColor.Text, IntColor = tbIntColor.Text, Km = int.Parse(tbKm.Text), Liters = float.Parse(tbLiters.Text), Model = tbModel.Text, Price = float.Parse(tbPrice.Text), Year = int.Parse(tbYear.Text) }; IDatabase database = LiteDBDatabase.GetInstance(); database.InsertAuto(nuevoAuto); _previous.LoadData(); Close(); } else { MessageBox.Show(string.Join(System.Environment.NewLine, Errores), "Datos Invalidos", MessageBoxButtons.OK, MessageBoxIcon.Error); } }