public List <eOrdenDespacho> OrdenDespacho_ListarOrdenAll()
        {
            SqlCommand cmd = new SqlCommand("usp_tb_orden_despachoSelectAll");

            cmd.CommandType = CommandType.StoredProcedure;

            SqlDataReader         reader         = ExecuteReader(cmd);
            List <eOrdenDespacho> lOrdenDespacho = new List <eOrdenDespacho>();

            while (reader.Read())
            {
                eOrdenDespacho oOrdenDespacho = new eOrdenDespacho();
                oOrdenDespacho.CodigoOrdenDespacho          = ((!reader[0].Equals(DBNull.Value)) ? reader.GetString(0) : "");
                oOrdenDespacho.EstadoOrdenDespacho          = ((!reader[1].Equals(DBNull.Value)) ? reader.GetString(1) : "");
                oOrdenDespacho.TipoComprobanteOrdenDespacho = ((!reader[2].Equals(DBNull.Value)) ? reader.GetString(2) : "");
                oOrdenDespacho.FechaEstimadaRecojo          = ((!reader[3].Equals(DBNull.Value)) ? reader.GetDateTime(3) : DateTime.Today);
                oOrdenDespacho.CodigoOrden         = ((!reader[4].Equals(DBNull.Value)) ? reader.GetString(4) : "");
                oOrdenDespacho.CodigoDespacho      = ((!reader[5].Equals(DBNull.Value)) ? reader.GetInt32(5) : 0);
                oOrdenDespacho.RazonSocialDespacho = ((!reader[6].Equals(DBNull.Value)) ? reader.GetString(6) : "");
                oOrdenDespacho.RucDespacho         = ((!reader[7].Equals(DBNull.Value)) ? reader.GetString(7) : "");
                lOrdenDespacho.Add(oOrdenDespacho);
            }
            reader.Close();
            return(lOrdenDespacho);
        }
        public eOrdenDespacho OrdenDespacho_ListarOrden(string codigo_orden)
        {
            SqlCommand cmd = new SqlCommand("usp_tb_orden_despachoSelect");

            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.Add("@codigo_orden", SqlDbType.VarChar).Value = codigo_orden;

            SqlDataReader  reader         = ExecuteReader(cmd);
            eOrdenDespacho oOrdenDespacho = new eOrdenDespacho();

            if (reader.Read())
            {
                oOrdenDespacho.CodigoOrdenDespacho          = ((!reader[0].Equals(DBNull.Value)) ? reader.GetString(0) : "");
                oOrdenDespacho.EstadoOrdenDespacho          = ((!reader[1].Equals(DBNull.Value)) ? reader.GetString(1) : "");
                oOrdenDespacho.TipoComprobanteOrdenDespacho = ((!reader[2].Equals(DBNull.Value)) ? reader.GetString(2) : "");
                oOrdenDespacho.FechaEstimadaRecojo          = ((!reader[3].Equals(DBNull.Value)) ? reader.GetDateTime(3) : DateTime.Today);
                oOrdenDespacho.CodigoOrden         = ((!reader[4].Equals(DBNull.Value)) ? reader.GetString(4) : "");
                oOrdenDespacho.CodigoDespacho      = ((!reader[5].Equals(DBNull.Value)) ? reader.GetInt32(5) : 0);
                oOrdenDespacho.RazonSocialDespacho = ((!reader[6].Equals(DBNull.Value)) ? reader.GetString(6) : "");
                oOrdenDespacho.RucDespacho         = ((!reader[7].Equals(DBNull.Value)) ? reader.GetString(7) : "");
            }
            reader.Close();

            return(oOrdenDespacho);
        }
