void NewGrpup() { Cursor c = this.Cursor; this.Cursor = Cursors.Wait; this.btnOK.IsEnabled = false; NavigateGroup vItem = new NavigateGroup(); vItem.ID = Guid.NewGuid().ToString().ToUpper(); vItem.Name = this.tbName.Text; vItem.Description = this.tbDescription.Text; vItem.Attributes = this.Props; vItem.ParentID = this.ParentID.ToUpper(); DataPortal <NavigateGroup> dp = new DataPortal <NavigateGroup>(); dp.BeginExistsInDb(vItem).Completed += (s, e) => { FuncTask funcTask = s as FuncTask; if (funcTask.Error != null) { this.Cursor = c; this.btnOK.IsEnabled = true; MessageBox.Show("检查导航信息时发生错误:" + funcTask.Error.Message, "错误", MessageBoxButton.OK); return; } else { List <string> members = new List <string>(this.memberList.Count); foreach (var item in this.memberList) { members.Add(item.Guid.ToUpper()); } FuncTask task = new FuncTask(); IGroupService service = ServiceContainer.GetService <IGroupService>(task); service.UpdateGroup(vItem, members); task.Completed += (s2, e2) => { if (task.Error != null) { this.Cursor = c; this.btnOK.IsEnabled = true; MessageBox.Show("完成业务处理时发生错误:" + task.Error.Message, "错误", MessageBoxButton.OK); return; } else { this.Cursor = c; this.btnOK.IsEnabled = true; this.iclose = true; this.DataEntity = task.Result; this.DialogResult = true; this.Close(); } }; } }; }
void NewItem() { Cursor c = this.Cursor; this.Cursor = Cursors.Wait; this.btnOK.IsEnabled = false; AppSetting vItem = new AppSetting(); vItem.Category = this.tbCategory.Text; vItem.Key = this.tbName.Text; vItem.Description = this.tbDescription.Text; vItem.Value = this.tbValue.Text; DataPortal <AppSetting> dp = new DataPortal <AppSetting>(); dp.BeginExistsInDb(vItem).Completed += (s, e) => { FuncTask funcTask = s as FuncTask; if (funcTask.Error != null) { this.Cursor = c; this.btnOK.IsEnabled = true; MessageBox.Show("检查参数信息时发生错误:" + funcTask.Error.Message, "错误", MessageBoxButton.OK); return; } else { bool exists = (bool)funcTask.Result; if (exists) { this.Cursor = c; this.btnOK.IsEnabled = true; this.tbName.Focus(); MessageBox.Show("已存在同名的账户类型,请重新定义账户类型信息!" + funcTask.Error.Message, "错误", MessageBoxButton.OK); return; } dp.BeginInsert(vItem).Completed += (s2, e2) => { InvokeTask task = s2 as InvokeTask; if (task.Error != null) { this.Cursor = c; this.btnOK.IsEnabled = true; MessageBox.Show("完成业务处理时发生错误:" + task.Error.Message, "错误", MessageBoxButton.OK); return; } else { this.Cursor = c; this.btnOK.IsEnabled = true; this.iclose = true; this.DataEntity = vItem; this.DialogResult = true; this.Close(); } }; } }; }
void NewRole() { Cursor c = this.Cursor; this.Cursor = Cursors.Wait; this.btnOK.IsEnabled = false; Role vRole = new Role(); vRole.Name = this.tbName.Text; vRole.Description = this.tbDescription.Text; DataPortal <Role> dp = new DataPortal <Explorer.Entities.Role>(); dp.BeginExistsInDb(vRole).Completed += (s, e) => { FuncTask funcTask = s as FuncTask; if (funcTask.Error != null) { this.Cursor = c; this.btnOK.IsEnabled = true; MessageBox.Show("检查角色信息时发生错误:" + funcTask.Error.Message, "错误", MessageBoxButton.OK); return; } else { List <string> members = new List <string>(this.memberList.Count); foreach (var item in this.memberList) { members.Add(item.LoginID); } List <ACL> pList = new List <ACL>(); foreach (var item in this.permissionList) { pList.Add(new ACL { PObject = item.PObject.ToUpper(), PType = item.PType, Privileger = item.Privileger, PValue = item.PValue }); } InvokeTask task = new InvokeTask(); IRoleService service = ServiceContainer.GetService <IRoleService>(task); service.UpdateRole(vRole, members, pList); task.Completed += (s2, e2) => { if (task.Error != null) { this.Cursor = c; this.btnOK.IsEnabled = true; MessageBox.Show("完成业务处理时发生错误:" + task.Error.Message, "错误", MessageBoxButton.OK); return; } else { this.Cursor = c; this.btnOK.IsEnabled = true; this.iclose = true; this.DataEntity = vRole; this.DialogResult = true; this.Close(); } }; } }; }
void NewAccount() { Cursor c = this.Cursor; this.Cursor = Cursors.Wait; this.btnOK.IsEnabled = false; Account vItem = new Account(); vItem.LoginID = this.tbLoginID.Text; vItem.OrganID = this.tbCategory.Tag.ToString(); vItem.OrganName = this.tbCategory.Text; vItem.Name = this.tbName.Text; vItem.Description = this.tbDescription.Text; vItem.Leader = this.cbLeader.IsChecked.HasValue ? (this.cbLeader.IsChecked.Value ? 1:0) : 0; DataPortal <Account> dp = new DataPortal <Explorer.Entities.Account>(); dp.BeginExistsInDb(vItem).Completed += (s, e) => { FuncTask funcTask = s as FuncTask; if (funcTask.Error != null) { this.Cursor = c; this.btnOK.IsEnabled = true; MessageBox.Show("检查账号信息时发生错误:" + funcTask.Error.Message, "错误", MessageBoxButton.OK); return; } else { List <string> members = new List <string>(this.memberList.Count); foreach (var item in this.memberList) { members.Add(item.RoleName); } List <ACL> pList = new List <ACL>(); foreach (var item in this.permissionList) { pList.Add(new ACL { PObject = item.PObject, PType = item.PType, Privileger = item.Privileger, PValue = item.PValue }); } InvokeTask task = new InvokeTask(); IAccountService service = ServiceContainer.GetService <IAccountService>(task); service.UpdateAccount(vItem, this.tbPassword.Text, members, pList); task.Completed += (s2, e2) => { if (task.Error != null) { this.Cursor = c; this.btnOK.IsEnabled = true; MessageBox.Show("完成业务处理时发生错误:" + task.Error.Message, "错误", MessageBoxButton.OK); return; } else { this.Cursor = c; this.btnOK.IsEnabled = true; this.iclose = true; this.DataEntity = vItem; this.DialogResult = true; this.Close(); } }; } }; }