Exemple #1
0
        private void BuscarProveedores(string tipo_busqueda, string texto_busqueda)
        {
            try
            {
                DataTable tableProveedores =
                    NProveedores.BuscarProveedores(tipo_busqueda, texto_busqueda, out string rpta);
                if (tableProveedores != null)
                {
                    this.dgvProveedores.Enabled  = true;
                    this.dgvProveedores.PageSize = 30;
                    this.dgvProveedores.SetPagedDataSource(tableProveedores, this.bindingNavigator1);

                    string[] columns_header =
                    {
                        "Id proveedor", "Fecha ingreso", "Nombre", "Teléfono", "Correo electrónico"
                    };

                    bool[] columns_visible =
                    {
                        false, false, true, true, true
                    };

                    this.dgvProveedores =
                        DatagridString.ChangeHeaderTextAndVisibleCustomDataGrid(this.dgvProveedores,
                                                                                columns_header, columns_visible);
                    this.lblResultados.Text = "Se encontraron " + tableProveedores.Rows.Count + " proveedores";
                }
                else
                {
                    if (!rpta.Equals("OK"))
                    {
                        throw new Exception(rpta);
                    }

                    this.dgvProveedores.clearDataSource();
                    this.dgvProveedores.Enabled = false;
                    this.lblResultados.Text     = "No se encontraron proveedores";
                }
            }
            catch (Exception ex)
            {
                Mensajes.MensajeErrorCompleto(this.Name, "BuscarProveedores",
                                              "Hubo un error al buscar un proveedor", ex.Message);
            }
        }
