示例#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!!!");
     }
 }
示例#2
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!!!");
     }
 }
示例#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!!!");
            }
        }
示例#4
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.ToString(),
                    EmployeeName = txtName.Text.ToString()
                };

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