private void reportito_Loaded(object sender, RoutedEventArgs e) { Finalbd.Cbd.Mibd db = new Cbd.Mibd(); Finalbd.Cbd.Sancion sn = new Cbd.Sancion(); Finalbd.Cbd.Ciudadano ci = new Cbd.Ciudadano(); Aut.ItemsSource = db.Auts.ToList(); Aut.DisplayMemberPath = "Placa"; Aut.SelectedValuePath = "IDAuto"; cbCiudadano.ItemsSource = db.Cius.ToList(); cbCiudadano.DisplayMemberPath = "Nombre"; cbCiudadano.SelectedValuePath = "IDCiudadano"; cbAgente.ItemsSource = db.Agens.ToList(); cbAgente.DisplayMemberPath = "Nombre"; cbAgente.SelectedValuePath = "IDAgente"; cbMulta.ItemsSource = db.Mults.ToList(); cbMulta.DisplayMemberPath = "Descripcion"; cbMulta.SelectedValuePath = "IDMulta"; cbreport.ItemsSource = db.Sans.ToList(); cbreport.DisplayMemberPath = "IdS"; cbreport.SelectedValuePath = "IdS"; }
private void Limpiar() { //shopping cart = a new empty list carri = new List<Sancion>(); //Textboxes and labels are set to defaults prec.Text = string.Empty; total.Content = "Total: $0.00"; //DataGrid items are set to null reportito.ItemsSource = null; reportito.Items.Refresh(); //Tmp variable is erased using null tmpSan = null; }
private void meter_Click(object sender, RoutedEventArgs e) { int Id = Convert.ToInt32(cbreport.SelectedValue); Finalbd.Cbd.Mibd db = new Finalbd.Cbd.Mibd(); Finalbd.Cbd.Sancion sn = db.Sans.SingleOrDefault(x => x.IdS == Id); tmpSan = sn; carri.RemoveAll(s => s.IdS == tmpSan.IdS); if (tmpSan == null) { //if tmpProduct is empty (Product not found) we exit the procedure MessageBox.Show("No hay reportes realizados", "Sin reportes", MessageBoxButton.OK, MessageBoxImage.Exclamation); //exit procedure } carri.Add(new Sancion() { IdS = tmpSan.IdS, Precio = tmpSan.Precio, IDAgente = tmpSan.IDAgente, IDAuto = tmpSan.IDAuto, IDCiudadano = tmpSan.IDCiudadano, IDMulta = tmpSan.IDMulta, Fec = tmpSan.Fec }); LlenaGrid(); tmpSan= null; }
private void Guardar_Click(object sender, RoutedEventArgs e) { Mibd db = new Mibd(); Sancion sn = new Sancion(); sn.Precio = int.Parse(prec.Text); sn.Fec = DateTime.Now; sn.IDAuto = Convert.ToInt32(Aut.SelectedValue.ToString()); sn.IDAgente = Convert.ToInt32(cbAgente.SelectedValue.ToString()); sn.IDCiudadano = Convert.ToInt32(cbCiudadano.SelectedValue.ToString()); sn.IDMulta = Convert.ToInt32(cbMulta.SelectedValue.ToString()); db.Sans.Add(sn); db.SaveChanges(); MessageBox.Show("Se Guardaron Los Cambios Correctamente"); cbreport.ItemsSource = db.Sans.ToList(); }