protected void btnDelete_Click(object sender, EventArgs e)
 {
     using (EmployeeInformationDataContext db = new EmployeeInformationDataContext())
     {
         EmployeeDetail emp = db.EmployeeDetails.SingleOrDefault(em => em.EmployeeId == 2);
         db.EmployeeDetails.DeleteOnSubmit(emp);
         db.SubmitChanges();
     }
     GetData();
 }
        protected void btnSubmitUpdate_Click(object sender, EventArgs e)
        {
            using (EmployeeInformationDataContext db = new EmployeeInformationDataContext())
            {
                EmployeeDetail emp = db.EmployeeDetails.SingleOrDefault(em => em.EmployeeId == Convert.ToInt32(SearchTextBox.Text));
                emp.EmployeeName = NameTextBox.Text;
                emp.ContactInfo  = ContactTextBox.Text;

                db.SubmitChanges();
            }
            GetData();
        }
 protected void SearchButton_Click(object sender, EventArgs e)
 {
     using (EmployeeInformationDataContext db = new EmployeeInformationDataContext())
     {
         EmployeeDetail emp = db.EmployeeDetails.SingleOrDefault(em => em.EmployeeId == Convert.ToInt32(SearchTextBox.Text));
         if (emp == null)
         {
             Label1.Text    = "Employee not exist with Id " + SearchTextBox.Text;
             Label1.Visible = true;
         }
         else
         {
             InsertView();
             TextBoxEmpId.Text       = emp.EmployeeId.ToString();
             NameTextBox.Text        = emp.EmployeeName;
             ContactTextBox.Text     = emp.ContactInfo;
             btnSubmitUpdate.Visible = true;
             TextBoxEmpId.Visible    = true;
             Idlabel.Visible         = true;
         }
     }
 }
 protected void btnSubmit_Click(object sender, EventArgs e)
 {
     using (EmployeeInformationDataContext db = new EmployeeInformationDataContext())
     {
         EmployeeDetail newemp = new EmployeeDetail()
         {
             EmployeeName = NameTextBox.Text,
             ContactInfo  = ContactTextBox.Text
         };
         var contact = db.EmployeeDetails.FirstOrDefault(em => em.ContactInfo == ContactTextBox.Text);
         if (contact == null)
         {
             db.EmployeeDetails.InsertOnSubmit(newemp);
             db.SubmitChanges();
         }
         else
         {
             Label1.Visible = true;
         }
     }
     GetData();
 }
Exemplo n.º 5
0
 partial void DeleteEmployeeDetail(EmployeeDetail instance);
Exemplo n.º 6
0
 partial void UpdateEmployeeDetail(EmployeeDetail instance);
Exemplo n.º 7
0
 partial void InsertEmployeeDetail(EmployeeDetail instance);