Esempio n. 1
0
 protected void btnDelete_Click(object sender, EventArgs e)
 {
     using (DataClassDataContext dbContext = new DataClassDataContext())
     {
         var employee = dbContext.Employees.OrderByDescending(emp => emp.ID).Take(1);
         foreach (var emp in employee)
         {
             dbContext.Employees.DeleteOnSubmit(emp);
         }
         dbContext.SubmitChanges();
     }
     GetData();
 }
Esempio n. 2
0
 protected void btnUpdate_Click(object sender, EventArgs e)
 {
     using (DataClassDataContext dbContext = new DataClassDataContext())
     {
         var employee = dbContext.Employees.OrderByDescending(emp => emp.ID).Take(1);
         foreach (var emp in employee)
         {
             emp.Salary       = 55555;
             emp.DepartmentId = 1;
         }
         dbContext.SubmitChanges();
     }
     GetData();
 }
Esempio n. 3
0
 protected void btnInsert_Click(object sender, EventArgs e)
 {
     using (DataClassDataContext dbContext = new DataClassDataContext())
     {
         Employee employee = new Employee
         {
             FirstName    = "Deborah",
             LastName     = "Kurata",
             Gender       = "Female",
             Salary       = 30000,
             DepartmentId = 3
         };
         dbContext.Employees.InsertOnSubmit(employee);
         dbContext.SubmitChanges();
     }
     GetData();
 }