Exemplo n.º 1
0
        protected void ProfessorsGridView_RowUpdating(object sender, GridViewUpdateEventArgs e)
        {
            string ProfID = ((Label)ProfessorsGridView.Rows[e.RowIndex]
                             .FindControl("lblProfessorID")).Text;
            string FirstName = ((TextBox)ProfessorsGridView.Rows[e.RowIndex]
                                .FindControl("txtProfessorFirstName")).Text;
            string LastName = ((TextBox)ProfessorsGridView.Rows[e.RowIndex]
                               .FindControl("txtProfessorLastName")).Text;
            DateTime startDate = ((Calendar)ProfessorsGridView.Rows[e.RowIndex]
                                  .FindControl("calendarStartDate")).SelectedDates[0];
            List <int> chkLabsIds = ((CheckBoxList)ProfessorsGridView.Rows[e.RowIndex]
                                     .FindControl("chkLabs")).Items.Cast <ListItem>().Where(i => i.Selected).Select(t => int.Parse(t.Value)).ToList();
            User prof = new User();

            prof.UserID    = int.Parse(ProfID);
            prof.LastName  = LastName;
            prof.FirstName = FirstName;
            prof.HireDate  = startDate;

            universityBL.UpdateProfessor(prof);

            universityBL.UpdateProfPerLab(int.Parse(ProfID), chkLabsIds);
            ProfessorsGridView.EditIndex  = -1;
            ProfessorsGridView.DataSource = universityBL.GetProfessors();
            ProfessorsGridView.DataBind();
        }
Exemplo n.º 2
0
        protected void lnkRemove_Click(object sender, EventArgs e)
        {
            LinkButton lnkRemove = (LinkButton)sender;
            int        profID    = int.Parse(lnkRemove.CommandArgument);

            universityBL.DeleteProfessor(profID);
            ProfessorsGridView.DataSource = universityBL.GetProfessors();
            ProfessorsGridView.DataBind();
        }
Exemplo n.º 3
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         ProfessorsGridView.DataSource = universityBL.GetProfessors();
         ProfessorsGridView.DataBind();
         chkLabsBind();
     }
 }
Exemplo n.º 4
0
        protected void btnAdd_Click(object sender, EventArgs e)
        {
            TextBox      firstname = (TextBox)ProfessorsGridView.FooterRow.FindControl("txtNewProfFirstName") as TextBox;
            TextBox      lastname  = (TextBox)ProfessorsGridView.FooterRow.FindControl("txtNewProfLastName") as TextBox;
            Calendar     hiredate  = (Calendar)ProfessorsGridView.FooterRow.FindControl("cNewProfHireDate") as Calendar;
            CheckBoxList labs      = (CheckBoxList)ProfessorsGridView.FooterRow.FindControl("chkLabsNewProf") as CheckBoxList;

            User newProf = new User
            {
                LastName  = lastname.Text,
                FirstName = firstname.Text,
                HireDate  = hiredate.SelectedDate
            };
            int id = universityBL.InsertProfessor(newProf);

            universityBL.InsertProfPerLab(id, labs.Items.Cast <ListItem>().Where(i => i.Selected).Select(t => int.Parse(t.Value)).ToList());
            ProfessorsGridView.DataSource = universityBL.GetProfessors();
            ProfessorsGridView.DataBind();
        }
Exemplo n.º 5
0
 protected void SearchButton_Click(object sender, EventArgs e)
 {
     ProfessorsGridView.DataSource = universityBL.GetProfessorsByName(SearchTextBox.Text).ToList();
     ProfessorsGridView.DataBind();
 }
Exemplo n.º 6
0
 protected void ProfessorsGridView_RowCancelingEdit(object sender, GridViewCancelEditEventArgs e)
 {
     ProfessorsGridView.EditIndex  = -1;
     ProfessorsGridView.DataSource = universityBL.GetProfessors();
     ProfessorsGridView.DataBind();
 }
Exemplo n.º 7
0
 protected void ProfessorsGridView_RowEditing(object sender, GridViewEditEventArgs e)
 {
     ProfessorsGridView.EditIndex  = e.NewEditIndex;
     ProfessorsGridView.DataSource = universityBL.GetProfessors();
     ProfessorsGridView.DataBind();
 }