public StaffRole Put(StaffRoleDTO obj)
        {
            StaffRole staffRole = new StaffRole();

            staffRole = obj.Map <StaffRole>();
            SessionManager.DoWork(session =>
            {
                if (obj.Id == 0)
                {
                    staffRole.Id = GetMaxId();
                    if (obj.AgentObjectId != Guid.Empty)
                    {
                        staffRole.AgentObject    = new AgentObject();
                        staffRole.AgentObject.Id = obj.AgentObjectId;
                    }
                }
                else
                {
                    if (staffRole != null)
                    {
                        staffRole = obj.Map <StaffRole>();
                        if (obj.AgentObjectId != Guid.Empty)
                        {
                            staffRole.AgentObject    = new AgentObject();
                            staffRole.AgentObject.Id = obj.AgentObjectId;
                        }
                    }
                }
                session.SaveOrUpdate(staffRole);
            });
            return(staffRole);
        }
Example #2
0
 public void ModifyStaffRole(StaffRole request, StaffRoleResponse response)
 {
     ValidRequest(request, new StaffRoleVaildator());
     _roleRepository.DeleteStaffRoleInfo(request.StaffNo);
     _roleRepository.UpdateStaffRoleInfo(request.StaffNo, request.Roles.ToList(), request.CurrOper);
     response.ResponseStatus.ErrorCode = "OK";
 }
Example #3
0
        /// <summary>
        /// 根据选中与取消选中判断权限
        /// </summary>
        /// <param name="Id"></param>
        /// <param name="RoleId"></param>
        /// <returns></returns>
        public ActionResult SystemModelChoice(string Id, string RoleId)
        {
            //string id = Request["Id"].ToString();
            Guid   Sid  = new Guid(RoleId);
            string dSQL = "delete from RoleResourceModule Where RoleId='" + RoleId + "'";

            db.Database.ExecuteSqlCommand(dSQL);
            var       sArray = Id.Split(',');
            StaffRole r      = new StaffRole();

            if (Id != null)
            {
                string sql = "";
                foreach (string a in sArray)  //取出一个添加一个,最后一起保存
                {
                    if (a != "")
                    {
                        sql += string.Format("insert into RoleResourceModule values('{0}','{1}')\r", RoleId, a);
                    }
                }
                db.Database.ExecuteSqlCommand(sql);
            }

            int i = 1;

            return(Json(i > 0, JsonRequestBehavior.AllowGet));
        }
Example #4
0
        private void pbManager_Click(object sender, EventArgs e)
        {
            selectedRole      = StaffRole.Manager;
            labelLogo.Visible = false;

            pbWaiter.Visible   = false;
            pbCook.Visible     = false;
            pbCustomer.Visible = false;

            Point currentLocation = ((PictureBox)sender).Location;
            int   n = 20;

            for (int i = 1; i <= n; i++)
            {
                pbManager.Location = new Point(currentLocation.X + i * (22 - currentLocation.X) / n, currentLocation.Y + i * (82 - currentLocation.Y) / n);
                Refresh();
                Thread.Sleep(5);
            }
            pbManager.Location    = new Point(22, 82);
            labelUsername.Visible = true;
            labelPassword.Visible = true;
            txtUsername.Visible   = true;
            txtPassword.Visible   = true;
            btnLogin.Visible      = true;
            txtUsername.Focus();
        }
Example #5
0
        //GET: Staffs n Role
        public ActionResult Index()
        {
            List <StaffRole> listStaffRole = new List <StaffRole>();
            StaffRole        sr            = null;
            string           connString    = ConfigurationManager.ConnectionStrings["DefaultConnection"].ToString();
            //get User from DB
            SqlConnection conn = new SqlConnection(connString);

            conn.Open();
            string sql = " SELECT U.Name,U.Username,U.Email,R.id FROM users u  "
                         + " INNER JOIN UserRoles ur ON ur.userid = u.id LEFT OUTER JOIN Roles r ON r.id = ur.roleid where ur.roleid = 4 "
                         + " or ur.roleid = 5 or ur.roleid = 6  or ur.roleid = 7";

            SqlCommand    cmd = new SqlCommand(sql, conn);
            SqlDataReader dr  = cmd.ExecuteReader();

            while (dr.Read())
            {
                sr            = new StaffRole();
                sr.StaffName  = dr.GetString(0).Trim();
                sr.StaffEmail = dr.GetString(2).Trim();
                sr.RoleName   = Help.GetStaffRole(Int16.Parse(dr.GetString(3)));
                listStaffRole.Add(sr);
            }
            conn.Close();

            ViewBag.ListOfStaffRole = listStaffRole;

            return(View());
        }
