Example #1
0
 // Metodo BuscarFechas
 private void BuscarIngresoFechas()
 {
     this.dataListado.DataSource = IngresoBL.IngresoBuscarFecha(this.dtFecha1.Value.ToString("dd/MM/yyyy"),
                                                                this.dtFecha2.Value.ToString("dd/MM/yyyy"));
     this.OcultarColumnas();
     lblTotal.Text = "Total De Registros: " + Convert.ToString(dataListado.Rows.Count);
 }
        private void btnEliminarIngreso_Click(object sender, EventArgs e)
        {
            int          idIngresoAEliminar = int.Parse(dgvListadoIngresos.SelectedRows[0].Cells[0].Value.ToString());
            DialogResult resultadoDialgo    = MetroMessageBox.Show(this, "¿Desea eliminar esta compra?", "¡Aviso!",
                                                                   MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2);

            if (resultadoDialgo == DialogResult.Yes)
            {
                List <DetalleIngreso> listadoDetalles = DetalleIngresoBL.ObtenerTodos(idIngresoAEliminar);
                if (listadoDetalles.Count >= 1)
                {
                    DialogResult resultado = MetroMessageBox.Show(this, "Se eliminarán la compra y todos sus detalles.", "¡Advertencia!",
                                                                  MessageBoxButtons.OKCancel, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button2);
                    if (resultado == DialogResult.OK)
                    {
                        foreach (var item in listadoDetalles)
                        {
                            DetalleIngresoBL.Eliminar(item.Id);
                        }
                        IngresoBL.Eliminar(idIngresoAEliminar);
                    }
                }
                else
                {
                    IngresoBL.Eliminar(idIngresoAEliminar);
                }
                CargarIngresos();
            }
        }
Example #3
0
        private int GenerarID()
        {
            DataTable dt = new DataTable();

            dt = IngresoBL.GenerarIdingreso();
            return(Convert.ToInt32(dt.Rows[0][0].ToString()));
        }
Example #4
0
 void CargarDatosAlFormulario()
 {
     ingresoEditando       = IngresoBL.BuscarPorId((int)idIngreso);
     txtNumeroCCF.Text     = ingresoEditando.NumeroCCF;
     dtpFechaIngreso.Value = ingresoEditando.FechaIngreso;
     lblUsuario.Text       = ingresoEditando.Usuario;
     marca = MarcaBL.BuscarPorId(ingresoEditando.IdMarca);
     lblNombreMarca.Text         = marca.Nombre;
     lblComentarioMarca.Text     = marca.Comentario;
     listadoViejoDetallesIngreso = DetalleIngresoBL.ObtenerTodos(ingresoEditando.Id);
     if (listadoViejoDetallesIngreso != null)
     {
         for (int i = 0; i < listadoViejoDetallesIngreso.Count; i++)
         {
             dgvListadoDetallesIngreso.Rows.Add();
             dgvListadoDetallesIngreso.Rows[i].Cells[0].Value = listadoViejoDetallesIngreso[i].Id;
             dgvListadoDetallesIngreso.Rows[i].Cells[1].Value = listadoViejoDetallesIngreso[i].Cantidad;
             dgvListadoDetallesIngreso.Rows[i].Cells[2].Value = listadoViejoDetallesIngreso[i].Producto;
             dgvListadoDetallesIngreso.Rows[i].Cells[3].Value = listadoViejoDetallesIngreso[i].Descripcion;
             dgvListadoDetallesIngreso.Rows[i].Cells[4].Value = listadoViejoDetallesIngreso[i].PrecioUnitario;
             dgvListadoDetallesIngreso.Rows[i].Cells[5].Value = listadoViejoDetallesIngreso[i].SubTotal;
             listadoDetallesIngreso.Add(listadoViejoDetallesIngreso[i]);
         }
         CalcularTotales();
     }
 }