示例#3
0
        public void ActualizarComprobante()
        {
            oOrdenDespacho = cCMS.OrdenDespacho_ListarOrden(codigoOrden);
            oOrdenEntrega  = cCMS.OrdenEntrega_ListarOrden(codigoOrden);

            string despachado = (oOrdenDespacho.CodigoDespacho != 0) ? "despacho" : "entrega";

            //cambiarle el estado al tipo de comprobante
            switch (despachado)
            {
            case "despacho":
                oOrdenDespacho.TipoComprobanteOrdenDespacho = comprobante;
                oOrdenDespacho.RucDespacho         = ruc;
                oOrdenDespacho.RazonSocialDespacho = razon_social;
                cCMS.Update_OrdenDespachoRUC(oOrdenDespacho);
                break;

            case "entrega":
                oOrdenEntrega.TipoComprobanteOrdenEntrega = comprobante;
                oOrdenEntrega.RazonSocialEntrega          = razon_social;
                oOrdenEntrega.RucEntrega = ruc;
                cCMS.Update_OrdenEntregaRUC(oOrdenEntrega);
                break;
            }
        }
        public int OrdenDespacho_Add(eOrdenDespacho oOrdenDespacho)
        {
            int addNew = 0;

            IdException = cOrdenDespacho.Insert(oOrdenDespacho);
            if (IdException == 0)
            {
                addNew = cOrdenDespacho.getLastID;
            }
            return(addNew);
        }
        public int Update_OrdenDespachoRUC(eOrdenDespacho oOrdenDespacho)
        {
            SqlCommand cmd = new SqlCommand("usp_tb_orden_despachoUpdateRUC");

            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.Add("@codigo_orden_despacho", SqlDbType.VarChar, 100).Value           = oOrdenDespacho.CodigoOrdenDespacho;
            cmd.Parameters.Add("@ruc_despacho", SqlDbType.VarChar, 100).Value                    = oOrdenDespacho.RucDespacho;
            cmd.Parameters.Add("@razon_despacho", SqlDbType.VarChar, 100).Value                  = oOrdenDespacho.RazonSocialDespacho;
            cmd.Parameters.Add("@tipo_comprobante_orden_despacho", SqlDbType.VarChar, 100).Value = oOrdenDespacho.TipoComprobanteOrdenDespacho;

            return(UpdateCommand(cmd));
        }
        public int Update_OrdenDespacho(eOrdenDespacho oOrdenDespacho)
        {
            SqlCommand cmd = new SqlCommand("usp_tb_orden_despachoUpdate");

            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.Add("@codigo_orden_despacho", SqlDbType.VarChar, 100).Value           = oOrdenDespacho.CodigoOrdenDespacho;
            cmd.Parameters.Add("@estado_orden_despacho", SqlDbType.VarChar, 100).Value           = oOrdenDespacho.EstadoOrdenDespacho;
            cmd.Parameters.Add("@tipo_comprobante_orden_despacho", SqlDbType.VarChar, 100).Value = oOrdenDespacho.TipoComprobanteOrdenDespacho;
            cmd.Parameters.Add("@fecha_estimada_recojo", SqlDbType.DateTime).Value = oOrdenDespacho.FechaEstimadaRecojo;
            cmd.Parameters.Add("@codigo_orden", SqlDbType.VarChar, 100).Value      = oOrdenDespacho.CodigoOrden;
            cmd.Parameters.Add("@codigo_despacho", SqlDbType.Int).Value            = oOrdenDespacho.CodigoDespacho;

            return(UpdateCommand(cmd));
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            codigoDeComercioSoles   = ConfigurationManager.AppSettings["codigoComercioSoles"].ToString();
            codigoDeComercioDolares = ConfigurationManager.AppSettings["codigoComercioDolares"].ToString();

            if (!Page.IsPostBack)
            {
                //eticket recuperado de visanet

                /*
                 * para pasarlo a produccion poner Request.Form
                 * */

                eTicket = (Request["ETICKET"] != null) ? Request.Form["ETICKET"].ToString() : "";

                string[] parts = eTicket.Split(new char[] { ',' });

                eTicket = parts[0];

                Trace.Warn("ETICKET", eTicket);
                eOrden oOrdenETicket = new eOrden();
                oOrdenETicket        = cCMS.Orden_itemETicket(eTicket);
                codigoComercioMoneda = (oOrdenETicket.MonedaOrden == "Soles") ? codigoDeComercioSoles : codigoDeComercioDolares;
                oPagoConsulta        = ConsultarEstadoPedido(eTicket, codigoComercioMoneda);
                /* DFC 20150306 Mapping moneda pago*/
                oPagoConsulta.MonedaPago = oOrdenETicket.MonedaOrden;

                //codigoOrden = (Request["codigoOrden"] != null) ? Request["codigoOrden"] : "";
                codigoOrden = oPagoConsulta.NumOtPago;
                if (codigoOrden == "")
                {
                    Response.Redirect("" + url_root + "producto_compras");
                }

                eOrden oOrden = new eOrden();
                oOrden = cCMS.Orden_item(codigoOrden);

                oUsuarioWeb = (oOrden.CodigoOrden != null) ? cCMS.UsuariosWeb_item(oOrden.IdUsuario) : null;
                if (oUsuarioWeb == null)
                {
                    Response.Redirect("" + url_root + "cuenta");
                }

                lOrdenProducto = cCMS.Producto_HistorialPedidos(codigoOrden);
                if (lOrdenProducto.Count == 0)
                {
                    Response.Redirect("" + url_root);
                }

                StringBuilder sb = new StringBuilder();
                if (oPagoConsulta.RespuestaPago == "1")
                {
                    eOrdenEntrega  oOrdenEntrega  = new eOrdenEntrega();
                    eOrdenDespacho oOrdenDespacho = new eOrdenDespacho();

                    cCMS.ActualizarEstadoOrden(oOrden.TipoOrden, Int32.Parse(codigoOrden));

                    imgIcono.ImageUrl    = "~/images/ico_gracias.png";
                    litTitulo.Text       = "Gracias por comprar en Ferreyshop";
                    divHistorial.Visible = true;

                    sb.Append("<ul>\n");
                    sb.Append("<li><strong>Número pedido:</strong> " + oPagoConsulta.NumOtPago + "</li>\n");
                    sb.Append("<li><strong>Nombre:</strong> " + oPagoConsulta.NombrePago + "</li>\n");
                    sb.Append("<li><strong>Número de Tarjeta enmascarada:</strong> " + oPagoConsulta.NumTarjetaPan + "</li>\n");
                    sb.Append("<li><strong>Fecha y hora del pedido:</strong> " + oPagoConsulta.FechaYHoraPago.ToString() + "</li>\n");
                    sb.Append("<li><strong>Importe:</strong> " + oPagoConsulta.ImpTotal + "</li>\n");
                    sb.Append("<li><strong>Moneda:</strong> " + oPagoConsulta.MonedaPago + "</li>\n");
                    sb.Append("<li><strong>Descripción:</strong> " + GetProductos() + "</li>\n");
                    sb.Append("</ul>\n");

                    litDetalleTrans.Text = sb.ToString();
                    EnviarCorreo(codigoOrden); //Enviar mail al usuario y webmaster
                    ValidarStock();

                    Session["carrito"] = null;
                }
                else
                {
                    imgIcono.ImageUrl    = "~/images/ico_error.png";
                    litTitulo.Text       = "Orden de compra no procesada";
                    divHistorial.Visible = false;

                    sb.Append("<ul>\n");
                    sb.Append("<li><strong>Número pedido:</strong> " + oPagoConsulta.NumOtPago + "</li>\n");
                    sb.Append("<li><strong>Fecha y hora del pedido:</strong> " + oPagoConsulta.FechaYHoraPago.ToString() + "</li>\n");
                    sb.Append("<li><strong>Motivo:</strong> " + VisaNet.MensajeError(oPagoConsulta.CodigoAccion) + "</li>\n");
                    sb.Append("</ul>\n");
                    litDetalleTrans.Text = sb.ToString();
                }
            }
        }
