protected void cmbConcepto_SelectedIndexChanged(object sender, EventArgs e)
 {
     Concepto Concepto = new Concepto();
     Concepto = ConceptoDAO.Get(Convert.ToInt32(cmbConcepto.SelectedValue));
     TiposConceptos = Concepto.Rellenar().Tipos;
     cmbTipoConcepto.DataSource = TiposConceptos;
     cmbTipoConcepto.DataBind();
 }
Beispiel #2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            Usuario = Utilerias.FiltrarUsuario(this);
            Periodo = Usuario.ConsultarPeriodoActual();

            string claveProgramaDetalle = Request.QueryString["idPD"];

            string clave = Request.QueryString["id"];

            claveProg = clave;
            string necId = Request.QueryString["idNec"];

            claveNec = necId;
            string tipo  = Request.QueryString["tipo"];
            string Filas = "";

            if (!IsPostBack)
            {
                try
                {
                    detallesNecesidad = NecesidadDetalleDAO.Listar().Where(w => w.ClaveNecesidad == Convert.ToInt32(necId)).ToList();

                    if (clave != null && tipo == "eliminar")
                    {
                        int resultado = ProgramaDetalleDAO.Eliminar(Convert.ToInt32(claveProgramaDetalle));
                        if (resultado == 0)
                        {
                            Mensaje Mensaje = new Mensaje()
                            {
                                Titulo    = "Algo salió mal",
                                Contenido = "El programa no pudo eliminarse. Para más información consulte al administrador del sistema",
                                Tipo      = TipoMensaje.ALERTA
                            };
                            litPrueba.Text = Disenio.GenerarMensaje(Mensaje);
                            return;
                        }

                        Response.Redirect(ResolveUrl("~/App/Area/CrearProgramaDetalle.aspx?id=" + clave + "&idNec=" + necId));
                    }
                    else if (clave != null)
                    {
                        foreach (NecesidadDetalle det in detallesNecesidad)
                        {
                            det.Rellenar();

                            if (det.TipoConcepto == null)
                            {
                                Filas += Disenio.GenerarFilaTabla(det.Volumen.ToString(),
                                                                  det.PrecioUnitario.ToString(),
                                                                  Utilerias.ToCurrency(det.CalcularImporte()),
                                                                  det.Concepto.ToString(),
                                                                  "");
                                conceptosDisponibles.Add(det.Concepto);
                            }
                            else
                            {
                                Filas += Disenio.GenerarFilaTabla(det.Volumen.ToString(),
                                                                  det.PrecioUnitario.ToString(),
                                                                  Utilerias.ToCurrency(det.CalcularImporte()),
                                                                  det.Concepto.ToString(),
                                                                  det.TipoConcepto.ToString());
                                tipoConceptoDisponible.Add(det.TipoConcepto);
                            }
                        }

                        litTBody.Text = Filas;



                        Conceptos = ConceptoDAO.Listar().ToList();

                        cmbConcepto.DataSource = Conceptos;
                        cmbConcepto.DataBind();
                        Concepto Concepto = new Concepto();
                        Concepto                   = ConceptoDAO.Get(Convert.ToInt32(cmbConcepto.SelectedValue));
                        TiposConceptos             = Concepto.Rellenar().Tipos;
                        cmbTipoConcepto.DataSource = TiposConceptos;
                        cmbTipoConcepto.DataBind();

                        Circuitos = CircuitoDAO.Listar().Where(z => z.ClaveArea == Usuario.ClaveArea).ToList();
                        cmbCircuito.DataSource = Circuitos;
                        cmbCircuito.DataBind();


                        List <ProgramaDetalle> progDets = ProgramaDetalleDAO.Listar().Where(p => p.ClavePrograma == Convert.ToInt32(clave)).ToList();
                        string FilasDetalles            = "";

                        foreach (ProgramaDetalle p in progDets)
                        {
                            p.Rellenar();


                            string urlDelete = ResolveUrl("~/App/Area/CrearProgramaDetalle.aspx?idPD=" + p.Clave + "&id=" + clave + "&idNec=" + necId + "&tipo=eliminar");


                            if (p.TipoConcepto == null)
                            {
                                FilasDetalles += Disenio.GenerarFilaTabla(
                                    p.Cantidad.ToString(),
                                    p.FechaInicio.ToString(),
                                    p.PrecioUnitario.ToString(),
                                    p.Circuito.Descripcion.ToString(),
                                    p.Concepto.ToString(),
                                    "",
                                    "<a href='" + urlDelete + "' class='btn btn-default btn-block'>Eliminar</a>");
                            }
                            else
                            {
                                FilasDetalles += Disenio.GenerarFilaTabla(
                                    p.Cantidad.ToString(),
                                    p.FechaInicio.ToString(),
                                    p.PrecioUnitario.ToString(),
                                    p.Circuito.Descripcion.ToString(),
                                    p.Concepto.ToString(),
                                    p.TipoConcepto.ToString(),
                                    "<a href='" + urlDelete + "' class='btn btn-default btn-block'>Eliminar</a>"
                                    );
                            }
                        }

                        LitDetalles.Text = FilasDetalles;
                    }
                }



                catch (Exception Ex)
                {
                    Mensaje Mensaje = new Mensaje()
                    {
                        Titulo    = "Error en el proceso del detalle de programa de ejecucion",
                        Contenido = Ex.Message,
                        Tipo      = TipoMensaje.ERROR
                    };

                    litMensaje.Text = Disenio.GenerarMensaje(Mensaje);
                }
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {

            Usuario = Utilerias.FiltrarUsuario(this);

            if (!IsPostBack)
            {
                string clave = Request.QueryString["id"];
                string claveDetalle = Request.QueryString["idNecesidadDetalle"];
                string tipo = Request.QueryString["tipo"];
                string Filas = "";

                try
                {
                  
                        Necesidad Necesidad = new Necesidad();
                        Necesidad = NecesidadDAO.Get(Convert.ToInt32(clave));

                    if (Necesidad.ClaveEstatus == 2 )
                        {
                            btnEnivar.Visible = false;
                        btnRegistrarNecesidad.Visible = false;
                        }
                    

                    if (claveDetalle != null && tipo == "editar")
                    {
                        NecesidadDetalle NecesidadDetalle = new NecesidadDetalle();
                        NecesidadDetalle = NecesidadDetalleDAO.Get(Convert.ToInt32(claveDetalle));
                        txtVolumen.Text = NecesidadDetalle.Volumen.ToString();
                        txtPrecioU.Text = NecesidadDetalle.PrecioUnitario.ToString();
                        Conceptos = new List<Concepto>();
                        Conceptos.Add(NecesidadDetalle.Rellenar().Concepto);
                        cmbConcepto.DataSource = Conceptos;
                        cmbConcepto.DataBind();
                        cmbConcepto.Enabled = false;
                        TiposConceptos = new List<TipoConcepto>();
                        TiposConceptos.Add(NecesidadDetalle.Rellenar().TipoConcepto);
                        cmbTipoConcepto.DataSource = TiposConceptos;
                        cmbTipoConcepto.DataBind();
                        cmbTipoConcepto.Enabled = false;



                    }
                    else if (claveDetalle != null && tipo == "eliminar")
                    {
                        int resultado = NecesidadDetalleDAO.Eliminar(Convert.ToInt32(claveDetalle));
                        if (resultado == 0)
                        {
                            Mensaje Mensaje = new Mensaje()
                            {
                                Titulo = "Algo salió mal",
                                Contenido = "La Necesidad no pudo guardarse. Para más información consulte al administrador del sistema",
                                Tipo = TipoMensaje.ALERTA
                            };
                            litMensaje.Text = Disenio.GenerarMensaje(Mensaje);
                            return;
                        }

                        Response.Redirect(ResolveUrl("~/App/Area/RegistroNecesidadDetalle.aspx?id=" + clave));

                    }
                    else
                    {
                        Conceptos = ConceptoDAO.Listar();
                        cmbConcepto.DataSource = Conceptos;
                        cmbConcepto.DataBind();

                        Concepto Concepto = new Concepto();
                        Concepto = ConceptoDAO.Get(Convert.ToInt32(cmbConcepto.SelectedValue));
                        TiposConceptos = Concepto.Rellenar().Tipos;
                        cmbTipoConcepto.DataSource = TiposConceptos;
                        cmbTipoConcepto.DataBind();
                    }
                    double importeTotal = 0;
                    List<NecesidadDetalle> NecesidadesDetalle = new List<NecesidadDetalle>();
                    NecesidadesDetalle = NecesidadDetalleDAO.Listar().Where(p => p.ClaveNecesidad == Convert.ToInt32(clave)).ToList();
                    foreach (NecesidadDetalle p in NecesidadesDetalle)
                    {
                        p.Rellenar();

                        string urlEdit = ResolveUrl("~/App/Area/RegistroNecesidadDetalle.aspx?id=" + clave + "&idNecesidadDetalle=" + p.Clave + "&tipo=editar");
                        string urlDelete = ResolveUrl("~/App/Area/RegistroNecesidadDetalle.aspx?id=" + clave + "&idNecesidadDetalle=" + p.Clave + "&tipo=eliminar");

                        if(p.TipoConcepto == null)
                        {
                            Filas += Disenio.GenerarFilaTabla(p.Volumen.ToString(),
                            p.PrecioUnitario.ToString(),
                            Utilerias.ToCurrency(p.CalcularImporte()),
                            p.Concepto.ToString(),
                            "",
                             "<a href='" + urlEdit + "' class='btn btn-default btn-block'>Editar</a>",
                             "<a href='" + urlDelete + "' class='btn btn-default btn-block'>Eliminar</a>");

                            importeTotal += p.Volumen * p.PrecioUnitario;
                        }else
                        {
                            Filas += Disenio.GenerarFilaTabla(p.Volumen.ToString(),
                            p.PrecioUnitario.ToString(),
                            Utilerias.ToCurrency(p.CalcularImporte()),
                            p.Concepto.ToString(),
                            p.TipoConcepto.ToString(),
                             "<a href='" + urlEdit + "' class='btn btn-default btn-block'>Editar</a>",
                             "<a href='" + urlDelete + "' class='btn btn-default btn-block'>Eliminar</a>");
                            importeTotal += p.Volumen * p.PrecioUnitario;
                        }
                        

                    }
                    litTBody.Text = Filas;
                    LitimporteTotal.Text = "IMPORTE TOTAL = $ " + importeTotal.ToString();
                }
                catch (Exception Ex)
                {

                    Mensaje Mensaje = new Mensaje()
                    {
                        Titulo = "Error al mostrar el detalle",
                        Contenido = Ex.Message,
                        Tipo = TipoMensaje.ERROR
                    };

                    litMensaje.Text = Disenio.GenerarMensaje(Mensaje);

                }
            }
        }
Beispiel #4
0
        /// <summary>
        /// Genera el código html para construir una tabla de un concepto con sus volúmenes e importes totales
        /// </summary>
        /// <param name="Concepto">El concepto del cual se generará el reporte</param>
        /// <param name="Areas">Las áreas que contemplará el reporte</param>
        /// <param name="ClavePeriodo">La clave del periodo del reporte</param>
        /// <returns></returns>
        public static string GenerarReporteConcepto(Concepto Concepto, List <Area> Areas, int ClavePeriodo)
        {
            List <TipoConcepto> Tipos = Concepto.Rellenar().Tipos;

            string Html = @"<div class='table-responsive'>
            <table class='table table-bordered'>
                <thead>
                    <tr>
                        <th colspan = '4' class='text-center'>" + Concepto.Descripcion + @"</th>
                    </tr>
                    <tr>" +
                          (Tipos.Count > 0 ? "<th>Tipo</th>" : "") + @"
                        <th>Unidad de medida</th>
                        <th>Volúmen</th>
                        <th>Importe</th>
                    </tr>
                </thead>
                <tbody>
                    " +

                          /*Si el concepto tiene subconceptos se genera una tabla de éstos y calcula
                           * sus volúmenes y sus importes totales. De lo contrario se crea una fila con
                           * la unidad de mediad, y el volúmen e importe total del concepto
                           */
                          (Tipos.Count > 0 ? GenerarTabla(Tipos, t =>
            {
                return(new string[]
                {
                    t.Descripcion,
                    Concepto.MedidaAbreviacion,
                    t.CalcularVolumenTotal(Areas, ClavePeriodo).ToString("N"),
                    Utilerias.ToCurrency(t.CalcularImporteTotal(Areas, ClavePeriodo))
                });
            })
                    :
                           "<td>" + Concepto.MedidaAbreviacion + "</td>" +
                           "<td>" + Concepto.CalcularVolumenTotal(Areas, ClavePeriodo).ToString("N") + "</td>" +
                           "<td>" + Utilerias.ToCurrency(Concepto.CalcularImporteTotal(Areas, ClavePeriodo)) + "</td>"
                          )
                          + @"    
                </tbody>" +

                          /* Si el concepto tiene subconceptos se generará el pie de la tabla.
                           * De lo contrario habrá pie de tabla
                           */
                          (Tipos.Count > 0 ?
                           @"<tfoot>
                    <tr>
                        <th colspan='2' class='text-right'>TOTAL: </th>
                        <td>" + Concepto.CalcularVolumenTotal(Areas, ClavePeriodo).ToString("N") + @"</td>
                        <td>" + Utilerias.ToCurrency(Concepto.CalcularImporteTotal(Areas, ClavePeriodo)) + @"</td>
                    </tr>
                </tfoot>"
                :
                           ""
                          ) +
                          @"
            </table>
            </div>";


            return(Html);
        }