Example #5
0
        private void FrmVerDetalleIngreso_Load(object sender, EventArgs e)
        {
            Ingreso ingreso = IngresoBL.BuscarPorId(idIngreso);

            lblNumeroCCF.Text    = ingreso.NumeroCCF;
            lblFechaIngreso.Text = ingreso.FechaIngreso.ToString("d");
            lblMarca.Text        = ingreso.Marca;
            List <DetalleIngreso> listadoDetalleIngreso = DetalleIngresoBL.ObtenerTodos(idIngreso);

            if (listadoDetalleIngreso.Count > 0)
            {
                double Sumas = 0;
                for (int i = 0; i < listadoDetalleIngreso.Count; i++)
                {
                    dgvListadoDetallesIngreso.Rows.Add();
                    dgvListadoDetallesIngreso.Rows[i].Cells[0].Value = listadoDetalleIngreso[i].Id;
                    dgvListadoDetallesIngreso.Rows[i].Cells[1].Value = listadoDetalleIngreso[i].Cantidad;
                    dgvListadoDetallesIngreso.Rows[i].Cells[2].Value = listadoDetalleIngreso[i].Producto;
                    dgvListadoDetallesIngreso.Rows[i].Cells[3].Value = listadoDetalleIngreso[i].Descripcion;
                    dgvListadoDetallesIngreso.Rows[i].Cells[4].Value = listadoDetalleIngreso[i].PrecioUnitario.ToString("c");
                    dgvListadoDetallesIngreso.Rows[i].Cells[5].Value = listadoDetalleIngreso[i].SubTotal.ToString("c");
                    Sumas += listadoDetalleIngreso[i].SubTotal;
                }
                lblSumas.Text = Sumas.ToString("c");
                lblIva.Text   = (Sumas * 0.13).ToString("c");
                lblTotal.Text = (Sumas * 1.13).ToString("c");
            }

            lblUsuario.Text = ingreso.Usuario;
        }
 public void CargarIngresos(string pCondicion = "%")
 {
     dgvListadoIngresos.Rows.Clear();
     listadoIngresos = IngresoBL.ObtenerTodos(pCondicion);
     for (int i = 0; i < listadoIngresos.Count; i++)
     {
         dgvListadoIngresos.Rows.Add();
         dgvListadoIngresos.Rows[i].Cells[0].Value = listadoIngresos[i].Id;
         dgvListadoIngresos.Rows[i].Cells[1].Value = listadoIngresos[i].NumeroCCF;
         dgvListadoIngresos.Rows[i].Cells[2].Value = listadoIngresos[i].Marca;
         dgvListadoIngresos.Rows[i].Cells[3].Value = listadoIngresos[i].FechaIngreso.ToString("d");
         dgvListadoIngresos.Rows[i].Cells[4].Value = listadoIngresos[i].Sumas.ToString("N");
         dgvListadoIngresos.Rows[i].Cells[5].Value = listadoIngresos[i].Iva.ToString("N");
         dgvListadoIngresos.Rows[i].Cells[6].Value = listadoIngresos[i].Total.ToString("N");
         dgvListadoIngresos.Rows[i].Cells[7].Value = listadoIngresos[i].Usuario;
     }
 }
Example #7
0
        private void btnGuardar_Click(object sender, EventArgs e)
        {
            try
            {
                string rpta = "";
                if (this.txtIdproveedor.Text == string.Empty || this.txtIgv.Text == string.Empty)
                {
                    MensajeError("Falta ingresar algunos datos, serán remarcados");
                    errorIcono.SetError(txtIdproveedor, "Ingrese un Valor");
                    errorIcono.SetError(txtIgv, "Ingrese un Valor");
                }
                else
                {
                    if (this.IsNuevo)
                    {
                        rpta = IngresoBL.Insertar(Convert.ToInt32(this.txtIdingreso.Text), Convert.ToInt32(this.txtIdarticulo.Text), Convert.ToInt32(this.txtIdproveedor.Text),
                                                  this.dtFecha.Value, this.cbTipo_Pago.Text, this.txtNum_comprobante.Text, Convert.ToDecimal(this.txtIgv.Text), Idtrabajador, dtDetalle);
                    }

                    if (rpta.Equals("OK"))
                    {
                        if (this.IsNuevo)
                        {
                            this.MensajeOk("Se Insertó de forma correcta el registro");
                            totalPagado = 0;
                        }
                    }
                    else
                    {
                        this.MensajeError(rpta);
                    }

                    this.IsNuevo = false;
                    this.Botones();
                    this.Limpiar();
                    this.LimpiarDetalle();
                    this.Mostrar();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message + ex.StackTrace);
            }
        }
