Ejemplo n.º 1
0
        public static String SecurityLevel()
        {
            String result = String.Empty;
            var    staff  = StaffEx.GetByStaffId(ConfigHelper.CurrentUserId);

            if (staff != null)
            {
                result = StaffGroupEx.GetGradeCodeById(staff.GroupId.Value);
            }

            return(result);
        }
Ejemplo n.º 2
0
        public static string PermissionLevel()
        {
            string result = "1"; // Guest

            var user = StaffEx.GetByStaffId(ConfigHelper.CurrentUserId);

            if (user != null)
            {
                result = StaffGroupEx.GetGradeCodeById(user.GroupId.Value);
            }

            return(result);
        }
Ejemplo n.º 3
0
        private void Save()
        {
            using (var ctx = new EF6.RT2020Entities())
            {
                var oSecurity = ctx.StaffSecurity.Find(_SecurityId);
                if (oSecurity == null)
                {
                    oSecurity            = new EF6.StaffSecurity();
                    oSecurity.SecurityId = Guid.NewGuid();
                    oSecurity.StaffId    = _StaffId;
                    ctx.StaffSecurity.Add(oSecurity);
                }

                string gradeCode = StaffGroupEx.GetGradeCodeById((Guid)cboGrade.SelectedValue);
                if (gradeCode.Length > 0)
                {
                    oSecurity.GradeCode = gradeCode;
                }

                oSecurity.Module    = "*";
                oSecurity.Functions = "*";
                oSecurity.CanRead   = chkCanRead.Checked;
                oSecurity.CanWrite  = chkCanWrite.Checked;
                oSecurity.CanPost   = chkCanPost.Checked;
                oSecurity.CanDelete = chkCanDelete.Checked;

                ctx.SaveChanges();

                var id = Guid.Empty;
                if (Guid.TryParse(cboGrade.SelectedValue.ToString(), out id))
                {
                    var oStaff = ctx.Staff.Find(_StaffId);
                    if (oStaff != null)
                    {
                        if (oStaff.GroupId != new Guid(cboGrade.SelectedValue.ToString()))
                        {
                            oStaff.GroupId    = new Guid(cboGrade.SelectedValue.ToString());
                            oStaff.ModifiedBy = ConfigHelper.CurrentUserId;
                            oStaff.ModifiedOn = DateTime.Now;

                            ctx.SaveChanges();
                        }
                    }
                }
            }
        }