示例#1
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (SessionManager.CurrentUser == null)
     {
         Common.RedirectToLoginPage(this);
         return;
     }
     else if (!IsPostBack)
     {
         FillLabelLanguage();
         if (!string.IsNullOrEmpty(Request.QueryString["StudyID"]))
         {
             int studyID = int.Parse(Request.QueryString["StudyID"]);
             ParamFormation study = new ParamFormationRepository().FindOne(new ParamFormation(studyID));
             txtStudyLabel.Text = study.Label;
         }
     }
 }
示例#2
0
    protected void OnBtnSaveClicked(object sender, EventArgs e)
    {
        ParamFormationRepository repo = new ParamFormationRepository();

        ParamFormation saveItem = new ParamFormation();
        saveItem.Label = txtStudyLabel.Text.Trim();

        if (string.IsNullOrEmpty(Request.QueryString["StudyID"]))
        {
            IList<ParamFormation> oldList = repo.GetAllParamFormations(saveItem.Label);
            if (oldList.Count > 0)
            {
                string message = ResourceManager.GetString("itemAlreadyExist");
                string script1 = "<script type=\"text/javascript\">";
                script1 += " alert(\"" + message + "\");";
                script1 += " </script>";

                if (!ClientScript.IsClientScriptBlockRegistered("redirectUser"))
                    ClientScript.RegisterStartupScript(this.GetType(), "redirectUser", script1);
            }
            else
            {
                repo.Insert(saveItem);
            }
        }
        else
        {
            saveItem.FormationID = int.Parse(Request.QueryString["StudyID"]);
            repo.Update(saveItem);
        }

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

        if (!ClientScript.IsClientScriptBlockRegistered("redirectUser"))
            ClientScript.RegisterStartupScript(this.GetType(), "redirectUser", script);
    }
    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;
            }
        }
    }
示例#4
0
    protected void OnStudyDeleteClicked(object sender, EventArgs e)
    {
        LinkButton lnkItem = (LinkButton)sender;
        int studyID = int.Parse(lnkItem.CommandArgument);

        ParamFormation deleteItem = new ParamFormation(studyID);
        ParamFormationRepository repo = new ParamFormationRepository();
        repo.Delete(deleteItem);

        BindGridData();
        gridStudy.DataBind();
    }
示例#5
0
 private void BindGridData()
 {
     ParamFormationRepository repo = new ParamFormationRepository();
     gridStudy.DataSource = repo.GetAllParamFormations();
 }