Exemplo n.º 1
0
    void Page_Load(object sender, EventArgs e)
    {
        // disable the UI for annonymous user when the config switch is disable

          if (Page.User.IsInRole("ProjectAdministrator"))
          {

          SQLDataAccess objSQLDataAccess = new SQLDataAccess();
          List<Category> objCategorylist = objSQLDataAccess.GetCategoriesByUserName(Convert.ToString(""));
          DropDownList CategoryList = (DropDownList)CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("categoryList");
          CategoryList.DataSource = objCategorylist;
          CategoryList.DataTextField = "Name";
          CategoryList.DataValueField = "Id";
          CategoryList.DataBind();
          }
          if (!Page.User.Identity.IsAuthenticated && String.Compare(ConfigurationManager.AppSettings["AllowUserCreationForAnonymousUsers"], "0") == 0)
          {
          noAccessMsg.Visible = true;
          CreateUserWizard1.Visible = false;
          }

          if (!Page.IsPostBack)
          {
          if (Page.User.IsInRole("ProjectAdministrator"))
          {
              CreateUserWizard1.LoginCreatedUser = false;
              GroupName.SelectedValue = GetDefaultRoleForNewUser();
          }
          bindTeamLeaders();
          }
    }
Exemplo n.º 2
0
    void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack) {
          if ((Page.User.IsInRole("ProjectAdministrator") || Page.User.IsInRole("ProjectManager"))) {
        UserList.DataSourceID = "ProjectMembers";

        //if (Page.User.ToString() != null && Page.User.ToString() != "")
        //{
        //    UserList.SelectedValue = Page.User.ToString();
        //}
          //UserList.SelectedValue=
        if (Page.User.IsInRole("ProjectAdministrator")) {
          ProjectData.SortParameterName = "sortParameter";
          ProjectData.SelectMethod = "GetAllProjects";
          divTimeSheet.Visible = false;
          AllProjectList.DataBind();
          ListItem select = new ListItem("Select", "0");
          if (AllProjectList.Items.Contains(select).ToString() != "True")
          {
              AllProjectList.Items.Insert(0, new ListItem("Select All", "0"));
          }
          UserList.DataBind();

          ProjectList.Items.Insert(0, new ListItem("Select", "0"));
          admin.Attributes.Add("style","width:0px;");
          admin.Visible = false;
        }
        else if (Page.User.IsInRole("ProjectManager")) {

          ProjectData.SelectParameters.Add(new Parameter("userName", TypeCode.String, Page.User.Identity.Name));
          ProjectData.SelectMethod = "GetProjectsByUserName";
          SQLDataAccess objSQLDataAccess = new SQLDataAccess();
          List<Category> objCategorylist = objSQLDataAccess.GetCategoriesByUserName(Convert.ToString(""));
          CategoryList.DataSource = objCategorylist;
          CategoryList.DataTextField = "Name";
          CategoryList.DataValueField = "Id";
          //CategoryList.DA =Convert.ToString(objCategorylist[0].Name);
          //CategoryList.SelectedValue = Convert.ToString(objCategorylist[0].Id);
          CategoryList.DataBind();
          AllProjectList.DataBind();
          ListItem select = new ListItem("Select", "0");
          if (AllProjectList.Items.Contains(select).ToString() != "True")
          {
              AllProjectList.Items.Insert(0, new ListItem("Select All", "0"));
          }
          UserList.DataBind();
          UserList.Items.Insert(0, new ListItem("Select", "0"));
          //ProjectList.Items.Insert(0, new ListItem("Select", "0"));
        }
          }
          else if (Page.User.IsInRole("TeamLeader"))
          {
          ProjectData.SelectParameters.Add(new Parameter("userName", TypeCode.String, Page.User.Identity.Name));
          ProjectData.SelectMethod = "GetProjectsByUserName";
          UserList.Items.Add(Page.User.Identity.Name);

          SQLDataAccess objSQLDataAccess = new SQLDataAccess();
          List<Category> objCategorylist = objSQLDataAccess.GetCategoriesByUserName(Convert.ToString(Page.User.Identity.Name));
          CategoryList.DataSource = objCategorylist;
          CategoryList.DataTextField = "Name";
          CategoryList.DataValueField = "Id";
          //CategoryList.DA =Convert.ToString(objCategorylist[0].Name);
          //CategoryList.SelectedValue = Convert.ToString(objCategorylist[0].Id);
          CategoryList.DataBind();
          AllProjectList.DataBind();
          ListItem select = new ListItem("Select", "0");
          if (AllProjectList.Items.Contains(select).ToString() != "True")
          {
              AllProjectList.Items.Insert(0, new ListItem("Select All", "0"));
          }

         // ProjectList.Items.Insert(0, new ListItem("Select", "0")); /
          }
          else
          {
          ProjectData.SelectParameters.Add(new Parameter("userName", TypeCode.String, Page.User.Identity.Name));

          ProjectData.SelectMethod = "GetProjectsByUserName";
          CustomFacade objCustomFacade = new CustomFacade();
          List<Project> listProject = new List<Project>();
          //listProject = objCustomFacade.GetProjectsByUserName(Page.User.Identity.Name);

          UserList.Items.Add(Page.User.Identity.Name);
          //UserList.Items.Insert(0, new ListItem("Select", "0"));

          SQLDataAccess objSQLDataAccess = new SQLDataAccess();
          List<Category> objCategorylist = objSQLDataAccess.GetCategoriesByUserName(Convert.ToString(Page.User.Identity.Name));
          CategoryList.DataSource = objCategorylist;
          CategoryList.DataTextField = "Name";
          CategoryList.DataValueField = "Id";
          //CategoryList.DA =Convert.ToString(objCategorylist[0].Name);
          //CategoryList.SelectedValue = Convert.ToString(objCategorylist[0].Id);
          CategoryList.DataBind();
          AllProjectList.DataBind();
          ListItem select = new ListItem("Select", "0");
          if (AllProjectList.Items.Contains(select).ToString() != "True")
          {
              AllProjectList.Items.Insert(0, new ListItem("Select All", "0"));
          }
          //ProjectList.Items.Insert(0, new ListItem("Select", "0"));
          }
          username.Text = "Welcome: " + Session["username"];
          ProjectList.DataBind();
          //ProjectList.Items.Insert(0, new ListItem("Select", "0"));

          //if (ProjectList.SelectedValue != "0" && ProjectList.SelectedValue != "")
          //{
          //    if (Session["username"] != null && Session["username"] != "")
          //    {
          //        UserList.SelectedItem.Text = Convert.ToString(Session["username"]);
          //    }
          //}

          //if (ProjectListGridView.Rows.Count==0)
          //{
          //    lblexport.Visible =false;
          //    lnkexport.Visible = false;
          //}
          if (ProjectList.Items.Count >= 1)
          {
          TimeEntryView.Visible = true;
          MessageView.Visible = false;
          }
          else
          {
          TimeEntryView.Visible = true;
          MessageView.Visible = false;
          }
          StartDate.Text = DateTime.Now.Date.AddDays(-7).ToShortDateString();
          EndDate.Text = DateTime.Now.ToShortDateString();
          ProjectListGridView.DataBind();
        }
        if (UserList.Items.Count == 0) {
        AddEntry.Enabled = false;
        }
    }
    void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            MonthList.SelectedValue = Convert.ToString(DateTime.Now.Month);
            YearList.SelectedValue = Convert.ToString(DateTime.Now.Year);
            if (Page.User.IsInRole("ProjectAdministrator") || Page.User.IsInRole("ProjectManager"))
            {

                SQLDataAccess objSQLDataAccess = new SQLDataAccess();
                List<Category> objCategorylist = objSQLDataAccess.GetCategoriesByUserName(Convert.ToString(""));
                CategoryList.DataSource = objCategorylist;
                CategoryList.DataTextField = "Name";
                CategoryList.DataValueField = "Id";
                CategoryList.DataBind();

            }
            DateTime startingDate = DateTime.Now;
            DateTime endDate = DateTime.Now;
            StartDate.Text = DateTime.Now.Date.AddDays(-7).ToShortDateString();
            txtDate.Text = DateTime.Now.Date.ToShortDateString();
            BindProjects();
        }
    }