public void EventHandler_Agregar(object sender, EventArgs e) { Button btnCurrent = (sender as Button); ListBox lbxInfraDetalle = currentExpander.FindName("lbx_childExpander") as ListBox; Grid gridExpander = currentExpander.FindName("gridExpander") as Grid; Expander expanderAgregar = currentExpander.FindName("expanderAgregar") as Expander; TextBox txt_tamano = gridExpander.FindName("textBox") as TextBox; RichTextBox rtbx_descripcion = gridExpander.FindName("richTextBox") as RichTextBox; Model.Infraestructura_Detalle nuevoInfraDetalle = new Model.Infraestructura_Detalle() { Id_Infra = btnCurrent.Tag.ToString(), Tamano = txt_tamano.Text, Descripcion = GetString(rtbx_descripcion) }; if (LocalDataStore.GuardarDetalleInfraestructura(nuevoInfraDetalle)) { lbxInfraDetalle.ItemsSource = LocalDataStore.GetInfraestructuraDetalle(btnCurrent.Tag.ToString()); lbxInfraDetalle.Items.Refresh(); MessageBox.Show("Se guardo exitosamente", "Registro de Detalle Infraestructura", MessageBoxButton.OK, MessageBoxImage.Information); txt_tamano.Text = ""; FlowDocument fd = new FlowDocument(); fd.Blocks.Add(new Paragraph(new Run(""))); rtbx_descripcion.Document = fd; expanderAgregar.IsExpanded = false; } else { MessageBox.Show("No se guardo", "Registro de Detalle Infraestructura", MessageBoxButton.OK, MessageBoxImage.Exclamation); } }
private void cbx_infra_SelectionChanged(object sender, SelectionChangedEventArgs e) { Model.Infraestructura_Detalle infra = cbx_infra.SelectedItem as Model.Infraestructura_Detalle; if (infra == null) { return; } _IdInfra = infra.Id; }
public static bool GuardarDetalleInfraestructura(Model.Infraestructura_Detalle infraestructuraDetalle) { string response = ServicesManager.Instance.ServiceClient.GuardarInfraestructuraDetalle(infraestructuraDetalle); if (response != "") { infraestructuraDetalle.Id = response; DictionaryInfraestructura.First(I => I.Key.Id == infraestructuraDetalle.Id_Infra).Value.Add(infraestructuraDetalle); return(true); } return(false); }
private void Button_Click(object sender, RoutedEventArgs e) { Button b_ok = sender as Button; ListBox lbxInfraDetalle = currentExpander.FindName("lbx_childExpander") as ListBox; List <Grid> temp = new List <Grid>(); HelpContentVisual.GetListChild <Grid>(lbxInfraDetalle, temp, "grid"); Grid gridfound = temp.Find(G => G.Tag.ToString() == b_ok.Tag.ToString()); CheckBox checkSelected = gridfound.FindName("chbx_DetalleInfra") as CheckBox; if (!(bool)checkSelected.IsChecked) { MessageBox.Show("Selecione un opcion"); return; } ComboBox combo = gridfound.FindName("cbx_Numbers") as ComboBox; ComboBoxItem elem = combo.SelectedValue as ComboBoxItem; if (elem == null) { MessageBox.Show("Selecione una cantidad", "", MessageBoxButton.OK, MessageBoxImage.Exclamation); return; } var containerItem = lbxInfraDetalle.FindName("Grid_ContainerItem"); foreach (Model.Infraestructura_Detalle infra in lbxInfraDetalle.Items) { if (b_ok.Tag.ToString() == infra.Id) { _infraDetalleSelected = infra; break; } } Model.Infraestructura_Apartamento nuevoInfraApartamento = new Model.Infraestructura_Apartamento(); nuevoInfraApartamento.Id_Apartamento = _id_Apartamento; nuevoInfraApartamento.Cantidad = Convert.ToInt16(elem.Content); nuevoInfraApartamento.Id_Infrac_Detalle = _infraDetalleSelected.Id; if (LocalDataStore.GuardarInfraestructuraApartamento(nuevoInfraApartamento)) { MessageBox.Show("Se guardo exitosamente", "Registro de Infraestructura", MessageBoxButton.OK, MessageBoxImage.Information); } else { MessageBox.Show("No se guardo", "Registro de Infraestructura", MessageBoxButton.OK, MessageBoxImage.Exclamation); } }