Example #6
0
        public ActionResult editStaffRole(List <Role> r, Guid strid)
        {
            var a = osms.StaffRole.Where(x => x.StaffId == strid).ToList();

            if (a.Count() > 0)
            {
                foreach (var item in a)
                {
                    osms.StaffRole.Remove(item);
                }
            }

            if (r != null)
            {
                foreach (var item in r)
                {
                    StaffRole sro = new StaffRole();
                    sro.id      = Guid.NewGuid();
                    sro.RoleId  = item.Id;
                    sro.StaffId = strid;
                    osms.StaffRole.Add(sro);
                }
            }


            osms.SaveChanges();
            return(Json("OK", JsonRequestBehavior.AllowGet));
        }
Example #7
0
        public ActionResult DeleteConfirmed(int id)
        {
            StaffRole staffRole = db.StaffRoles.Find(id);

            db.StaffRoles.Remove(staffRole);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
        public int GetMaxId()
        {
            var result = new StaffRole();

            SessionManager.DoWork(session =>
            {
                result = session.Query <StaffRole>().OrderByDescending(s => s.Id).Take(1).SingleOrDefault();
            });
            return(result.Id + 1);
        }
Example #9
0
 public ActionResult Edit([Bind(Include = "StaffRoleID,RoleName")] StaffRole staffRole)
 {
     if (ModelState.IsValid)
     {
         db.Entry(staffRole).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(staffRole));
 }
Example #10
0
        public void QueryStaffRoleInfo(StaffRole request, StaffRoleResponse response)
        {
            ValidRequest(request, new StaffRoleVaildator());
            var list = _roleRepository.QueryStaffRoleInfo(request.StaffNo);

            response.QueryData = new Report {
                total = list.Count, rows = list
            };
            response.ResponseStatus.ErrorCode = "OK";
        }
Example #11
0
        public ActionResult QueryPrStaffNoRole(string searchStaffNo)
        {
            StaffRole request = new StaffRole
            {
                RequestType = 0,
                StaffNo     = searchStaffNo
            };
            string response = WeChatHelper.PostService("StaffRole", request);

            return(JavaScript(response));
        }
Example #12
0
        public ActionResult Create([Bind(Include = "StaffRoleID,RoleName")] StaffRole staffRole)
        {
            if (ModelState.IsValid)
            {
                db.StaffRoles.Add(staffRole);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(staffRole));
        }
Example #13
0
        public ActionResult ModifyPrStaffRole(IEnumerable <string> ids, string staffNo)
        {
            StaffRole request = new StaffRole
            {
                RequestType = 1,
                Roles       = ids.ToList(),
                StaffNo     = staffNo,
                CurrOper    = Session["StaffNo"].CastTo(""),
            };
            StaffRoleResponse response = WeChatHelper.PostService <StaffRole, StaffRoleResponse>("StaffRole", request);

            return(Json(response, JsonRequestBehavior.DenyGet));
        }
Example #14
0
        /// <summary>
        /// 员工角色维护
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        public object Post(StaffRole request)
        {
            StaffRoleResponse rsp = new StaffRoleResponse();

            if (request.RequestType == (short)StaffRoleRequestType.QueryStaffRole)
            {
                _privilegeService.QueryStaffRoleInfo(request, rsp);
            }
            if (request.RequestType == (short)StaffRoleRequestType.ModifyStaffRole)
            {
                _privilegeService.ModifyStaffRole(request, rsp);
            }
            return(rsp);
        }
Example #15
0
        // GET: StaffRoles/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            StaffRole staffRole = db.StaffRoles.Find(id);

            if (staffRole == null)
            {
                return(HttpNotFound());
            }
            return(View(staffRole));
        }
        public IEnumerable <Staff> GetByRole(StaffRole role)
        {
            DataTable dt = new DataTable();

            dt = SQLHelper.ExecuteDataTable("select * from T_StaffInfo where [Role]=@Role", new SqlParameter("Role", role));
            List <Staff> list = new List <Staff>();

            foreach (DataRow row in dt.Rows)
            {
                Staff staff = new Staff();
                staff.Name     = (string)row["Name"];
                staff.Password = (string)row["Password"];
                staff.Role     = (StaffRole)row["Role"];
                list.Add(staff);
            }
            return(list);
        }
