protected void Page_Load(object sender, EventArgs e)
        {
            string tipoF = Request.QueryString["Tipo"];
            string folio = Request.QueryString["Folio"];
            string posi  = Request.QueryString["Posi"];
            string oper  = Request.QueryString["Oper"];

            Conexion  con = new Conexion();
            catalogos c   = new catalogos();

            string links = "";

            if (!oper.Equals("N"))
            {
                string   href = "";
                string[] hh   = Request.Url.AbsoluteUri.Split('/');

                for (int i = 0; i < hh.Length - 1; i++)
                {
                    href += hh[i] + "/";
                }

                links += "<a target='-blank' href='" + href + "Procesa.aspx";
                links += "?Tipo=" + tipoF + "&Folio=" + folio + "&Oper=A&Posi=" + posi;
                links += "'>Autorizar</a>&nbsp;|&nbsp;<a target='-blank' href='" + href + "Procesa.aspx";
                links += "?Tipo=" + tipoF + "&Folio=" + folio + "&Oper=R&Posi=" + posi;
                links += "'>Rechazar</a>&nbsp;&nbsp;";
            }

            lblLinks.InnerHtml = links;
            //lblLinks.InnerHtml = "<a href='Default.aspx'>Autorizar</a>&nbsp;|&nbsp;<a href='Default.aspx'>Rechazar</a>&nbsp;&nbsp;";

            if (con.conectar())
            {
                if (tipoF.Equals("01"))
                {
                    IRfcTable          header = con.consultaCabecera(folio, "");
                    IRfcTable          detail = con.consultaDetalle(folio, "");
                    List <Solicitudes> ss     = new List <Solicitudes>();

                    if (header.Count > 0)
                    {
                        string stat = con.estatusSol(tipoF, folio);
                        if (stat.Equals("Pendiente"))
                        {
                            txtFolio.InnerHtml = "Autorización de Solicitud: ";
                        }
                        if (stat.Equals("Aprobada"))
                        {
                            txtFolio.InnerHtml = "Solicitud Aprobada: ";
                        }
                        if (stat.Equals("Rechazada"))
                        {
                            txtFolio.InnerHtml = "Solicitud Rechazada: ";
                        }
                        txtFolio.InnerHtml += header.GetString("ID_SOLICITUD");
                        txtPERNR.InnerText  = header.GetString("PERNR") + " " + con.nombrePERNR(header.GetString("PERNR"));
                        txtDATE.InnerText   = f.fechaToOUT(f.fecha(header.GetString("FECHA")));
                        string comm = "";
                        comm += "<table border='0' style='border-width: 0px; border-style: None; width: 1150px; border-collapse: collapse;'><tbody>";
                        comm += "<tr><td class='cell12' style='width:1150px;'>Comentario</td></tr><tr><td style='text-align:left;font-size:12px;'>";
                        comm += header.GetString("COMMENTS");
                        comm += "</td></tr></tbody></table>";
                        txtCOMM.InnerHtml = comm;

                        for (int i = 0; i < detail.Count; i++)
                        {
                            detail.CurrentIndex = i;
                            Solicitudes s = new Solicitudes();
                            s.vkorg   = detail.GetString("VKORG");
                            s.vtweg   = detail.GetString("VTWEG");
                            s.spart   = detail.GetString("SPART");
                            s.kunnr   = detail.GetString("KUNNR");
                            s.pltyp   = detail.GetString("LP_ANT");
                            s.pltyp_n = detail.GetString("LP_NVO");
                            s.date    = f.fecha(detail.GetString("FECHA"));
                            if (!s.pltyp.Equals(""))
                            {
                                //s.pltyp_desc = c.getDescLP(s.pltyp);
                                s.pltyp_desc = con.getLP_Desc("", s.pltyp);
                            }
                            else
                            {
                                s.pltyp_desc = "Sin lista de precios";
                            }

                            if (!s.pltyp_n.Equals(""))
                            {
                                //s.pltyp_n_desc = c.getDescLP(s.pltyp_n);
                                s.pltyp_n_desc = con.getLP_Desc("", s.pltyp_n);
                            }
                            else
                            {
                                s.pltyp_n_desc = "Sin lista de precios";
                            }

                            s.name1 = c.getColumnaCliente(s.vkorg, s.vtweg, s.spart, s.kunnr, "NAME1");

                            ss.Add(s);
                        }
                        string tab = "";

                        tab  = "<table border='0' style='border-width: 0px; border-style: None; width: 1150px; border-collapse: collapse;'><tbody>";
                        tab += "<tr><td class='cell12'>Org. Compras</td><td class='cell12'>Canal Dist.</td><td class='cell12'>Sector</td><td class='cell12'>Cliente</td><td class='cell12'>Nombre</td><td class='cell12'>Lista anterior</td><td class='cell12'>Nueva Lista de precios</td><td class='cell12'>Vigencia</td></tr>";
                        foreach (Solicitudes s in ss)
                        {
                            string style = "";
                            if (s.error)
                            {
                                style = "background-color: red !important;";
                            }

                            tab += "<tr style='" + style + "'>";

                            if (s.error)
                            {
                                style = "white-text";
                            }
                            tab += "<td class='cell18 " + style + "'>" + s.vkorg + "</td>";
                            tab += "<td class='cell18 " + style + "'>" + s.vtweg + "</td>";
                            tab += "<td class='cell18 " + style + "'>" + s.spart + "</td>";
                            tab += "<td class='cell18 " + style + "'>" + s.kunnr + "</td>";
                            tab += "<td class='cell17 " + style + "'>" + s.name1 + "</td>";
                            tab += "<td class='cell18 " + style + "'>" + s.pltyp_desc + "</td>";
                            tab += "<td class='cell18 " + style + "'>" + s.pltyp_n_desc + "</td>";
                            tab += "<td class='cell18 " + style + "'>" + s.date.ToString("dd/MM/yyyy") + "</td>";


                            tab += "</tr>";
                        }
                        tab += "</tbody></table>";
                        lblTabla.InnerHtml = tab;
                    }
                    else
                    {
                        Response.Redirect("Default.aspx", false);
                    }
                }
                else if (tipoF.Equals("02"))
                {
                    IRfcTable           header = con.consultaCabeceraL(folio, "");
                    IRfcTable           detail = con.consultaDetalleL(folio, "");
                    List <SolicitudesL> ss     = new List <SolicitudesL>();

                    if (header.Count > 0)
                    {
                        //txtFolio.InnerText = header.GetString("ID_SOLICITUD");
                        //txtPERNR.InnerText = header.GetString("PERNR") + " " + con.nombrePERNR(header.GetString("PERNR"));
                        //txtDATE.InnerText = f.fechaToOUT(f.fecha(header.GetString("FECHA")));
                        //txtCOMM.InnerText = header.GetString("COMMENTS");
                        string stat = con.estatusSol(tipoF, folio);
                        if (stat.Equals("Pendiente"))
                        {
                            txtFolio.InnerHtml = "Autorización de Solicitud: ";
                        }
                        if (stat.Equals("Aprobada"))
                        {
                            txtFolio.InnerHtml = "Solicitud Aprobada: ";
                        }
                        if (stat.Equals("Rechazada"))
                        {
                            txtFolio.InnerHtml = "Solicitud Rechazada: ";
                        }
                        txtFolio.InnerHtml += header.GetString("ID_SOLICITUD");
                        txtPERNR.InnerText  = header.GetString("PERNR") + " " + con.nombrePERNR(header.GetString("PERNR"));
                        txtDATE.InnerText   = f.fechaToOUT(f.fecha(header.GetString("FECHA")));
                        string comm = "";
                        comm += "<table border='0' style='border-width: 0px; border-style: None; width: 1150px; border-collapse: collapse;'><tbody>";
                        comm += "<tr><td class='cell12' style='width:1150px;'>Comentario</td></tr><tr><td style='text-align:left;font-size:12px;'>";
                        comm += header.GetString("COMMENTS");
                        comm += "</td></tr></tbody></table>";
                        txtCOMM.InnerHtml = comm;


                        string vkorg = header.GetString("VKORG");
                        string vtweg = header.GetString("VTWEG");
                        string spart = header.GetString("SPART");
                        string kunnr = header.GetString("KUNNR");
                        string pltyp = header.GetString("PLTYP");
                        string matnr = header.GetString("MATNR");

                        string cabecera = "<table style='position: relative; left: 50%; margin-left: -200px'>";
                        //cabecera += "<tr>";
                        if (!vkorg.Equals(""))
                        {
                            cabecera += "<tr><td class='cell03'>Org. Compras</td>";
                            cabecera += "<td class='cell05'>" + vkorg + " " + con.ListaVKORG(vkorg, "").GetString("VTEXT") + "</td></tr>";
                        }
                        if (!vtweg.Equals(""))
                        {
                            cabecera += "<tr><td class='cell03'>Canal Distribución</td>";
                            cabecera += "<td class='cell05'>" + vtweg + " " + con.ListaVTWEG(vtweg, "", "").GetString("VTEXT") + "</td></tr>";
                        }
                        if (!spart.Equals(""))
                        {
                            cabecera += "<tr><td class='cell03'>Sector</td>";
                            cabecera += "<td class='cell05'>" + spart + " " + con.ListaSPART(spart, "", "", "", "").GetString("VTEXT") + "</td></tr>";
                        }
                        if (!kunnr.Equals(""))
                        {
                            cabecera += "<tr><td class='cell03'>Cliente</td>";
                            cabecera += "<td class='cell05'>" + kunnr + " " + con.getCliente(vkorg, vtweg, spart, kunnr).GetString("NAME1") + "</td></tr>";
                        }
                        if (!pltyp.Equals(""))
                        {
                            cabecera += "<tr><td class='cell03'>Lista de precios</td>";
                            cabecera += "<td class='cell05'>" + con.getLP_Desc("", pltyp) + "</td></tr>";
                        }
                        if (!matnr.Equals(""))
                        {
                            cabecera += "<tr><td class='cell03'>Material</td>";
                            cabecera += "<td class='cell05'>" + matnr + " " + con.columnaMatnr(matnr, "MAKTG", "X") + "</td></tr>";
                        }

                        cabecera += "<tr><td class='cell03'>Porcentaje</td>";
                        cabecera += "<td class='cell05'>" + header.GetString("PORCENTAJE") + " %" + "</td></tr>";
                        cabecera += "</table>";

                        lblFolio.InnerHtml = cabecera;


                        string tipo   = header.GetString("TIPO");
                        string obj    = "";
                        string titulo = "";
                        if (tipo.Substring(1, 1).Equals("M"))
                        {
                            obj    = "MATNR";
                            titulo = "Material";
                        }
                        else if (tipo.Substring(1, 1).Equals("G"))
                        {
                            obj    = "MATKL";
                            titulo = "Grupo de artículos";
                        }
                        else if (tipo.Substring(1, 1).Equals("P"))
                        {
                            obj    = "EBELN";
                            titulo = "Pedido de cliente";
                        }
                        else if (tipo.Substring(1, 1).Equals("L"))
                        {
                            obj    = "CHARG";
                            titulo = "Lote";
                        }

                        for (int i = 0; i < detail.Count; i++)
                        {
                            detail.CurrentIndex = i;
                            SolicitudesL s = new SolicitudesL();
                            s.obj = detail.GetString(obj);
                            //s.desc = detail.GetString("VTWEG");
                            s.desc2     = detail.GetString("MEINS");
                            s.importe   = detail.GetString("PR_ANT");
                            s.moneda    = detail.GetString("MON_ANT");
                            s.importe_n = detail.GetString("PR_NVO");
                            s.moneda_n  = detail.GetString("MON_NVO");
                            s.fecha_a   = f.fecha(detail.GetString("FECHA_INI"));
                            s.fecha_b   = f.fecha(detail.GetString("FECHA_FIN"));

                            s.escala = detail.GetString("ESCALA");

                            //if (tipo.Substring(1, 1).Equals("M"))
                            //{
                            //    s.desc = con.columnaMatnr(s.obj, "MAKTG");
                            //    s.desc2 = con.columnaMatnr(s.obj, "MEINS");
                            //}
                            //else if (tipo.Substring(1, 1).Equals("G"))
                            //{
                            //    s.desc = con.columnaMatkl(s.obj, "WGBEZ");
                            //}

                            ss.Add(s);
                        }

                        ss = obtenerDatos(ss, tipo.Substring(1, 1));
                        string tab = "";

                        tab  = "<table border='0' style='border-width: 0px; border-style: None; width: 1150px; border-collapse: collapse;'><tbody>";
                        tab += "<tr>";
                        tab += "<td class='cell10'>" + titulo + "</td>";
                        if (!tipo.Substring(1, 1).Equals("P") & !tipo.Substring(1, 1).Equals("L"))
                        {
                            tab += "<td class='cell11'>Denominación</td>";
                        }
                        //if (tipo.Substring(1, 1).Equals("M"))
                        tab += "<td class='cell12'>Unidad</td>";
                        tab += "<td class='cell12'>Precio Anterior</td>";
                        tab += "<td class='cell12'>Moneda</td>";
                        tab += "<td class='cell12'>Precio nuevo</td>";
                        tab += "<td class='cell12'>Moneda</td>";
                        tab += "<td class='cell12'>Válido de</td>";
                        tab += "<td class='cell12'>Válido a</td>";
                        tab += "<td class='cell12'>E</td>";
                        tab += "</tr>";
                        foreach (SolicitudesL s in ss)
                        {
                            string style = "";
                            if (s.error)
                            {
                                style = "background-color: red !important;";
                            }

                            tab += "<tr style='" + style + "'>";

                            if (s.error)
                            {
                                style = "white-text";
                            }
                            tab += "<td class='cell16 " + style + "'>" + s.obj + "</td>";
                            if (!tipo.Substring(1, 1).Equals("P") & !tipo.Substring(1, 1).Equals("L"))
                            {
                                tab += "<td class='cell17 " + style + "'>" + s.desc + "</td>";
                            }
                            //if (tipo.Substring(1, 1).Equals("M"))
                            tab += "<td class='cell18 " + style + "'>" + s.desc2 + "</td>";
                            tab += "<td class='cell18 " + style + "'>" + s.importe + "</td>";
                            tab += "<td class='cell18 " + style + "'>" + s.moneda + "</td>";
                            tab += "<td class='cell18 " + style + "'>" + s.importe_n + "</td>";
                            tab += "<td class='cell18 " + style + "'>" + s.moneda_n + "</td>";
                            tab += "<td class='cell18 " + style + "'>" + s.fecha_a.ToString("dd/MM/yyyy") + "</td>";
                            tab += "<td class='cell18 " + style + "'>" + s.fecha_b.ToString("dd/MM/yyyy") + "</td>";

                            string   href = "";
                            string[] hh   = Request.Url.AbsoluteUri.Split('/');

                            for (int i = 0; i < hh.Length - 1; i++)
                            {
                                href += hh[i] + "/";
                            }

                            if (s.escala.Equals("X"))
                            {
                                tab += "<td><a style='color:black;font-size:12px' target ='-blank' href ='" + href + "Procesa.aspx?Tipo=" + tipoF + "&Folio=" + folio + "&Oper=N&Posi=" + posi + "'>Ver Escalas</a></td>";
                            }
                            else
                            {
                                tab += "<td></td>";
                            }


                            tab += "</tr>";
                        }
                        tab += "</tbody></table>";
                        lblTabla.InnerHtml = tab;
                    }
                }

                IRfcTable bitacora = con.getBitacora(tipoF, folio);
                string    tabla    = "";

                tabla  = "<table border='0' style='border-width: 0px; border-style: None; width: 1150px; border-collapse: collapse;'><tbody>";
                tabla += "<tr><td class='cell12'>Empleado</td><td class='cell12' style='width: 100px'>Evento</td><td class='cell12' style='width: 150px'>Fecha autorizar</td><td class='cell12' style='width: 150px'>Fecha Procesada</td><td class='cell12' style='width: 50px'>Status</td><td class='cell12'>Comentario</td></tr>";

                for (int i = 0; i < bitacora.Count; i++)
                {
                    bitacora.CurrentIndex = i;
                    tabla += "<tr><td class='cell17'>";
                    tabla += bitacora.GetString("ZUSRA") + " - " + bitacora.GetString("ZDUSA");
                    tabla += "</td>";
                    tabla += "<td class='cell18' style='width: 100px'>";
                    tabla += bitacora.GetString("ZDEEV");
                    tabla += "</td>";
                    tabla += "<td class='cell18' style='width: 150px'>";
                    tabla += bitacora.GetString("ZFEAL") + "[" + bitacora.GetString("ZHOAL") + "]";
                    tabla += "</td>";
                    tabla += "<td class='cell18' style='width: 150px'>";
                    tabla += bitacora.GetString("ZFEUM") + "[" + bitacora.GetString("ZHOUM") + "]";
                    tabla += "</td>";
                    tabla += "<td class='cell18' style='width: 50px'>";
                    tabla += bitacora.GetString("ZSWAR");
                    tabla += "</td>";
                    tabla += "<td class='cell18'>";
                    tabla += bitacora.GetString("ZCOME");
                    //tabla += "sad ads fas a s fasifu sa disad iasduasdiasud a sdaiud asi duiasdhasoidha soih sad sahdjashdiusahd sa ";
                    tabla += "</td>";
                    tabla += "</tr>";
                }

                lblBItacora.InnerHtml = tabla;
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                hidUsuario.Value = Session["Usuario"].ToString();
                hidNumEmp.Value  = Session["NumEmp"].ToString();
                hidTipoEmp.Value = Session["TipoEmp"].ToString();
                //string[] a = Request.Form.AllKeys;
                //Conexion c = new Conexion("E-DESARROLL2", "Initial02");
                Conexion  con = new Conexion();
                catalogos c   = new catalogos();
                if (con.conectar())
                {
                    List <string> mon = con.monedas();
                    List <meins>  mei = con.meinss();
                    monedas      = formaMoneda("MXN", mon);
                    um_meins     = formaMeins("", mei);
                    fecha_limite = con.fechaLimite();
                    if (Request.Form.AllKeys.Length == 0)
                    {
                        //IRfcTable lista_vkorg = con.ListaVKORG("");
                        //IRfcTable lista_vtweg = con.ListaVTWEG("");
                        IRfcTable lista_spart = con.ListaSPART("", hidNumEmp.Value, "", "", "02");
                        //IRfcTable lista_pltyp = con.ListaPLTYP(hidNumEmp.Value);

                        //for (int i = 0; i < lista_vkorg.Count; i++)
                        //{
                        //    lista_vkorg.CurrentIndex = i;
                        //    txtVKORG.Items.Add(new ListItem(lista_vkorg.GetString("VKORG") + " " + lista_vkorg.GetString("VTEXT"), lista_vkorg.GetString("VKORG")));
                        //}
                        //for (int i = 0; i < lista_vtweg.Count; i++)
                        //{
                        //    lista_vtweg.CurrentIndex = i;
                        //    txtVTWEG.Items.Add(new ListItem(lista_vtweg.GetString("VTWEG") + " " + lista_vtweg.GetString("VTEXT"), lista_vtweg.GetString("VTWEG")));
                        //}
                        for (int i = 0; i < lista_spart.Count; i++)
                        {
                            lista_spart.CurrentIndex = i;
                            txtSPART.Items.Add(new ListItem(lista_spart.GetString("SPART") + " " + lista_spart.GetString("VTEXT"), lista_spart.GetString("SPART")));
                        }
                    }
                    if (Request.Form.AllKeys.Length > 0)
                    {
                        string vkorg = Request.Form["txtVKORG"];
                        string vtweg = Request.Form["txtVTWEG"];
                        string spart = Request.Form["txtSPART"];
                        string pltyp = Request.Form["txtPLTYP"].Split(' ')[0];
                        string matkl = Request.Form["txtMATKL"];

                        string p_inc = Request.Form["P_inc"];
                        string p_dec = Request.Form["P_dec"];
                        string c_inc = Request.Form["C_inc"];
                        string c_dec = Request.Form["C_dec"];

                        string cambio = p_inc + p_dec + c_inc + c_dec;
                        if (cambio.Trim().Equals(""))
                        {
                            cambio = "X";
                        }
                        else
                        {
                            cambio = "";
                        }

                        matkl = matkl.Split(' ')[0];

                        IRfcTable a720 = con.consultaLPDetail("", "", spart, "", "", matkl, pltyp, "A610");
                        txtPos.Value = a720.Count + "";
                        string tabla   = "";
                        string valores = "";
                        tabla  = "<table id='Table9' style='borde -width: 0px; border-style: None; width: 100 %; border-collapse: collapse;'><tbody><tr class='cell08'><td></td></tr></tbody></table>";
                        tabla += "<table id='tblTabla' border='0' style='border-width: 0px; border-style: None; width: 100%; border-collapse: collapse;'><tbody>";
                        tabla += "<tr><td class='tablahead'>Gpo de artículos</td><td class='tablahead'>Denominación</td><td class='tablahead'>Unidad</td>" +
                                 "<td class='tablahead'>Precio actual</td><td class='tablahead'>Moneda</td>" +
                                 "<td class='tablahead'>Precio nuevo</td><td class='tablahead'>Moneda</td>" +
                                 "<td class='tablahead'>Válido de</td><td class='tablahead'>Válido a</td><td class='tablahead'></td><td class='tablahead'></td></tr>";
                        if (a720.Count > 0)
                        {
                            List <SolicitudesL> ss = new List <SolicitudesL>();
                            for (int i = 0; i < a720.Count; i++)
                            {
                                SolicitudesL s = new SolicitudesL();
                                a720.CurrentIndex = i;
                                s.obj             = a720.GetString("MATKL");
                                s.importe         = a720.GetString("KBETR");
                                s.moneda          = a720.GetString("KONWA");
                                s.importe_n       = nuevoPrecio(a720.GetString("KBETR"));
                                s.moneda_n        = a720.GetString("KONWA");
                                s.fecha_a         = f.fecha(a720.GetString("DATAB"));
                                s.fecha_b         = f.fecha(a720.GetString("DATBI"));
                                s.id     = a720.GetString("KNUMH");
                                s.escala = a720.GetString("ESCALA");
                                s.desc2  = a720.GetString("KMEIN");

                                ss.Add(s);
                            }

                            ss = obtenerDatos(ss, "G");
                            int pos = 0;
                            for (int i = 0; i < ss.Count; i++)
                            {
                                pos++;
                                tabla += "<tr id='tr-" + pos + "'><td class='tablaCent' id='OBJ-" + pos + "' ondblclick='escalas(this.id)'>";
                                tabla += "<input type='hidden' id='MATKL-" + pos + "' value='" + ss[i].obj + "' />";
                                tabla += ss[i].obj;
                                tabla += "</td>";
                                tabla += "<td class='tablaCent' id='DESC-" + pos + "' ondblclick='escalas(this.id)'>";
                                tabla += ss[i].desc;
                                tabla += "</td>";
                                tabla += "<td class='tablaCent' id='DESC2-" + pos + "' ondblclick='escalas(this.id)'>";
                                tabla += "<select  id='MEINS-" + pos + "' class='cell031' style='width:40px;' onchange='cambiaMeins(this.id, this.value)' />";
                                tabla += formaMeins(ss[i].desc2, mei);
                                tabla += "</select>";
                                tabla += "</td>";
                                tabla += "<td class='tablaCent'>";
                                tabla += ss[i].importe;
                                tabla += "</td><td class='tablaCent'>";
                                tabla += ss[i].moneda;
                                tabla += "<td class='tablaCent'>";
                                tabla += "<input class='cell031' type='text' onchange='cambiaCant(this.id)' id='KBETR-" + pos + "' value='";
                                tabla += ss[i].importe_n;
                                tabla += "' />";
                                tabla += "</td><td class='tablaCent'>";
                                tabla += "<select class='cell031' type='text' onchange='cambiaMone(this)' id='KONWA-" + pos + "' >";
                                //tabla += "<option>MXN</option><option>USD</option><option>EUR</option>";
                                tabla += formaMoneda(ss[i].moneda_n, mon);
                                tabla += "' </select>";
                                tabla += "</td><td class='tablaCent'>";
                                tabla += "<input class='cell031 datepicker' type='text' onchange='cambiaFechA(this.value, this.id);'  ondblclick='copiaA(this.value)' id='DATAB-" + pos + "' value='";
                                tabla += f.fechaToOUT(ss[i].fecha_a);
                                tabla += "' />";
                                tabla += "</td><td class='tablaCent'>";
                                tabla += "<input class='cell031 datepicker' type='text' onchange='cambiaFechB(this.value, this.id);' ondblclick='copiaB(this.value)' id='DATBI-" + pos + "' value='";
                                tabla += f.fechaToOUT(ss[i].fecha_b);
                                tabla += "' />";
                                tabla += "</td>";

                                tabla += "<td><input type='checkbox' id='chk-" + pos + "'";
                                if (ss[i].escala.Equals("X"))
                                {
                                    tabla += "checked disabled='disabled' /><input type='hidden' id='knumh-" + pos + "' value='" + ss[i].id + "' /><script>generaEscalas('" + ss[i].id + "', " + pos + ");</script></td>";
                                }
                                else
                                {
                                    tabla += " disabled='disabled' /><input type='hidden' id='knumh-" + pos + "' value='' /></td>";
                                }

                                tabla += "<td class='tablaCent'><input type='button' id='btn-" + pos + "' value='-' class='btn2' onclick='elimina(this.id)' /></td></tr>";

                                valores += ss[i].obj + "|" + ss[i].importe + "|" + ss[i].moneda + "|";
                                valores += ss[i].importe_n;
                                if (ss[i].moneda_n.Trim().Equals(""))
                                {
                                    valores += "|MXN|";
                                }
                                else
                                {
                                    valores += "|" + ss[i].moneda_n + "|";
                                }
                                valores           += f.fechaToOUT(ss[i].fecha_a) + "|" + f.fechaToOUT(ss[i].fecha_b) + "|" + ss[i].id + "|X|";
                                btnSubmit.Disabled = false;
                                valores           += ss[i].desc2 + "|";
                                if (!matkl.Trim().Equals(""))
                                {
                                    btnAgregar.Disabled = true;
                                }
                                else
                                {
                                    btnAgregar.Disabled = false;
                                }
                                btnCargar.Disabled = false;
                            }
                        }
                        else
                        {
                            if (!matkl.Trim().Equals(""))
                            {
                                tabla += "<tr id='tr-1'><td class='tablaCent' id='OBJ-1' ondblclick='escalas(this.id)'>";
                                tabla += "<input type='hidden' id='MATKL-1' value='" + matkl + "' />";
                                tabla += matkl;
                                tabla += "</td>";
                                tabla += "<td>";
                                tabla += con.columnaMatkl(matkl, "WGBEZ");
                                tabla += "</td>";
                                tabla += "<td>";
                                tabla += "<select  id='MEINS-1' class='cell031' style='width:40px;' onchange='cambiaMeins(this.id, this.value)' />";
                                tabla += formaMeins("M2", mei);
                                tabla += "</select>";
                                tabla += "</td>";
                                tabla += "<td>0.00</td><td></td>";
                                tabla += "<td class='tablaCent'><input class='cell031' type='text' onchange='cambiaCant(this.id)' id='KBETR-1' /></td>";
                                tabla += "<td class='tablaCent'><select class='cell031' onchange='cambiaMone(this)' id='KONWA-1'>";
                                tabla += formaMoneda("MXN", mon);
                                tabla += "</select></td>";
                                tabla += "<td class='tablaCent'><input class='cell031 datepicker' type='text' onchange='cambiaFechA(this.value, this.id);'  ondblclick='copiaA(this.value)' onblur='revisaFechaA(this.id);' id='DATAB-1' /></td>";
                                tabla += "<td class='tablaCent'><input class='cell031 datepicker' type='text' onchange='cambiaFechB(this.value, this.id)'  ondblclick='copiaB(this.value)' onblur='revisaFechaA(this.id);' id='DATBI-1' /></td>";

                                tabla += "<td><input type='checkbox' id='chk-1'";
                                tabla += " disabled='disabled' /><input type='hidden' id='knumh-1' value='' /></td>";

                                tabla += "<td class='tablaCent'><input type='button' id='chk-1' value='-' class='btn2' onclick='elimina(this.id)' /></td></tr>";

                                if (con.columnaMatkl(matkl, "WGBEZ").Equals(""))
                                {
                                    txtMATKL.Value = "";
                                    tabla          = "";
                                    txtPos.Value   = "0";
                                }
                                else
                                {
                                    btnAgregar.Disabled = true;
                                    btnSubmit.Disabled  = false;
                                    valores            += matkl + "|0.00||0.00|MXN||||X|M|";
                                    txtPos.Value        = "0";
                                }
                            }
                            else
                            {
                                btnAgregar.Disabled = false;
                                btnCargar.Disabled  = false;
                                txtPos.Value        = "0";
                            }
                        }
                        //else
                        //{
                        //    btnSubmit.Disabled = true;
                        //}

                        tabla += "</tbody></table>";

                        lblTabla.InnerHtml = tabla;
                        txtTabla.Value     = valores;
                    }
                }
            }
            catch (Exception ex)
            {
                //Response.Redirect("../../../Default.aspx");
                var page = HttpContext.Current.Handler as Page;
                if (page != null)
                {
                    page.ClientScript.RegisterClientScriptBlock(typeof(string), "Redirect", "window.parent.location='https://www.terzaonline.com/nworkflow/login/';", true);
                }
                //ClientScriptManager.RegisterClientScriptBlock(this.GetType(), "RedirectScript", "window.parent.location = '../../../Default.aspx'", true);
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            string folio = Request.QueryString["Folio"];

            try
            {
                hidUsuario.Value = Session["Usuario"].ToString();
                hidNumEmp.Value  = Session["NumEmp"].ToString();
                Conexion  con    = new Conexion();
                catalogos c      = new catalogos();
                IRfcTable header = con.consultaCabeceraL(folio, hidNumEmp.Value);
                IRfcTable detail = con.consultaDetalleL(folio, hidNumEmp.Value);
                meinss = con.meinss();
                List <SolicitudesL> ss = new List <SolicitudesL>();

                if (header.Count > 0)
                {
                    header.CurrentIndex = 0;
                    txtFolio.Value      = header.GetString("ID_SOLICITUD");
                    txtCOMM.InnerText   = header.GetString("COMMENTS");
                    tipo = header.GetString("TIPO");
                    string vkorg = header.GetString("VKORG");
                    string vtweg = header.GetString("VTWEG");
                    string spart = header.GetString("SPART");
                    string kunnr = header.GetString("KUNNR");
                    string pltyp = header.GetString("PLTYP");
                    string matnr = header.GetString("MATNR");

                    if (!vkorg.Equals(""))
                    {
                        txtVKORG.Value = vkorg + " " + con.ListaVKORG(vkorg, "").GetString("VTEXT");
                    }
                    if (!vtweg.Equals(""))
                    {
                        txtVTWEG.Value = vtweg + " " + con.ListaVTWEG(vtweg, "", "").GetString("VTEXT");
                    }
                    txtSPART.Value = spart + " " + con.ListaSPART(spart, "", "", "", "").GetString("VTEXT");

                    if (!kunnr.Equals(""))
                    {
                        IRfcTable kunn = con.getCliente(vkorg, vtweg, spart, kunnr);
                        if (kunn.Count > 0)
                        {
                            txtKUNNR.Value = kunnr + " " + con.getCliente(vkorg, vtweg, spart, kunnr).GetString("NAME1");
                        }
                    }
                    if (!pltyp.Equals(""))
                    {
                        txtPLTYP.Value = con.getLP_Desc("", pltyp);
                    }
                    if (!matnr.Equals(""))
                    {
                        txtMATNR.Value = matnr + " " + con.columnaMatnr(matnr, "MAKTG", "X");
                    }
                    txtPORC.Value = header.GetString("PORCENTAJE") + " %";

                    string obj    = "";
                    string titulo = "";
                    if (tipo.Substring(1, 1).Equals("M"))
                    {
                        obj    = "MATNR";
                        titulo = "Material";
                    }
                    else if (tipo.Substring(1, 1).Equals("G"))
                    {
                        obj    = "MATKL";
                        titulo = "Grupo de artículos";
                    }
                    else if (tipo.Substring(1, 1).Equals("P"))
                    {
                        obj    = "EBELN";
                        titulo = "Pedido de cliente";
                    }
                    else if (tipo.Substring(1, 1).Equals("L"))
                    {
                        obj    = "CHARG";
                        titulo = "Lote";
                    }

                    for (int i = 0; i < detail.Count; i++)
                    {
                        detail.CurrentIndex = i;
                        SolicitudesL s = new SolicitudesL();
                        s.obj = detail.GetString(obj);
                        //s.desc = detail.GetString("VTWEG");
                        s.desc2      = detail.GetString("MEINS");
                        s.importe    = detail.GetString("PR_ANT");
                        s.moneda     = detail.GetString("MON_ANT");
                        s.importe_n  = detail.GetString("PR_NVO");
                        s.moneda_n   = detail.GetString("MON_NVO");
                        s.fecha_a    = f.fecha(detail.GetString("FECHA_INI"));
                        s.fecha_b    = f.fecha(detail.GetString("FECHA_FIN"));
                        s.comentario = detail.GetString("COMMENTS");
                        s.escala     = detail.GetString("ESCALA");
                        s.pos        = detail.GetString("POS");;


                        //if (tipo.Substring(1, 1).Equals("M"))
                        //{
                        //    s.desc = con.columnaMatnr(s.obj, "MAKTG");
                        //    s.desc2 = con.columnaMatnr(s.obj, "MEINS");
                        //}
                        //else if (tipo.Substring(1, 1).Equals("G"))
                        //{
                        //    s.desc = con.columnaMatkl(s.obj, "WGBEZ");
                        //}

                        ss.Add(s);
                    }

                    ss = obtenerDatos(ss, tipo.Substring(1, 1));
                    string tab = "";

                    tab  = "<table border='0' style='border-width: 0px; border-style: None; width: 100%; border-collapse: collapse;'><tbody>";
                    tab += "<tr>";
                    tab += "<td class='tablahead'>" + titulo + "</td>";
                    if (!tipo.Substring(1, 1).Equals("P") & !tipo.Substring(1, 1).Equals("L"))
                    {
                        tab += "<td class='tablahead'>Denominación</td>";
                    }
                    //if (tipo.Substring(1, 1).Equals("M"))
                    tab += "<td class='tablahead'>Unidad</td>";
                    tab += "<td class='tablahead'>Precio Anterior</td>";
                    tab += "<td class='tablahead'>Moneda</td>";
                    tab += "<td class='tablahead'>Precio nuevo</td>";
                    tab += "<td class='tablahead'>Moneda</td>";
                    tab += "<td class='tablahead'>Válido de</td>";
                    tab += "<td class='tablahead'>Válido a</td>";
                    if (tipo.Substring(1, 1).Equals("L"))
                    {
                        tab += "<td class='tablahead'>Comentario</td>";
                    }
                    tab += "<td class='tablahead'>E</td>";
                    tab += "</tr>";
                    foreach (SolicitudesL s in ss)
                    {
                        string style = "";
                        if (s.error)
                        {
                            style = "background-color: red !important;";
                        }

                        tab += "<tr style='" + style + "' id='tr-" + s.pos + "' ondblclick='escalas(this.id)'>";

                        if (s.error)
                        {
                            style = "white-text";
                        }
                        tab += "<td class='tablaCent " + style + "'>" + s.obj + "</td>";
                        if (!tipo.Substring(1, 1).Equals("P") & !tipo.Substring(1, 1).Equals("L"))
                        {
                            tab += "<td class='tablaIzq " + style + "'>" + s.desc + "</td>";
                        }
                        //if (tipo.Substring(1, 1).Equals("M"))
                        tab += "<td class='tablaCent " + style + "' id='MEINS-" + s.pos + "'>" + MeinsEsp(s.desc2) + "</td>";
                        tab += "<td class='tablaCent " + style + "'>" + s.importe + "</td>";
                        tab += "<td class='tablaCent " + style + "'>" + s.moneda + "</td>";
                        tab += "<td class='tablaCent " + style + "'>" + s.importe_n + "</td>";
                        tab += "<td class='tablaCent " + style + "' id='KONWA-" + s.pos + "'>" + s.moneda_n + "</td>";
                        tab += "<td class='tablaCent " + style + "'>" + s.fecha_a.ToString("dd/MM/yyyy") + "</td>";
                        tab += "<td class='tablaCent " + style + "'>" + s.fecha_b.ToString("dd/MM/yyyy") + "</td>";
                        if (tipo.Substring(1, 1).Equals("L"))
                        {
                            tab += "<td class='tablaCent " + style + "'>" + s.comentario + "</td>";
                        }
                        if (s.escala.Equals("X"))
                        {
                            tab += "<td><input type='checkbox' checked disabled id='chk-" + s.pos + "'/></td>";
                        }
                        else
                        {
                            tab += "<td><input type='checkbox' disabled id='chk-" + s.pos + "'/></td>";
                        }
                        tab += "</tr>";
                    }
                    tab += "</tbody></table>";
                    lblTabla.InnerHtml = tab;

                    IRfcTable bitacora = con.getBitacora("02", folio);
                    string    tabla    = "";

                    tabla  = "<table border='0' style='border-width: 0px; border-style: None; width: 100%; border-collapse: collapse;'><tbody>";
                    tabla += "<tr><td class='cell12'>Empleado</td><td class='cell12'>Evento</td><td class='cell12'>Fecha autorizar</td><td class='cell12'>Fecha Procesada</td><td class='cell12'>Status</td><td class='cell12'>Comentario</td></tr>";

                    for (int i = 0; i < bitacora.Count; i++)
                    {
                        bitacora.CurrentIndex = i;
                        tabla += "<tr><td class='cell17'>";
                        tabla += bitacora.GetString("ZUSRA") + " - " + bitacora.GetString("ZDUSA");
                        tabla += "</td>";
                        tabla += "<td class='cell18'>";
                        tabla += bitacora.GetString("ZDEEV");
                        tabla += "</td>";
                        tabla += "<td class='cell18'>";
                        tabla += bitacora.GetString("ZFEAL") + "[" + bitacora.GetString("ZHOAL") + "]";
                        tabla += "</td>";
                        tabla += "<td class='cell18'>";
                        tabla += bitacora.GetString("ZFEUM") + "[" + bitacora.GetString("ZHOUM") + "]";
                        tabla += "</td>";
                        tabla += "<td class='cell18'>";
                        tabla += bitacora.GetString("ZSWAR");
                        tabla += "</td>";
                        tabla += "<td class='cell18' style='max-width:200px;overflow-y:hidden;'>";
                        tabla += bitacora.GetString("ZCOME");
                        //tabla += "sad ads fas a s fasifu sa disad iasduasdiasud a sdaiud asi duiasdhasoidha soih sad sahdjashdiusahd sa ";
                        tabla += "</td>";
                        tabla += "</tr>";
                    }

                    lblBItacora.InnerHtml = tabla;
                }
                else
                {
                    Response.Redirect("Default.aspx", false);
                }
            }
            catch (Exception ex)
            {
                Response.Redirect("https://www.terzaonline.com/nworkflow/login/");
            }
        }
Exemple #4
0
        protected void Page_Load(object sender, EventArgs e)
        {
            //string[] tabla = Request.Form["txtTabla"].Split('|');
            //string tipo = Request.Form["txtTipo"];
            //List<SolicitudesL> solicitud = new List<SolicitudesL>();
            string[]            tabla     = Request.Form["txtTabla"].Split('|');
            string[]            escalas   = Request.Form["txtEscalas"].Split('|');
            string              tipo      = Request.Form["txtTipo"];
            List <SolicitudesL> solicitud = new List <SolicitudesL>();
            List <Escala>       escala    = new List <Escala>();

            int longitud = 0;

            //if (tipo.Equals("1") | tipo.Equals("2"))
            //{
            longitud = 9;
            longitud = 10; //ADD RSG 23.05.2017
            //}

            for (int i = 0; i < tabla.Length - 1; i += longitud)
            {
                SolicitudesL s = new SolicitudesL();
                s.obj       = tabla[i];
                s.importe   = tabla[i + 1];
                s.moneda    = tabla[i + 2];
                s.importe_n = tabla[i + 3];
                s.moneda_n  = tabla[i + 4];
                s.fecha_a   = f.fechaD(tabla[i + 5]);
                s.fecha_b   = f.fechaD(tabla[i + 6]);
                s.id        = tabla[i + 7];
                s.modif     = tabla[i + 8];
                s.desc2     = tabla[i + 9];

                solicitud.Add(s);
            }
            for (int i = 0; i < escalas.Length - 1; i += 6)
            {
                Escala s = new Escala();

                s.obj      = escalas[i];
                s.id       = escalas[i + 1];
                s.pos      = escalas[i + 2];
                s.cantidad = escalas[i + 3];
                s.importe  = escalas[i + 4];
                s.meins    = escalas[i + 5];

                //ADD RSG 10.08.2018 ----------------------------------------------
                foreach (SolicitudesL ss in solicitud)
                {
                    if (ss.obj == s.obj)
                    {
                        escala.Add(s);
                        break;
                    }
                }
                //ADD RSG 10.08.2018----------------------------------------------

                //escala.Add(s); //DELETE RSG 10.08.2018----------------------------------------------
            }
            Conexion  con = new Conexion();
            CabeceraL c   = new CabeceraL();

            c.folio = "";
            switch (tipo)
            {
            case "1":
                c.tipo = "CM";
                break;

            case "2":
                c.tipo = "SM";
                break;

            case "3":
                c.tipo = "CG";
                break;

            case "4":
                c.tipo = "LM";
                break;

            case "5":
                c.tipo = "LG";
                break;

            case "6":
                c.tipo = "SG";
                break;
            }

            c.fecha   = f.fechaToSAP(DateTime.Now);
            c.hora    = f.hora(DateTime.Now);
            c.usuario = Request.Form["hidUsuario"];
            c.pernr   = Request.Form["hidNumEmp"];
            c.estatus = "P";
            c.visto   = " ";
            string comentarios = Request.Form["txtCOMM"];

            c.comentario = comentarios;

            string p_inc = Request.Form["P_inc"];
            string p_dec = "";

            if (p_inc.Equals(""))
            {
                p_dec = "-" + Request.Form["P_dec"];
            }

            string cambio = p_inc + p_dec;

            c.porcentaje = cambio;

            c.spart = Request.Form["txtSPART"];

            if (tipo.Equals("1") | tipo.Equals("3"))
            {
                c.vkorg = Request.Form["txtVKORG"];
                c.vtweg = Request.Form["txtVTWEG"];
                c.kunnr = Request.Form["txtKUNNR"];
            }
            else if (tipo.Equals("4") | tipo.Equals("5"))
            {
                c.vkorg = Request.Form["txtVKORG"];
                c.vtweg = Request.Form["txtVTWEG"];
                c.pltyp = Request.Form["txtPLTYP"].Split(' ')[0];
            }

            List <DetalleL> ds = new List <DetalleL>();

            for (int i = 0; i < solicitud.Count; i++)
            {
                DetalleL d = new DetalleL();
                d.folio   = "";
                d.pos     = i + 1;
                d.estatus = " ";
                if (tipo.Equals("1") | tipo.Equals("2") | tipo.Equals("4"))
                {
                    d.matnr = solicitud[i].obj;
                }
                else
                {
                    d.matkl = solicitud[i].obj;
                }
                d.pr_ant     = solicitud[i].importe;
                d.mon_ant    = solicitud[i].moneda;
                d.pr_nvo     = solicitud[i].importe_n;
                d.mon_nvo    = solicitud[i].moneda_n;
                d.porcentaje = Request.Form["P_inc"];
                if (d.porcentaje == null)
                {
                    d.porcentaje = "-" + Request.Form["P_dec"];
                }
                d.date  = f.fechaToSAP(solicitud[i].fecha_a);
                d.dateA = f.fechaToSAP(solicitud[i].fecha_b);
                d.knumh = solicitud[i].id;
                d.meins = solicitud[i].desc2.ToUpper(); //ADD RSG 23.05.2017
                ds.Add(d);

                //ADD RSG 10.08.2018 ----------------------------------------------
                foreach (Escala ss in escala)
                {
                    if (tipo.Equals("1") | tipo.Equals("2") | tipo.Equals("4"))
                    {
                        if (ss.obj == d.matnr)
                        {
                            ss.id = d.pos + "";
                        }
                    }
                    else
                    {
                        if (ss.obj == d.matkl)
                        {
                            ss.id = d.pos + "";
                        }
                    }
                }
                //ADD RSG 10.08.2018----------------------------------------------
            }


            //string folio = con.InsertaSolicitudL(c, ds);
            //lblFolio.InnerHtml = "<p class=''>" + folio + "</p>";
            string folio = con.InsertaSolicitudL(c, ds, escala);

            if (!folio.Equals(""))
            {
                folio = "La solicitud de modificación de Listas de precio ha sido recibida, y será procesada con el folio<br />" + folio;
            }
            else
            {
                folio = "Hubo un error en la creación de la Solicitud.";
            }
            lblFolio.InnerHtml = "<p class=''>" + folio + "</p>";
        }
Exemple #5
0
        private List <SolicitudesL> formarSolicitud(DataTable tbl, string t)
        {
            List <SolicitudesL> ss = new List <SolicitudesL>();

            int columnas = 0;

            if (t.Equals("2"))
            {
                columnas = 7;
                columnas = 13;//ADD RSG 15.05.2017
            }
            else
            {
                columnas = 9;
                columnas = 15;//ADD RSG 15.05.2017
            }

            if (tbl.Columns.Count == columnas)
            {
                foreach (DataRow row in tbl.Rows)
                {
                    for (int i = 0; i < tbl.Columns.Count; i += columnas)
                    {
                        DataColumnCollection columns = tbl.Columns;

                        SolicitudesL s = new SolicitudesL();
                        s.obj       = row[columns[i + (columnas - 11)]].ToString();
                        s.desc2     = MeinsValor(row[columns[i + (columnas - 10)]].ToString().ToUpper());
                        s.importe_n = row[columns[i + (columnas - 9)]].ToString();
                        s.moneda_n  = row[columns[i + (columnas - 8)]].ToString().ToUpper();
                        string fecha_A = row[columns[i + (columnas - 7)]].ToString();
                        string fecha_B = row[columns[i + (columnas - 6)]].ToString();
                        s.escala = row[columns[i + (columnas - 5)]].ToString();
                        s.menge  = row[columns[i + (columnas - 4)]].ToString();
                        s.um1    = MeinsValor(row[columns[i + (columnas - 3)]].ToString().ToUpper());
                        s.kbetr  = row[columns[i + (columnas - 2)]].ToString();
                        s.um2    = MeinsValor(row[columns[i + (columnas - 1)]].ToString().ToUpper());
                        if (s.escala.Equals("X"))
                        {
                            s.desc2     = s.um2;
                            s.importe_n = s.kbetr;
                        }//END RSG 15.05.2017

                        if (!s.obj.Trim().Equals("") & !fecha_A.Trim().Equals("") & !fecha_B.Trim().Equals(""))
                        {
                            s.fecha_a = f.fechaD(fecha_A);
                            s.fecha_b = f.fechaD(fecha_B);
                            ss.Add(s);
                        }
                    }
                }

                List <SolicitudesL> sol_final = quitarRepetidos(ss);
                ss = sol_final;

                foreach (SolicitudesL s in ss)
                {
                    //if (s.desc.Equals(""))
                    //{
                    //    s.error = true;
                    //    s.tipo_error = "1";
                    //}
                    if (s.fecha_a > s.fecha_b)
                    {
                        s.error      = true;
                        s.tipo_error = "4";
                    }

                    //VERIFICAR SI ES CANTIDAD
                    if (!esCantidad(s.importe_n))
                    {
                        s.error = true;
                    }

                    //VERIFICAR SI LA MONEDA EXISTE
                    if (!existeMoneda(s.moneda_n))
                    {
                        s.error = true;
                    }
                }
            }
            return(ss);
        }