Пример #1
0
 private void cargaCbxTipoGasto()
 {
     try
     {
         cbxTipoGasto.DataTextField  = "Descripcion";
         cbxTipoGasto.DataValueField = "IdTipoGasto";
         using (ControladorGastos c_gastos = new ControladorGastos())
         {
             cbxTipoGasto.DataSource = c_gastos.BuscarListTipoGasto();
             cbxTipoGasto.DataBind();
         }
     }
     catch (ExcepcionPropia myex)
     {
         mostrarExcepcion(myex.Message);
     }
 }
Пример #2
0
 protected void btnAceptarConfirmar_Click(object sender, EventArgs e)
 {
     try
     {
         using (ControladorGastos c_gastos = new ControladorGastos())
         {
             c_gastos.AnularGasto(Convert.ToInt32(hfidGastoConfirmacionModal.Value));
         }
         cerrarModal(modalConfirmacion);
         mostrarMensaje("Gasto Anulado Con Exito");
         bindGrillaGasto();
     }
     catch (ExcepcionPropia myex)
     {
         mostrarExcepcion(myex.Message);
         cerrarModal(modalConfirmacion);
     }
 }
Пример #3
0
    protected void dgvGastos_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        validarCajaAbierta();
        int index = Convert.ToInt32(e.CommandArgument);

        if (e.CommandName.Equals("editar"))
        {
            try
            {
                int id = Convert.ToInt32(dgvGastos.DataKeys[index].Value);
                using (ControladorGastos c_gasto = new ControladorGastos())
                {
                    gastoActual = c_gasto.BuscarGasto(id);
                }
                txtFechaModal.Text           = gastoActual.Fecha.ToShortDateString();
                txtMontoModal.Text           = gastoActual.Monto.ToString();
                txtObservaionGastoModal.Text = gastoActual.Descripcion;
                cbxFormaPago.SelectedValue   = gastoActual.ListFormaPago[0].IdtipoFormaPago.ToString();
                cbxTipoGasto.SelectedValue   = gastoActual.TipoGasto.IdTipoGasto.ToString();

                lblTituloModalGasto.Text = "Modificando Gasto";
                lblPanelModalGasto.Text  = "Gasto";
                abrirModal(modalGasto);
                btnAceptarModalGasto.Text = "Modificar";
            }
            catch (ExcepcionPropia myex)
            {
                mostrarExcepcion(myex.Message);
            }
        }
        else if (e.CommandName.Equals("eliminar"))
        {
            try
            {
                hfidGastoConfirmacionModal.Value = dgvGastos.DataKeys[index].Value.ToString();
                abrirModal(modalConfirmacion);
            }
            catch (ExcepcionPropia myex)
            {
                mostrarExcepcion(myex.Message);
            }
        }
    }
Пример #4
0
    private void bindGrillaGasto()
    {
        try
        {
            List <Gasto> listG;
            using (ControladorGastos c_gastos = new ControladorGastos())
            {
                listG = c_gastos.BuscarListGastos(Convert.ToDateTime(txtFechaDesde.Text), Convert.ToDateTime(txtFechaHasta.Text), ApplicationSesion.ActiveSucursal.IdSucursal);
            }
            lblTotalGastos.Text  = string.Empty;
            dgvGastos.DataSource = null;
            dgvGastos.DataSource = listG;
            dgvGastos.DataBind();

            if (listG != null && listG.Count > 0)
            {
                string textoGastoAMostrar = "Totales [ ";
                lblTotalGastos.Text = "";
                var groupBy = listG.GroupBy(lg => new { lg.DescTipoGasto });
                foreach (var grupo in groupBy)
                {
                    string tipoGast = grupo.Key.DescTipoGasto;
                    string total    = listG.Where(g => g.Anulado == false && g.DescTipoGasto == tipoGast).Sum(g => g.Monto).ToString();
                    textoGastoAMostrar = textoGastoAMostrar + tipoGast + ": $" + total + " | ";
                }
                textoGastoAMostrar  = textoGastoAMostrar + "] Total: $" + listG.Sum(gg => gg.Monto);
                lblTotalGastos.Text = textoGastoAMostrar;
            }
        }
        catch (ExcepcionPropia myex)
        {
            mostrarExcepcion(myex.Message);
            dgvGastos.DataSource = null;
            dgvGastos.DataBind();
            lblTotalGastos.Text = "";
        }
    }