Example #17
0
 public DepartmentDTO Put(DepartmentDTO obj)
 {
     SessionManager.DoWork(session =>
     {
         Staff st      = session.Query <Staff>().SingleOrDefault(a => a.Id == obj.StaffId);
         StaffRole str = st.StaffRoles.SingleOrDefault(a => a.Id == obj.StaffRoleId);
         if (str != null)
         {
             st.StaffRoles.Remove(str);
         }
         st.StaffRoles.Add(new StaffRole()
         {
             Id = obj.StaffRoleId
         });
         session.SaveOrUpdate(st);
     });
     return(obj);
 }
Example #18
0
        public List <Models.SystemResourceModule> GetSystemResources(Guid id)
        {
            StaffRole   sRData           = db.StaffRole.Where(x => x.StaffId == id).FirstOrDefault();//用户是什么角色
            List <Guid> ResourceModuleId = new List <Guid>();

            if (sRData != null)
            {
                List <RoleResourceModule> rrData = db.RoleResourceModule.Where(x => x.RoleId == sRData.RoleId).ToList();//这个角色有什么资源
                foreach (RoleResourceModule item in rrData)
                {
                    ResourceModuleId.Add(item.ResourceModuleId);
                }
            }

            List <SystemResourceModule> srsDate = db.SystemResourceModule.Where(x => ResourceModuleId.Contains(x.Id)).ToList();//查询系统资源库中包含ResourceModuleId的条目

            return(srsDate);
        }
