private void numeroDocumentoWaterMarkTextBox_Validating(object sender, CancelEventArgs e)
        {
            string error = null;

            if (!Validacion.esCadenaNumero(numeroDocumentoWaterMarkTextBox))
            {
                numeroDocumentoWaterMarkTextBox.BackColor = Color.White;
                error    = "Ingrese el numero de documento";
                e.Cancel = true;
                errorProvider1.SetError((Control)sender, error);
            }
            else if (DatosRepartidor.existeRepartidorND(id, numeroDocumentoWaterMarkTextBox.Text))
            {
                correoElectronicoAlternativoWaterMarkTextBox.BackColor = colorOk;
                errorProvider1.SetError(numeroDocumentoWaterMarkTextBox, String.Empty);
            }
            else if (DatosRepartidor.existeDocumento(numeroDocumentoWaterMarkTextBox.Text))
            {
                numeroDocumentoWaterMarkTextBox.BackColor = Color.White;
                error    = "El de numero documento ingresado ya existe";
                e.Cancel = true;
                errorProvider1.SetError((Control)sender, error);
            }
            else
            {
                numeroDocumentoWaterMarkTextBox.BackColor = colorOk;
                errorProvider1.SetError((Control)sender, String.Empty);
            }
        }
        private void correoElectronicoAlternativoWaterMarkTextBox_Validating(object sender, CancelEventArgs e)
        {
            string error = null;

            if (!Validacion.esEmail(correoElectronicoAlternativoWaterMarkTextBox))
            {
                correoElectronicoAlternativoWaterMarkTextBox.BackColor = Color.White;
                error    = "Ingrese el correo electronico alternativo";
                e.Cancel = true;
                errorProvider1.SetError((Control)sender, error);
            }
            else if (DatosRepartidor.existeRepartidorCEA(id, correoElectronicoAlternativoWaterMarkTextBox.Text))
            {
                correoElectronicoAlternativoWaterMarkTextBox.BackColor = colorOk;
                errorProvider1.SetError(correoElectronicoAlternativoWaterMarkTextBox, String.Empty);
            }
            else if (DatosRepartidor.existeCorreoEA(correoElectronicoAlternativoWaterMarkTextBox.Text))
            {
                correoElectronicoAlternativoWaterMarkTextBox.BackColor = Color.White;
                error    = "El correo electronico alternativo ingresado ya existe";
                e.Cancel = true;
                errorProvider1.SetError((Control)sender, error);
            }
            else
            {
                correoElectronicoAlternativoWaterMarkTextBox.BackColor = colorOk;
                errorProvider1.SetError((Control)sender, String.Empty);
            }
        }
        private void numeroCelularWaterMarkTextBox_Validating(object sender, CancelEventArgs e)
        {
            string error = null;

            if (!Validacion.esTelefono(numeroCelularWaterMarkTextBox))
            {
                numeroCelularWaterMarkTextBox.BackColor = Color.White;
                error    = "Ingrese el numero de celular";
                e.Cancel = true;
                errorProvider1.SetError((Control)sender, error);
            }
            else if (DatosRepartidor.existeRepartidorNC(id, numeroCelularWaterMarkTextBox.Text))
            {
                numeroCelularWaterMarkTextBox.BackColor = colorOk;
                errorProvider1.SetError(numeroCelularWaterMarkTextBox, String.Empty);
            }
            else if (DatosRepartidor.existeCelular(numeroCelularWaterMarkTextBox.Text))
            {
                numeroCelularWaterMarkTextBox.BackColor = Color.White;
                error    = "El numero de celular ingresado ya existe";
                e.Cancel = true;
                errorProvider1.SetError((Control)sender, error);
            }
            else
            {
                numeroCelularWaterMarkTextBox.BackColor = colorOk;
                errorProvider1.SetError((Control)sender, String.Empty);
            }
        }
Beispiel #4
0
        private void btnEliminar_Click(object sender, EventArgs e)
        {
            try
            {
                Repartidor r = (Repartidor)repartidorBindingSource.Current;
                if (!DatosRepartidor.enUso(r.Id))
                {
                    r.Activo = false;

                    if (MessageBox.Show("¿Esta seguro de eliminar a " + r.Nombre + "?", "Eliminar", MessageBoxButtons.YesNo) == DialogResult.Yes)
                    {
                        DatosRepartidor.Modificar(r);
                        Actualizar();
                    }
                }
                else
                {
                    MessageBox.Show("El objeto seleccionado no puede ser eliminado");
                }
            }
            catch
            {
                MessageBox.Show("No seleccionó nada");
            }
        }