Пример #5
0
    protected void btnAceptarModalGasto_Click(object sender, EventArgs e)
    {
        try
        {
            ///Si estoy agregando
            if (gastoActual == null)
            {
                Gasto g = new Gasto();
                g.Fecha = Convert.ToDateTime(txtFechaModal.Text);
                //g.ListFormaPago
                g.Monto       = Convert.ToDecimal(txtMontoModal.Text);
                g.Descripcion = txtObservaionGastoModal.Text;

                g.TipoGasto             = new TipoGasto();
                g.TipoGasto.Descripcion = cbxTipoGasto.SelectedItem.Text;
                g.TipoGasto.IdTipoGasto = Convert.ToInt32(cbxTipoGasto.SelectedValue);

                FormaPago fp = new FormaPago();
                fp.Descripcion     = cbxFormaPago.SelectedItem.Text;
                fp.IdtipoFormaPago = Convert.ToInt32(cbxFormaPago.SelectedValue);
                fp.Monto           = g.Monto;

                g.ListFormaPago = new List <FormaPago>();
                g.ListFormaPago.Add(fp);
                g.Sucursal_ = ApplicationSesion.ActiveSucursal;
                g.IdCaja    = ApplicationSesion.ActiveCaja.Idcaja;
                using (ControladorGastos c_gastos = new ControladorGastos())
                {
                    c_gastos.AgregarGasto(g);
                }
                mostrarMensaje("Gasto Agregado con Exito");
                cerrarModal(modalGasto);
                txtFechaDesde.Text = DateTime.Today.AddDays(-15).ToShortDateString();
                txtFechaHasta.Text = DateTime.Today.ToShortDateString();
                bindGrillaGasto();
            }
            ///Si estoy modificando
            else
            {
                gastoActual.Fecha = Convert.ToDateTime(txtFechaModal.Text);
                //g.ListFormaPago
                gastoActual.Monto       = Convert.ToDecimal(txtMontoModal.Text);
                gastoActual.Descripcion = txtObservaionGastoModal.Text;

                gastoActual.TipoGasto             = new TipoGasto();
                gastoActual.TipoGasto.Descripcion = cbxTipoGasto.SelectedItem.Text;
                gastoActual.TipoGasto.IdTipoGasto = Convert.ToInt32(cbxTipoGasto.SelectedValue);

                FormaPago fp = new FormaPago();
                fp.Descripcion     = cbxFormaPago.SelectedItem.Text;
                fp.IdtipoFormaPago = Convert.ToInt32(cbxFormaPago.SelectedValue);
                fp.Monto           = gastoActual.Monto;

                gastoActual.ListFormaPago = new List <FormaPago>();
                gastoActual.ListFormaPago.Add(fp);
                using (ControladorGastos c_gastos = new ControladorGastos())
                {
                    c_gastos.ModificarGasto(gastoActual);
                }
                mostrarMensaje("Gasto Modificado con Exito");
                cerrarModal(modalGasto);
                txtFechaDesde.Text = DateTime.Today.AddDays(-15).ToShortDateString();
                txtFechaHasta.Text = DateTime.Today.ToShortDateString();
                bindGrillaGasto();
            }
        }
        catch (ExcepcionPropia myex)
        {
            mostrarExcepcion(myex.Message);
            cerrarModal(modalGasto);
        }
    }
Пример #6
0
 public frmControleGastos()
 {
     InitializeComponent();
     controlador = new ControladorGastos();
 }