private void btnGuardar_Click(object sender, RoutedEventArgs e) { try { AsociadoMantenimiento asociado = new AsociadoMantenimiento(); foreach (uc_ItemEntrega item in stpContenedor.Children) { if (item.Valida() == true) { if (item.txbCantidadNeta.Text == 0.ToString()) { item.txbCantidadNeta.Text = (-1).ToString(); } asociado.CompletarEntrega(item.getId(), Convert.ToDouble(item.txbCantidadNeta.Text), PK_UMedida, item.producto, item.getEstado()); } else { item.txbCantidadNeta.Foreground = Brushes.Red; throw new ArgumentException("Error de formato."); } } asociado.RevisaFactura(PK_Factura); asociado.CantidadNetaFactura(PK_Factura); MessageBox.Show("Registro realizado con éxito.", "SIGEEA", MessageBoxButton.OK, MessageBoxImage.Exclamation); this.Close(); } catch (Exception ex) { MessageBox.Show(ex.Message, "SIGEEA", MessageBoxButton.OK, MessageBoxImage.Error); } }
private void RegistraEntrega() { try { AsociadoMantenimiento asociadoM = new AsociadoMantenimiento(); List <SIGEEA_DetFacAsociado> listaDetalles = new List <SIGEEA_DetFacAsociado>(); SIGEEA_FacAsociado factura = new SIGEEA_FacAsociado(); factura.Estado_FacAsociado = true; factura.FecEntrega_FacAsociado = DateTime.Now; factura.FK_Id_Asociado = asociado.PK_Id_Asociado; factura.Numero_FacAsociado = asociadoM.ObtenerNumeroFacturaEntrega(); foreach (uc_IngresoProducto ip in stpContenedor.Children) { SIGEEA_DetFacAsociado fac = new SIGEEA_DetFacAsociado(); fac.CanTotal_DetFacAsociado = ip.getCantidad(); fac.FK_Id_Lote = ip.getLote(); fac.Mercado_DetFacAsociado = ip.getMercado(); fac.FK_Id_PreProCompra = ip.getProducto();//Se le asigna la PK del producto, en la función de registrar de AsociadoMantenimiento se hace el cambio necesario. listaDetalles.Add(fac); } asociadoM.RegistraEntrega(factura, listaDetalles); MessageBox.Show("Entrega registrada con éxito.", "SIGEEA", MessageBoxButton.OK, MessageBoxImage.Exclamation); wnwFacturaEntrega ventana = new wnwFacturaEntrega(factura.PK_Id_FacAsociado, asociado.Codigo_Asociado); ventana.ShowDialog(); this.Close(); } catch (Exception ex) { MessageBox.Show("Error al registrar: " + ex.Message, "SIGEEA", MessageBoxButton.OK, MessageBoxImage.Error); } }
private void CargaDeudores(int pCuota) { AsociadoMantenimiento asociado = new AsociadoMantenimiento(); List <SIGEEA_spObtenerDeudoresCuotasResult> deudores = asociado.ListarDeudoresCuotas(pCuota); bool color = true; if (deudores.Count > 0) { stpDeudores.Children.Clear(); grdPrimaria.Visibility = Visibility.Collapsed; grdSecundaria.Visibility = Visibility.Visible; foreach (SIGEEA_spObtenerDeudoresCuotasResult d in deudores) { uc_DeudorCuota deudor = new uc_DeudorCuota(); deudor.CuotaAsociadoId = d.PK_Id_Cuota_Asociado; deudor.CedulaPersona = d.Cedula; deudor.NombrePersona = d.NombrePersona; deudor.NombreCuota = d.NombreCuota; deudor.MontoCuota = d.MontoCuota; deudor.SaldoPendiente = d.SaldoPendiente; deudor.Color(color); deudor.btnPagar.Tag = d.PK_Id_Cuota_Asociado; deudor.btnPagar.Click += BtnPagar_Click; color = !color; stpDeudores.Children.Add(deudor); } } }
private void btnEfectuarPago_Click(object sender, RoutedEventArgs e) { try { List <int> llaves = new List <int>(); List <double> montos = new List <double>(); foreach (Detalle d in Detalles) { llaves.Add(d.getLlave()); montos.Add(d.getMonto()); } if (Detalles.Count > 0 && MessageBox.Show("¿Realmente quiere realizar el pago?", "SIGEEA", MessageBoxButton.YesNo, MessageBoxImage.Warning) == MessageBoxResult.Yes) { AsociadoMantenimiento asociado = new AsociadoMantenimiento(); if (asociado.CancelaFacturaAsociado(llaves, montos, MetodoPago, numChequeTransferencia, total) == true) { MessageBox.Show("Pago realizado con éxito", "SIGEEA", MessageBoxButton.OK, MessageBoxImage.Exclamation); //print(txbFactura); } else { throw new ArgumentException("No se ha seleccionado ningún elemento."); } } } catch (Exception ex) { MessageBox.Show("Error: " + ex.Message, "SIGEEA", MessageBoxButton.OK, MessageBoxImage.Error); } }
public void CargaFamiliares(string pCedula) { try { stpContenedor.Children.Clear(); AsociadoMantenimiento asociado = new AsociadoMantenimiento(); List <SIGEEA_spListarFamiliaresResult> lista = asociado.ListarFamiliares(pCedula); SIGEEA_DiagramaDataContext dc = new SIGEEA_DiagramaDataContext(); SIGEEA_spObtenerAsociadoResult autentica = asociado.AutenticaAsociado(pCedula); pk_asociado = autentica.PK_Id_Asociado; cedula = autentica.CedParticular_Persona; foreach (SIGEEA_spListarFamiliaresResult f in lista) { uc_ItemFamiliar familiar = new uc_ItemFamiliar(f, true); familiar.Color(color); familiar.btnEliminar.Click += BtnEliminar_Click; familiar.btnEditar.Click += BtnEditar_Click; color = !color; stpContenedor.Children.Add(familiar); } } catch (Exception Ex) { MessageBox.Show("Error: La información se ha guardado correctamente." + Ex.Message, "SIGEEA", MessageBoxButton.OK, MessageBoxImage.Error); } }
private void btnEditar_Click(object sender, RoutedEventArgs e) { AsociadoMantenimiento asociado = new AsociadoMantenimiento(); wnwRegistrarPersona ventana = new wnwRegistrarPersona("Asociado", asociado.AutenticaAsociado(CedulaAsociado), null, null); ventana.ShowDialog(); }
private void BtnSiguiente_Click(object sender, RoutedEventArgs e) { try { ValidaCedula(); if (cedValida == false || (cedValida == true && cedula == txbCedula.Text)) { if (tipoPersona == "Asociado") { RegistrarPersona(); if (editar == false) { AsociadoMantenimiento Asociado = new AsociadoMantenimiento(); SIGEEA_Asociado nuevoAsociado = new SIGEEA_Asociado(); nuevoAsociado.Estado_Asociado = true; nuevoAsociado.FK_Id_Representante = null; nuevoAsociado.FecIngreso_Asociado = DateTime.Today; nuevoAsociado.FK_Id_Empresa = 1; Asociado.RegistrarAsociado(nuevaPersona, nuevoAsociado); } else { nuevaPersona.PK_Id_Persona = pk_Persona; PersonaMantenimiento Persona = new PersonaMantenimiento(); Persona.ModificarPersona(nuevaPersona); } MessageBox.Show("Su solicitud se ha concluido de manera correcta."); this.Close(); } else if (tipoPersona == "Empleado") { RegistrarPersona(); grdPersona.Visibility = Visibility.Collapsed; grdEmpleado.Visibility = Visibility.Visible; grdCliente.Visibility = Visibility.Collapsed; } else if (tipoPersona == "Cliente") { RegistrarPersona(); grdPersona.Visibility = Visibility.Collapsed; grdEmpleado.Visibility = Visibility.Collapsed; grdCliente.Visibility = Visibility.Visible; listarCategorias(); } } else { MessageBox.Show("Ya existe una persona registrada con es cédula"); txbCedula.Text = ""; } } catch (Exception ex) { MessageBox.Show("Debe ingresar la información de manera correcta."); } }
private void btnGuardar_Click(object sender, RoutedEventArgs e) { try { ValidacionesMantenimiento validacion = new ValidacionesMantenimiento(); bool valido = true; foreach (TextBox txb in grdValidar.Children) { BrushConverter bc = new BrushConverter(); txb.Foreground = (Brush)bc.ConvertFrom("#FF000000"); if (validacion.Validar(txb.Text, Convert.ToInt32(txb.Tag)) == false) { valido = false; txb.Foreground = (Brush)bc.ConvertFrom("#FFFF0404"); } } if (valido == true) { SIGEEA_Cuota cuota = new SIGEEA_Cuota(); AsociadoMantenimiento asociado = new AsociadoMantenimiento(); cuota.Nombre_Cuota = txbNombre.Text; cuota.Monto_Cuota = Convert.ToDouble(txbMonto.Text); cuota.FecInicio_Cuota = dtpFecInicio.SelectedDate.Value; cuota.FecFin_Cuota = dtpFecFin.SelectedDate.Value; cuota.FK_Id_Moneda = ucMoneda.getMoneda(); if (pk_cuota == 0) { asociado.RegistrarCuota(cuota); } else { cuota.PK_Id_Cuota = pk_cuota; asociado.EditarCuota(cuota); } MessageBox.Show("La cuota se ha registrado con éxito.", "SIGEEA", MessageBoxButton.OK, MessageBoxImage.Information); this.Close(); } else { throw new System.ArgumentException("Los datos ingresados no coinciden con los formatos requeridos."); } } catch (Exception ex) { MessageBox.Show("Error: " + ex.Message, "SIGEEA", MessageBoxButton.OK, MessageBoxImage.Error); } }
private void btnGuardar_Click(object sender, RoutedEventArgs e) { List <SIGEEA_spObtenerListadoAsistenciaResult> lista = new List <SIGEEA_spObtenerListadoAsistenciaResult>(); AsociadoMantenimiento asociado = new AsociadoMantenimiento(); foreach (uc_AsociadoAsamblea a in stpContenedor.Children) { SIGEEA_spObtenerListadoAsistenciaResult item = new SIGEEA_spObtenerListadoAsistenciaResult(); item.PK_Id_AsiAsamblea = a.AsociadoAsambleaId; item.Cedula = a.AsociadoAsambleaCedula; item.Estado_AsiAsamblea = a.ObtenerEstado(); item.Nombre = a.AsociadoAsambleaNombre; lista.Add(item); } asociado.ActualizarDetalleAsamblea(lista); }
private void btnGuardar_Click(object sender, RoutedEventArgs e) { try { ValidacionesMantenimiento validacion = new ValidacionesMantenimiento(); bool correcto = true; if (validacion.Validar(txbNumActa.Text, 4) == true) { correcto = true; } else { correcto = false; txbNumActa.BorderBrush = Brushes.Red; } if (correcto == true) { AsociadoMantenimiento asociado = new AsociadoMantenimiento(); SIGEEA_Asamblea nuevaAsamblea = new SIGEEA_Asamblea(); nuevaAsamblea.Fecha_Asamblea = dtpFecha.SelectedDate.Value; nuevaAsamblea.NumActa_Asamblea = txbNumActa.Text; nuevaAsamblea.Observaciones_Asamblea = txbObservaciones.Text; if (cmbTipoAsamblea.SelectedIndex == 0) { nuevaAsamblea.Tipo_Asamblea = 1; } else if (cmbTipoAsamblea.SelectedIndex == 1) { nuevaAsamblea.Tipo_Asamblea = 2; } asociado.RegistraAsamblea(nuevaAsamblea); MessageBox.Show("¡Asamblea registrada con éxito!", "SIGEEA", MessageBoxButton.OK, MessageBoxImage.Information); } else { throw new ArgumentException("Formato incorrecto."); } } catch (Exception ex) { MessageBox.Show("Error: " + ex.Message, "SIGEEA", MessageBoxButton.OK, MessageBoxImage.Error); } }
private void btnGuardar_Click(object sender, RoutedEventArgs e) { try { AsociadoMantenimiento asociado = new AsociadoMantenimiento(); List <SIGEEA_Familiar> lista = new List <SIGEEA_Familiar>(); foreach (uc_ItemFamiliar f in stpContenedor.Children) { if ((string)f.lblIdFamiliar.Content == "-1") { SIGEEA_Familiar familiar = new SIGEEA_Familiar(); familiar.Nombre_Familiar = f.txbNombre.Text; familiar.DesEstudios_Familiar = f.txbDetalles.Text; familiar.Escolaridad_Familiar = f.Escolaridad(); familiar.PK_Id_Familiar = Convert.ToInt32(f.lblIdFamiliar.Content); lista.Add(familiar); } else { foreach (int i in editados) { if (f.ObtieneIdFamiliar() == i) { SIGEEA_Familiar familiar = new SIGEEA_Familiar(); familiar.Nombre_Familiar = f.txbNombre.Text; familiar.DesEstudios_Familiar = f.txbDetalles.Text; familiar.Escolaridad_Familiar = f.Escolaridad(); familiar.PK_Id_Familiar = Convert.ToInt32(f.lblIdFamiliar.Content); lista.Add(familiar); } } } } asociado.AgregaEditaFamiliares(pk_asociado, lista); MessageBox.Show("La información se ha guardado correctamente.", "SIGEEA", MessageBoxButton.OK, MessageBoxImage.Information); //lista.Clear(); CargaFamiliares(cedula); } catch (Exception Ex) { MessageBox.Show("Error: La información no se ha guardado correctamente." + Ex.Message, "SIGEEA", MessageBoxButton.OK, MessageBoxImage.Error); } }
private void btnRegistrar_Click(object sender, RoutedEventArgs e) { if (solicitud == "EditarAsociado") { AsociadoMantenimiento Asociado = new AsociadoMantenimiento(); if (Asociado.AutenticaAsociado(txbInformacion.Text) != null) { wnwRegistrarPersona ventana = new wnwRegistrarPersona(pTipoPersona: "Asociado", pAsociado: Asociado.AutenticaAsociado(txbInformacion.Text), pEmpleado: null, pCliente: null); ventana.ShowDialog(); this.Close(); } else { MessageBox.Show("Los datos ingresados no coinciden con ningún registro.", "SIGEEA", MessageBoxButton.OK); } } else if (solicitud == "Direccion") { AsociadoMantenimiento Asociado = new AsociadoMantenimiento(); if (Asociado.AutenticaAsociado(txbInformacion.Text) != null) { wnwDirecciones ventana = new wnwDirecciones(txbInformacion.Text, "Asociado", pkFinca: 0); ventana.ShowDialog(); this.Close(); } else { MessageBox.Show("Los datos ingresados no coinciden con ningún registro.", "SIGEEA", MessageBoxButton.OK); } } else if (solicitud == "Entrega") { AsociadoMantenimiento Asociado = new AsociadoMantenimiento(); Asociado = new AsociadoMantenimiento(); DataClasses1DataContext dc = new DataClasses1DataContext(); if (Asociado.AutenticaAsociado(txbInformacion.Text) != null) { wnwEntregaProducto ventana = new wnwEntregaProducto(dc.SIGEEA_spObtenerAsociado(txbInformacion.Text).First()); ventana.ShowDialog(); this.Close(); } } }
private void btnAnular_Click(object sender, RoutedEventArgs e) { if (MessageBox.Show("¿Realmente quiere cancelar la entrega?", "SIGEEA", MessageBoxButton.YesNo, MessageBoxImage.Warning) == MessageBoxResult.Yes) { AsociadoMantenimiento asoc = new AsociadoMantenimiento(); string mensaje = asoc.AnularEntregaProducto(encabezado.First().NumFactura); if (mensaje.Equals("OK")) { wnwEntregaProducto ventana = new wnwEntregaProducto(asoc.obtenerAsociadoPorID(CodigoAsociado), detalles); this.Close(); ventana.ShowDialog(); } else { MessageBox.Show(mensaje); } } }
private void btnGenerar_Click(object sender, RoutedEventArgs e) { int indFactura, indAsociado; if (txbFecInicio.Text.Contains("Fecha de") || txbFecFin.Text.Contains("Fecha de") || (rbtAscEspecifico.IsChecked == true && txbCedulaCodigo.Text == String.Empty)) { MessageBox.Show("Debe completar todos los campos", "SIGEEA", MessageBoxButton.OK, MessageBoxImage.Error); } else { if (rbtFacTodas.IsChecked == true) { indFactura = 0; } else if (rbtFacIncompletas.IsChecked == true) { indFactura = 1; } else if (rbtFacPendientes.IsChecked == true) { indFactura = 2; } else { indFactura = -1; } if (rbtAscConsolidado.IsChecked == true) { wnwReportesAsociado ventana = new wnwReportesAsociado(indFactura, 0, dpFecInicio.Text, dpFecFin.Text); ventana.ShowDialog(); this.Close(); } else if (rbtAscEspecifico.IsChecked == true && txbCedulaCodigo.Text != String.Empty) { AsociadoMantenimiento asoc = new AsociadoMantenimiento(); wnwReportesAsociado ventana = new wnwReportesAsociado(indFactura, 1, dpFecInicio.Text, dpFecFin.Text, asoc.AutenticaAsociado(txbCedulaCodigo.Text).PK_Id_Asociado); ventana.ShowDialog(); this.Close(); } } }
private void btnListaFacAsociado_Click(object sender, RoutedEventArgs e) { try { AsociadoMantenimiento asociado = new AsociadoMantenimiento(); if (asociado.AutenticaAsociado(txbAsociado.Text) != null) { wnwFacturasPendientes ventana = new wnwFacturasPendientes(txbAsociado.Text, solicitud); ventana.ShowDialog(); } else { throw new ArgumentException("La información suministrada no coincide con ningún registro."); } } catch (Exception ex) { MessageBox.Show("Error: " + ex.Message, "SIGEEA", MessageBoxButton.OK, MessageBoxImage.Error); } }
private void txbAsociado_TextChanged(object sender, TextChangedEventArgs e) { AsociadoMantenimiento asociado = new AsociadoMantenimiento(); List <SIGEEA_spListarAsociadoResult> lista = asociado.ListarAsociados(txbAsociado.Text); stpAsociados.Children.Clear(); bool color = true; foreach (SIGEEA_spListarAsociadoResult a in lista) { uc_ItemAsociado item = new uc_ItemAsociado(); item.CedulaAsociado = a.CedParticular_Persona; item.NombreAsociado = a.Nombre; item.CodigoAsociado = a.Codigo_Asociado; item.PersonaId = a.PK_Id_Persona; item.AsociadoId = a.PK_Id_Asociado; item.Color(color); color = !color; stpAsociados.Children.Add(item); } }
private void btnValidar_Click(object sender, RoutedEventArgs e) { if (tipoSolicitud == "Contacto") { PersonaMantenimiento persona = new PersonaMantenimiento(); int pk_persona = persona.AutenticaPersona(txbCedula.Text); if (pk_persona != 0) { wnwContactos ventana = new wnwContactos(pk_persona); ventana.ShowDialog(); this.Close(); } } else if (tipoSolicitud == "Direccion") { EmpleadoMantenimiento empleado = new EmpleadoMantenimiento(); AsociadoMantenimiento asociado = new AsociadoMantenimiento(); if (empleado.AutenticaEmpleado(txbCedula.Text) != null) //Es un empleado { wnwDirecciones ventana = new wnwDirecciones(txbCedula.Text, "Empleado", pkFinca: 0); ventana.ShowDialog(); this.Close(); } else if (asociado.AutenticaAsociado(txbCedula.Text) != null) //Es un asociado { wnwDirecciones ventana = new wnwDirecciones(txbCedula.Text, "Asociado", pkFinca: 0); ventana.ShowDialog(); this.Close(); } else { MessageBox.Show("Error: el número de cédula digitado no se encuentra registrado.", "SIGEEA", MessageBoxButton.OK); } } }
public wnwCuotas() { InitializeComponent(); AsociadoMantenimiento asociado = new AsociadoMantenimiento(); List <SIGEEA_spObtenerCuotasResult> listaCuotas = asociado.ListarCuotasActivas(); bool color = true; stpCuotas.Children.Clear(); foreach (SIGEEA_spObtenerCuotasResult c in listaCuotas) { uc_Cuota cuota = new uc_Cuota(); cuota.CuotaId = c.PK_ID_CUOTA; cuota.NombreCuota = c.NOMBRE_CUOTA; cuota.MontoCuota = c.MONTO; cuota.Rango = c.RANGO; cuota.Color(color); color = !color; cuota.btnSeleccionar.Click += BtnSeleccionar_Click; cuota.btnSeleccionar.Tag = cuota.getIdCuota(); stpCuotas.Children.Add(cuota); } }
private void btnPagarCuota_Click(object sender, RoutedEventArgs e) { try { if (MessageBox.Show("¿Realmente quiere realizar el pago?", "SIGEEA", MessageBoxButton.YesNo, MessageBoxImage.Warning) == MessageBoxResult.Yes) { ValidacionesMantenimiento validacion = new ValidacionesMantenimiento(); if (validacion.Validar(txbMonto.Text, Convert.ToInt32(txbMonto.Tag)) == true) { AsociadoMantenimiento asociado = new AsociadoMantenimiento(); DataClasses1DataContext dc = new DataClasses1DataContext(); double SaldoAnterior = dc.SIGEEA_Cuota_Asociados.First(c => c.PK_Id_Cuota_Asociado == id_cuota_asociado).Saldo_Cuota_Asociado; if (SaldoAnterior - Convert.ToDouble(txbMonto.Text) >= 0) { if (asociado.RealizarPagoCuota(id_cuota_asociado, Convert.ToDouble(txbMonto.Text)) == true) { MessageBox.Show("Pago realizado con éxito", "SIGEEA", MessageBoxButton.OK, MessageBoxImage.Exclamation); SIGEEA_spGenerarFacturaCuotaResult factura = asociado.GenerarFacturaCuota(id_cuota_asociado, Convert.ToDouble(txbMonto.Text), SaldoAnterior); txbFactura.AppendText(factura.Nombre_Empresa); txbFactura.AppendText(Environment.NewLine); txbFactura.AppendText(factura.CedJuridica); txbFactura.AppendText(Environment.NewLine); txbFactura.AppendText(factura.Direccion_Empresa); txbFactura.AppendText(Environment.NewLine); txbFactura.AppendText(factura.Telefono); txbFactura.AppendText(Environment.NewLine); txbFactura.AppendText(factura.Correo); txbFactura.AppendText(Environment.NewLine); txbFactura.AppendText(factura.Fecha); txbFactura.AppendText(" " + factura.Hora); txbFactura.AppendText(Environment.NewLine); txbFactura.AppendText(Environment.NewLine); txbFactura.AppendText(factura.NombreAsociado); txbFactura.AppendText(Environment.NewLine); txbFactura.AppendText(factura.CedPersona); txbFactura.AppendText(Environment.NewLine); txbFactura.AppendText(factura.CodigoAsociado); txbFactura.AppendText(Environment.NewLine); txbFactura.AppendText(Environment.NewLine); txbFactura.AppendText(factura.NombreCuota); txbFactura.AppendText(Environment.NewLine); txbFactura.AppendText(factura.Total); txbFactura.AppendText(Environment.NewLine); txbFactura.AppendText("Saldo anterior: " + dc.SIGEEA_spObtenerMonedaCuota(id_cuota_asociado).First().Simbolo_Moneda + SaldoAnterior.ToString()); txbFactura.AppendText(Environment.NewLine); txbFactura.AppendText(factura.Monto); txbFactura.AppendText(Environment.NewLine); txbFactura.AppendText(factura.Saldo); txbFactura.AppendText(Environment.NewLine); txbFactura.AppendText(Environment.NewLine); txbFactura.AppendText("¡Gracias por su preferencia!"); grdIndicarMonto.Visibility = Visibility.Collapsed; grdFactura.Visibility = Visibility.Visible; } else { throw new System.ArgumentException("Ha sido imposible realizar el pago."); } } else { throw new System.ArgumentException("El saldo actual es menor que el monto digitado."); } } else { BrushConverter bc = new BrushConverter(); txbMonto.Foreground = (Brush)bc.ConvertFrom("#FFFF0404"); throw new System.ArgumentException("El formato del monto es incorrecto"); } } } catch (Exception ex) { MessageBox.Show(ex.Message, "SIGEEA", MessageBoxButton.OK, MessageBoxImage.Error); } }
public wnwDirecciones(string pCedula_pCodigo, string tipoPersona, int pkFinca) { InitializeComponent(); PersonaMantenimiento persona = new PersonaMantenimiento(); SIGEEA_DiagramaDataContext dc = new SIGEEA_DiagramaDataContext(); AsociadoMantenimiento asociado = new AsociadoMantenimiento(); cmbProvincia.ItemsSource = persona.ListarProvinciasNacionales();//Se carga el ComboBox de provincias pk_finca = pkFinca; tipo = tipoPersona; if (tipoPersona == "Asociado") { if (asociado.DireccionRegistradaAsociado(pCedula: pCedula_pCodigo, pCodigo: null) == true)//Si el asociado tiene ya una dirección registrada { CargaInformacion(tipoPersona, pCedula: pCedula_pCodigo, pCodigo: null, pIdFinca: null); editar = true; } else { MessageBox.Show("Este asociado no cuenta con ninguna dirección registrada. Puede registrarla a continuación.", "SIGEEA", MessageBoxButton.OK); editar = false; if (pCedula_pCodigo.Length < 9) { pk_persona = dc.SIGEEA_Asociados.FirstOrDefault(p => p.Codigo_Asociado == pCedula_pCodigo).FK_Id_Persona; } else { pk_persona = dc.SIGEEA_Personas.First(p => p.CedParticular_Persona == pCedula_pCodigo).PK_Id_Persona; } } } else if (tipoPersona == "Empleado") { EmpleadoMantenimiento empleado = new EmpleadoMantenimiento(); if (empleado.DireccionRegistradaEmpleado(pCedula_pCodigo) == true)// Si el empleado ya tiene una dirección registrada { CargaInformacion(tipoPersona, pCedula: pCedula_pCodigo, pCodigo: null, pIdFinca: null); editar = true; } else { MessageBox.Show("Este empleado no cuenta con ninguna dirección registrada. Puede registrarla a continuación.", "SIGEEA", MessageBoxButton.OK); editar = false; pk_persona = dc.SIGEEA_Personas.First(p => p.CedParticular_Persona == pCedula_pCodigo).PK_Id_Persona; } } else if (tipoPersona == "Finca") { FincaMantenimiento finca = new FincaMantenimiento(); if (finca.DireccionRegistradaFinca(pk_finca.ToString()) == true)// Si el empleado ya tiene una dirección registrada { CargaInformacion(tipoPersona, pCedula: pCedula_pCodigo, pCodigo: null, pIdFinca: null); editar = true; } else { MessageBox.Show("Esta Finca no cuenta con ninguna dirección registrada. Puede registrarla a continuación.", "SIGEEA", MessageBoxButton.OK); editar = false; } } }
/// <summary> /// Carga la dirección del asociado a la interfaz gráfica /// </summary> /// <param name="pCedula"></param> /// <param name="pCodigo"></param> public void CargaInformacion(string tipoPersona, string pCedula, string pCodigo, string pIdFinca) { if (tipoPersona == "Asociado") { AsociadoMantenimiento asociado = new AsociadoMantenimiento(); if (pCedula != null && pCodigo == null) { SIGEEA_spObtenerDireccionAsociadoResult direccion = asociado.ObtenerDireccionAsociado(pCedula: pCedula, pCodigo: null); CargaCantones(direccion.Nombre_Provincia); CargaDistritos(direccion.Nombre_Canton); pk_persona = direccion.PK_Id_Persona; cmbProvincia.SelectedItem = direccion.Nombre_Provincia; cmbCanton.SelectedItem = direccion.Nombre_Canton; cmbDistrito.SelectedItem = direccion.Nombre_Distrito; txbDetalles.Text = direccion.Detalles_Direccion; } else { SIGEEA_spObtenerDireccionAsociadoResult direccion = asociado.ObtenerDireccionAsociado(pCedula: null, pCodigo: pCodigo); CargaCantones(direccion.Nombre_Provincia); CargaDistritos(direccion.Nombre_Canton); pk_persona = direccion.PK_Id_Persona; cmbProvincia.SelectedItem = direccion.Nombre_Provincia; cmbCanton.SelectedItem = direccion.Nombre_Canton; cmbDistrito.SelectedItem = direccion.Nombre_Distrito; txbDetalles.Text = direccion.Detalles_Direccion; } } else if (tipoPersona == "Empleado") { EmpleadoMantenimiento empleado = new EmpleadoMantenimiento(); if (pCedula != null && pCodigo == null) { SIGEEA_spObtenerDireccionEmpleadoResult direccion = empleado.ObtenerDireccionEmpleado(pCedula); CargaCantones(direccion.Nombre_Provincia); CargaDistritos(direccion.Nombre_Canton); pk_persona = direccion.PK_Id_Persona; cmbProvincia.SelectedItem = direccion.Nombre_Provincia; cmbCanton.SelectedItem = direccion.Nombre_Canton; cmbDistrito.SelectedItem = direccion.Nombre_Distrito; txbDetalles.Text = direccion.Detalles_Direccion; } } else if (tipoPersona == "Finca") { FincaMantenimiento Finca = new FincaMantenimiento(); if (pIdFinca == null) { SIGEEA_spObtenerDireccionFincaResult direccion = Finca.ObtenerDireccionFinca(Convert.ToInt32(pIdFinca)); CargaCantones(direccion.Nombre_Provincia); CargaDistritos(direccion.Nombre_Canton); cmbProvincia.SelectedItem = direccion.Nombre_Provincia; cmbCanton.SelectedItem = direccion.Nombre_Canton; cmbDistrito.SelectedItem = direccion.Nombre_Distrito; txbDetalles.Text = direccion.Detalles_Direccion; } } }