Example #19
0
        public JsonResult EditStaffRole(StaffRole role)
        {
            StaffData data = new StaffData();

            try
            {
                data.EditStaffRole(role);

                return(Json(new
                {
                    data = "บันทึกข้อมูลสำเร็จ",
                    success = true
                }, JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                return(Json(new
                {
                    data = ex.Message,
                    success = false
                }, JsonRequestBehavior.AllowGet));
            }
        }
 public void DeleteStaffRoleRelationship(StaffRole staffRole)
 {
     _context.StaffRoles.Remove(staffRole);
 }
Example #21
0
        public async Task InitializeHotel(int hotelId, string adminId)
        {
            ctx.HotelConfigs.Add(new HotelConfig {
                Id = hotelId,
                IsPrintReciptAfterPayingOffline = true
            });

            ctx.PayKinds.Add(new PayKind {
                Name     = "现金",
                Type     = PayKindType.Cash,
                Usable   = true,
                Discount = 1
            });
            ctx.PayKinds.Add(new PayKind {
                Name        = "微信支付",
                Type        = PayKindType.Online,
                Usable      = true,
                Discount    = 1,
                RedirectUrl = "/WeixinTest",
                CompleteUrl = "/Payment/Complete",
                NotifyUrl   = "/Payment/OnlineNotify"
            });
            ctx.PayKinds.Add(new PayKind {
                Name     = "积分抵扣",
                Type     = PayKindType.Points,
                Usable   = false,
                Discount = 1
            });
            ctx.PayKinds.Add(new PayKind {
                Name        = "其他支付",
                Type        = PayKindType.Other,
                Usable      = true,
                Discount    = 1,
                CompleteUrl = "/Payment/Complete"
            });
            ctx.PayKinds.Add(new PayKind {
                Name     = "随机立减",
                Type     = PayKindType.RandomPreference,
                Usable   = true,
                Discount = 1,
            });

            Staff staff = new Staff {
                Id         = adminId,
                Name       = "管理员",
                StaffRoles = new List <StaffRole>(),
            };
            StaffRole role = new StaffRole {
                Name    = "管理员组",
                Schemas = new List <StaffRoleSchema>()
            };

            staff.StaffRoles.Add(role);
            foreach (Schema item in Enum.GetValues(typeof(Schema)))
            {
                role.Schemas.Add(new StaffRoleSchema {
                    StaffRole = role,
                    Schema    = item
                });
            }
            ctx.Staffs.Add(staff);

            ctx.PrinterFormats.Add(new PrinterFormat {
                PaperSize                 = 278,
                Font                      = "宋体",
                ColorDepth                = 55,
                ReciptBigFontSize         = 12,
                ReciptFontSize            = 8,
                ReciptSmallFontSize       = 7,
                KitchenOrderFontSize      = 10,
                KitchenOrderSmallFontSize = 8,
                ServeOrderFontSize        = 10,
                ServeOrderSmallFontSize   = 8,
                ShiftBigFontSize          = 12,
                ShiftFontSize             = 8,
                ShiftSmallFontSize        = 7
            });
            await ctx.SaveChangesAsync();
        }
Example #22
0
 public IActionResult Put([FromBody] StaffRole model)
 {
     _staffRoleService.Update (model);
     return Ok ();
 }
 public IEnumerable <Staff> GetByRole(StaffRole role)
 {
     return(staffService.GetByRole(role));
 }
 public int DeleteByRole(StaffRole role)
 {
     return(SQLHelper.ExecuteNonQuery("delete from T_StaffInfo where [Role]=@Role", new SqlParameter("Role", role)));
 }
 public StaffRole SaveRole(StaffRole staffRole)
 {
     return(_staffRoleRepository.Save(staffRole));
 }
        public SettingRegRespObj AddStaffRole(RegStaffRoleObj regObj)
        {
            var response = new SettingRegRespObj
            {
                Status = new APIResponseStatus
                {
                    IsSuccessful = false,
                    Message      = new APIResponseMessage()
                }
            };

            try
            {
                if (regObj.Equals(null))
                {
                    response.Status.Message.FriendlyMessage  = "Error Occurred! Unable to proceed with your request";
                    response.Status.Message.TechnicalMessage = "Registration Object is empty / invalid";
                    return(response);
                }

                if (!EntityValidatorHelper.Validate(regObj, out var valResults))
                {
                    var errorDetail = new StringBuilder();
                    if (!valResults.IsNullOrEmpty())
                    {
                        errorDetail.AppendLine("Following error occurred:");
                        valResults.ForEachx(m => errorDetail.AppendLine(m.ErrorMessage));
                    }

                    else
                    {
                        errorDetail.AppendLine(
                            "Validation error occurred! Please check all supplied parameters and try again");
                    }
                    response.Status.Message.FriendlyMessage  = errorDetail.ToString();
                    response.Status.Message.TechnicalMessage = errorDetail.ToString();
                    response.Status.IsSuccessful             = false;
                    return(response);
                }

                if (!HelperMethods.IsUserValid(regObj.AdminUserId, regObj.SysPathCode, HelperMethods.getStaffRoles(),
                                               ref response.Status.Message))
                {
                    return(response);
                }

                if (IsRoleDuplicate(regObj.Name, 1, ref response))
                {
                    return(response);
                }

                var staffrole = new StaffRole
                {
                    Name   = regObj.Name,
                    Status = (ItemStatus)regObj.Status
                };

                var added = _repository.Add(staffrole);

                _uoWork.SaveChanges();

                if (added.StaffRoleId < 1)
                {
                    response.Status.Message.FriendlyMessage =
                        "Error Occurred! Unable to complete your request. Please try again later";
                    response.Status.Message.TechnicalMessage = "Unable to save to database";
                    return(response);
                }
                resetCache();
                response.Status.IsSuccessful = true;
                response.SettingId           = added.StaffRoleId;
            }
            catch (DbEntityValidationException ex)
            {
                ErrorManager.LogApplicationError(ex.StackTrace, ex.Source, ex.Message);
                response.Status.Message.FriendlyMessage  = "Error Occurred! Please try again later";
                response.Status.Message.TechnicalMessage = "Error: " + ex.GetBaseException().Message;
                response.Status.IsSuccessful             = false;
                return(response);
            }
            catch (Exception ex)
            {
                ErrorManager.LogApplicationError(ex.StackTrace, ex.Source, ex.Message);
                response.Status.Message.FriendlyMessage  = "Error Occurred! Please try again later";
                response.Status.Message.TechnicalMessage = "Error: " + ex.GetBaseException().Message;
                response.Status.IsSuccessful             = false;
                return(response);
            }
            return(response);
        }
 public int DeleteByRole(StaffRole role)
 {
     return(staffService.DeleteByRole(role));
 }
 public StaffRole Delete(StaffRole obj)
 {
     SessionManager.DoWork(session => session.Delete(obj));
     return(obj);
 }
Example #29
0
 public StaffRoleData(string username, StaffRole role)
 {
     this.Username = username;
     this.Role     = role;
 }
Example #30
0
 public IActionResult Post([FromBody] StaffRole model)
 {
     _staffRoleService.Insert (model);
     return Ok ();
 }