Exemplo n.º 1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            DireccionesFacturacionDeUsuario.Clear();
            DireccionesEnvioDeUsuario.Clear();
            cargarTipoTel();
            usuarioentidad = (UsuarioEntidad)HttpContext.Current.Session["Usuario"];

            if (usuarioentidad == null)
            {
                Response.Redirect("Home.aspx");
            }

            usuario.Value = usuarioentidad.NombreUsuario;
            clave.Value   = usuarioentidad.Clave;
            clave.Value   = clave.Value.Replace(usuarioentidad.Clave, "*********");

            DatosPersonalesDTO DatosPersonalesDTO = new DatosPersonalesDTO()
            {
                Apellido = usuarioentidad.Apellido,
                Email    = usuarioentidad.Email,
                Nombre   = usuarioentidad.Nombre
            };


            List <DatosPersonalesDTO> ListaDatosPersonalesDTO = new List <DatosPersonalesDTO>();

            ListaDatosPersonalesDTO.Add(DatosPersonalesDTO);
            grilladedatospersonales.DataSource = ListaDatosPersonalesDTO;


            if (!IsPostBack)
            {
                idioma = (LenguajeEntidad)Session["Idioma"];
                if (idioma == null)
                {
                    idioma = new LenguajeEntidad();
                    idioma.DescripcionLenguaje = "es";
                    Session["Idioma"]          = idioma;
                }
                cotizacion = new MonedaEmpresaEntidad();
                cotizacion = (MonedaEmpresaEntidad)Session["Cotizacion"];
                Session.Add("cotizacionAnterior", "");
                grilladedatospersonales.DataBind();
            }
            else
            {
                cotizacion.IdMoneda        = Convert.ToInt16(Master.obtenerValorDropDown());
                Session["Cotizacion"]      = cotizacion;
                idioma.DescripcionLenguaje = Master.obtenerIdiomaCombo();
                Session["Idioma"]          = idioma;
            }
            if (cotizacion != null)
            {
                moneda = _coreMoneda.selectMoneda(cotizacion.IdMoneda);
            }


            TelefonosDelUsuario = UsuarioBLL.SelectTelefonosDeUsuario(usuarioentidad.CUIT, usuarioentidad.NombreUsuario);
            if (TelefonosDelUsuario != null && TelefonosDelUsuario.Count > 0)
            {
                TelefonosDelUsuario = TelefonosDelUsuario.Where(X => X.FecBaja == null).ToList();
            }


            foreach (var tel in TelefonosDelUsuario)
            {
                TelefonoDTO TipodeTelefono = new TelefonoDTO();
                TipodeTelefono.Tipo     = UsuarioBLL.ObtenerTipodeTelefono(tel.miTipoTel.IdTipoTel);
                TipodeTelefono.Telefono = tel.NroTelefono;
                TipodeTelefono.CodArea  = tel.CodArea;
                ListaDeTelefonosDTO.Add(TipodeTelefono);
            }

            grillatelefonos.DataSource = ListaDeTelefonosDTO;

            if (!IsPostBack)
            {
                grillatelefonos.DataBind();
            }

            DireccionesDeUsuario = UsuarioBLL.SelectDireccionesDeUsuarioActuales(usuarioentidad);

            foreach (var item in DireccionesDeUsuario)
            {
                if (item.IdTipoDireccion == 1)
                {
                    DireccionesFacturacionDeUsuario.Add(item);
                }
                else if (item.IdTipoDireccion == 2)
                {
                    DireccionesEnvioDeUsuario.Add(item);
                }
            }

            grilladirecciondefacturacion.DataSource = DireccionesFacturacionDeUsuario;
            if (!IsPostBack)
            {
                grilladirecciondefacturacion.DataBind();
            }

            grilladirecciondeenvio.DataSource = DireccionesEnvioDeUsuario;
            if (!IsPostBack)
            {
                grilladirecciondeenvio.DataBind();
            }

            if (!IsPostBack)
            {
                CargarDropdownProvinciasFact();
                cargarLocalidadesFact();
                CargarDropdownProvinciasEnvio();
                cargarLocalidadesEnvio();
            }

            DropDownList lblIdioma = FindControlFromMaster <DropDownList>("ddlLanguages");

            if (lblIdioma != null)
            {
                lblIdioma.SelectedValue = idioma.DescripcionLenguaje;
            }
            DropDownList lblStatus = FindControlFromMaster <DropDownList>("MonedaDRW");

            if (lblStatus != null)
            {
                if (cotizacion != null)
                {
                    lblStatus.SelectedValue = cotizacion.IdMoneda.ToString();
                }
            }
        }