示例#8
0
        private void BindControl()
        {
            decimal monto_total = 0;

            rblMoneda.Items.Add(new ListItem("Soles", "1"));
            rblMoneda.Items.Add(new ListItem("Dólares", "2"));
            rblMoneda.Items[1].Selected = true;

            #region validarProductos
            //validar producto

            lCarritoSave = cCMS.Carrito_itemEmail(oUsuarioWeb.id_usuario);
            foreach (var item in lCarritoSave)
            {
                eProducto oProducto = new eProducto();
                oProducto.IDProducto     = item.IdProducto;
                oProducto.ImagenChica    = item.ImagenCarrito;
                oProducto.ModeloProducto = item.NombreProductoCarrito;
                eProducto oProductoss = new eProducto();
                oProductoss = cCMS.Producto_item(item.IdProducto);
                string  stockMinimo = cCMS.ParametroAlias(5);
                int     stockMin    = Convert.ToInt32(stockMinimo);
                int     IgvInt      = Convert.ToInt32(cCMS.ParametroAlias(4).Replace("%", ""));
                string  IgvString   = "1." + IgvInt.ToString();
                decimal igv         = Convert.ToDecimal(IgvString);
                oProducto.PrecioProducto   = (oProductoss.StockProducto <= stockMin) ? 0 : decimal.Round((oProductoss.PrecioProducto * igv != item.PrecioProducto) ? oProductoss.PrecioProducto * igv : item.PrecioProducto, 2);
                oProducto.CantidadProducto = (oProductoss.StockProducto <= stockMin) ? 0 : item.CantidadProducto;
                //oProducto.CantidadProducto = item.CantidadProducto;
                //oProducto.PrecioProducto = item.PrecioProducto;
                oProducto.DescripcionProducto = item.DescripcionProducto;

                eProducto oProductoActivo = new eProducto();
                oProductoActivo  = cCMS.Producto_item(oProducto.IDProducto);
                oProducto.Activo = oProductoActivo.Activo;
                oProducto.IdProductoCategoria = oProductoActivo.IdProductoCategoria;
                lProducto.Add(oProducto);
            }

            for (int i = 0; i < lProducto.Count; i++)
            {
                /***********************************************/
                //validar si los padres no están inactivos
                eArticulo oArticulos     = cCMS.Articulo_item(lProducto[i].IdProductoCategoria);
                eArticulo oArticuloPadre = cCMS.Articulo_item(oArticulos.IdArticuloPadre);

                if (lProducto[i].CantidadProducto != 0 && lProducto[i].Activo && oArticulos.Activo & oArticuloPadre.Activo)
                {
                    decimal subtotal        = lProducto[i].PrecioProducto * lProducto[i].CantidadProducto;
                    string  precioDecimal   = Convert.ToDouble(lProducto[i].PrecioProducto).ToString("N", CultureInfo.InvariantCulture);
                    string  subtotalDecimal = Convert.ToDouble(subtotal).ToString("N", CultureInfo.InvariantCulture);
                    monto_total += subtotal;

                    litProductos.Text += "	<li>"+
                                         "    <div class=\"producto_entrega\">" +
                                         "        <figure><img src=\"" + url_root + Directorio.Pagina_Imagen + lProducto[i].ImagenChica + "\"></figure>" +
                                         "        <blockquote>" +
                                         "		    <h2>"+ lProducto[i].ModeloProducto + "</h2>" +
                                         "	        <p>"+ lProducto[i].DescripcionProducto + "</p>" +
                                         "        </blockquote>" +
                                         "    </div>" +
                                         "    <div class=\"precios\">" +
                                         "        <span>US$." + precioDecimal.ToString() + "</span>" +
                                         "    </div>" +
                                         "    <div class=\"cantidades\">" +
                                         "        <span>" + lProducto[i].CantidadProducto + "</span>" +
                                         "    </div>" +
                                         "    <div class=\"subtotales\">" +
                                         "        <span>US$." + subtotalDecimal + "</span>" +
                                         "    </div>" +
                                         "</li> ";
                }
            }

            //valida si se actualizó el stock y no hay nada
            if (monto_total == 0)
            {
                Response.Redirect(url_root + "producto_compras");
            }

            oOrden.FechaOrden        = DateTime.Now;
            oOrden.EmailUsuarioOrden = oUsuarioWeb.email_usuario;
            oOrden.IdUsuario         = oUsuarioWeb.id_usuario;

            eOrden oOrdenUltima = cCMS.OrdenUltima(oUsuarioWeb.id_usuario);

            if (oOrdenUltima.CodigoOrden != null)
            {
                oOrden.CodigoOrden = oOrdenUltima.CodigoOrden;
                cCMS.Orden_Limpiar(oOrden.CodigoOrden, oOrden.FechaOrden);
            }
            else
            {
                oOrden.CodigoOrden = cCMS.Orden_add(oOrden);
                RegistrarLogsCms(oUsuarioWeb.id_usuario, "Se agregó un registro a la tabla tb_orden con código de orden : " + codigoOrden);
            }

            if (oOrden.CodigoOrden.Equals(""))
            {
                Session["codigoOrden"] = null;
                Response.Redirect(url_root + "producto_compras?error=no_genero_codigo");
                return;
            }

            string  costoEnvio      = cCMS.ParametroAlias(1);         // (cCMS.ParametroAlias(1) != null) ? cCMS.ParametroAlias(1) : "";
            decimal tipCambio       = cCMS.ObtenerTipoCambioUltimo(); //(cCMS.ObtenerTipoCambioUltimo() != null) ? cCMS.ObtenerTipoCambioUltimo() : 0;
            bool    es_trabajador   = cCMS.ValidarTrabajador(oUsuarioWeb.descripcion_documento_identidad_usuario);
            decimal monto_descuento = OrdenDescuento.AplicarDescuentos(oOrden.CodigoOrden, es_trabajador, monto_total);
            decimal total_descuento = monto_total - monto_descuento;
            decimal totalSoles      = total_descuento == 0 ? monto_total * tipCambio : (total_descuento * tipCambio);
            decimal totalDolares    = total_descuento == 0 ? monto_total : total_descuento;
            totalSoles   = decimal.Round(totalSoles, 2);
            totalDolares = decimal.Round(totalDolares, 2);
            codigoOrden  = oOrden.CodigoOrden;

            if (monto_descuento > 0)
            {
                litDescuento.Text            = Convert.ToDouble(monto_descuento).ToString("N", CultureInfo.InvariantCulture).ToString(); //decimal.Round(dscto_total, 2).ToString();
                litDescuentoDescripcion.Text = " (" + OrdenDescuento.DescuentosAplicadosDescripcion() + ")";
                trDescuento.Visible          = true;
            }

            if (es_trabajador)
            {
                rblElementos.Items.Add(new ListItem("Boleta", "1"));
                rblElementos.Items[0].Selected = true;
            }
            else
            {
                rblElementos.Items.Add(new ListItem("Boleta", "1"));
                rblElementos.Items.Add(new ListItem("Factura", "2"));
                rblElementos.Items[0].Selected = true;

                if (oUsuarioWeb.estado_trabajador == 1)
                {
                    Response.Redirect(url_root + "registro?action=Edit");
                }
            }

            decimal gastoenvio = 0;
            if (cCMS.Orden_UpdateMontoCostoTotal(codigoOrden, monto_total, gastoenvio, totalDolares, monto_descuento, tipCambio))
            {
                RegistrarLogsCms(oUsuarioWeb.id_usuario, "Se agregó a la orden : " + codigoOrden + " los campos subtotal, gasto envio y total");
            }

            litTotal.Text        = Convert.ToDouble(totalSoles).ToString("N", CultureInfo.InvariantCulture).ToString();
            litTotalDolares.Text = Convert.ToDouble(totalDolares).ToString("N", CultureInfo.InvariantCulture).ToString();
            litTipoCambio.Text   = tipCambio.ToString();

            #endregion


            //registrar en tb_orden_producto
            foreach (var item in lProducto)
            {
                /***********************************************/
                //validar si los padres no están inactivos
                eProducto oProductoActive = new eProducto();
                oProductoActive = cCMS.Producto_item(item.IDProducto);
                eArticulo oArticulos     = cCMS.Articulo_item(oProductoActive.IdProductoCategoria);
                eArticulo oArticuloPadre = cCMS.Articulo_item(oArticulos.IdArticuloPadre);

                if (oProductoActive.Activo && oArticulos.Activo && oArticuloPadre.Activo)
                {
                    eOrdenProducto oOrdenProducto = new eOrdenProducto();
                    eProducto      oProd          = new eProducto();
                    oOrdenProducto.CodigoOrden           = oOrden.CodigoOrden;
                    oOrdenProducto.IdProducto            = item.IDProducto;
                    oOrdenProducto.CantidadOrdenProducto = item.CantidadProducto;
                    oOrdenProducto.TipoOrdenProducto     = 1; // boleta
                    oProd.PrecioProducto     = item.PrecioProducto;
                    oOrdenProducto.eProducto = oProd;
                    int agregarOrdenProducto = cCMS.OrdenProducto_Add(oOrdenProducto);
                    RegistrarLogsCms(oUsuarioWeb.id_usuario, "Se agregó un registro a la tabla tb_orden_productos con código de orden : " + oOrden.CodigoOrden + " y id de producto: " + item.IDProducto);
                }
            }

            //validar direccion de despacho
            string despacho = (Request["despacho"] != null) ? Request["despacho"] : "";
            string recojo   = (Request["recojo"] != null) ? Request["recojo"] : "";

            if (despacho == "" && recojo == "")
            {
                if (DirDespacho.Text == "" && DirRecojo.Text == "")
                {
                    Response.Redirect("" + url_root + "direccion");
                }
                else
                {
                    despacho = DirDespacho.Text;
                    recojo   = DirRecojo.Text;
                }
            }
            if (despacho == "")
            {
                tipoDireccion = 1;
                //en caso sea una direccion de recojo
                string codigo_recojo = recojo;
                //hplPagar.Attributes.Add("rel",url_root + "confirmacion_visanet?recojo=" + codigo_recojo);
                oDireccionEntrega = cCMS.Entrega_Listar(codigo_recojo);
                //valida que el codigo exista
                if (oDireccionEntrega == null)
                {
                    Response.Redirect("" + url_root + "despacho");
                }

                litNombreEntrega.Text    = oDireccionEntrega.NombreEntrega;
                litDireccionEntrega.Text = oDireccionEntrega.DireccionEntrega; //falta distrito provincia departamento y pais;
                litTelefonoEntrega.Text  = oDireccionEntrega.Telefono01 + " / " + oDireccionEntrega.Telefono02 + " / " + oDireccionEntrega.Telefono03 + " / " + oDireccionEntrega.Telefono04;

                //agregar a tb_orden_direccion
                eOrdenDireccion oOrdenDireccionValidar = new eOrdenDireccion();
                oOrdenDireccionValidar = cCMS.Orden_Direccion_itemCodigoOrden(codigoOrden);
                if (oOrdenDireccionValidar == null)
                {
                    eOrdenDireccion oOrdenDireccion = new eOrdenDireccion();
                    oOrdenDireccion.CodigoDireccion         = oDireccionEntrega.CodigoEntrega;
                    oOrdenDireccion.TipoDireccion           = "tb_direccion_entrega";
                    oOrdenDireccion.NombreDireccion         = oDireccionEntrega.NombreEntrega;
                    oOrdenDireccion.IdPaisDireccion         = oDireccionEntrega.IdPaisEntrega;
                    oOrdenDireccion.IdDepartamentoDireccion = oDireccionEntrega.IdDepartamentoEntrega;
                    oOrdenDireccion.IdProvinciaDireccion    = oDireccionEntrega.IdProvinciaEntrega;
                    oOrdenDireccion.IdDistritoDireccion     = oDireccionEntrega.IdDistritoEntrega;
                    oOrdenDireccion.DireccionDireccion      = oDireccionEntrega.DireccionEntrega;
                    oOrdenDireccion.Telefono01Direccion     = oDireccionEntrega.Telefono01;
                    oOrdenDireccion.Telefono02Direccion     = oDireccionEntrega.Telefono02;
                    oOrdenDireccion.Telefono03Direccion     = oDireccionEntrega.Telefono03;
                    oOrdenDireccion.Telefono04Direccion     = oDireccionEntrega.Telefono04;
                    oOrdenDireccion.EmailUsuarioDireccion   = oUsuarioWeb.email_usuario;
                    oOrdenDireccion.ReferenciaDireccion     = oDireccionEntrega.ReferenciaEntrega;
                    oOrdenDireccion.CodigoOrden             = codigoOrden;
                    int agregarOrdenDireccion = cCMS.Orden_Direccion_add(oOrdenDireccion);
                    RegistrarLogsCms(oUsuarioWeb.id_usuario, "Seleccionó como direccion de entrega: " + oOrdenDireccion.NombreDireccion + " con código " + oOrdenDireccion.CodigoDireccion + " para la orden " + codigoOrden);
                }
                else
                {
                }
                //RegistrarLogsCms(oUsuarioWeb.email_usuario, "Seleccionó como direccion de entrega: " + despacho);
            }
            if (recojo == "")
            {
                tipoDireccion = 2;
                string codigo_despacho = despacho;
                // hplPagar.Attributes.Add("rel",url_root + "confirmacion_visanet?despacho="+codigo_despacho);
                oDireccionDespacho = cCMS.DireccionDespacho_Listar(oUsuarioWeb.id_usuario, codigo_despacho);
                //valida que no sea otro código que no corresponda
                if (oDireccionDespacho == null)
                {
                    Response.Redirect("" + url_root + "despacho");
                }

                //agregar a tb_orden_direccion
                eOrdenDireccion oOrdenDireccionValidar = new eOrdenDireccion();
                oOrdenDireccionValidar = cCMS.Orden_Direccion_itemCodigoOrden(codigoOrden);
                if (oOrdenDireccionValidar == null)
                {
                    eOrdenDireccion oOrdenDireccion = new eOrdenDireccion();
                    oOrdenDireccion.CodigoDireccion               = oDireccionDespacho.CodigoDespacho;
                    oOrdenDireccion.TipoDireccion                 = "tb_direccion_despacho";
                    oOrdenDireccion.TipoDocumentoDireccion        = oDireccionDespacho.TipoDocumentoDespacho;
                    oOrdenDireccion.DescripcionDocumentoDireccion = oDireccionDespacho.DescripcionDocumentoDespacho;
                    oOrdenDireccion.NombreDireccion               = oDireccionDespacho.NombreDespacho;
                    oOrdenDireccion.ApellidoDireccion             = oDireccionDespacho.ApellidoDespacho;
                    oOrdenDireccion.TipoTelefonoDireccion         = oDireccionDespacho.TipoTelefonoDespacho;
                    oOrdenDireccion.Telefono01Direccion           = oDireccionDespacho.DescripcionTelefonoDespacho;
                    oOrdenDireccion.IdPaisDireccion               = oDireccionDespacho.IdPaisDespacho;
                    oOrdenDireccion.IdDepartamentoDireccion       = oDireccionDespacho.IdDepartamentoDespacho;
                    oOrdenDireccion.IdProvinciaDireccion          = oDireccionDespacho.IdProvinciaDespacho;
                    oOrdenDireccion.IdDistritoDireccion           = oDireccionDespacho.IdDistritoDespacho;
                    oOrdenDireccion.DireccionDireccion            = oDireccionDespacho.DireccionDespacho;
                    oOrdenDireccion.ReferenciaDireccion           = oDireccionDespacho.ReferenciaDespacho;
                    oOrdenDireccion.CiudadDireccion               = oDireccionDespacho.CiudadDespacho;
                    oOrdenDireccion.CodigoPostalDireccion         = oDireccionDespacho.CodigoPostalDespacho;
                    oOrdenDireccion.EmailUsuarioDireccion         = oDireccionDespacho.Emailusuario;
                    oOrdenDireccion.CodigoOrden = codigoOrden;
                    int agregarOrdenDireccion = cCMS.Orden_Direccion_add(oOrdenDireccion);
                    RegistrarLogsCms(oUsuarioWeb.id_usuario, "Seleccionó como direccion de despacho: " + oOrdenDireccion.NombreDireccion + " con código " + oOrdenDireccion.CodigoDireccion + " para la orden " + codigoOrden);
                }
                else
                {
                }
                litNombreEntrega.Text    = oDireccionDespacho.NombreDespacho + " " + oDireccionDespacho.ApellidoDespacho;
                litDireccionEntrega.Text = oDireccionDespacho.DireccionDespacho; //falta distrito provincia departamento y pais;
                litTelefonoEntrega.Text  = oDireccionDespacho.DescripcionTelefonoDespacho;
                //RegistrarLogsCms(oUsuarioWeb.email_usuario, "Seleccionó como direccion de recojo: " + recojo);
            }


            //hplPagar.Attributes.Add("rel", url_root + "confirmacion_visanet?codigoOrden=" + codigoOrden);
            hplPagar.Attributes.Add("rel", url_root + "Content/VisanetPaymentForm.aspx");
            hplPagar.Attributes.Add("relfalse", url_root + "producto_compras");

            DateTime fechaEntrega = new DateTime();
            fechaEntrega         = DateTime.Now.AddDays(5); //DateTime.Now.AddDays(2);
            litFechaEntrega.Text = fechaEntrega.ToShortDateString();
            //agregar la direccion
            //tipoDireccion 1 entrega 2 despacho
            eOrdenEntrega  oOrdenEntrega  = new eOrdenEntrega();
            eOrdenDespacho oOrdenDespacho = new eOrdenDespacho();



            switch (tipoDireccion)
            {
            case 1:
                //agregar a tb_orden_entrega
                oOrdenEntrega.CodigoOrdenEntrega          = recojo;
                oOrdenEntrega.CodigoOrden                 = oOrden.CodigoOrden;
                oOrdenEntrega.EstadoOrdenEntrega          = "No procesada";
                oOrdenEntrega.FechaEstimadaRecojo         = fechaEntrega;
                oOrdenEntrega.TipoComprobanteOrdenEntrega = "No seleccionado";
                int agregaOrdenEntrega = cCMS.OrdenEntrega_Add(oOrdenEntrega);
                break;

            case 2:
                //agregar a tb_orden_despacho
                oOrdenDespacho.CodigoOrden                  = oOrden.CodigoOrden;
                oOrdenDespacho.CodigoOrdenDespacho          = despacho;
                oOrdenDespacho.EstadoOrdenDespacho          = "No procesada";
                oOrdenDespacho.FechaEstimadaRecojo          = fechaEntrega;
                oOrdenDespacho.TipoComprobanteOrdenDespacho = "No seleccionado";
                int agregaOrdenDespacho = cCMS.OrdenDespacho_Add(oOrdenDespacho);
                break;
            }

            //Parametros para generar el eTicket
            ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "orden_cliente", "var codigoOrden='" + codigoOrden + "'; totalSoles='" + totalSoles + "'; var totalDolares='" + totalDolares + "';", true);
        }
        private void FillRegistro()
        {
            //productos
            decimal            monto_total        = 0;
            eDireccionEntrega  oDireccionEntrega  = new eDireccionEntrega();
            eDireccionDespacho oDireccionDespacho = new eDireccionDespacho();
            eOrden             oOrden             = cCMS.Orden_item(codigo_orden);

            foreach (eOrdenProducto oOrdenProducto in lOrdenProducto)
            {
                decimal PrecioConTodo = oOrdenProducto.eProducto.PrecioProducto;
                PrecioConTodo = decimal.Round(PrecioConTodo, 2);
                decimal subtotal = PrecioConTodo * oOrdenProducto.CantidadOrdenProducto;
                subtotal = decimal.Round(subtotal, 2);

                string productos = "<tr>" +
                                   "<td width=\"80\">" +
                                   "    <img src=\"" + url_root + webcontentUC.Directorio.Pagina_Imagen + oOrdenProducto.eProducto.ImagenChica.ToString() + "\" width=\"67\" height=\"67\">" +
                                   "</td>" +
                                   "<td width=\"130\" style=\"padding-right:20px\">" +
                                   "    <strong>" + oOrdenProducto.eProducto.ModeloProducto + " " + oOrdenProducto.eProducto.CodigoProducto + "</strong><br>" +
                                   "    " + oOrdenProducto.eProducto.DescripcionProducto + "" +
                                   "</td>" +
                                   "<td>" +
                                   "    <strong>US$." + PrecioConTodo.ToString() + "</strong>" +
                                   "</td>" +
                                   "<td style=\"text-align:center\">" +
                                   "    " + oOrdenProducto.CantidadOrdenProducto.ToString() + "" +
                                   "</td>" +
                                   "<td>" +
                                   "    <strong>US$." + subtotal.ToString() + "</strong>" +
                                   "</td>" +
                                   "</tr>" +
                                   "<tr>" +
                                   "    <td colspan=\"5\" style=\"padding:0 0 10px 0\">" +
                                   "    </td>" +
                                   "</tr>";
                litProductos.Text += productos;
                monto_total       += subtotal;
            }

            litSubTotal.Text = monto_total.ToString();

            litTotal.Text        = decimal.Round(oOrden.MontoTotalSoles, 2).ToString();
            litDescuento.Text    = decimal.Round(oOrden.MontoConDescuento, 2).ToString();
            litTotalDolares.Text = decimal.Round(oOrden.MontoTotal, 2).ToString();
            if (oOrden.MontoConDescuento > 0)
            {
                litDescuento.Text   = (oOrden.MontoTotal - oOrden.MontoConDescuento).ToString();
                trDescuento.Visible = true;
            }


            //validar direccion de despacho
            eOrdenEntrega  oOrdenEntrega  = cCMS.OrdenEntrega_ListarOrden(codigo_orden);
            eOrdenDespacho oOrdenDespacho = cCMS.OrdenDespacho_ListarOrden(codigo_orden);

            string entrega  = (oOrdenEntrega.CodigoEntrega == 0) ? "" : oOrdenEntrega.CodigoEntrega.ToString();
            string despacho = (oOrdenDespacho.CodigoDespacho == 0) ? "" : oOrdenDespacho.CodigoDespacho.ToString();

            if (despacho == "")
            {
                //spanGastoEnvio.Visible = false;
                tipoDireccion = 1;
                //en caso sea una direccion de recojo
                litTipoComprobante.Text = oOrdenEntrega.TipoComprobanteOrdenEntrega;
                string codigo_recojo = entrega;
                oDireccionEntrega = cCMS.Entrega_Listar(codigo_recojo);
                //valida que el codigo exista
                if (oDireccionEntrega == null)
                {
                    Response.Redirect("" + url_root + "despacho");
                }

                litDireccionEntrega.Text = oDireccionEntrega.NombreEntrega + " - " + oDireccionEntrega.DireccionEntrega; //falta distrito provincia departamento y pais;
                litRuc.Text         = oOrdenEntrega.RucEntrega;
                litRazonSocial.Text = oOrdenEntrega.RazonSocialEntrega;
            }
            else if (entrega == "")
            {
                //despacho dilevery
                tipoDireccion                      = 2;
                litTipoComprobante.Text            = oOrdenDespacho.TipoComprobanteOrdenDespacho;
                oOrdenDespacho.EstadoOrdenDespacho = "Pagado";
                string codigo_despacho = despacho;
                oDireccionDespacho = cCMS.DireccionDespacho_Listar(oOrden.IdUsuario, codigo_despacho);
                //valida que no sea otro código que no corresponda
                if (oDireccionDespacho == null)
                {
                    Response.Redirect("" + url_root + "despacho");
                }

                litDireccionEntrega.Text = oDireccionDespacho.DireccionDespacho; //falta distrito provincia departamento y pais;
                litRuc.Text         = oOrdenDespacho.RucDespacho;
                litRazonSocial.Text = oOrdenDespacho.RazonSocialDespacho;
            }

            if (litTipoComprobante.Text == "Boleta")
            {
                spanRazon.Visible = false;
                spanRuc.Visible   = false;
            }


            //recuperar el numero de orden
            DateTime fechaEntrega = new DateTime();

            fechaEntrega         = DateTime.Now.AddDays(5);
            litFechaEntrega.Text = fechaEntrega.ToShortDateString();
            litTipoMoneda.Text   = oOrden.MonedaOrden;

            //Datos Adicionales para la notificación

            eUsuariosWeb oUsuarioWeb = cCMS.UsuariosWeb_item(oOrden.IdUsuario);

            litCliente.Text = (oOrden.TipoOrden == 1) ? oUsuarioWeb.nombre_usuario + " " + oUsuarioWeb.apellido_usuario : oOrden.eDireccionDespacho.NombreDespacho;

            litTelefono.Text     = (oOrden.TipoOrden == 1) ? oUsuarioWeb.descripcion_telefono_usuarios : oOrden.eDireccionDespacho.DescripcionTelefonoDespacho;
            litDocIdenti.Text    = oUsuarioWeb.tipo_documento_identidad_usuario + ": " + oUsuarioWeb.descripcion_documento_identidad_usuario;
            litETicket.Text      = oOrden.Eticket;
            litFechaCompra.Text  = oOrden.FechaOrden.ToString();
            litDirecCliente.Text = oUsuarioWeb.direccion_usuario;
            litEmail.Text        = oUsuarioWeb.email_usuario;

            litDisclaimer.Visible = colaborador;
        }
        public List <eOrden> Orden_listar_FiltradoEntregaMes(Int64 id_usuario, string mes)
        {
            //llenamos la lista de Entrega....
            SqlCommand cmd = new SqlCommand("usp_tb_ordenFiltroDespachoMesOrden");

            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.Add("@id_usuario", SqlDbType.BigInt).Value = id_usuario;
            cmd.Parameters.Add("@mes", SqlDbType.VarChar, 100).Value  = mes;

            SqlDataReader reader = ExecuteReader(cmd);
            List <eOrden> lista  = new List <eOrden>();

            while (reader.Read())
            {
                eOrden             oOrden             = new eOrden();
                eOrdenDireccion    oOrdenDireccion    = new eOrdenDireccion();
                eDireccionEntrega  oDireccionEntrega  = new eDireccionEntrega();
                eOrdenEntrega      oOrdenEntrega      = new eOrdenEntrega();
                eDireccionDespacho oDireccionDespacho = new eDireccionDespacho();
                eOrdenDespacho     oOrdenDespacho     = new eOrdenDespacho();
                oOrden.CodigoOrden = ((!reader[0].Equals(DBNull.Value)) ? reader.GetString(0) : "");
                oOrden.FechaOrden  = ((!reader[1].Equals(DBNull.Value)) ? reader.GetDateTime(1) : DefaultDateTime);
                oDireccionEntrega.NombreEntrega                = ((!reader[2].Equals(DBNull.Value)) ? reader.GetString(2) : "");
                oDireccionEntrega.DireccionEntrega             = ((!reader[3].Equals(DBNull.Value)) ? reader.GetString(3) : "");
                oDireccionEntrega.Telefono01                   = ((!reader[4].Equals(DBNull.Value)) ? reader.GetString(4) : "");
                oDireccionEntrega.Telefono02                   = ((!reader[5].Equals(DBNull.Value)) ? reader.GetString(5) : "");
                oDireccionEntrega.Telefono03                   = ((!reader[6].Equals(DBNull.Value)) ? reader.GetString(6) : "");
                oDireccionEntrega.Telefono04                   = ((!reader[7].Equals(DBNull.Value)) ? reader.GetString(7) : "");
                oOrdenEntrega.EstadoOrdenEntrega               = ((!reader[8].Equals(DBNull.Value)) ? reader.GetString(8) : "");
                oOrdenEntrega.TipoComprobanteOrdenEntrega      = ((!reader[9].Equals(DBNull.Value)) ? reader.GetString(9) : "");
                oOrdenEntrega.FechaEstimadaRecojo              = ((!reader[10].Equals(DBNull.Value)) ? reader.GetDateTime(10) : DateTime.Today);
                oDireccionDespacho.NombreDespacho              = ((!reader[11].Equals(DBNull.Value)) ? reader.GetString(11) : "");
                oDireccionDespacho.DireccionDespacho           = ((!reader[12].Equals(DBNull.Value)) ? reader.GetString(12) : "");
                oDireccionDespacho.DescripcionTelefonoDespacho = ((!reader[13].Equals(DBNull.Value)) ? reader.GetString(13) : "");
                oOrdenDespacho.EstadoOrdenDespacho             = ((!reader[14].Equals(DBNull.Value)) ? reader.GetString(14) : "");
                oOrdenDespacho.TipoComprobanteOrdenDespacho    = ((!reader[15].Equals(DBNull.Value)) ? reader.GetString(15) : "");
                oOrdenDespacho.FechaEstimadaRecojo             = ((!reader[16].Equals(DBNull.Value)) ? reader.GetDateTime(16) : DateTime.Today);
                oOrdenDireccion.TipoDireccion                  = ((!reader[17].Equals(DBNull.Value)) ? reader.GetString(17) : "");
                oOrden.IdUsuario          = ((!reader[18].Equals(DBNull.Value)) ? reader.GetInt64(18) : Convert.ToInt64(0));
                oOrden.eDireccionEntrega  = oDireccionEntrega;
                oOrden.eOrdenEntrega      = oOrdenEntrega;
                oOrden.eOrdenDespacho     = oOrdenDespacho;
                oOrden.eDireccionDespacho = oDireccionDespacho;

                if (oOrdenDireccion.TipoDireccion == "tb_direccion_entrega")
                {
                    oOrden.TipoOrden = 1;
                }
                else
                {
                    oOrden.TipoOrden = 2;
                }
                lista.Add(oOrden);
            }
            reader.Close();
            ////llenamoe la lista de despacho...
            //SqlCommand cmd2 = new SqlCommand("usp_tb_ordenFiltroDespachoAno");
            //cmd2.CommandType = CommandType.StoredProcedure;
            //cmd2.Parameters.Add("@email_usuario", SqlDbType.VarChar, 100).Value = email_usuario;
            //cmd2.Parameters.Add("@ano", SqlDbType.VarChar, 100).Value = ano;
            //SqlDataReader reader2 = ExecuteReader(cmd2);
            //while (reader2.Read())
            //{
            //    eOrden oOrden = new eOrden();
            //    eDireccionDespacho oDireccionDespacho = new eDireccionDespacho();
            //    eOrdenDespacho oOrdenDespacho = new eOrdenDespacho();
            //    oOrden.CodigoOrden = ((!reader2[0].Equals(DBNull.Value)) ? reader2.GetString(0) : "");
            //    oOrden.FechaOrden = ((!reader2[1].Equals(DBNull.Value)) ? reader2.GetDateTime(1) : DefaultDateTime);
            //    oDireccionDespacho.NombreDespacho = ((!reader2[2].Equals(DBNull.Value)) ? reader2.GetString(3) : "");
            //    oDireccionDespacho.DireccionDespacho = ((!reader2[3].Equals(DBNull.Value)) ? reader2.GetString(3) : "");
            //    oDireccionDespacho.DescripcionTelefonoDespacho = ((!reader2[4].Equals(DBNull.Value)) ? reader2.GetString(4) : "");
            //    oOrdenDespacho.EstadoOrdenDespacho = ((!reader2[5].Equals(DBNull.Value)) ? reader2.GetString(5) : "");
            //    oOrdenDespacho.TipoComprobanteOrdenDespacho = ((!reader2[6].Equals(DBNull.Value)) ? reader2.GetString(6) : "");
            //    oOrdenDespacho.FechaEstimadaRecojo = ((!reader2[7].Equals(DBNull.Value)) ? reader2.GetDateTime(7) : DateTime.Today);
            //    oOrden.eOrdenDespacho = oOrdenDespacho;
            //    oOrden.eDireccionDespacho = oDireccionDespacho;


            //    oOrden.TipoOrden = 2;
            //    lista.Add(oOrden);
            //}
            //reader.Close();

            return(lista);
        }
        public List <eOrden> Orden_listar_FiltradoEntrega(Int64 id_usuario)
        {
            //llenamos la lista de Entrega....
            SqlCommand cmd = new SqlCommand("usp_tb_ordenFiltroDespachoOrden");

            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.Add("@id_usuario", SqlDbType.BigInt).Value = id_usuario;

            SqlDataReader reader = ExecuteReader(cmd);
            List <eOrden> lista  = new List <eOrden>();

            while (reader.Read())
            {
                string             tipo               = "";
                eOrden             oOrden             = new eOrden();
                eDireccionEntrega  oDireccionEntrega  = new eDireccionEntrega();
                eOrdenEntrega      oOrdenEntrega      = new eOrdenEntrega();
                eDireccionDespacho oDireccionDespacho = new eDireccionDespacho();
                eOrdenDespacho     oOrdenDespacho     = new eOrdenDespacho();
                oOrden.CodigoOrden = ((!reader[0].Equals(DBNull.Value)) ? reader.GetString(0) : "");
                oOrden.FechaOrden  = ((!reader[1].Equals(DBNull.Value)) ? reader.GetDateTime(1) : DefaultDateTime);
                oDireccionEntrega.NombreEntrega                = ((!reader[2].Equals(DBNull.Value)) ? reader.GetString(2) : "");
                oDireccionEntrega.DireccionEntrega             = ((!reader[3].Equals(DBNull.Value)) ? reader.GetString(3) : "");
                oDireccionEntrega.Telefono01                   = ((!reader[4].Equals(DBNull.Value)) ? reader.GetString(4) : "");
                oDireccionEntrega.Telefono02                   = ((!reader[5].Equals(DBNull.Value)) ? reader.GetString(5) : "");
                oDireccionEntrega.Telefono03                   = ((!reader[6].Equals(DBNull.Value)) ? reader.GetString(6) : "");
                oDireccionEntrega.Telefono04                   = ((!reader[7].Equals(DBNull.Value)) ? reader.GetString(7) : "");
                oOrdenEntrega.EstadoOrdenEntrega               = ((!reader[8].Equals(DBNull.Value)) ? reader.GetString(8) : "");
                oOrdenEntrega.TipoComprobanteOrdenEntrega      = ((!reader[9].Equals(DBNull.Value)) ? reader.GetString(9) : "");
                oOrdenEntrega.FechaEstimadaRecojo              = ((!reader[10].Equals(DBNull.Value)) ? reader.GetDateTime(10) : DateTime.Today);
                oDireccionDespacho.NombreDespacho              = ((!reader[11].Equals(DBNull.Value)) ? reader.GetString(11) : "");
                oDireccionDespacho.DireccionDespacho           = ((!reader[12].Equals(DBNull.Value)) ? reader.GetString(12) : "");
                oDireccionDespacho.DescripcionTelefonoDespacho = ((!reader[13].Equals(DBNull.Value)) ? reader.GetString(13) : "");
                oOrdenDespacho.EstadoOrdenDespacho             = ((!reader[14].Equals(DBNull.Value)) ? reader.GetString(14) : "");
                oOrdenDespacho.TipoComprobanteOrdenDespacho    = ((!reader[15].Equals(DBNull.Value)) ? reader.GetString(15) : "");
                oOrdenDespacho.FechaEstimadaRecojo             = ((!reader[16].Equals(DBNull.Value)) ? reader.GetDateTime(16) : DateTime.Today);
                tipo = ((!reader[17].Equals(DBNull.Value)) ? reader.GetString(17) : "");
                oOrdenDespacho.RazonSocialDespacho = ((!reader[18].Equals(DBNull.Value)) ? reader.GetString(18) : "");
                oOrdenDespacho.RucDespacho         = ((!reader[19].Equals(DBNull.Value)) ? reader.GetString(19) : "");
                oOrdenEntrega.RazonSocialEntrega   = ((!reader[20].Equals(DBNull.Value)) ? reader.GetString(20) : "");
                oOrdenEntrega.RucEntrega           = ((!reader[21].Equals(DBNull.Value)) ? reader.GetString(21) : "");
                oOrden.IdUsuario         = ((!reader[22].Equals(DBNull.Value)) ? reader.GetInt64(22) : Convert.ToInt64(0));
                oOrden.MontoConDescuento = ((!reader[23].Equals(DBNull.Value)) ? reader.GetDecimal(23) : Convert.ToDecimal(0));

                oOrden.eDireccionEntrega  = oDireccionEntrega;
                oOrden.eOrdenEntrega      = oOrdenEntrega;
                oOrden.eOrdenDespacho     = oOrdenDespacho;
                oOrden.eDireccionDespacho = oDireccionDespacho;

                if (tipo == "tb_direccion_entrega")
                {
                    oOrden.TipoOrden = 1;
                }
                else
                {
                    oOrden.TipoOrden = 2;
                }
                lista.Add(oOrden);
            }
            reader.Close();
            return(lista);
        }
