private void btnInsert_Click(object sender, RoutedEventArgs e) { try { CapgeminiDetails c = new CapgeminiDetails(); c.EmployeeId = ((Employee)cbEmployeeId.SelectedItem).EmployeeID; c.Email = txtEmail.Text; c.LevelId = ((Level)cbLevel.SelectedItem).LevelId; c.DateHired = DateTime.Parse(dpDateHired.Text); c.SpecialityId = ((Speciality)cbSpeciality.SelectedItem).SpecialityID; c.StatusId = ((CivilStatus)cbStatus.SelectedItem).StatusId; bll.Add(c); lsSearch.ItemsSource = bll.GetAll(); lsSearch.DisplayMemberPath = "EmployeeId"; cbEmployeeId.ItemsSource = bll.GetAllEmployee(); cbEmployeeId.DisplayMemberPath = "EmployeeID"; cbStatus.ItemsSource = bll.GetAllStatus(); cbStatus.DisplayMemberPath = "StatusDescription"; cbSpeciality.ItemsSource = bll.GetAllSpeciality(); cbSpeciality.DisplayMemberPath = "SpecialityName"; cbLevel.ItemsSource = bll.GetAllLevel(); cbLevel.DisplayMemberPath = "LevelDescription"; dgRecords.ItemsSource = bll.GetAll(); ClearWindow(); MessageBox.Show("Capgemini Details Added Sucessfully"); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
protected void btnInsert_Click(object sender, EventArgs e) { try { CapgeminiDetails det = new CapgeminiDetails(); det.EmployeeId = int.Parse(ddEmployeeID.SelectedValue); det.Email = txtEmail.Text; det.LevelId = int.Parse(ddlevel.SelectedValue); det.DateHired = DateTime.Parse(dpDateHired.Text); det.SpecialityId = int.Parse(ddSpeciality.SelectedValue); det.StatusId = int.Parse(DropDownList1.SelectedValue); bll.Add(det); Response.Write("<script type='text/javascript'>alert('Details Inserted Successfully');</script>"); Response.Redirect("CapgeminiDetailSearch.aspx"); } catch (CapgeminiDetailsException ex) { Response.Write("<script type='text/javascript'>alert('" + ex.Message + "');</script>"); } catch (SystemException ex) { Response.Write("<script type='text/javascript'>alert('" + ex.Message + "');</script>"); } }