Exemplo n.º 1
0
        /// <summary>
        /// A continent has been selected
        /// </summary>
        /// <param name="sender">The sender of the events</param>
        /// <param name="e">The args of the event</param>
        protected void ContinentsList_SelectedIndexChanged(object sender, EventArgs e)
        {
            Extensions.SqlOperation operation = () =>
            {
                var countries = new CountriesDAO().GetCountries(new Continent { Name = ContinentsList.SelectedValue });
                CountriesList.DataBindWithEmptyElement(countries, "Name", "Name");
            };

            this.Verified(operation, ErrorLabel);
        }
Exemplo n.º 2
0
 /// <summary>
 /// A continent has been selected
 /// </summary>
 /// <param name="sender">The sender of the events</param>
 /// <param name="e">The args of the event</param>
 protected void ContinentList_SelectedIndexChanged(object sender, EventArgs e)
 {
     Extensions.SqlOperation operation = () =>
     {
         var countriesDAO = new CountriesDAO();
         var countries = countriesDAO.GetCountries(new Continent { Name = ContinentList.SelectedValue });
         CountryList.DataSource = countries;
         CountryList.DataBind();
     };
     this.Verified(operation, ErrorLabel);
 }
Exemplo n.º 3
0
        /// <summary>
        /// Load the lists
        /// </summary>
        /// <param name="sender">The sender of the events</param>
        /// <param name="e">The args of the event</param>
        protected void Page_Load(object sender, EventArgs e)
        {
            if (IsPostBack)
            {
                return;
            }

            Extensions.SqlOperation operation = () =>
            {
                //Fill language list
                var languages = new LanguagesDAO().GetAllLanguages();
                LanguagesList.DataBindWithEmptyElement(languages, "Name", "Name");

                //Fill continent list
                var continents = new CountriesDAO().GetAllContinents();
                ContinentsList.DataBindWithEmptyElement(continents, "Name", "Name");
            };

            this.Verified(operation, ErrorLabel);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Load the page, fill the lists and load the informations about the instituion. 
        /// </summary>
        /// <param name="sender">The sender of the events</param>
        /// <param name="e">The args of the event</param>
        protected void Page_Load(object sender, EventArgs e)
        {
            DepartmentLabel.Visible = false;
            if (IsPostBack)
                return;
            Extensions.SqlOperation operation = () =>
            {
                //Languages databound
                var languagesDAO = new LanguagesDAO();
                var languages = languagesDAO.GetAllLanguages();
                LanguageList.DataSource = languages;
                LanguageList.DataBind();

                //Continents databound
                var countriesDAO = new CountriesDAO();
                var continents = countriesDAO.GetAllContinents();
                ContinentList.DataSource = continents;
                ContinentList.DataBind();

                //Add institution
                if (Request.QueryString["institution"] == null)
                {
                    EditAddLabel.Text = "Nouvelle";
                    EditButton.Visible = false;
                    AddButton.Visible = true;

                    //Contries databound
                    var countries = countriesDAO.GetCountries(continents[0]);
                    CountryList.DataSource = countries;
                    CountryList.DataBind();
                }
                //Edit institution
                else
                {
                    EditAddLabel.Text = "Modification";
                    var institutionId = Request.QueryString["institution"].ToInt();

                    var connection = DBManager.GetInstance().GetNewConnection();
                    var transaction = connection.BeginTransaction(IsolationLevel.ReadUncommitted);

                    new InstitutionsDAO().LockInstitution(institutionId, transaction);

                    var tr = Interlocked.Increment(ref transactionId);

                    Session["connection" + tr] = connection;
                    Session["transaction" + tr] = transaction;

                    ViewState["transaction"] = tr;

                    //TODO: start transaction to commit add button click
                    EditButton.Visible = true;
                    AddButton.Visible = false;

                    var institution = new InstitutionsDAO().GetInstitution(institutionId, transaction);

                    NameText.Text = institution.Name;
                    DescriptionText.Text = institution.Description;
                    CityText.Text = institution.City;
                    ContinentList.SelectedValue = institution.Country.Continent.Name;

                    //Contries databound
                    var countries = countriesDAO.GetCountries(institution.Country.Continent);
                    CountryList.DataSource = countries;
                    CountryList.DataBind();

                    LanguageList.SelectedValue = institution.Language.Name;
                    InterestText.Text = institution.Interest;

                    //Departments databound
                    DepartmentList.DataSource = institution.Departments;
                    DepartmentList.DataBind();
                }
            };

            this.Verified(operation, ErrorLabel);
        }