Beispiel #5
0
 private void Actualizar()
 {
     try
     {
         repartidorBindingSource.DataSource = DatosRepartidor.getRepartidores();
     }
     catch
     {
     }
 }
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                if (!validaciones())
                {
                    return;
                }

                Repartidor r = (Repartidor)repartidorBindingSource.Current;

                r.Localidad = (Localidad)cbLocalidad.SelectedItem;
                r.Zona      = (Zona)cbZona2.SelectedItem;

                if (rbtnM.Checked)
                {
                    r.Sexo = true;
                }
                else if (rbtnF.Checked)
                {
                    r.Sexo = false;
                }

                if (tipoDocumentoDropbox.SelectedIndex == 0)
                {
                    r.TipoDocumento = "DNI";
                }
                else if (tipoDocumentoDropbox.SelectedIndex == 1)
                {
                    r.TipoDocumento = "PASAPORTE";
                }
                else
                {
                    r.TipoDocumento = "OTRO";
                }

                r.Activo          = true;
                r.FechaNacimiento = fechaNacimientoDateTimePicker.Value;
                r.FechaIngreso    = fechaIngresoDateTimePicker.Value;

                if (r.Id == 0)
                {
                    DatosRepartidor.Crear(r);
                }
                else
                {
                    DatosRepartidor.Modificar(r);
                }
                Close();
            }
            catch
            {
                MessageBox.Show("Complete todos los campos");
            }
        }
        private void Actualizar()
        {
            try
            {
                Repartidor r = DatosRepartidor.getRepartido(id);

                //se puede utilizar el metodo de arriba, pero este abajo es mas conveniente. pero el otro es menos codigo.//
                //repartidorBindingSource.Add(DatosRepartidor.getRepartido(id));
                //Repartidor r = (Repartidor)repartidorBindingSource.Current;

                //localidad
                provinciaBindingSource.DataSource = DatosProvincia.getProvinciasPorPais(r.Localidad.Provincia.Pais.Id);

                if (cbProvincia.SelectedValue == null)
                {
                    localidadBindingSource.DataSource = null;
                }
                else
                {
                    localidadBindingSource.DataSource = DatosLocalidad.getLocalidadesPorProvincia(r.Localidad.Provincia.Id);
                }

                //zona
                provinciaBindingSource2.DataSource = DatosProvincia.getProvinciasPorPais(r.Zona.Localidad.Provincia.Pais.Id);
                if (cbProvincia2.SelectedValue == null)
                {
                    localidadBindingSource2.DataSource = null;
                }
                else
                {
                    localidadBindingSource2.DataSource = DatosLocalidad.getLocalidadesPorProvincia(r.Zona.Localidad.Provincia.Id);
                    if (cbLocalidad2.SelectedValue == null)
                    {
                        zonaBindingSource2.DataSource = null;
                    }
                    else
                    {
                        zonaBindingSource2.DataSource = DatosZona.getZonasPorLocalidad(r.Zona.Localidad.Id);
                    }
                }
            }
            catch
            {
            }
        }
        public FrmEditarRepartidor(int id)
        {
            InitializeComponent();
            paisBindingSource.DataSource  = DatosPais.getPaises();
            paisBindingSource2.DataSource = DatosPais.getPaises();

            this.id = id;

            this.fechaNacimientoDateTimePicker.MaxDate = DateTime.Today.AddYears(-16);
            this.fechaIngresoDateTimePicker.MaxDate    = DateTime.Today.AddDays(1);

            if (id == 0)
            {
                Actualizar2();
                repartidorBindingSource.Add(new Repartidor());
            }
            else
            {
                Actualizar();
                fechaNacimiento = true;

                repartidorBindingSource.Add(DatosRepartidor.getRepartido(id));
                Repartidor r = (Repartidor)repartidorBindingSource.Current;

                repartidorBindingSource.Add(r);

                if (r.Sexo)
                {
                    rbtnM.Select();
                }
                else
                {
                    rbtnF.Select();
                }

                if (r.TipoDocumento == "DNI")
                {
                    tipoDocumentoDropbox.Text = "DNI";
                }
                else if (r.TipoDocumento == "PASAPORTE")
                {
                    tipoDocumentoDropbox.Text = "PASAPORTE";
                }
                else
                {
                    tipoDocumentoDropbox.Text = "OTRO";
                }

                //localidad
                cbLocalidad.SelectedItem  = ((Repartidor)repartidorBindingSource.Current).Localidad;
                cbLocalidad.SelectedValue = ((Repartidor)repartidorBindingSource.Current).Localidad.Id;

                cbProvincia.SelectedItem  = ((Localidad)localidadBindingSource.Current).Provincia;
                cbProvincia.SelectedValue = ((Localidad)localidadBindingSource.Current).Provincia.Id;

                cbPais.SelectedItem  = ((Provincia)provinciaBindingSource.Current).Pais;
                cbPais.SelectedValue = ((Provincia)provinciaBindingSource.Current).Pais.Id;

                //zona
                cbZona2.SelectedItem  = ((Repartidor)repartidorBindingSource.Current).Zona;
                cbZona2.SelectedValue = ((Repartidor)repartidorBindingSource.Current).Zona.IdZona;

                cbLocalidad2.SelectedItem  = ((Zona)zonaBindingSource2.Current).Localidad;
                cbLocalidad2.SelectedValue = ((Zona)zonaBindingSource2.Current).Localidad.Id;

                cbProvincia2.SelectedItem  = ((Localidad)localidadBindingSource2.Current).Provincia;
                cbProvincia2.SelectedValue = ((Localidad)localidadBindingSource2.Current).Provincia.Id;

                cbPais2.SelectedItem  = ((Provincia)provinciaBindingSource2.Current).Pais;
                cbPais2.SelectedValue = ((Provincia)provinciaBindingSource2.Current).Pais.Id;

                if (r.Nombre != "")
                {
                    this.Text = "Editar " + r.Nombre;
                }
            }
        }
Beispiel #9
0
 public void cargarVendedores()
 {
     repartidorBindingSource.DataSource = DatosRepartidor.getRepartidores();
 }