protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                DBConn oConn = new DBConn();
                if (oConn.Open())
                {
                    cCliente  oCliente   = new cCliente(ref oConn);
                    DataTable tblCliente = oCliente.Get();
                    if (tblCliente != null)
                    {
                        if (tblCliente.Rows.Count > 0)
                        {
                            oCmbCliente.Items.Add(new ListItem("Seleccione Cliente", ""));
                            foreach (DataRow oRow in tblCliente.Rows)
                            {
                                oCmbCliente.Items.Add(new ListItem(oRow["snombre"].ToString(), oRow["nkey_cliente"].ToString()));
                            }
                        }
                        tblCliente.Dispose();
                    }
                    oCliente = null;
                }
                oConn.Close();
                sTipo.Value = oWeb.GetData("sTipo");
                oCmbTipoConsulta.Items.Add(new ListItem("Seleccione Tipo Consulta", ""));
                switch (sTipo.Value)
                {
                case "calidadproductiva":
                    oCmbTipoConsulta.Items.Add(new ListItem("Analista", "A"));
                    oCmbTipoConsulta.Items.Add(new ListItem("Cliente", "C"));
                    oCmbTipoConsulta.Items.Add(new ListItem("Supervisor", "S"));
                    break;

                case "impecabilidad":
                    oCmbTipoConsulta.Items.Add(new ListItem("Analista", "A"));
                    oCmbTipoConsulta.Items.Add(new ListItem("Cliente", "C"));
                    break;

                case "managersp1":
                case "managersp2":
                    oCmbTipoConsulta.Items.Add(new ListItem("Supervisor", "S"));
                    break;

                case "analistap1":
                case "analistap2":
                    oCmbTipoConsulta.Items.Add(new ListItem("Analista", "A"));
                    break;

                case "riegooperacional":
                    oCmbTipoConsulta.Items.Add(new ListItem("Manual", "M"));
                    break;

                case "tesoreriaproceso":
                    oCmbTipoConsulta.Items.Add(new ListItem("Analista", "A"));
                    break;
                }
            }
        }
        protected void lnkButton_Click(object sender, EventArgs e)
        {
            string sPath = string.Empty;

            DBConn oConn = new DBConn();

            if (oConn.Open())
            {
                cCliente oCliente = new cCliente(ref oConn);
                oCliente.NkeyCliente = "79";
                DataTable dt = oCliente.Get();
                if (dt != null)
                {
                    sPath = dt.Rows[0]["pathsdocscaneados"].ToString();
                }
                dt = null;
            }
            oConn.Close();



            sPath = sPath + "Mattel Europa\\ContratosWeb\\" + hddpdfcontrato.Value;
            Response.AppendHeader("Content-Disposition", "attachment; filename=" + hddpdfcontrato.Value);

            // Write the file to the Response
            const int bufferLength = 10000;

            byte[] buffer   = new Byte[bufferLength];
            int    length   = 0;
            Stream download = null;

            try
            {
                download = new FileStream(sPath, FileMode.Open, FileAccess.Read);
                do
                {
                    if (Response.IsClientConnected)
                    {
                        length = download.Read(buffer, 0, bufferLength);
                        Response.OutputStream.Write(buffer, 0, length);
                        buffer = new Byte[bufferLength];
                    }
                    else
                    {
                        length = -1;
                    }
                }while (length > 0);
                Response.Flush();
                Response.End();
            }
            finally
            {
                if (download != null)
                {
                    download.Close();
                }
            }
        }
Esempio n. 3
0
        protected void LoadGrid()
        {
            DBConn oConn = new DBConn();

            if (oConn.Open())
            {
                cCliente oCliente = new cCliente(ref oConn);
                if (!string.IsNullOrEmpty(txtlogo.Text))
                {
                    oCliente.SNombre = txtlogo.Text;
                }
                gridLogos.DataSource = oCliente.Get();
                gridLogos.DataBind();

                oConn.Close();
            }
        }
