Beispiel #1
0
 private void button3_Click(object sender, RoutedEventArgs e)
 {
     using (EmployeeDataContext Empdb = new EmployeeDataContext(strConnectionString))
     {
         IQueryable <Employee> EmpQuery = from Emp in Empdb.Employees where Emp.EmployeeName == txtName.Text select Emp;
         Employee EmpRemove             = EmpQuery.FirstOrDefault();
         Empdb.Employees.DeleteOnSubmit(EmpRemove);
         Empdb.SubmitChanges();
         MessageBox.Show("Employee Deleted Successfully!!!");
     }
 }
 private void button3_Click(object sender, RoutedEventArgs e)
 {
     using (EmployeeDataContext Empdb = new EmployeeDataContext(strConnectionString))
     {
         IQueryable<Employee> EmpQuery = from Emp in Empdb.Employees where Emp.EmployeeName == txtName.Text select Emp;
         Employee EmpRemove = EmpQuery.FirstOrDefault();
         Empdb.Employees.DeleteOnSubmit(EmpRemove);
         Empdb.SubmitChanges();
         MessageBox.Show("Employee Deleted Successfully!!!");
     }
 }
Beispiel #3
0
        private void button2_Click(object sender, RoutedEventArgs e)
        {
            //Adding data to the local database
            using (EmployeeDataContext Empdb = new EmployeeDataContext(strConnectionString))
            {
                Employee newEmployee = new Employee
                {
                    EmployeeID   = Convert.ToInt32(txtEmpid.Text),
                    EmployeeAge  = txtAge.Text,
                    EmployeeName = txtName.Text
                };

                Empdb.Employees.InsertOnSubmit(newEmployee);
                Empdb.SubmitChanges();
                MessageBox.Show("Employee Added Successfully!!!");
            }
        }
        private void button2_Click(object sender, RoutedEventArgs e)
        {
            //Adding data to the local database
            using (EmployeeDataContext Empdb = new EmployeeDataContext(strConnectionString))
            {
                Employee newEmployee = new Employee
                {
                    EmployeeID = Convert.ToInt32(txtEmpid.Text),
                    EmployeeAge = txtAge.Text.ToString(),
                    EmployeeName = txtName.Text.ToString()
                };

                Empdb.Employees.InsertOnSubmit(newEmployee);
                Empdb.SubmitChanges();
                MessageBox.Show("Employee Added Successfully!!!");
            }
        }