示例#12
0
 public bool Update_OrdenDespacho(eOrdenDespacho oOrdenDespacho)
 {
     IdException = cOrdenDespacho.Update_OrdenDespacho(oOrdenDespacho);
     return(IdException == 0);
 }
示例#13
0
        public void FindControl(string ano)
        {
            List <eOrden> lOrden = new List <eOrden>();

            lOrden = (ano == "Todos") ? cCMS.Orden_listar_FiltradoAll(oUsuarioWeb.id_usuario) : cCMS.Orden_listar_FiltradoAnos(oUsuarioWeb.id_usuario, ano);
            lOrden = (drpOrdenes_mes.SelectedValue == "All") ? cCMS.Orden_listar_FiltradoAll(oUsuarioWeb.id_usuario) : cCMS.Orden_listar_FiltradoMes(oUsuarioWeb.id_usuario, drpOrdenes_mes.SelectedValue);

            foreach (var itemOrden in lOrden)
            {
                litFechaOrden  = itemOrden.FechaOrden.ToShortDateString();
                litCodigoOrden = itemOrden.CodigoOrden;
                int tipoOrden = itemOrden.TipoOrden;
                // 1 entrega
                //2 despacho
                if (itemOrden.eOrdenEntrega.EstadoOrdenEntrega == "")
                {
                    tipoOrden = 2;
                }
                litEstado           = (tipoOrden == 1) ? itemOrden.eOrdenEntrega.EstadoOrdenEntrega : itemOrden.eOrdenDespacho.EstadoOrdenDespacho;
                litTipoComprobante  = (tipoOrden == 1) ? itemOrden.eOrdenEntrega.TipoComprobanteOrdenEntrega : itemOrden.eOrdenDespacho.TipoComprobanteOrdenDespacho;
                litFechaEntrega     = (tipoOrden == 1) ? itemOrden.eOrdenEntrega.FechaEstimadaRecojo.ToShortDateString() : itemOrden.eOrdenDespacho.FechaEstimadaRecojo.ToShortDateString();
                litNombreEntrega    = (tipoOrden == 1) ? itemOrden.eDireccionEntrega.NombreEntrega : itemOrden.eDireccionDespacho.NombreDespacho;
                litDireccionEntrega = (tipoOrden == 1) ? itemOrden.eDireccionEntrega.DireccionEntrega : itemOrden.eDireccionDespacho.DireccionDespacho;
                litTelefonoEntrega  = (tipoOrden == 1) ? itemOrden.eDireccionEntrega.Telefono01 + " / " + itemOrden.eDireccionEntrega.Telefono02 + " / " + itemOrden.eDireccionEntrega.Telefono03 + " / " + itemOrden.eDireccionEntrega.Telefono04 : itemOrden.eDireccionDespacho.DescripcionTelefonoDespacho;
                litRazon            = (tipoOrden == 1) ? itemOrden.eOrdenEntrega.RazonSocialEntrega : itemOrden.eOrdenDespacho.RazonSocialDespacho;
                litRuc = (tipoOrden == 1) ? itemOrden.eOrdenEntrega.RucEntrega : itemOrden.eOrdenDespacho.RucDespacho;

                string bloqueAdicional = "";

                if (litTipoComprobante == "Factura")
                {
                    bloqueAdicional = "	<span><strong>RUC: </strong>" + litRuc + "</span><span><strong>Razón Social: </strong>" + litRazon + "</span>";
                }


                List <eOrdenProducto> lOrdenProducto = new List <eOrdenProducto>();
                lOrdenProducto = cCMS.Orden_Producto_HistorialPedidos(litCodigoOrden);
                litProductos   = "";
                total          = 0;
                //igv
                int     IgvInt     = Convert.ToInt32(cCMS.ParametroAlias(4).Replace("%", ""));
                string  IgvString  = "1." + IgvInt.ToString();
                decimal igv        = Convert.ToDecimal(IgvString);
                string  tipoCambio = "";
                foreach (var itemProducto in lOrdenProducto)
                {
                    //tipo de cambio registrado en BD
                    //string tipoCambio = (cCMS.ParametroAlias(2) != null) ? cCMS.ParametroAlias(2) : "1";
                    tipoCambio = itemProducto.TipoCambioOrden;
                    string  rutaImagenChica = ClientScriptHelper.getURLHome() + Directorio.Pagina_Imagen + itemProducto.eProducto.ImagenChica;
                    decimal PrecioConTodo   = itemProducto.eProducto.PrecioProducto; // *igv;
                    PrecioConTodo = decimal.Round(PrecioConTodo, 2);
                    decimal subtotal = PrecioConTodo * itemProducto.CantidadOrdenProducto;
                    subtotal = decimal.Round(subtotal, 2);
                    string precioDecimal         = Convert.ToDouble(PrecioConTodo).ToString("N", CultureInfo.InvariantCulture);
                    string precioSubTotalDecimal = Convert.ToDouble(subtotal).ToString("N", CultureInfo.InvariantCulture);


                    litProductos += "<li>" +
                                    "<div class=\"producto_entrega\">" +
                                    "<figure><img src=\"" + rutaImagenChica + "\"></figure>" +
                                    "<blockquote>" +
                                    "	<h2>"+ itemProducto.eProducto.ModeloProducto + " " + itemProducto.eProducto.CodigoProducto + "</h2>" +
                                    "	<p></p>"+
                                    "</blockquote>" +
                                    "</div>" +
                                    "<div class=\"precios\">" +
                                    "    <span>US$." + precioDecimal.ToString() + "<span>" +
                                    "</div>" +
                                    "<div class=\"cantidades\">" +
                                    "    <span>" + itemProducto.CantidadOrdenProducto.ToString() + "</span>" +
                                    "</div>" +
                                    "<div class=\"subtotales\">" +
                                    "    <span>US$." + precioSubTotalDecimal + "</span>" +
                                    "</div>" +
                                    "</li>";
                    total += subtotal;
                }
                string preciosTotalDecimal = Convert.ToDouble(total).ToString("N", CultureInfo.InvariantCulture);

                litSubTotal = preciosTotalDecimal.ToString();
                //validar si es delivery
                eOrdenDespacho oOrdenDespacho = cCMS.OrdenDespacho_ListarOrden(itemOrden.CodigoOrden);
                //string textoGastoEnvio = "";
                //if (oOrdenDespacho.CodigoOrdenDespacho != null)
                //{
                //    litGastoEnvio = (cCMS.ParametroAlias(1) != null) ? cCMS.ParametroAlias(1) : "1";
                //    textoGastoEnvio = "		<span>GASTOS DE ENV&Iacute;O: S/. " + litGastoEnvio + "</span>";
                //}
                //else
                //{
                //    litGastoEnvio = "0";
                //    textoGastoEnvio = "";
                //}

                //litTotal = (total + Convert.ToDecimal(litGastoEnvio)).ToString();
                //si es usuario de ferreyros
                string  palabraCortada           = Right(oUsuarioWeb.email_usuario, 17);
                string  precioDescuentoFerreyros = "";
                string  divPrecioDEscuento       = "";
                string  litTotalDolares          = "";
                decimal precioTotalSoles         = 0;

                if (itemOrden.MontoConDescuento != 0)
                {
                    Decimal descuento = decimal.Round(Convert.ToDecimal(preciosTotalDecimal) - Convert.ToDecimal(itemOrden.MontoConDescuento), 2);

                    //double subtotal = Convert.ToDouble(litSubTotal);
                    //double subtot = (subtotal) - (subtotal * 0.2);
                    //decimal descuento20;
                    //descuento20 = Convert.ToDecimal(subtot);
                    //descuento20 = decimal.Round(descuento20, 2);
                    string precioDescuentoDecimal = descuento.ToString("N", CultureInfo.InvariantCulture);
                    precioDescuentoFerreyros = precioDescuentoDecimal.ToString();
                    divPrecioDEscuento       = "		<span>SUBTOTAL C/ DSCTOS: US$. "+ precioDescuentoFerreyros + "</span>";
                    litTotalDolares          = precioDescuentoFerreyros;
                    precioTotalSoles         = Convert.ToDecimal(litTotalDolares) * Convert.ToDecimal(tipoCambio);
                }
                else
                {
                    litTotalDolares = litSubTotal;
                    if (litSubTotal == "0.00")
                    {
                        return;
                    }
                    precioTotalSoles = Convert.ToDecimal(litSubTotal) * Convert.ToDecimal(tipoCambio);
                }


                precioTotalSoles          = decimal.Round(precioTotalSoles, 2);
                litTotal                  = precioTotalSoles.ToString();
                litHistorialPedidos.Text += "<div class=\"verificar_compras\">" +
                                            "<h4>FECHA DE ORDEN: <span>" + litFechaOrden + "</span>C&Oacute;DIGO DE ORDEN: <span>" + litCodigoOrden + "</span></h4>" +
                                            "<div class=\"datos_entrega\">" +
                                            "<h3>DATOS DE ENTREGA / RECOJO</h3>" +
                                            "	<span><strong>Estado:</strong>"+ litEstado + "</span>" +
                                            "	<span><strong>Tipo de Comprobante de Pago:</strong>"+ litTipoComprobante + "</span>" +
                                            bloqueAdicional +
                                            "	<span><strong>Fecha estimada de entrega/recojo: </strong>"+ litFechaEntrega + "</span>" +
                                            "	<span><strong>Nombre:</strong>"+ litNombreEntrega + "</span>" +
                                            "	<span><strong>Direcci&oacute;n:</strong></span>"+
                                            "	<p>"+ litDireccionEntrega + "</p>" +
                                            "	<span><strong>Tel&eacute;fono:</strong>"+ litTelefonoEntrega + "</span>" +
                                            "</div>" +
                                            "<div class=\"lista_productos\">" +
                                            "<ul class=\"titulos\">" +
                                            "	<li>PRODUCTO</li><li>PRECIO</li><li>CANTIDAD</li><li>SUBTOTAL</li>"+
                                            "</ul>" +
                                            "<ul>						"+
                                            "<!--repetir productos --> " +
                                            litProductos +
                                            "</ul>" +
                                            "</div>" +
                                            "<div class=\"clear\"></div>" +
                                            "<div class=\"resultado_costos\">" +
                                            "	<div class=\"subtotal\">"+
                                            "		<span class=\"color_valor\">VALOR DE LA ORDEN:</span>"+
                                            "		<span>SUBTOTAL: US$. "+ litSubTotal + "</span>" +
                                            divPrecioDEscuento +
                                            "		<span>TOTAL: US$. "+ litTotalDolares + "</span>" +
                                            //textoGastoEnvio +
                                            "		<span class=\"color_total\">TOTAL: S/. "+ litTotal + "</span> " +
                                            "	</div>"+
                                            "</div>" +
                                            "</div>";
            }
        }