Esempio n. 4
0
        protected void Page_Load(object sender, EventArgs e)
        {
            oWeb.ValidaSessionAdm();
            if (!IsPostBack)
            {
                string sFile = string.Empty;
                CodCliente.Value = oWeb.GetData("CodCliente");
                hddTipo.Value    = oWeb.GetData("tp");
                DBConn oConn = new DBConn();
                if (oConn.Open())
                {
                    cCliente oCliente = new cCliente(ref oConn);
                    oCliente.NKey_cliente = CodCliente.Value;
                    DataTable dtCliente = oCliente.Get();
                    if (dtCliente.Rows.Count > 0)
                    {
                        Label1.Text = dtCliente.Rows[0]["sNombre"].ToString();
                    }

                    cAppLogoCliente oAppLogoCliente = new cAppLogoCliente(ref oConn);
                    oAppLogoCliente.NKey_cliente = CodCliente.Value;
                    DataTable dtLogo = oAppLogoCliente.Get();
                    if (dtLogo != null)
                    {
                        if (dtLogo.Rows.Count > 0)
                        {
                            hddAccion.Value = "EDITAR";
                            if (!string.IsNullOrEmpty(dtLogo.Rows[0]["logo_cliente"].ToString()))
                            {
                                sFile = dtLogo.Rows[0]["logo_cliente"].ToString();
                                getImage(sFile);
                            }
                            else
                            {
                                getImage("nada.jpg");
                            }
                        }
                    }
                }
                oConn.Close();
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                rdCmbCliente.Items.Add(new ListItem("<< Seleccione Cliente", "0"));
                rdCmbLicencitarios.Items.Add(new ListItem("<< Seleccione Licenciatario", "0"));
                DBConn oConn = new DBConn();
                if (oConn.Open())
                {
                    cCliente  oCliente  = new cCliente(ref oConn);
                    DataTable dtCliente = oCliente.Get();
                    if (dtCliente != null)
                    {
                        foreach (DataRow oRow in dtCliente.Rows)
                        {
                            rdCmbCliente.Items.Add(new ListItem(oRow["sNombre"].ToString(), oRow["nKey_cliente"].ToString()));
                        }
                    }
                    dtCliente = null;

                    cDeudor   oDeudor  = new cDeudor(ref oConn);
                    DataTable dtDeudor = oDeudor.Get();
                    if (dtDeudor != null)
                    {
                        foreach (DataRow oRow in dtDeudor.Rows)
                        {
                            rdCmbLicencitarios.Items.Add(new ListItem(oRow["sNombre"].ToString(), oRow["nKey_Deudor"].ToString()));
                        }
                    }
                    dtDeudor = null;

                    oConn.Close();
                }
                hdd_codusuario.Value = oWeb.GetData("codusuario");
                if (!string.IsNullOrEmpty(hdd_codusuario.Value))
                {
                    getUsuario();
                }
            }
        }
        public void ProcessRequest(HttpContext context)
        {
            string sPath        = string.Empty;
            string sNomFactura  = oWeb.GetData("sNomFactura");
            string sNumContrato = oWeb.GetData("sNumContrato");
            DBConn oConn        = new DBConn();

            if (oConn.Open())
            {
                cContratos oContratos = new cContratos(ref oConn);
                oContratos.NumContrato = sNumContrato;
                DataTable dtContrato = oContratos.Get();
                if (dtContrato != null)
                {
                    if (dtContrato.Rows.Count > 0)
                    {
                        cCliente oCliente = new cCliente(ref oConn);
                        oCliente.NkeyCliente = dtContrato.Rows[0]["nkey_cliente"].ToString();
                        DataTable dtCliente = oCliente.Get();
                        if (dtCliente != null)
                        {
                            if (dtCliente.Rows.Count > 0)
                            {
                                sPath = dtCliente.Rows[0]["pathsdocscaneados"].ToString() + "\\" + dtCliente.Rows[0]["direcarchivos"].ToString();
                            }
                        }
                        dtContrato = null;
                    }
                }
            }
            oConn.Close();

            System.Web.HttpResponse oResponse = System.Web.HttpContext.Current.Response;

            sPath = sPath + "\\" + sNomFactura + ".pdf";
            oResponse.ContentType = "application/pdf";
            oResponse.AppendHeader("Content-Disposition", "attachment; filename=" + sNomFactura + ".pdf");

            // Write the file to the Response
            const int bufferLength = 10000;

            byte[] buffer   = new Byte[bufferLength];
            int    length   = 0;
            Stream download = null;

            try
            {
                download = new FileStream(sPath, FileMode.Open, FileAccess.Read);
                do
                {
                    if (oResponse.IsClientConnected)
                    {
                        length = download.Read(buffer, 0, bufferLength);
                        oResponse.OutputStream.Write(buffer, 0, length);
                        buffer = new Byte[bufferLength];
                    }
                    else
                    {
                        length = -1;
                    }
                }while (length > 0);
                oResponse.Flush();
                oResponse.End();
            }
            finally
            {
                if (download != null)
                {
                    download.Close();
                }
            }
        }
Esempio n. 7
0
        protected override void OnPreRender(EventArgs e)
        {
            base.OnPreRender(e);

            Web    oWeb        = new Web();
            string sTimePage   = string.Empty;
            string sUrlPage    = string.Empty;
            string pCodMonitor = oWeb.GetData("codmonitor");
            string indexToken  = oWeb.GetData("indexToken");
            string pCodUsuario = oWeb.GetData("codusuario");
            string pOrderPage  = oWeb.GetData("order");

            DBConn oConn = new DBConn();

            if (oConn.Open())
            {
                cAptMonitorPages oAptMonitorPages = new cAptMonitorPages(ref oConn);
                oAptMonitorPages.CodMonitor = pCodMonitor;
                oAptMonitorPages.OrderPage  = (Convert.ToInt32(pOrderPage) + 1).ToString();
                DataTable dtMPage = oAptMonitorPages.Get();
                if (dtMPage != null)
                {
                    if (dtMPage.Rows.Count > 0)
                    {
                        sUrlPage = dtMPage.Rows[0]["url_page"].ToString();
                        sUrlPage = sUrlPage + "?codmonitor=" + pCodMonitor;
                        sUrlPage = sUrlPage + "&indexToken=" + indexToken;
                        if (!string.IsNullOrEmpty(pCodUsuario))
                        {
                            sUrlPage = sUrlPage + "&codusuario=" + pCodUsuario;
                        }
                        sUrlPage  = sUrlPage + "&order=" + dtMPage.Rows[0]["order_page"].ToString();
                        sTimePage = dtMPage.Rows[0]["time_page"].ToString();
                    }
                    else
                    {
                        oAptMonitorPages.OrderPage = string.Empty;
                        dtMPage = oAptMonitorPages.Get();
                        if (dtMPage != null)
                        {
                            if (dtMPage.Rows.Count > 0)
                            {
                                if ((string.IsNullOrEmpty(dtMPage.Rows[0]["cod_cliente"].ToString())) && (string.IsNullOrEmpty(dtMPage.Rows[0]["cod_holding"].ToString())))
                                {
                                    cCliente  oCliente  = new cCliente(ref oConn);
                                    DataTable dtCliente = oCliente.Get();
                                    if (!string.IsNullOrEmpty(indexToken))
                                    {
                                        if (dtCliente.Rows.Count == (Convert.ToInt32(Session[indexToken].ToString()) + 1))
                                        {
                                            Session[indexToken] = 0;
                                        }
                                        else
                                        {
                                            Session[indexToken] = Convert.ToInt32(Session[indexToken].ToString()) + 1;
                                        }
                                    }
                                    else
                                    {
                                        if (dtCliente.Rows.Count == (Convert.ToInt32(Session["indexcliente"].ToString()) + 1))
                                        {
                                            Session["indexcliente"] = 0;
                                        }
                                        else
                                        {
                                            Session["indexcliente"] = Convert.ToInt32(Session["indexcliente"].ToString()) + 1;
                                        }
                                    }
                                    dtCliente = null;
                                }

                                sUrlPage = dtMPage.Rows[0]["url_page"].ToString();
                                sUrlPage = sUrlPage + "?codmonitor=" + pCodMonitor;
                                sUrlPage = sUrlPage + "&indexToken=" + indexToken;
                                if (!string.IsNullOrEmpty(pCodUsuario))
                                {
                                    sUrlPage = sUrlPage + "&codusuario=" + pCodUsuario;
                                }
                                sUrlPage  = sUrlPage + "&order=" + dtMPage.Rows[0]["order_page"].ToString();
                                sTimePage = dtMPage.Rows[0]["time_page"].ToString();
                            }
                        }
                    }
                }
                dtMPage = null;

                Response.AppendHeader("Refresh", sTimePage + "; URL=" + sUrlPage);
            }
            oConn.Close();
        }
