Example #1
0
        private void Button1_Click(object sender, EventArgs e)
        {
            Cls_N_Reportes.acumulador = 0;
            ArrayList temp = new ArrayList();

            temp.Clear();
            foreach (DataGridViewRow fila in dgBoleta.Rows)
            {
                if (fila.Cells[3].Value.ToString() == dtFecha.Value.ToShortDateString() && fila.Cells[8].Value.ToString() != "0")
                {
                    Cls_N_Reportes objN       = new Cls_N_Reportes();
                    Cls_E_Boleta   objEBoleta = new Cls_E_Boleta();
                    objEBoleta.Serie    = fila.Cells[0].Value.ToString();
                    objEBoleta.Numero   = fila.Cells[1].Value.ToString();
                    objEBoleta.Empleado = fila.Cells[2].Value.ToString();
                    objEBoleta.Fecha    = Convert.ToDateTime(fila.Cells[3].Value.ToString());
                    objEBoleta.Cliente  = fila.Cells[4].Value.ToString();
                    objEBoleta.Subtotal = double.Parse(fila.Cells[5].Value.ToString());
                    objEBoleta.Igv      = double.Parse(fila.Cells[6].Value.ToString());
                    objEBoleta.Total    = double.Parse(fila.Cells[7].Value.ToString());
                    objEBoleta.Estado   = fila.Cells[8].Value.ToString();
                    temp.Add(objEBoleta);
                    if (objEBoleta.Estado != "0")
                    {
                        Cls_N_Reportes.acumulador = Cls_N_Reportes.acumulador + float.Parse(fila.Cells[7].Value.ToString());
                    }
                }
            }
            dgConsultaBoleta.DataSource = null;
            dgConsultaBoleta.DataSource = temp;
            txtTotal.Text = Cls_N_Reportes.acumulador.ToString();
            mtdPintarCeldas();
        }
Example #2
0
        private void BtnVerRangoFecha_Click(object sender, EventArgs e)
        {
            Cls_N_Reportes.acumulador = 0;
            ArrayList temp        = new ArrayList();
            DateTime  fechainicio = Convert.ToDateTime(dtFechainicio.Value.ToShortDateString());
            DateTime  fechafin    = Convert.ToDateTime(dtFechaFin.Value.ToShortDateString());
            DateTime  fecha;

            foreach (DataGridViewRow fila in dgBoleta.Rows)
            {
                fecha = Convert.ToDateTime(fila.Cells[3].Value);
                if (fecha >= fechainicio && fecha <= fechafin && fila.Cells[8].Value.ToString() != "0")
                {
                    Cls_E_Boleta   objE       = new Cls_E_Boleta();
                    Cls_N_Reportes objN       = new Cls_N_Reportes();
                    Cls_E_Boleta   objEBoleta = new Cls_E_Boleta();
                    objEBoleta.Serie    = fila.Cells[0].Value.ToString();
                    objEBoleta.Numero   = fila.Cells[1].Value.ToString();
                    objEBoleta.Empleado = fila.Cells[2].Value.ToString();
                    objEBoleta.Fecha    = Convert.ToDateTime(fila.Cells[3].Value.ToString());
                    objEBoleta.Cliente  = fila.Cells[4].Value.ToString();
                    objEBoleta.Subtotal = double.Parse(fila.Cells[5].Value.ToString());
                    objEBoleta.Igv      = double.Parse(fila.Cells[6].Value.ToString());
                    objEBoleta.Total    = double.Parse(fila.Cells[7].Value.ToString());
                    objEBoleta.Estado   = fila.Cells[8].Value.ToString();
                    temp.Add(objEBoleta);
                    Cls_N_Reportes.acumulador = Cls_N_Reportes.acumulador + float.Parse(fila.Cells[7].Value.ToString());
                }
            }
            dgConsultaBoleta.DataSource = null;
            dgConsultaBoleta.DataSource = temp;
            txtTotal.Text = Cls_N_Reportes.acumulador.ToString();
        }
Example #3
0
        public Boolean MtdAgregarABoleta(Cls_E_Boleta objEBoleta)
        {
            try
            {
                ClsConexionSQL objConexion = new ClsConexionSQL();
                SqlCommand     objComando  = new SqlCommand();
                objComando.Connection  = objConexion.conectar();
                objComando.CommandText = "USP_I_AgregarCompra";
                objComando.CommandType = CommandType.StoredProcedure;
                objComando.Parameters.Add(new SqlParameter("ser", SqlDbType.VarChar));
                objComando.Parameters.Add(new SqlParameter("num", SqlDbType.VarChar));
                objComando.Parameters.Add(new SqlParameter("dnie", SqlDbType.VarChar));
                objComando.Parameters.Add(new SqlParameter("fecha", SqlDbType.Date));
                objComando.Parameters.Add(new SqlParameter("dnic", SqlDbType.VarChar));
                objComando.Parameters.Add(new SqlParameter("sub", SqlDbType.Decimal));
                objComando.Parameters.Add(new SqlParameter("igv", SqlDbType.Decimal));
                objComando.Parameters.Add(new SqlParameter("total", SqlDbType.Decimal));
                objComando.Parameters.Add(new SqlParameter("estado", SqlDbType.VarChar));
                objComando.Parameters.Add(new SqlParameter("tipopago", SqlDbType.VarChar));
                objComando.Parameters["ser"].Value      = objEBoleta.Serie;
                objComando.Parameters["num"].Value      = objEBoleta.Numero;
                objComando.Parameters["dnie"].Value     = objEBoleta.Empleado;
                objComando.Parameters["fecha"].Value    = objEBoleta.Fecha;
                objComando.Parameters["dnic"].Value     = objEBoleta.Cliente;
                objComando.Parameters["sub"].Value      = objEBoleta.Total;
                objComando.Parameters["igv"].Value      = objEBoleta.Total;
                objComando.Parameters["total"].Value    = objEBoleta.Total;
                objComando.Parameters["estado"].Value   = objEBoleta.Estado;
                objComando.Parameters["tipopago"].Value = objEBoleta.Empleado;
                objComando.Connection = objConexion.conectar();
                objComando.ExecuteNonQuery();
                return(true);
            }
            catch (Exception ex)
            {
                return(false);

                throw ex;
            }
        }
