private void button1_Click(object sender, RoutedEventArgs e) { //using (TransactionScope ts = new TransactionScope()) //{ // DepartmentDAL deptDal = new DepartmentDAL(); // deptDal.Insert("aaa"); // deptDal.Insert("fffffffffffffffffffffffffff"); // test2();//嵌套事务 // throw new Exception(); // ts.Complete(); //} using (TransactionScope ts = new TransactionScope()) { DepartmentDAL dal = new DepartmentDAL(); dal.Insert("测试1"); //EmployeeDAL employeeDAl = new EmployeeDAL(); //Employee emp = new Employee(); //emp. //employeeDAl.Insert(emp); Operator op = new Operator(); op.UserName = "******"; op.Password = "******"; op.RealName = "haha"; new OperatorDAL().Insert(op); ts.Complete(); } }
private void Window_Loaded_1(object sender, RoutedEventArgs e) { if (!IsAddNew) { Department dept = new DepartmentDAL().GetById(EditingId); txtName.Text = dept.Name; } txtName.Focus(); }