public void AddFaculty() { Faculty_BLL facultyBLL = new Faculty_BLL(); string Code = txtCode.Text; string Name = txtName.Text; DateTime Creation_Date = Convert.ToDateTime(txtCreationDate.Text); int University = int.Parse(ddlUniversity.SelectedValue); facultyBLL.AddFaculty(Code, Name, Creation_Date, University); }
public void AddFaculty() { Faculty_BLL facultyBLL = new Faculty_BLL(); Faculty faculty = new Faculty(); //Accesing to the attributes from my faculty object faculty.Code = txtCode.Text; faculty.Name = txtName.Text; faculty.Creation_date = Convert.ToDateTime(txtCreationDate.Text); faculty.University = int.Parse(ddlUniversity.SelectedValue); faculty.City = int.Parse(ddlCity.SelectedValue); try { //LINQ SubjectFaculty subjectFaculty; List <SubjectFaculty> subjectList = new List <SubjectFaculty>(); foreach (ListItem item in SubjectListBox.Items) { if (item.Selected) { subjectFaculty = new SubjectFaculty(); subjectFaculty.subject = int.Parse(item.Value); subjectFaculty.faculty = faculty.ID_Faculty; subjectList.Add(subjectFaculty); } } facultyBLL.AddFaculty(faculty//,subjectList ); ClearFields(); } catch (Exception ex) { Page.ClientScript.RegisterStartupScript(this.GetType(), "Registration", "alert('" + ex.Message + "')", true); } }