Ejemplo n.º 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!!!");
     }
 }
Ejemplo n.º 2
0
 public IList<Employee> GetEmployeeList()
 {
     // Fetching data from local database
     IList<Employee> EmployeeList = null;
     using (EmployeeDataContext Empdb = new EmployeeDataContext(strConnectionString))
     {
         IQueryable<Employee> EmpQuery = from Emp in Empdb.Employees select Emp;
         EmployeeList = EmpQuery.ToList();
     }
     return EmployeeList;
 }
Ejemplo n.º 3
0
 private void button1_Click(object sender, RoutedEventArgs e)
 {
     //create database
     using (EmployeeDataContext Empdb = new EmployeeDataContext(strConnectionString))
     {
         if (Empdb.DatabaseExists() == false)
         {
             Empdb.CreateDatabase();
             MessageBox.Show("Employee Database Created Successfully!!!");
         }
         else
         {
             MessageBox.Show("Employee Database already exists!!!");
         }
     }
 }
Ejemplo n.º 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!!!");
            }
        }
Ejemplo n.º 5
0
 private void button5_Click(object sender, RoutedEventArgs e)
 {
     //delete database
     using (EmployeeDataContext Empdb = new EmployeeDataContext(strConnectionString))
     {
         if (Empdb.DatabaseExists())
         {
             Empdb.DeleteDatabase();
             MessageBox.Show("Employee Database Deleted Successfully!!!");
         }
     }
 }