コード例 #1
0
ファイル: AddInstitution.aspx.cs プロジェクト: wichtounet/ICM
        /// <summary>
        /// Add the institution. 
        /// </summary>
        /// <param name="sender">The sender of the events</param>
        /// <param name="e">The args of the event</param>
        protected void AddButton_Click(object sender, EventArgs e)
        {
            Extensions.SqlOperation operation = () =>
            {
                var institutionsDAO = new InstitutionsDAO();

                var departments = (from ListItem department in DepartmentList.Items select new Department {Name = department.Text}).ToList();

                //Intantiate institution
                var language = new Language { Name = LanguageList.SelectedValue };
                var continent = new Continent { Name = ContinentList.SelectedValue };
                var country = new Country { Name = CountryList.SelectedValue, Continent = continent };
                var institution = new Institution(-1,
                                                            NameText.Text,
                                                            DescriptionText.Text,
                                                            CityText.Text,
                                                            InterestText.Text,
                                                            language,
                                                            country,
                                                            departments,
                                                            false);
                var institutionId = institutionsDAO.AddInstitution(institution);
                Response.Redirect("ShowInstitution.aspx?institution=" + institutionId);
            };
            this.Verified(operation, ErrorLabel);
        }
コード例 #2
0
ファイル: Institution.cs プロジェクト: wichtounet/ICM
 /// <summary>
 /// Institution constructor.
 /// </summary>
 /// <param name="Id">Institution's id.</param>
 /// <param name="Name">Institutin's name.</param>
 /// <param name="Description">Institution's description.</param>
 /// <param name="City">Institution's city.</param>
 /// <param name="Interest">Institutin's insterest.</param>
 /// <param name="Language">Institution's language.</param>
 /// <param name="Country">Institution's country.</param>
 /// <param name="Departments">Institution's department.</param>
 /// <param name="IsArchived">Institution's state (archived or not archived).</param>
 public Institution( int Id,
                     string Name,
                     string Description,
                     string City,
                     string Interest,
                     Language Language,
                     Country Country,
                     List<Department> Departments,
                     bool IsArchived)
 {
     this.Id = Id;
     this.Name = Name;
     this.Description = Description;
     this.City = City;
     this.Interest = Interest;
     this.Language = Language;
     this.Country = Country;
     this.Departments = Departments;
     this.IsArchived = IsArchived;
 }
コード例 #3
0
ファイル: AddInstitution.aspx.cs プロジェクト: wichtounet/ICM
        /// <summary>
        /// Save the changes. 
        /// </summary>
        /// <param name="sender">The sender of the events</param>
        /// <param name="e">The args of the event</param>
        protected void EditButton_Click(object sender, EventArgs e)
        {
            Extensions.SqlOperation operation = () =>
            {
                var tr = (int) ViewState["transaction"];
                var transaction = (SqlTransaction) Session["transaction" + tr];
                var connection = (SqlConnection) Session["connection" + tr];

                var institutionId = Request.QueryString["institution"].ToInt();
                var institutionsDAO = new InstitutionsDAO();

                //Instantiate and fill department list
                var departments = (from ListItem department in DepartmentList.Items select new Department {Name = department.Text}).ToList();

                //Intantiate institution
                var language = new Language { Name = LanguageList.SelectedValue };
                var continent = new Continent { Name = ContinentList.SelectedValue };
                var country = new Country { Name = CountryList.SelectedValue, Continent = continent };
                var institution = new Institution(institutionId,
                                                            NameText.Text,
                                                            DescriptionText.Text,
                                                            CityText.Text,
                                                            InterestText.Text,
                                                            language,
                                                            country,
                                                            departments,
                                                            false);

                institutionsDAO.UpdateInstitution(institution, transaction);

                transaction.Commit();
                connection.Close();

                Response.Redirect("ShowInstitution.aspx?institution=" + institutionId);
            };
            this.Verified(operation, ErrorLabel);
        }