Esempio n. 8
0
        protected void Page_Load(object sender, EventArgs e)
        {
            DBConn oConn          = new DBConn();
            Web    oWeb           = new Web();
            string pCodMonitor    = oWeb.GetData("codmonitor");
            string pCodUsuario    = oWeb.GetData("codusuario");
            string pAuthenCodUser = oWeb.GetData("authuser");
            string indexToken     = oWeb.GetData("indexToken");

            string pCodPage     = string.Empty;
            string pOrderPage   = oWeb.GetData("order");
            string pCodCliente  = string.Empty;
            string pTipoUsuario = string.Empty;
            string sIdFecha     = string.Empty;
            int    maxdt        = (new DateTime(DateTime.Now.Year, DateTime.Now.Month, 1).AddMonths(1).AddDays(-1)).Day;

            firtDay.InnerText = "01-" + DateTime.Now.ToString("MM-yyyy");
            lastDay.InnerText = maxdt.ToString() + "-" + DateTime.Now.ToString("MM-yyyy");

            if (!string.IsNullOrEmpty(pAuthenCodUser))
            {
                AuthenticUser(pAuthenCodUser);
            }

            oWeb.ValidaUserPanel();

            if (!IsPostBack)
            {
                if (oConn.Open())
                {
                    cAptMonitorPages oAptMonitorPages = new cAptMonitorPages(ref oConn);
                    oAptMonitorPages.CodMonitor = pCodMonitor;
                    oAptMonitorPages.OrderPage  = pOrderPage;
                    DataTable dtMPage = oAptMonitorPages.Get();

                    if (dtMPage != null)
                    {
                        if (dtMPage.Rows.Count > 0)
                        {
                            pCodPage     = dtMPage.Rows[0]["cod_page"].ToString();
                            pTipoUsuario = dtMPage.Rows[0]["tipo_usuario"].ToString();
                            if (!string.IsNullOrEmpty(dtMPage.Rows[0]["cod_cliente"].ToString()))
                            {
                                pCodCliente = dtMPage.Rows[0]["cod_cliente"].ToString();
                            }
                            else if (!string.IsNullOrEmpty(dtMPage.Rows[0]["cod_holding"].ToString()))
                            {
                                pCodCliente  = dtMPage.Rows[0]["cod_holding"].ToString();
                                pTipoUsuario = "H";
                            }
                            else
                            {
                                cCliente  oCliente  = new cCliente(ref oConn);
                                DataTable dtCliente = oCliente.Get();
                                if (!string.IsNullOrEmpty(indexToken))
                                {
                                    pCodCliente = dtCliente.Rows[Convert.ToInt32(Session[indexToken].ToString())]["nkey_cliente"].ToString();
                                }
                                else
                                {
                                    pCodCliente = dtCliente.Rows[Convert.ToInt32(Session["indexcliente"].ToString())]["nkey_cliente"].ToString();
                                }
                                dtCliente = null;
                            }
                        }
                    }
                    dtMPage = null;

                    oCmbTipoConsulta.Value = pTipoUsuario;
                    oCmbCliente.Value      = pCodCliente;
                    if (!string.IsNullOrEmpty(oCmbCliente.Value))
                    {
                        cAppLogoCliente oAppLogoCliente = new cAppLogoCliente(ref oConn);
                        oAppLogoCliente.NKey_cliente = pCodCliente;
                        oAppLogoCliente.Tipo         = (pTipoUsuario == "H" ? pTipoUsuario : "C");
                        DataTable dtlogo = oAppLogoCliente.Get();
                        if (dtlogo != null)
                        {
                            if (dtlogo.Rows.Count > 0)
                            {
                                imglogo.ImageUrl = "images/logos/" + dtlogo.Rows[0]["logo_cliente"].ToString();
                            }
                        }
                    }
                    else
                    {
                        imglogo.Visible = false;
                    }
                }
                oConn.Close();
            }

            if (oConn.Open())
            {
                cIndejecucion oIndejecucion = new cIndejecucion(ref oConn);
                DataTable     tblEjecucion  = oIndejecucion.Get();
                if (tblEjecucion != null)
                {
                    if (tblEjecucion.Rows.Count > 0)
                    {
                        sIdFecha = tblEjecucion.Rows[0]["idfecha"].ToString();
                    }
                    tblEjecucion.Dispose();
                }
                tblEjecucion = null;

                DateTime idFechaMesAnterior = new DateTime(Int32.Parse(sIdFecha.Substring(0, 4)), Int32.Parse(sIdFecha.Substring(4, 2)), Int32.Parse(sIdFecha.Substring(6, 2)), Int32.Parse(sIdFecha.Substring(8, 2)), Int32.Parse(sIdFecha.Substring(10, 2)), 0);
                idFechaMesAnterior = idFechaMesAnterior.AddMonths(-1);

                cAptPagesKpi oAptPagesKpi = new cAptPagesKpi(ref oConn);
                oAptPagesKpi.CodCliente = pCodUsuario;
                oAptPagesKpi.CodPage    = pCodPage;
                DataTable dtKPIs = oAptPagesKpi.Get();
                if (dtKPIs != null)
                {
                    cIndresultado oIndResultado = new cIndresultado(ref oConn);
                    DataTable     tblColumn1    = null;
                    cIndumbral    oIndumbral    = null;
                    HtmlTableCell oCell;

                    HtmlTableCell      oCelldataColumn;
                    HtmlGenericControl dynDiv;

                    HtmlTableCell      oCelldataAceptacion;
                    HtmlGenericControl oDivAceptacion;

                    HtmlTableCell      oCellSLA;
                    HtmlGenericControl oDivSLA;

                    HtmlTableCell      oCellMesAnterior;
                    HtmlGenericControl oDivImg;
                    Image oImage;

                    foreach (DataRow oRow in dtKPIs.Rows)
                    {
                        string iDato    = "0";
                        string sKeyTipo = string.Empty;

                        oCell    = new HtmlTableCell();
                        oCell.ID = "tdCell_" + oRow["identificador_kpi"].ToString();
                        oCell.Controls.Add(new LiteralControl("<div align=\"center\" class=\"tbTit\">" + oRow["nombrekpi"].ToString() + "</div>"));
                        HeaderId.Controls.Add(oCell);

                        oCelldataColumn    = new HtmlTableCell();
                        oCelldataColumn.ID = "tdCell_dataColumn" + oRow["identificador_kpi"].ToString();
                        oCelldataColumn.Attributes.Add("class", "clDtPanel");

                        dynDiv    = new HtmlGenericControl("div");
                        dynDiv.ID = "divControl_" + oRow["identificador_kpi"].ToString();

                        oIndResultado.Tipo       = oCmbTipoConsulta.Value;
                        oIndResultado.KeyCliente = oCmbCliente.Value;
                        oIndResultado.IdFecha    = sIdFecha;
                        oIndResultado.Indicador  = oRow["identificador_kpi"].ToString();
                        tblColumn1 = oIndResultado.Get();
                        if (tblColumn1 != null)
                        {
                            if (tblColumn1.Rows.Count > 0)
                            {
                                iDato            = (!string.IsNullOrEmpty(tblColumn1.Rows[0]["valor"].ToString()) ? tblColumn1.Rows[0]["valor"].ToString() : "0");
                                sKeyTipo         = tblColumn1.Rows[0]["nkey_tipo"].ToString();
                                dynDiv.InnerText = String.Format("{0:0}", double.Parse(iDato));
                                //oColumn1.InnerText = String.Format("{0:0}", double.Parse(iDato));
                            }
                            tblColumn1.Dispose();
                        }
                        tblColumn1 = null;

                        oCellMesAnterior    = new HtmlTableCell();
                        oCellMesAnterior.ID = "tdCell_mesanterior" + oRow["identificador_kpi"].ToString();
                        oCellMesAnterior.Attributes.Add("class", "clDtPanel");

                        /*******************************************************/
                        /***************** Mes Anterior ************************/
                        /*******************************************************/
                        oIndResultado.IdFecha = idFechaMesAnterior.ToString("yyyyMMddHHmm");
                        tblColumn1            = oIndResultado.GetMesAnterior();
                        if (tblColumn1 != null)
                        {
                            if (tblColumn1.Rows.Count > 0)
                            {
                                oDivImg = new HtmlGenericControl("div");
                                oDivImg.Attributes.Add("class", "tbDat");

                                oImage          = new Image();
                                oImage.ImageUrl = oWeb.getColorArrowCalidad(double.Parse(iDato), double.Parse(tblColumn1.Rows[0]["valor"].ToString()));

                                oDivImg.Controls.Add(oImage);
                                oCellMesAnterior.Controls.Add(oDivImg);
                                //oColumnMesAnt1.ImageUrl = oWeb.getColorArrowCalidad(double.Parse(iDato), double.Parse(tblColumn1.Rows[0]["valor"].ToString()));
                            }
                            tblColumn1.Dispose();
                        }
                        tblColumn1 = null;

                        oCelldataAceptacion    = new HtmlTableCell();
                        oCelldataAceptacion.ID = "tdCell_aceptacion" + oRow["identificador_kpi"].ToString();
                        oCelldataAceptacion.Attributes.Add("class", "clDtPanel");

                        oDivAceptacion    = new HtmlGenericControl("div");
                        oDivAceptacion.ID = "divAceptacion_" + oRow["identificador_kpi"].ToString();
                        oDivAceptacion.Attributes.Add("class", "tbDat");

                        oCellSLA    = new HtmlTableCell();
                        oCellSLA.ID = "tdCell_SLA" + oRow["identificador_kpi"].ToString();
                        oCellSLA.Attributes.Add("class", "clDtPanel");

                        oDivSLA    = new HtmlGenericControl("div");
                        oDivSLA.ID = "divSLA_" + oRow["identificador_kpi"].ToString();
                        oDivSLA.Attributes.Add("class", "tbDat");

                        oIndumbral            = new cIndumbral(ref oConn);
                        oIndumbral.KeyCliente = oCmbCliente.Value;
                        oIndumbral.Tipo       = oCmbTipoConsulta.Value;
                        oIndumbral.Indicador  = oRow["identificador_kpi"].ToString();
                        oIndumbral.KeyTipo    = sKeyTipo;
                        tblColumn1            = oIndumbral.Get();
                        if (tblColumn1 != null)
                        {
                            if (tblColumn1.Rows.Count > 0)
                            {
                                oDivAceptacion.InnerText = tblColumn1.Rows[0]["criterio_aceptacion"].ToString() + tblColumn1.Rows[0]["unidad"].ToString();
                                oCelldataAceptacion.Controls.Add(oDivAceptacion);
                                //oCAceptacion1.InnerHtml = tblColumn1.Rows[0]["criterio_aceptacion"].ToString() + tblColumn1.Rows[0]["unidad"].ToString();

                                oDivSLA.InnerText = tblColumn1.Rows[0]["sla"].ToString();
                                oCellSLA.Controls.Add(oDivSLA);
                                //oSLA1.InnerHtml = tblColumn1.Rows[0]["sla"].ToString();

                                dynDiv.Attributes.Add("class", oWeb.getColorNumAvance(double.Parse(iDato), tblColumn1));
                                oCelldataColumn.Controls.Add(dynDiv);
                                //oColumn1.Attributes.Add("class", oWeb.getColorNumAvance(double.Parse(iDato), tblColumn1));
                            }
                            tblColumn1.Dispose();
                        }
                        tblColumn1 = null;

                        dataColumn.Controls.Add(oCelldataColumn);
                        dataAceptacion.Controls.Add(oCelldataAceptacion);
                        dataSLA.Controls.Add(oCellSLA);
                        dataMesAnterior.Controls.Add(oCellMesAnterior);
                    }
                }
                dtKPIs = null;

                oConn.Close();
            }
        }
        protected void oCmbTipoConsulta_OnClientSelectedIndexChanged(object o, Telerik.Web.UI.RadComboBoxSelectedIndexChangedEventArgs e)
        {
            DataTable oPages = null;

            tdselectvista.Visible = true;
            DBConn oConn = new DBConn();

            if (oConn.Open())
            {
                cAppPages oAppPages = new cAppPages(ref oConn);
                oAppPages.CodTipo = oCmbTipoConsulta.SelectedValue.ToString();

                if (oCmbTipoConsulta.SelectedValue.ToString() == "N")
                {
                    oAppPages.CodMonitor = CodMonitorView.Value;
                    oPages = oAppPages.GetByType();
                }
                else
                {
                    oPages = oAppPages.GetByTipo();
                }

                cAppTipoConnsulta oTipoConnsulta = new cAppTipoConnsulta(ref oConn);
                oTipoConnsulta.CodTipo     = oCmbTipoConsulta.SelectedValue.ToString();
                oTipoConnsulta.IndSegNivel = "S";
                DataTable dtTpCon = oTipoConnsulta.Get();
                if (dtTpCon != null)
                {
                    if (dtTpCon.Rows.Count > 0)
                    {
                        //tpconsulta_segundonivel.Visible = true;
                        tpconsulta_normal.Visible = false;
                        //oCmbPages.Visible = false;
                        //lblPage.Visible = true;

                        //if (oPages != null)
                        //{
                        //  if (oPages.Rows.Count > 0)
                        //  {
                        //    lblPage.Text = oPages.Rows[0]["nom_page"].ToString();
                        //    hddCodPage.Value = oPages.Rows[0]["cod_page"].ToString();
                        //LoadGrid();
                        //  }
                        //  oPages.Dispose();
                        //}
                        //oPages = null;
                        btnGrabar2.Visible = false;
                    }
                    else
                    {
                        lblPage.Visible = false;

                        cCliente  oCliente  = new cCliente(ref oConn);
                        DataTable dtcliente = oCliente.Get();
                        tpconsulta_normal.Visible       = true;
                        tpconsulta_segundonivel.Visible = false;
                        btnGrabar2.Visible = true;
                        //oCmbPages.Items.Add(new ListItem("Selecciona una vista", ""));

                        oCmbHolding.Items.Clear();
                        oCmbHolding.Items.Add(new ListItem("Selecciona holding", ""));
                        DataTable dtholding = oCliente.GetHolding();
                        if (dtholding != null)
                        {
                            foreach (DataRow oRow in dtholding.Rows)
                            {
                                oCmbHolding.Items.Add(new ListItem(oRow["holding"].ToString(), oRow["ncodholding"].ToString()));
                            }
                        }
                        dtholding = null;

                        oCmbCliente.Items.Clear();
                        oCmbCliente.Items.Add(new RadComboBoxItem("Selecciona cliente", ""));
                        if (dtcliente != null)
                        {
                            foreach (DataRow oRow in dtcliente.Rows)
                            {
                                oCmbCliente.Items.Add(new RadComboBoxItem(oRow["snombre"].ToString(), oRow["nkey_cliente"].ToString()));
                            }
                        }
                        dtcliente = null;
                    }
                }
                dtTpCon = null;

                oCmbPages.Visible = true;
                oCmbPages.Items.Clear();
                oCmbPages.Items.Add(new RadComboBoxItem("Selecciona una Vista", ""));
                if (oPages != null)
                {
                    if (oPages.Rows.Count > 0)
                    {
                        foreach (DataRow oRow in oPages.Rows)
                        {
                            oCmbPages.Items.Add(new RadComboBoxItem(oRow["nom_page"].ToString(), oRow["cod_page"].ToString()));
                        }
                    }
                    oPages.Dispose();
                }
                oPages = null;
            }
            oConn.Close();
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            DBConn        oConn = new DBConn();
            Web           oWeb  = new Web();
            StringBuilder sNAvance;
            string        pCodMonitor    = oWeb.GetData("codmonitor");
            string        pCodUsuario    = oWeb.GetData("codusuario");
            string        pAuthenCodUser = oWeb.GetData("authuser");
            string        indexToken     = oWeb.GetData("indexToken");

            string pCodPage      = string.Empty;
            string pOrderPage    = oWeb.GetData("order");
            string pCodCliente   = string.Empty;
            string pTipoConsulta = string.Empty;
            string pTipoCliente  = string.Empty;
            string sIdFecha      = string.Empty;
            string iDato         = "0";
            string sKeyTipo      = string.Empty;

            if (!string.IsNullOrEmpty(pAuthenCodUser))
            {
                AuthenticUser(pAuthenCodUser);
            }

            oWeb.ValidaUserPanel();

            int maxdt = (new DateTime(DateTime.Now.Year, DateTime.Now.Month, 1).AddMonths(1).AddDays(-1)).Day;

            firtDay.InnerText = "01-" + DateTime.Now.ToString("MM-yyyy");
            lastDay.InnerText = maxdt.ToString() + "-" + DateTime.Now.ToString("MM-yyyy");

            if (!IsPostBack)
            {
                if (oConn.Open())
                {
                    cAptMonitorPages oAptMonitorPages = new cAptMonitorPages(ref oConn);
                    oAptMonitorPages.CodMonitor = pCodMonitor;
                    oAptMonitorPages.OrderPage  = pOrderPage;
                    DataTable dtMPage = oAptMonitorPages.Get();

                    if (dtMPage != null)
                    {
                        if (dtMPage.Rows.Count > 0)
                        {
                            pCodPage      = dtMPage.Rows[0]["cod_page"].ToString();
                            pTipoConsulta = dtMPage.Rows[0]["tipo_usuario"].ToString();
                            if (!string.IsNullOrEmpty(dtMPage.Rows[0]["cod_cliente"].ToString()))
                            {
                                pCodCliente  = dtMPage.Rows[0]["cod_cliente"].ToString();
                                pTipoCliente = "C";
                            }
                            else if (!string.IsNullOrEmpty(dtMPage.Rows[0]["cod_holding"].ToString()))
                            {
                                pCodCliente  = dtMPage.Rows[0]["cod_holding"].ToString();
                                pTipoCliente = "H";
                            }
                            else
                            {
                                cCliente  oCliente  = new cCliente(ref oConn);
                                DataTable dtCliente = oCliente.Get();
                                if (!string.IsNullOrEmpty(indexToken))
                                {
                                    pCodCliente = dtCliente.Rows[Convert.ToInt32(Session[indexToken].ToString())]["nkey_cliente"].ToString();
                                }
                                else
                                {
                                    pCodCliente = dtCliente.Rows[Convert.ToInt32(Session["indexcliente"].ToString())]["nkey_cliente"].ToString();
                                }
                                dtCliente = null;
                            }
                        }
                    }
                    dtMPage = null;

                    oCmbTipoConsulta.Value = pTipoConsulta;
                    oCmbCliente.Value      = pCodCliente;

                    if (oCmbTipoConsulta.Value == "S")
                    {
                        pie.Attributes.Add("class", "tdPieManagers");
                        lblSubTitle.Text = "Medición de Managers";
                    }
                    else
                    {
                        pie.Attributes.Add("class", "tdPieEjecutivos");
                        lblSubTitle.Text = "Medición de Ejecutivos";
                    }

                    if (!string.IsNullOrEmpty(oCmbCliente.Value))
                    {
                        cAppLogoCliente oAppLogoCliente = new cAppLogoCliente(ref oConn);
                        oAppLogoCliente.NKey_cliente = pCodCliente;
                        oAppLogoCliente.Tipo         = (pTipoCliente == "H" ? pTipoCliente : "C");
                        DataTable dtlogo = oAppLogoCliente.Get();
                        if (dtlogo != null)
                        {
                            if (dtlogo.Rows.Count > 0)
                            {
                                imglogo.ImageUrl = "images/logos/" + dtlogo.Rows[0]["logo_cliente"].ToString();
                            }
                        }
                    }
                    else
                    {
                        imglogo.Visible = false;
                    }
                }
                oConn.Close();
            }

            if (oConn.Open())
            {
                if (!IsPostBack)
                {
                    cCliente oCliente = new cCliente(ref oConn);
                    oCliente.NKey_cliente = oCmbCliente.Value;
                    DataTable tblCliente = oCliente.Get();
                    if (!string.IsNullOrEmpty(oCliente.Error))
                    {
                        Response.Write(oCliente.Query);
                        Response.End();
                    }
                    if (tblCliente != null)
                    {
                        if (tblCliente.Rows.Count > 0)
                        {
                            hddNCod.Value = tblCliente.Rows[0]["ncod"].ToString();
                        }
                    }
                    tblCliente.Dispose();
                    tblCliente = null;
                }
                cIndejecucion oIndejecucion = new cIndejecucion(ref oConn);
                DataTable     tblEjecucion  = oIndejecucion.Get();
                if (tblEjecucion != null)
                {
                    if (tblEjecucion.Rows.Count > 0)
                    {
                        sIdFecha = tblEjecucion.Rows[0]["idfecha"].ToString();
                    }
                    tblEjecucion.Dispose();
                }
                tblEjecucion = null;

                DateTime idFechaMesAnterior = new DateTime(Int32.Parse(sIdFecha.Substring(0, 4)), Int32.Parse(sIdFecha.Substring(4, 2)), Int32.Parse(sIdFecha.Substring(6, 2)), Int32.Parse(sIdFecha.Substring(8, 2)), Int32.Parse(sIdFecha.Substring(10, 2)), 0);
                idFechaMesAnterior = idFechaMesAnterior.AddMonths(-1);

                HtmlTableCell htmlTblCell;
                cAnalista     oAnalista = new cAnalista(ref oConn);
                oAnalista.NCod         = hddNCod.Value;
                oAnalista.TipoAnalista = oCmbTipoConsulta.Value;
                DataTable tblAnalista = oAnalista.Get();
                if (tblAnalista != null)
                {
                    foreach (DataRow oRow in tblAnalista.Rows)
                    {
                        htmlTblCell = new HtmlTableCell();
                        htmlTblCell.Controls.Add(new LiteralControl("<div class=\"tbTit\">" + oRow["snombre"].ToString() + "</div>"));
                        trCabecera.Controls.Add(htmlTblCell);
                    }
                }
                tblAnalista.Dispose();
                tblAnalista = null;
                DataTable tblColumn2;

                HtmlGenericControl oDivImg;
                DataTable          tblColumn1;
                cIndresultado      oIndResultado;
                cIndumbral         oIndumbral;

                cAptPagesKpi oAptPagesKpi = new cAptPagesKpi(ref oConn);
                oAptPagesKpi.CodCliente = pCodUsuario;
                oAptPagesKpi.CodPage    = pCodPage;
                DataTable dtKPIs = oAptPagesKpi.Get();
                if (dtKPIs != null)
                {
                    foreach (DataRow oRowKpi in dtKPIs.Rows)
                    {
                        iDato    = string.Empty;
                        sKeyTipo = string.Empty;
                        HtmlTableCell HtmlTablecell;

                        HtmlTablecell = new HtmlTableCell();
                        StringBuilder sNomKpi = new StringBuilder();
                        sNomKpi.Append("<td class=\"clPanel\"><div class=\"tbTTitRow\">");
                        sNomKpi.Append(oRowKpi["nombrekpi"].ToString());
                        sNomKpi.Append("</div></td>");
                        HtmlTablecell.Controls.Add(new LiteralControl(sNomKpi.ToString()));
                        HtmlTableRow htmlTblRowKpi = new HtmlTableRow();
                        htmlTblRowKpi.ID = oRowKpi["cod_kpi"].ToString() + "_KPI";
                        htmlTblRowKpi.Controls.Add(HtmlTablecell);
                        tbl.Controls.Add(htmlTblRowKpi);

                        HtmlTablecell = new HtmlTableCell();
                        StringBuilder sCriterioAceptacion = new StringBuilder();
                        sCriterioAceptacion.Append("<td class=\"clPanel\"><div class=\"tbTitRow\">Criterio Aceptación</div></td>");
                        HtmlTablecell.Controls.Add(new LiteralControl(sCriterioAceptacion.ToString()));
                        HtmlTableRow htmlTblRowCriAcep = new HtmlTableRow();
                        htmlTblRowCriAcep.ID = oRowKpi["cod_kpi"].ToString() + "_CriAcept";
                        htmlTblRowCriAcep.Controls.Add(HtmlTablecell);
                        tbl.Controls.Add(htmlTblRowCriAcep);

                        HtmlTablecell = new HtmlTableCell();
                        StringBuilder sCriterioSLA = new StringBuilder();
                        sCriterioSLA.Append("<td class=\"clPanel\"><div class=\"tbTitRow\">SLA</div></td>");
                        HtmlTablecell.Controls.Add(new LiteralControl(sCriterioSLA.ToString()));
                        HtmlTableRow htmlTblRowSLA = new HtmlTableRow();
                        htmlTblRowSLA.ID = oRowKpi["cod_kpi"].ToString() + "_SLA";
                        htmlTblRowSLA.Controls.Add(HtmlTablecell);
                        tbl.Controls.Add(htmlTblRowSLA);

                        HtmlTablecell = new HtmlTableCell();
                        StringBuilder sCriterioMesAnte = new StringBuilder();
                        sCriterioMesAnte.Append("<td class=\"clPanel\"><div class=\"tbTitRow\">Mes Anterior</div></td>");
                        HtmlTablecell.Controls.Add(new LiteralControl(sCriterioMesAnte.ToString()));
                        HtmlTableRow htmlTblRowMesAnt = new HtmlTableRow();
                        htmlTblRowMesAnt.ID = oRowKpi["cod_kpi"].ToString() + "_MesAnt";
                        htmlTblRowMesAnt.Controls.Add(HtmlTablecell);
                        tbl.Controls.Add(htmlTblRowMesAnt);

                        HtmlTableRow htmlTblRow = new HtmlTableRow();
                        htmlTblRow.ID = oRowKpi["cod_kpi"].ToString() + "row";
                        HtmlTablecell = new HtmlTableCell();
                        HtmlTablecell.Controls.Add(new LiteralControl("<td colspan=\"20\" style=\"height: 10px; \"></td>"));
                        htmlTblRow.Controls.Add(HtmlTablecell);
                        tbl.Controls.Add(htmlTblRow);

                        oAnalista              = new cAnalista(ref oConn);
                        oAnalista.NCod         = hddNCod.Value;
                        oAnalista.TipoAnalista = oCmbTipoConsulta.Value;
                        tblAnalista            = oAnalista.Get();

                        if (tblAnalista != null)
                        {
                            foreach (DataRow oRow in tblAnalista.Rows)
                            {
                                oIndResultado            = new cIndresultado(ref oConn);
                                oIndResultado.Tipo       = oCmbTipoConsulta.Value;
                                oIndResultado.KeyCliente = oCmbCliente.Value;
                                oIndResultado.KeyTipo    = oRow["nKey_Analista"].ToString();
                                oIndResultado.Indicador  = oRowKpi["identificador_kpi"].ToString();
                                oIndResultado.IdFecha    = sIdFecha;
                                tblColumn1 = oIndResultado.Get();
                                if (tblColumn1 != null)
                                {
                                    if (tblColumn1.Rows.Count > 0)
                                    {
                                        iDato    = (!string.IsNullOrEmpty(tblColumn1.Rows[0]["valor"].ToString()) ? tblColumn1.Rows[0]["valor"].ToString() : "0");
                                        sKeyTipo = tblColumn1.Rows[0]["nkey_tipo"].ToString();

                                        oIndumbral            = new cIndumbral(ref oConn);
                                        oIndumbral.KeyCliente = oCmbCliente.Value;
                                        oIndumbral.Indicador  = oRowKpi["identificador_kpi"].ToString();
                                        oIndumbral.KeyTipo    = sKeyTipo;
                                        tblColumn2            = oIndumbral.Get();
                                        if (tblColumn2 != null)
                                        {
                                            if (tblColumn2.Rows.Count > 0)
                                            {
                                                sNAvance = new StringBuilder();
                                                sNAvance.Append("<div class=\"").Append(oWeb.getColorNumAvance(double.Parse(iDato), tblColumn2));
                                                sNAvance.Append("\">").Append(String.Format("{0:0}", double.Parse(iDato))).Append("</div>");

                                                htmlTblCell = new HtmlTableCell();
                                                htmlTblCell.Attributes.Add("align", "center");
                                                htmlTblCell.Attributes.Add("class", "clDtPanel");
                                                htmlTblCell.Controls.Add(new LiteralControl(sNAvance.ToString()));
                                                htmlTblRowKpi.Controls.Add(htmlTblCell);

                                                htmlTblCell = new HtmlTableCell();
                                                htmlTblCell.Attributes.Add("class", "clDtPanel");
                                                htmlTblCell.Controls.Add(new LiteralControl("<div class=\"tbDat\">" + tblColumn2.Rows[0]["criterio_aceptacion"].ToString() + " " + tblColumn2.Rows[0]["unidad"].ToString() + "</div>"));
                                                htmlTblRowCriAcep.Controls.Add(htmlTblCell);

                                                htmlTblCell = new HtmlTableCell();
                                                htmlTblCell.Attributes.Add("class", "clDtPanel");
                                                htmlTblCell.Controls.Add(new LiteralControl("<div class=\"tbDat\">" + tblColumn2.Rows[0]["sla"].ToString() + "</div>"));
                                                htmlTblRowSLA.Controls.Add(htmlTblCell);
                                            }
                                            tblColumn2.Dispose();
                                        }
                                        tblColumn2 = null;
                                    }
                                    tblColumn1.Dispose();
                                }
                                tblColumn1            = null;
                                oIndResultado.IdFecha = idFechaMesAnterior.ToString("yyyyMMddHHmm");
                                tblColumn1            = oIndResultado.GetMesAnterior();
                                if (tblColumn1 != null)
                                {
                                    if (tblColumn1.Rows.Count > 0)
                                    {
                                        htmlTblCell = new HtmlTableCell();
                                        htmlTblCell.Attributes.Add("class", "clDtPanel");

                                        oDivImg = new HtmlGenericControl("div");
                                        oDivImg.Attributes.Add("class", "tbDat");

                                        oDivImg.Controls.Add(new LiteralControl("<img src=\"" + oWeb.getColorArrowCalidad(double.Parse(iDato), double.Parse(tblColumn1.Rows[0]["valor"].ToString())) + "\" border=\"0\">"));

                                        htmlTblCell.Controls.Add(oDivImg);
                                        htmlTblRowMesAnt.Controls.Add(htmlTblCell);
                                    }
                                    tblColumn1.Dispose();
                                }
                                tblColumn1 = null;
                            }
                            oIndResultado = null;
                        }
                    }
                    tblAnalista = null;
                }
                dtKPIs = null;
            }
            oConn.Close();
        }
