protected void Page_Load(object sender, EventArgs e)
    {
        if (SessionManager.CurrentUser == null)
        {
            Common.RedirectToLoginPage(this);
            return;
        }
        else if (!IsPostBack)
        {
            FillLabelLanguage();
            ParamStudyHierarchyRepository repoHie = new ParamStudyHierarchyRepository();
            ddlHierarchy.DataTextField = "Label";
            ddlHierarchy.DataValueField = "HiararchyID";
            ddlHierarchy.DataSource = repoHie.FindAll();
            ddlHierarchy.DataBind();

            if (!string.IsNullOrEmpty(Request.QueryString["StudyLevelID"]))
            {
                int studyLevelID = int.Parse(Request.QueryString["StudyLevelID"]);
                ParamStudyLevel studyLevel = new ParamStudyLevelRepository().FindOne(new ParamStudyLevel(studyLevelID));
                if(studyLevel.ValueHierarchy.HasValue)
                    ddlHierarchy.SelectedValue = studyLevel.ValueHierarchy.Value.ToString();
                txtLabel.Text = studyLevel.Label;
            }
        }
    }
    protected void OnBtnSaveClicked(object sender, EventArgs e)
    {
        ParamStudyLevelRepository repo = new ParamStudyLevelRepository();

        ParamStudyLevel saveItem = new ParamStudyLevel();
        saveItem.ValueHierarchy = int.Parse(ddlHierarchy.SelectedValue);
        saveItem.Label = txtLabel.Text.Trim();

        if (string.IsNullOrEmpty(Request.QueryString["StudyLevelID"]))
        {
            repo.Insert(saveItem);
        }
        else
        {
            saveItem.SchoolID = int.Parse(Request.QueryString["StudyLevelID"]);
            repo.Update(saveItem);
        }

        string script = "<script type=\"text/javascript\">";
        script += " OnBtnSaveClientClicked();";
        script += " </script>";

        if (!ClientScript.IsClientScriptBlockRegistered("redirectUser"))
            ClientScript.RegisterStartupScript(this.GetType(), "redirectUser", script);
    }
Exemplo n.º 3
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (SessionManager.CurrentUser == null)
        {
            Common.RedirectToLoginPage(this);
            return;
        }
        else if (!IsPostBack)
        {
            FillLabelLanguage();
            //Fill data from drop down list.
            int nowYear = DateTime.Today.Year;
            ddlPeriodeFrom.Items.Add(new RadComboBoxItem(string.Empty, string.Empty));
            ddlPeriodeTo.Items.Add(new RadComboBoxItem(string.Empty, string.Empty));

            for (int i = nowYear; i >= 1900; i--)
            {
                ddlPeriodeFrom.Items.Add(new RadComboBoxItem(i.ToString(), i.ToString()));
                ddlPeriodeTo.Items.Add(new RadComboBoxItem(i.ToString(), i.ToString()));
            }

            ddlTraining.DataValueField = "FormationID";
            ddlTraining.DataTextField = "Label";
            ParamFormationRepository formationRepo = new ParamFormationRepository();
            ddlTraining.DataSource = formationRepo.FindAllWithAscSort();
            ddlTraining.DataBind();

            ddlLevel.DataValueField = "SchoolID";
            ddlLevel.DataTextField = "Label";
            ParamStudyLevelRepository studyLevelRepo = new ParamStudyLevelRepository();
            ddlLevel.DataSource = studyLevelRepo.FindAll();
            ddlLevel.Items.Insert(0, new Telerik.Web.UI.RadComboBoxItem(string.Empty, string.Empty));
            ddlLevel.DataBind();
        }
        if (!string.IsNullOrEmpty(Request.QueryString["CandidateFormationID"]))
        {
            if (!IsPostBack)
            {
                int candidateFormationID = int.Parse(Request.QueryString["CandidateFormationID"]);
                CandidateTrainingRepository repo = new CandidateTrainingRepository();
                CandidateTraining training = repo.FindOne(new CandidateTraining(candidateFormationID));

                if (!string.IsNullOrEmpty(training.Period))
                {
                    txtPeriodeString.Text = training.Period;

                    string expression = @"\d{4}\s*-\s*\d{4}";
                    if (Regex.IsMatch(training.Period, expression))
                    {
                        string[] yearArray = training.Period.Split('-');
                        if (1900 <= int.Parse(yearArray[0]) && int.Parse(yearArray[0]) <= DateTime.Now.Year)
                            ddlPeriodeFrom.SelectedValue = yearArray[0];
                        else
                            ddlPeriodeFrom.SelectedValue = string.Empty;
                        if (1900 <= int.Parse(yearArray[1]) && int.Parse(yearArray[1]) <= DateTime.Now.Year)
                            ddlPeriodeTo.SelectedValue = yearArray[1];
                        else
                            ddlPeriodeTo.SelectedValue = string.Empty;
                    }
                }
                if(training.FormationID.HasValue)
                    ddlTraining.SelectedValue = training.FormationID.Value.ToString();
                txtDiploma.Text = training.Diplome;
                if(training.StudyLevelID.HasValue)
                    ddlLevel.SelectedValue = training.StudyLevelID.Value.ToString();
                txtSchool.Text = training.School;
            }
        }
    }
Exemplo n.º 4
0
    protected void OnStudyLevelDeleteClicked(object sender, EventArgs e)
    {
        LinkButton lnkItem = (LinkButton)sender;
        int studyLevelID = int.Parse(lnkItem.CommandArgument);

        ParamStudyLevel deleteItem = new ParamStudyLevel(studyLevelID);
        ParamStudyLevelRepository repo = new ParamStudyLevelRepository();
        repo.Delete(deleteItem);

        BindGridData();
        gridStudyLevel.DataBind();
    }
Exemplo n.º 5
0
 private void BindGridData()
 {
     ParamStudyLevelRepository repo = new ParamStudyLevelRepository();
     gridStudyLevel.DataSource = repo.GetAllStudyLevels();
 }