private void rdow_Checked(object sender, RoutedEventArgs e) { if (lstModelConn.SelectedItem == null) { return; } int saveselectindex = lstModelConn.SelectedIndex; string connid = (lstModelConn.SelectedItem as DataRowView).Row.Field <System.Guid>("connid").ToString(); string modelid = (lstModelConn.SelectedItem as DataRowView).Row.Field <System.Guid>("modelid").ToString(); string sql = string.Format("update connectionsinmodels set isreadonly=0 where connid='{0}' and modelid='{1}'", connid, modelid); if (DBOperate.executeCommand(sql)) { vm.refreshModelConn(); } lstModelConn.SelectedIndex = saveselectindex; }
private void btnAddModelConnRelation_Click(object sender, RoutedEventArgs e) { if (lstConn.SelectedItem == null || lstModel.SelectedItem == null || string.IsNullOrWhiteSpace(vm.applicationid)) { return; } string connid = (lstConn.SelectedItem as DataRowView).Row.Field <System.Guid>("connid").ToString(); string connname = (lstConn.SelectedItem as DataRowView).Row.Field <string>("datasourcename"); string modelid = (lstModel.SelectedItem as DataRowView).Row.Field <System.Guid>("modelid").ToString(); string modelname = (lstModel.SelectedItem as DataRowView).Row.Field <string>("modelname"); string sql = string.Format("insert connectionsinmodels (connid,modelid) values ('{0}','{1}')", connid, modelid); if (DBOperate.executeCommand(sql)) { vm.refreshModelConn(); txtInfo.Text = string.Format("授权模块{0}拥有使用{1}权限。", modelname, connname); } }
private void btnAddRoleModelRelation_Click(object sender, RoutedEventArgs e) { if (lstRole.SelectedItem == null || lstModel.SelectedItem == null || string.IsNullOrWhiteSpace(vm.applicationid)) { return; } string roleid = (lstRole.SelectedItem as DataRowView).Row.Field <System.Guid>("roleid").ToString(); string rolename = (lstRole.SelectedItem as DataRowView).Row.Field <string>("rolename"); string modelid = (lstModel.SelectedItem as DataRowView).Row.Field <System.Guid>("modelid").ToString(); string modelname = (lstModel.SelectedItem as DataRowView).Row.Field <string>("modelname"); string sql = string.Format("insert modelsinroles (roleid,modelid) values ('{0}','{1}')", roleid, modelid); if (DBOperate.executeCommand(sql)) { vm.refreshRoleModel(); txtInfo.Text = string.Format("授权角色{0}拥有{1}模块权限。", rolename, modelname); } }
private void btnDelDBS_Click(object sender, RoutedEventArgs e) { if (lstConn.SelectedItem == null || string.IsNullOrWhiteSpace(vm.applicationid)) { return; } if (MessageBox.Show("删除后不可恢复,确定要删除吗?", "删除确认", MessageBoxButton.OKCancel) == MessageBoxResult.Cancel) { return; } string connid = (lstConn.SelectedItem as DataRowView).Row.Field <System.Guid>("connid").ToString(); string info = (lstConn.SelectedItem as DataRowView).Row.Field <string>("datasourcename") + "——>" + (lstConn.SelectedItem as DataRowView).Row.Field <string>("connname"); string sql = string.Format("delete connections where applicationid='{0}' and connid='{1}'", vm.applicationid, connid); if (DBOperate.executeCommand(sql)) { vm.refreshConn(); txtInfo.Text = string.Format("选定数据源{0}已删除。", info); } }
private void btnDelModelConnRelation_Click(object sender, RoutedEventArgs e) { if (lstModelConn.SelectedItem == null) { return; } if (MessageBox.Show("删除后不可恢复,确定要删除吗?", "删除确认", MessageBoxButton.OKCancel) == MessageBoxResult.Cancel) { return; } string connid = (lstModelConn.SelectedItem as DataRowView).Row.Field <System.Guid>("connid").ToString(); string modelid = (lstModelConn.SelectedItem as DataRowView).Row.Field <System.Guid>("modelid").ToString(); string connname = (lstModelConn.SelectedItem as DataRowView).Row.Field <string>("connname"); string modelname = (lstModelConn.SelectedItem as DataRowView).Row.Field <string>("modelname"); string sql = string.Format("delete connectionsinmodels where connid='{0}' and modelid='{1}'", connid, modelid); if (DBOperate.executeCommand(sql)) { vm.refreshModelConn(); txtInfo.Text = string.Format("已取消模块{0}对{1}的使用权限。", modelname, connname); } }
private void btnDelRoleModelRelation_Click(object sender, RoutedEventArgs e) { if (lstRoleModel.SelectedItem == null) { return; } if (MessageBox.Show("删除后不可恢复,确定要删除吗?", "删除确认", MessageBoxButton.OKCancel) == MessageBoxResult.Cancel) { return; } string roleid = (lstRoleModel.SelectedItem as DataRowView).Row.Field <System.Guid>("roleid").ToString(); string modelid = (lstRoleModel.SelectedItem as DataRowView).Row.Field <System.Guid>("modelid").ToString(); string rolename = (lstRoleModel.SelectedItem as DataRowView).Row.Field <string>("rolename"); string modelname = (lstRoleModel.SelectedItem as DataRowView).Row.Field <string>("modelname"); string sql = string.Format("delete modelsinroles where roleid='{0}' and modelid='{1}'", roleid, modelid); if (DBOperate.executeCommand(sql)) { vm.refreshRoleModel(); txtInfo.Text = string.Format("已取消角色{0}对{1}的使用授权。", rolename, modelname); } }
internal void refreshModelConn() { dtModelConn = DBOperate.getDataTable(string.Format("select t1.*, case when t1.isreadonly=0 then '读写' else '只读' end as flag ,t2.ConnName,t2.DatasourceName,t3.ModelName from ConnectionsInModels t1, Connections t2, Models t3 where t1.ConnID=t2.ConnID and t1.ModelID=t3.ModelID and t2.ApplicationID='{0}' order by t3.ModelName", applicationid)); RaisePropertyChanged(() => dtModelConn); }
internal void refreshRoleModel() { dtRoleModel = DBOperate.getDataTable(string.Format("select t1.*,t2.RoleName,t3.ModelName from ModelsInRoles t1, Roles t2, Models t3 where t1.RoleID=t2.RoleID and t1.ModelID=t3.ModelID and t2.ApplicationID='{0}' order by t2.rolename", applicationid)); RaisePropertyChanged(() => dtRoleModel); }
internal void refreshRoleUser() { dtRoleUser = DBOperate.getDataTable(string.Format("select t1.*,t2.RoleName,t3.UserName from UsersInRoles t1, Roles t2, Users t3 where t1.RoleID=t2.RoleID and t1.UserID=t3.UserID and t2.ApplicationID='{0}' order by t3.username", applicationid)); RaisePropertyChanged(() => dtRoleUser); }
internal void refreshConn() { dtConn = DBOperate.getDataTable(string.Format("select * from connections where applicationid='{0}' order by connname", applicationid)); RaisePropertyChanged(() => dtConn); }
internal void refreshModel() { dtModel = DBOperate.getDataTable(string.Format("select * from models where applicationid='{0}' order by modelname", applicationid)); RaisePropertyChanged(() => dtModel); }
internal void refreshUser() { dtUser = DBOperate.getDataTable(string.Format("select * from users where applicationid='{0}' order by username", applicationid)); RaisePropertyChanged(() => dtUser); }
internal void refreshRole() { dtRole = DBOperate.getDataTable(string.Format("select * from roles where applicationid='{0}' order by rolename", applicationid)); RaisePropertyChanged(() => dtRole); }
internal void refreshApplication() { dtApplication = DBOperate.getDataTable(string.Format("select * from applications")); RaisePropertyChanged(() => dtApplication); }