Exemple #2
0
        private async void BtnGuardar_Click(object sender, EventArgs e)
        {
            try
            {
                if (this.Comprobaciones(out Proveedores proveedor))
                {
                    if (this.IsEditar)
                    {
                        string rpta =
                            await NProveedores.EditarProveedor(proveedor.Id_proveedor, proveedor);

                        if (rpta.Equals("OK"))
                        {
                            Mensajes.MensajeInformacion("Se editó correctamente el proveedor", "Entendido");
                            this.Close();
                        }
                        else
                        {
                            throw new Exception(rpta);
                        }
                    }
                    else
                    {
                        var(rpta, id_proveedor) =
                            await NProveedores.InsertarProveedor(proveedor);

                        if (rpta.Equals("OK"))
                        {
                            proveedor.Id_proveedor = id_proveedor;
                            Mensajes.MensajeInformacion("Se ingresó correctamente el proveedor", "Entendido");
                            this.Close();
                        }
                        else
                        {
                            throw new Exception(rpta);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Mensajes.MensajeErrorCompleto(this.Name, "BtnGuardar_Click(object sender, EventArgs e)",
                                              "Hubo un error al guardar la información del proveedor", ex.Message);
            }
        }
        //------------------------------------------------Métodos-------------------------------------------------

        //Método CargarBancos - Inserta la tabla de bancos en los combobox.
        private void CargarBancos()
        {
            //Carga los bancos en los combobox.
            this.cbxBanco1.DataSource    = NProveedores.CargarBancos();
            this.cbxBanco1.ValueMember   = "ID_BANCO";
            this.cbxBanco1.DisplayMember = "NOMBRE";

            this.cbxBanco2.DataSource    = NProveedores.CargarBancos();
            this.cbxBanco2.ValueMember   = "ID_BANCO";
            this.cbxBanco2.DisplayMember = "NOMBRE";

            this.cbxBanco3.DataSource    = NProveedores.CargarBancos();
            this.cbxBanco3.ValueMember   = "ID_BANCO";
            this.cbxBanco3.DisplayMember = "NOMBRE";

            this.cbxBanco4.DataSource    = NProveedores.CargarBancos();
            this.cbxBanco4.ValueMember   = "ID_BANCO";
            this.cbxBanco4.DisplayMember = "NOMBRE";
        }
Exemple #4
0
        //btnEliminar - Evento Click - Elimina el usuario selecionado en el dgvProveedores.
        private void btnEliminar_Click(object sender, EventArgs e)
        {
            //Verificacion de fila seleccionada.
            if (this.dgvProveedores.Rows.Count > 0)
            {
                //Mensaje de confirmación.
                DialogResult MensajeConfirmacion = MessageBox.Show(String.Format("¿Seguro deseas eliminar el proveedor {0}?",
                                                                                 Convert.ToString(ObtenerFila().Cells["RAZÓN SOCIAL"].Value)), String.Format(Configuracion.Titulo,
                                                                                                                                                             "Eliminar Proveedor"), MessageBoxButtons.YesNo, MessageBoxIcon.Information);

                if (MensajeConfirmacion == DialogResult.Yes)
                {
                    String Respuesta = NProveedores.Eliminar(Convert.ToInt32(ObtenerFila().Cells["CÓDIGO"].Value));
                    if (Respuesta == "OK")
                    {
                        //Establece mensaje de eliminación el el "lblMensajes".
                        Mensaje(String.Format("El proveedor {0} ha sido ELIMINADO",
                                              Convert.ToString(ObtenerFila().Cells["RAZÓN SOCIAL"].Value)));

                        //Muestra mensaje de eliminación al usuario mediante un MessageBox
                        MessageBox.Show(String.Format("El proveedor {0} ha sido ELIMINADO",
                                                      Convert.ToString(ObtenerFila().Cells["RAZÓN SOCIAL"].Value)),
                                        String.Format(Configuracion.Titulo, "Proveedor Eliminado"),
                                        MessageBoxButtons.OK, MessageBoxIcon.Information);
                        Refrescar();
                    }
                    else
                    {
                        //Si ocurre un error muestra mensaje al usuario con la respuesta recibida.
                        MessageBox.Show(Respuesta, String.Format(Configuracion.Titulo, "Error"),
                                        MessageBoxButtons.OK, MessageBoxIcon.Error);
                        Refrescar();
                    }
                }
            }
            else
            {
                MessageBox.Show("Debes seleccionar una fila para eliminar.", String.Format(Configuracion.Titulo, "Error"),
                                MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
        }
Exemple #5
0
 //txtBuscar - Evento TextChanged - Muestra los datos que coincidan con la búsqueda en el "dgvProveedores".
 private void txtBuscar_TextChanged(object sender, EventArgs e)
 {
     if (this.txtBuscar.Text == String.Empty || this.cbxTipoBusqueda.Text == "")
     {
         Configuracion.NumeroPagina = 1;
         this.Mostrar();
         this.panelPaginacion.Show();
     }
     else
     {
         try
         {
             this.dgvProveedores.DataSource = NProveedores.Buscar(this.txtBuscar.Text, this.cbxTipoBusqueda.Text);
         }
         catch (Exception ex)
         {
             MessageBox.Show(ex.Message, String.Format(Configuracion.Titulo, "Error"),
                             MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
         this.panelPaginacion.Hide();
     }
 }
        private async Task BuscarProveedores(string tipo_busqueda, string texto_busqueda)
        {
            try
            {
                var(dtProveedores, rpta) =
                    await NProveedores.BuscarProveedores(tipo_busqueda, texto_busqueda);

                this.panelProveedores.clearDataSource();

                if (dtProveedores != null)
                {
                    List <UserControl> controls = new List <UserControl>();
                    foreach (DataRow row in dtProveedores.Rows)
                    {
                        Proveedores    proveedor      = new Proveedores(row);
                        ProveedorSmall proveedorSmall = new ProveedorSmall
                        {
                            Proveedor = proveedor,
                        };
                        proveedorSmall.OnBtnNext += ProveedorSmall_OnBtnNext;
                        controls.Add(proveedorSmall);
                    }

                    this.panelProveedores.AddArrayControl(controls);
                }
                else
                {
                    if (!rpta.Equals("OK"))
                    {
                        throw new Exception(rpta);
                    }
                }
            }
            catch (Exception ex)
            {
                Mensajes.MensajeErrorCompleto(this.Name, "BuscarProveedores(string tipo_busqueda, string texto_busqueda)",
                                              "Hubo un error al buscar los proveedores", ex.Message);
            }
        }
Exemple #7
0
        private void BtnGuardar_Click(object sender, EventArgs e)
        {
            try
            {
                string rpta = "";
                if (this.Comprobaciones())
                {
                    string mensaje = "";
                    int    id_proveedor;
                    if (this.IsEditar)
                    {
                        rpta    = NProveedores.EditarProveedores(this.Variables(), this.Id_proveedor);
                        mensaje = "Se actualizó correctamente el proveedor";
                    }
                    else
                    {
                        rpta    = NProveedores.InsertarProveedores(this.Variables(), out id_proveedor);
                        mensaje = "Se agregó correctamente el proveedor";
                    }

                    if (rpta.Equals("OK"))
                    {
                        Mensajes.MensajeOkForm(mensaje);
                        this.Limpiar();
                    }
                    else
                    {
                        throw new Exception(rpta);
                    }
                }
            }
            catch (Exception ex)
            {
                Mensajes.MensajeErrorCompleto(this.Name, "BtnGuardar_Click",
                                              "Hubo un error al guardar un proveedor", ex.Message);
            }
        }
Exemple #8
0
 //Método Mostrar - Muestra los registros actuales en el "dgvProveedores" y establece la cantidad de páginas.
 public void Mostrar()
 {
     this.dgvProveedores.DataSource = NProveedores.Mostrar(Configuracion.RegistrosPorPagina, Configuracion.NumeroPagina);
     Configuracion.CantidadPaginas  = NProveedores.Tamaño(Configuracion.RegistrosPorPagina);
     this.lblPaginacion.Text        = String.Format("Página {0} de {1}.", Configuracion.NumeroPagina, Configuracion.CantidadPaginas);
 }