Exemplo n.º 1
0
		///<summary>Deletes GroupPermissions based on primary key.  Do not call this method unless you have checked specific dependencies first.  E.g. after deleting this permission, there will still be a security admin user.  This method is only called from the CEMT sync.  RemovePermission should probably be used instead.</summary>
		public static void Delete(GroupPermission gp) {
			if(RemotingClient.RemotingRole==RemotingRole.ClientWeb) {
				Meth.GetVoid(MethodBase.GetCurrentMethod(),gp);
				return;
			}
			string command="DELETE FROM grouppermission WHERE GroupPermNum = "+POut.Long(gp.GroupPermNum);
			Db.NonQ(command);
		}
Exemplo n.º 2
0
		///<summary></summary>
		public static long Insert(GroupPermission gp){
			if(RemotingClient.RemotingRole==RemotingRole.ClientWeb) {
				gp.GroupPermNum=Meth.GetLong(MethodBase.GetCurrentMethod(),gp);
				return gp.GroupPermNum;
			}
			if(gp.NewerDate.Year>1880 && gp.NewerDays>0) {
				throw new Exception(Lans.g("GroupPermissions","Date or days can be set, but not both."));
			}
			if(!GroupPermissions.PermTakesDates(gp.PermType)) {
				if(gp.NewerDate.Year>1880 || gp.NewerDays>0) {
					throw new Exception(Lans.g("GroupPermissions","This type of permission may not have a date or days set."));
				}
			}
			return Crud.GroupPermissionCrud.Insert(gp);
		}
Exemplo n.º 3
0
		///<summary></summary>
		public static long Insert(GroupPermission gp){
			if(RemotingClient.RemotingRole==RemotingRole.ClientWeb) {
				gp.GroupPermNum=Meth.GetLong(MethodBase.GetCurrentMethod(),gp);
				return gp.GroupPermNum;
			}
			if(gp.NewerDate.Year>1880 && gp.NewerDays>0) {
				throw new Exception(Lans.g("GroupPermissions","Date or days can be set, but not both."));
			}
			if(!GroupPermissions.PermTakesDates(gp.PermType)) {
				if(gp.NewerDate.Year>1880 || gp.NewerDays>0) {
					throw new Exception(Lans.g("GroupPermissions","This type of permission may not have a date or days set."));
				}
			}
			if(gp.PermType==Permissions.SecurityAdmin) {
				//Make sure there are no hidden users in the group that is about to get the Security Admin permission.
				string command="SELECT COUNT(*) FROM userod WHERE IsHidden=1"
				+" AND UserGroupNum="+gp.UserGroupNum;
				int count=PIn.Int(Db.GetCount(command));
				if(count!=0) {//there are hidden users in this group
					throw new Exception(Lans.g("FormSecurity","Hidden users cannot have the Security Admin permission."));
				}
			}
			return Crud.GroupPermissionCrud.Insert(gp);
		}
Exemplo n.º 4
0
		///<summary></summary>
		public FormGroupPermEdit(GroupPermission cur){
			InitializeComponent();
			Lan.F(this);
			Cur=cur.Copy();
		}
Exemplo n.º 5
0
		private void butSetAll_Click(object sender,EventArgs e) {
			if(gridMain.SelectedIndices.Length==0){
				MsgBox.Show(this,"Please select user first.");
				return;
			}
			GroupPermission perm;
			for(int i=0;i<Enum.GetNames(typeof(Permissions)).Length;i++){
				if(i==(int)Permissions.SecurityAdmin
					|| i==(int)Permissions.StartupMultiUserOld
					|| i==(int)Permissions.StartupSingleUserOld
					|| i==(int)Permissions.EhrKeyAdd)
				{
					continue;
				}
				perm=GroupPermissions.GetPerm(SelectedGroupNum,(Permissions)i);
				if(perm==null){
					perm=new GroupPermission();
					perm.PermType=(Permissions)i;
					perm.UserGroupNum=SelectedGroupNum;
					try{
						GroupPermissions.Insert(perm);
					}
					catch(Exception ex){
						MessageBox.Show(ex.Message);
					}
					changed=true;
				}
			}
			FillTreePerm();
		}
Exemplo n.º 6
0
		private void treePermissions_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e) {
			clickedPermNode=treePermissions.GetNodeAt(e.X,e.Y);
			if(clickedPermNode==null){
				return;
			}
			//treePermissions.BeginUpdate();
			if(clickedPermNode.Parent==null){//level 1
				if(e.X<5 || e.X>17){
					return;
				}
			}
			else if(clickedPermNode.Parent.Parent==null){//level 2
				if(e.X<24 || e.X>36){
					return;
				}
			}
			else if(clickedPermNode.Parent.Parent.Parent==null){//level 3
				if(e.X<43 || e.X>55){
					return;
				}
			}
			if(clickedPermNode.ImageIndex==1){//unchecked, so need to add a permission
				GroupPermission perm=new GroupPermission();
				perm.PermType=(Permissions)clickedPermNode.Tag;
				perm.UserGroupNum=SelectedGroupNum;
				if(GroupPermissions.PermTakesDates(perm.PermType)){
					FormGroupPermEdit FormG=new FormGroupPermEdit(perm);
					FormG.IsNew=true;
					FormG.ShowDialog();
					if(FormG.DialogResult==DialogResult.Cancel){
						treePermissions.EndUpdate();
						return;
					}
				}
				else{
					try{
						GroupPermissions.Insert(perm);
					}
					catch(Exception ex){
						MessageBox.Show(ex.Message);
						return;
					}
				}
			}
			else if(clickedPermNode.ImageIndex==2){//checked, so need to delete the perm
				try{
					GroupPermissions.RemovePermission(SelectedGroupNum,(Permissions)clickedPermNode.Tag);
				}
				catch(Exception ex){
					MessageBox.Show(ex.Message);
					return;
				}
			}
			FillTreePerm();
			changed=true;		
		}
Exemplo n.º 7
0
		private void butSetAll_Click(object sender,EventArgs e) {
			if(gridMain.SelectedIndices.Length==0){
				MsgBox.Show(this,"Please select user first.");
				return;
			}
			GroupPermission perm;
			for(int i=0;i<Enum.GetNames(typeof(Permissions)).Length;i++){
				perm=GroupPermissions.GetPerm(_selectedGroupNum,(Permissions)i);
				if(perm==null){
					perm=new GroupPermission();
					perm.PermType=(Permissions)i;
					perm.UserGroupNum=_selectedGroupNum;
					try{
						GroupPermissions.Insert(perm);
					}
					catch(Exception ex){
						MessageBox.Show(ex.Message);
					}
				}
			}
			FillTreePerm();
		}
Exemplo n.º 8
0
		public FormCentralGroupPermEdit(GroupPermission perm) {
			InitializeComponent();
			_permCur=perm.Copy();
		}