public void GetWarehousePreSale()
        {
            try
            {
                var pResult             = "";
                var objWarehousepresale = new WSWarehouse.SwiftExpressWSWarehouse();
                _ds = objWarehousepresale.GetWarehousePreSale(Session["connectionString"].ToString(), ref pResult);

                if (pResult == "")
                {
                    Session["DS_WAREHOUSE_PRESALE"] = _ds;
                    if (_ds.Tables[0].Rows.Count > 0)
                    {
                        LookupWarehousePre.DataSource = _ds;
                        LookupWarehousePre.DataBind();
                    }
                }
                else
                {
                    ScriptManager.RegisterStartupScript(this, GetType(), "ErrorText", "CallError('" + pResult + "');", true);
                }
            }
            catch (Exception ex)
            {
                ScriptManager.RegisterStartupScript(this, GetType(), "ErrorText", "CallError('Error en carga inicial: " + ex.Message + "');", true);
            }
        }
        protected void ASPxMenu3_ItemClick(object source, MenuItemEventArgs e)
        {
            string enterprise = Session["CODE_ENTERPRISE"].ToString();

            try
            {
                switch (e.Item.Name)
                {
                case "btnUpdate":
                    var fileToString = string.Empty;
                    var usePackUnit  = 0;

                    if (UiCheckBoxDecideUnidadDeVenta.Checked)
                    {
                        usePackUnit = 1;
                    }

                    if (LookupSeller.Value == null)
                    {
                        LookupSeller.Value = "";
                    }


                    if (Session["ACTION"].Equals("UPDATE"))
                    {
                        //fileToString = cod.PhotoUtils.ConvertImageToBase64(previewImage);
                        if (Session["base64Profile"] != null)
                        {
                            fileToString             = Session["base64Profile"].ToString();
                            Session["base64Profile"] = null;
                        }

                        string bodega      = "";
                        string bodegapre   = "";
                        string login       = "";
                        int    correlative = 0;


                        if (LookupWarehouse.Value != null)
                        {
                            bodega = LookupWarehouse.Value?.ToString();
                        }

                        if (LookupWarehousePre.Value != null)
                        {
                            bodegapre = LookupWarehousePre?.Value.ToString();
                        }

                        if (Session["LOGIN_SELECCIONADO"] != null)
                        {
                            login = Session["LOGIN_SELECCIONADO"].ToString();
                        }

                        //Se colocó el valor de menos 1 ya que no se utiliza en ningun lugar.
                        correlative = -1;


                        // Convert.ToInt32()

                        _result = _objUsers.UpdateUser(ASPxTextBox4.Text, login, ASPxTextBox3.Text,
                                                       correlative, fileToString, CmbUserRole.Value.ToString(),
                                                       LookupSeller.Value.ToString(), bodega, bodegapre,
                                                       Convert.ToInt16(LookupRoles.Value),
                                                       UiListaRuta.Value?.ToString() ?? "", usePackUnit, Convert.ToInt32(UiListaZona.Value));

                        _result = _objUsers.UpdateUserLocal(ASPxTextBox4.Text, login, ASPxTextBox3.Text,
                                                            correlative, fileToString, CmbUserRole.Value.ToString(),
                                                            LookupSeller.Value.ToString(), bodega, bodegapre,
                                                            Convert.ToInt16(LookupRoles.Value),
                                                            UiListaRuta.Value?.ToString() ?? "", Session["connectionString"].ToString(), usePackUnit, Convert.ToInt32(UiListaZona.Value));

                        //byte[] imagen64 = new byte[uplImage.UploadedFiles.Length];
                        //uplImage.UploadedFiles[0].FileContent.Read(imagen64, 0, uplImage.UploadedFiles.Length);
                        //fileToString = System.Convert.ToBase64String(imagen64);
                        if (_result != "OK")
                        {
                            ScriptManager.RegisterStartupScript(this, GetType(), "ErrorText",
                                                                "CallError('Error: " + _result + "');", true);
                        }

                        GetWarehouseNotAsign("");
                        GetUsers();
                        Clean();
                    }
                    else
                    {
                        //fileToString = cod.PhotoUtils.ConvertImageToBase64(previewImage);
                        if (Session["base64Profile"] != null)
                        {
                            fileToString             = Session["base64Profile"].ToString();
                            Session["base64Profile"] = null;
                        }

                        try
                        {
                            string bodega    = "";
                            string bodegapre = "";

                            if (LookupWarehouse.Value != null)
                            {
                                bodega = LookupWarehouse.Value?.ToString();
                            }

                            if (LookupWarehousePre.Value != null)
                            {
                                bodegapre = LookupWarehousePre?.Value.ToString();
                            }


                            int correlative = 0;

                            if (ASPxTextBox1.Text != "")
                            {
                                try
                                {
                                    correlative = Convert.ToInt32(ASPxTextBox1.Text);
                                }
                                catch (Exception ex)
                                {
                                    ScriptManager.RegisterStartupScript(this, GetType(), "ErrorText",
                                                                        "CallError('Error: " + ex.Message + "');", true);
                                }
                            }


                            _result = _objUsers.InsertClient(ASPxTextBox5.Text + "@" + enterprise, ASPxTextBox4.Text,
                                                             ASPxComboBox1.Text, ASPxTextBox3.Text, enterprise, correlative, fileToString,
                                                             UiListaRuta.Value?.ToString() ?? "", LookupSeller.Value?.ToString(),
                                                             CmbUserRole.Value?.ToString(), bodega, bodegapre, LookupRoles.Value?.ToString(), usePackUnit);


                            _result += _objUsers.InsertClientLocal(Session["connectionString"].ToString(),
                                                                   ASPxTextBox5.Text + "@" + enterprise, ASPxTextBox4.Text,
                                                                   ASPxComboBox1.Text, ASPxTextBox3.Text, enterprise, fileToString,
                                                                   UiListaRuta.Value?.ToString() ?? "", LookupSeller.Value?.ToString(),
                                                                   CmbUserRole.Value?.ToString(), bodega, bodegapre, LookupRoles.Value?.ToString(), usePackUnit, Convert.ToInt32(UiListaZona.Value));
                        }
                        catch (Exception ex)
                        {
                            ScriptManager.RegisterStartupScript(this, GetType(), "ErrorText",
                                                                "CallError('Error: " + ex.Message + "');", true);
                        }

                        //byte[] imagen64 = new byte[uplImage.UploadedFiles.Length];
                        //uplImage.UploadedFiles[0].FileContent.Read(imagen64, 0, uplImage.UploadedFiles.Length);
                        //fileToString = System.Convert.ToBase64String(imagen64);
                        if (_result != "OKOK")
                        {
                            ScriptManager.RegisterStartupScript(this, GetType(), "ErrorText",
                                                                "CallError('Error: " + _result + "');", true);
                        }

                        GetWarehouseNotAsign("");
                        GetUsers();
                        Clean();
                    }



                    break;

                case "btnAgregarCliente":
                    fileToString      = string.Empty;
                    Session["ACTION"] = "INSERT";

                    if (Session["ListaRuta"] != null)
                    {
                        UiListaRuta.DataSource = Session["ListaRuta"];
                        UiListaRuta.DataBind();
                    }

                    if (Session["UiListaZona"] != null)
                    {
                        UiListaZona.DataSource = Session["UiListaZona"];
                        UiListaZona.DataBind();
                    }



                    GetWarehouseNotAsign("");

                    if (Session["DS_WAREHOUSE_PRESALE"] != null)
                    {
                        LookupWarehousePre.DataSource = Session["DS_WAREHOUSE_PRESALE"];
                        LookupWarehousePre.DataBind();
                    }
                    else
                    {
                        GetWarehousePreSale();
                    }

                    ASPxComboBox1.Enabled = true;
                    ASPxTextBox4.Enabled  = true;
                    ASPxTextBox5.Enabled  = true;
                    ASPxTextBox3.Enabled  = true;
                    ASPxTextBox1.Enabled  = true;
                    GetUsers();
                    Clean();
                    break;



                case "btnQuitarRuta":
                    _result = _objUsers.DeleteRouteUsers(ASPxTextBox5.Text, Session["connectionString"].ToString());
                    if (_result != "OK")
                    {
                        ScriptManager.RegisterStartupScript(this, GetType(), "ErrorText", "CallError('Error: " + _result + "');", true);
                    }
                    GetUsers();
                    Clean();
                    break;
                }
            }
            catch (Exception ex)
            {
                ScriptManager.RegisterStartupScript(this, GetType(), "ErrorText", "CallError('Error: " + ex.Message + "');", true);
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!ValidarConexionYUsuarioLogueado(sender))
            {
                return;
            }
            LookupWarehouse.GridView.Width = 300;
            LookupRoles.GridView.Width     = 300;
            ASPxTextBox5.Enabled           = true;
            ASPxMenu3.Items.FindByName("btnAgregarCliente").Visible = AgregarCliente();

            if (!Page.IsPostBack)
            {
                GetUsers();
                GetUserRole();
                GetSellers();
                GetWarehouseNotAsign("");
                GetWarehousePreSale();
                GetAllZones();
                //UsuarioSeleccionoUsuario?.Invoke(this,new RutaArgumento{ Data = new Ruta{CODE_ROUTE = "" }, Usuario = new Usuario{ LOGIN = ""}});
                return;
            }
            Connection = Session["connectionString"].ToString();
            if (!Page.IsPostBack)
            {
                Session["ACTION"]        = "UPDATE";
                Session["base64Profile"] = null;
            }
            if (Page.IsPostBack)
            {
                ReportView();
            }
            if (Session["DS_USER"] != null)
            {
                ASPxGridView1.DataSource = Session["DS_USER"];
                ASPxGridView1.DataBind();
            }
            else
            {
                GetUsers();
            }
            if (Session["DS_USER_ROLE"] != null)
            {
                CmbUserRole.DataSource = Session["DS_USER_ROLE"];
                CmbUserRole.ValueField = "NAME_CLASSIFICATION";
                CmbUserRole.TextField  = "VALUE_TEXT_CLASSIFICATION";
                CmbUserRole.DataBind();
            }
            else
            {
                GetUserRole();
            }
            if (Session["DS_SELLER_USER"] != null)
            {
                LookupSeller.DataSource = Session["DS_SELLER_USER"];
                LookupSeller.DataBind();
            }
            else
            {
                GetSellers();
            }
            if (Session["DS_WAREHOUSE_NOTASIGN"] != null)
            {
                LookupWarehouse.DataSource = Session["DS_WAREHOUSE_NOTASIGN"];
                LookupWarehouse.DataBind();
            }
            else
            {
                if (!Page.IsPostBack)
                {
                    GetWarehouseNotAsign("");
                }
            }
            if (Session["DS_WAREHOUSE_PRESALE"] != null)
            {
                LookupWarehousePre.DataSource = Session["DS_WAREHOUSE_PRESALE"];
                LookupWarehousePre.DataBind();
            }
            else
            {
                GetWarehousePreSale();
            }
            if (Session["UiVistaPoligonosDeRuta"] != null)
            {
                UiVistaPoligonosDeRuta.DataSource = Session["UiVistaPoligonosDeRuta"];
                UiVistaPoligonosDeRuta.DataBind();
            }

            if (Session["ListaRuta"] != null)
            {
                UiListaRuta.DataSource = Session["ListaRuta"];
                UiListaRuta.DataBind();
            }
            if (Session["UiListaZona"] != null)
            {
                UiListaZona.DataSource = Session["UiListaZona"];
                UiListaZona.DataBind();
            }
        }