Example #4
0
        private void PicGuardar_Click(object sender, EventArgs e)
        {
            if (dgvCompra.Rows.Count == 0 || cbTipoPago.SelectedIndex == -1)
            {
                MessageBox.Show("INGRESE PRODUCTOS/seleccione metodo de pago");
                return;
            }
            else
            {
                if (MessageBox.Show("¿Registrar Venta?", "Alerta", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation) == DialogResult.Yes)
                {
                    bool                comprobar2        = false;
                    Cls_E_Boleta        objEBoleta        = new Cls_E_Boleta();
                    Cls_E_DetalleBoleta objEDetalleBoelta = new Cls_E_DetalleBoleta();
                    Cls_N_Compras       objN = new Cls_N_Compras();
                    objEBoleta.Serie    = lblSerie.Text;
                    objEBoleta.Numero   = lblNumeroBoleta.Text;
                    objEBoleta.Estado   = "1";
                    objEBoleta.Cliente  = lblProveedor.Text;
                    objEBoleta.Empleado = lblDNIEMP.Text;
                    objEBoleta.Fecha    = Convert.ToDateTime(DateTime.Now.ToShortDateString());
                    objEBoleta.Subtotal = double.Parse(txtSubTotal.Text);
                    objEBoleta.Igv      = double.Parse(txtIgv.Text);
                    objEBoleta.Total    = double.Parse(txtTotal.Text);
                    objEBoleta.Tipopago = cbTipoPago.SelectedItem.ToString();
                    bool comprobar = objN.MtdAgregarABoleta(objEBoleta);
                    foreach (DataGridViewRow fila in dgvCompra.Rows)
                    {
                        objEDetalleBoelta.Serie           = lblSerie.Text;
                        objEDetalleBoelta.Numero          = lblNumeroBoleta.Text;
                        objEDetalleBoelta.Codigo          = int.Parse(fila.Cells[0].Value.ToString());
                        objEDetalleBoelta.Cantidad        = int.Parse(fila.Cells[1].Value.ToString());
                        objEDetalleBoelta.Importe         = double.Parse(fila.Cells[2].Value.ToString());
                        objEDetalleBoelta.Precio_unitario = double.Parse(fila.Cells[3].Value.ToString());
                        comprobar2 = objN.MtdAgregarDetalleBoleta(objEDetalleBoelta);
                    }

                    if (comprobar == true && comprobar2 == true)
                    {
                        int cantidad = 0;
                        foreach (DataGridViewRow fila in dgvCompra.Rows)
                        {
                            Cls_E_Producto objE = new Cls_E_Producto();
                            objE.Idproducto = int.Parse(fila.Cells[0].Value.ToString());
                            foreach (DataRow filas in productos.Rows)
                            {
                                if (filas[0].ToString() == fila.Cells[0].Value.ToString())
                                {
                                    cantidad = int.Parse(filas[4].ToString());
                                    break;
                                }
                            }
                            objE.Cantidad = cantidad + int.Parse(fila.Cells[1].Value.ToString());
                            objN.MtdIncrementarProductos(objE);
                        }
                        MessageBox.Show("Compra Registrada");
                        cbProveedor.Enabled = true;

                        boleta.Rows.Clear();
                        boleta = objN.MtdListarBoletas();
                        int numeroboletas = boleta.Rows.Count;
                        lblNumeroBoleta.Text = objN.MtdCalcularNumeroBoleta(numeroboletas);
                        dgvCompra.Rows.Clear();
                        cbProductos.SelectedIndex = -1;
                        cbProveedor.SelectedIndex = -1;

                        txtCantidadProducto.Clear();
                        txtPrecioUnitario.Clear();
                        lblProducto.Text  = "";
                        lblProveedor.Text = "";
                        txtIgv.Clear();
                        txtSubTotal.Clear();
                        txtTotal.Clear();
                        txtMonedaEnLEtras.Clear();
                    }
                    else
                    {
                        MessageBox.Show("Ingrese datos validos");
                    }
                }
            }
        }