Ejemplo n.º 1
0
        public IUsrPTO LoadUsrAsig(String cemexId, Int32 idPais, Int32 idRol)
        {
            IUsrPTO usuario = new UsrPTO();

            usuario = cnv.DTOtoPTO(Usr.LoadUsrR(cemexId, idPais));
            if (usuario != null)
            {
                if (Usr.isRolAsig(idRol, usuario.Rol.IdRol) == 1)
                {
                    return(usuario);
                }
                else
                {
                    return(null);
                }
            }
            else
            {
                return(null);
            }
        }
Ejemplo n.º 2
0
        protected void btnGuardar_Click(object sender, EventArgs e)
        {
            try
            {
                if (Page.IsValid)
                {
                    if (int.Parse(ddlRol.SelectedValue) != 0 & int.Parse(ddlStaRs.SelectedValue) != 0)
                    {
                        lblError.Visible = false;
                        IUsrPTO usr = new UsrPTO(txtCemexID.Text.ToLower().Trim(), txtNom.Text, txtEmail.Text,
                                                 new RolPTO(int.Parse(ddlRol.SelectedValue), ddlRol.SelectedItem.ToString()),
                                                 ((IUsr)Session["Usr"]).usr.Pais,
                                                 new StaRgPTO(int.Parse(ddlStaRs.SelectedValue), ddlStaRs.SelectedItem.ToString()));
                        switch (int.Parse(ddlRep.SelectedValue))
                        {
                        case 1:
                            switch (UsrServI.Instance.InsertUsr(usr))
                            {
                            case 0:
                                lblError.Text    = "El Usuario ya se encuentra en el sistema";
                                lblError.Visible = true;
                                break;

                            case 1:
                                btnGuardar.Enabled = false;
                                txtNom.Enabled     = false;
                                txtEmail.Enabled   = false;
                                ddlRol.Enabled     = false;
                                ddlStaRs.Enabled   = false;
                                txtCemexID.Enabled = false;
                                lblResp.Text       = "Datos Guardados";
                                lblResp.Visible    = true;
                                gv_Usr.DataSource  = RUsrServI.Instance.RepUsrs(1, ((IUsr)Session["Usr"]).usr.Pais.IdPais, ((IUsr)Session["Usr"]).usr.Rol.IdRol);
                                gv_Usr.DataBind();
                                break;

                            case 2:
                                lblError.Text    = "Se genero un error en la creación del usuario.";
                                lblError.Visible = true;
                                break;
                            }
                            break;

                        case 2:
                            switch (UsrServI.Instance.UpdateUsr(usr))
                            {
                            case 0:
                                lblError.Text    = "El Usuario a actualizar no existe";
                                lblError.Visible = true;
                                break;

                            case 1:
                                btnGuardar.Enabled = false;
                                txtNom.Enabled     = false;
                                txtEmail.Enabled   = false;
                                ddlRol.Enabled     = false;
                                ddlStaRs.Enabled   = false;
                                txtCemexID.Enabled = false;
                                lblResp.Text       = "Datos Guardados";
                                lblResp.Visible    = true;
                                gv_Usr.DataSource  = RUsrServI.Instance.RepUsrs(1, ((IUsr)Session["Usr"]).usr.Pais.IdPais, ((IUsr)Session["Usr"]).usr.Rol.IdRol);
                                gv_Usr.DataBind();
                                break;

                            case 2:
                                lblError.Text    = "Se genero un error en la actualización";
                                lblError.Visible = true;
                                break;
                            }
                            break;
                        }
                    }
                    else
                    {
                        lblError.Text    = "Datos Insuficientes";
                        lblError.Visible = true;
                    }
                }
            }
            catch (Exception)
            {
                lblError.Text    = "Se genero un error, Contacte al Administrador";
                lblError.Visible = true;
            }
        }