Example #8
0
        private void btnAnular_Click(object sender, EventArgs e)
        {
            try
            {
                DialogResult Opcion;
                Opcion = MessageBox.Show("Realmente Desea Anular los Registros", "Sistema de Ventas", MessageBoxButtons.OKCancel, MessageBoxIcon.Question);

                if (Opcion == DialogResult.OK)
                {
                    string Codigo;
                    string Rpta = "";

                    foreach (DataGridViewRow row in dataListado.Rows)
                    {
                        if (Convert.ToBoolean(row.Cells[0].Value))
                        {
                            Codigo = Convert.ToString(row.Cells[1].Value);
                            Rpta   = IngresoBL.Anular(Convert.ToInt32(Codigo));
                        }
                        //Se evalua si se anuló el registro
                        if (Rpta.Equals("OK"))
                        {
                            this.MensajeOk("Se Anuló Correctamente el registro");
                        }
                        else
                        {
                            this.MensajeError(Rpta);
                        }
                    }
                    //this.Mostrar();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message + ex.StackTrace);
            }
        }
Example #9
0
 //metodo mostrar los detalles
 private void MostrarDetalle()
 {
     this.dataListadoDetalle.DataSource = IngresoBL.MostrarDetalle(this.txtIdingreso.Text);
 }
Example #10
0
 //Metodo Mostrar
 private void Mostrar()
 {
     this.dataListado.DataSource = IngresoBL.Mostrar();
     this.OcultarColumnas();
     lblTotal.Text = "Total De Registros: " + Convert.ToString(dataListado.Rows.Count);
 }
Example #11
0
 // Metodo Buscar
 private void Buscar_Articulo_Nombre()
 {
     this.dataListado.DataSource = IngresoBL.Buscar_Articulo_Ingreso_Nombre(txtBuscar.Text);
     this.OcultarColumnas();
     lblTotal.Text = "Total De Registros: " + Convert.ToString(dataListado.Rows.Count);
 }
Example #12
0
 // Metodo BuscarNumero_Documento
 private void BuscarNum_Documento()
 {
     this.dataListado.DataSource = IngresoBL.Buscar_Proveedor_Ingreso_RNC(this.txtBuscar.Text);
     this.OcultarColumnas();
     lblTotal.Text = "Total De Registros: " + Convert.ToString(dataListado.Rows.Count);
 }
Example #13
0
 // Metodo BuscarRazon_Social
 private void BuscarRazon_Social()
 {
     this.dataListado.DataSource = IngresoBL.Buscar_Proveedor_Ingreso_Nombre(this.txtBuscar.Text);
     this.OcultarColumnas();
     lblTotal.Text = "Total De Registros: " + Convert.ToString(dataListado.Rows.Count);
 }
Example #14
0
        void GuardarCompra()
        {
            Cursor = Cursors.WaitCursor;
            //  try
            //{
            if (dgvListadoDetallesIngreso.Rows.Count < 1)
            {
                epValidadorControles.SetError(dgvListadoDetallesIngreso, "Debe agregar al menos un detalle.");
            }
            else
            {
                if (idIngreso == null)
                {
                    int     resultIngreso        = 0;
                    int     resultDetalleIngreso = 0;
                    Ingreso ingresoARegistrar    = new Ingreso();
                    ingresoARegistrar.IdUsuario    = FrmPrincipal.usuarioActual.Id;
                    ingresoARegistrar.IdMarca      = marca.Id;
                    ingresoARegistrar.FechaIngreso = dtpFechaIngreso.Value;
                    ingresoARegistrar.NumeroCCF    = txtNumeroCCF.Text.Trim();
                    resultIngreso += IngresoBL.Guardar(ingresoARegistrar);
                    for (int i = 0; i < listadoDetallesIngreso.Count; i++)
                    {
                        DetalleIngreso detalleIngresoARegistrar = new DetalleIngreso();
                        detalleIngresoARegistrar.IdIngreso      = IngresoBL.BuscarPorNumeroCCF(marca.Id, dtpFechaIngreso.Value, txtNumeroCCF.Text).Id;
                        detalleIngresoARegistrar.IdProducto     = listadoDetallesIngreso[i].IdProducto;
                        detalleIngresoARegistrar.Cantidad       = listadoDetallesIngreso[i].Cantidad;
                        detalleIngresoARegistrar.PrecioUnitario = listadoDetallesIngreso[i].PrecioUnitario;
                        resultDetalleIngreso += DetalleIngresoBL.Guardar(detalleIngresoARegistrar);
                    }
                    MetroMessageBox.Show(this, $"{resultIngreso} ingreso registrado.\n{resultDetalleIngreso} detalle(s) registrado(s).",
                                         "Registro de ingresos", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    Limpiar();
                }
                else
                {
                    int resultIngreso             = 0;
                    int resultDetallesModificados = 0;
                    int resultDetallesAñadidos    = 0;
                    int resultadoEliminados       = 0;
                    ingresoEditando.IdUsuario    = FrmPrincipal.usuarioActual.Id;
                    ingresoEditando.IdMarca      = marca.Id;
                    ingresoEditando.FechaIngreso = dtpFechaIngreso.Value;
                    ingresoEditando.NumeroCCF    = txtNumeroCCF.Text.Trim();
                    resultIngreso += IngresoBL.Modificar(ingresoEditando);
                    for (int i = 0; i < listadoDetallesIngreso.Count; i++)
                    {
                        DetalleIngreso detalleIngresoARegistrar = new DetalleIngreso();
                        detalleIngresoARegistrar.IdProducto     = listadoDetallesIngreso[i].IdProducto;
                        detalleIngresoARegistrar.Cantidad       = listadoDetallesIngreso[i].Cantidad;
                        detalleIngresoARegistrar.PrecioUnitario = listadoDetallesIngreso[i].PrecioUnitario;
                        if (listadoViejoDetallesIngreso.Find(x => x.Id == listadoViejoDetallesIngreso[i].Id) != null)
                        {
                            resultDetallesModificados += DetalleIngresoBL.Modificar(detalleIngresoARegistrar);
                        }
                        else
                        {
                            resultDetallesAñadidos += DetalleIngresoBL.Guardar(detalleIngresoARegistrar);
                        }
                    }
                    if (detallesViejosAEliminarDeLaBD.Count >= 1)
                    {
                        for (int i = 0; i < detallesViejosAEliminarDeLaBD.Count; i++)
                        {
                            resultadoEliminados += DetalleIngresoBL.Eliminar(detallesViejosAEliminarDeLaBD[i]);
                        }
                    }
                    objetoIngresosActual.CargarIngresos();
                    DialogResult resultadoDelDialgo = MetroMessageBox.Show
                                                          (this, $"{resultIngreso} ingreso actualizado.\n{resultDetallesModificados} detalle(s) actualizado(s).\n" +
                                                          $"{resultDetallesAñadidos} detalle(s) registrado(s).\n{resultadoEliminados} detalle(s) eliminado(s).\n¿Desea cerrar el editor?",
                                                          "Actualización de ingresos", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1);
                    if (resultadoDelDialgo == DialogResult.Yes)
                    {
                        Close();
                    }
                }
            }

            /*   }
             *  catch (Exception error)
             *  {
             *      MetroMessageBox.Show(this, $"¡Ha ocurrido un error!\nMÁS INFORMACIÓN: {error.Message}", "Error", MessageBoxButtons.OK,
             *          MessageBoxIcon.Error);
             *      Close();
             *  }*/
            Cursor = Cursors.Arrow;
        }