Esempio n. 11
0
        public void ProcessRequest(HttpContext context)
        {
            string sPath         = string.Empty;
            string sFileName     = string.Empty;
            string sCodUsuario   = oWeb.GetData("CodUsuario");
            string pCodReporting = oWeb.GetData("pCodReporting");

            DBConn oConn = new DBConn();

            if (oConn.Open())
            {
                cReportingRegional oReportingRegional = new cReportingRegional(ref oConn);
                oReportingRegional.CodReporting = pCodReporting;
                DataTable dtReportingRegional = oReportingRegional.Get();
                if (dtReportingRegional != null)
                {
                    if (dtReportingRegional.Rows.Count > 0)
                    {
                        sFileName = dtReportingRegional.Rows[0]["filename_reporting"].ToString();

                        cCliente oCliente = new cCliente(ref oConn);
                        oCliente.NkeyCliente = sCodUsuario;
                        DataTable dtCliente = oCliente.Get();
                        if (dtCliente != null)
                        {
                            if (dtCliente.Rows.Count > 0)
                            {
                                sPath = dtCliente.Rows[0]["pathsdocscaneados"].ToString();
                            }
                        }
                        dtReportingRegional = null;
                    }
                }
            }
            oConn.Close();

            System.Web.HttpResponse oResponse = System.Web.HttpContext.Current.Response;

            sPath = sPath + "\\Mattel Europa\\Reporte_Regional\\" + sFileName;
            oResponse.AppendHeader("Content-Disposition", "attachment; filename=" + sFileName);

            // Write the file to the Response
            const int bufferLength = 10000;

            byte[] buffer   = new Byte[bufferLength];
            int    length   = 0;
            Stream download = null;

            try
            {
                download = new FileStream(sPath, FileMode.Open, FileAccess.Read);
                do
                {
                    if (oResponse.IsClientConnected)
                    {
                        length = download.Read(buffer, 0, bufferLength);
                        oResponse.OutputStream.Write(buffer, 0, length);
                        buffer = new Byte[bufferLength];
                    }
                    else
                    {
                        length = -1;
                    }
                }while (length > 0);
                oResponse.Flush();
                oResponse.End();
            }
            finally
            {
                if (download != null)
                {
                    download.Close();
                }
            }
        }