Пример #1
0
        private bool IsShopAdmin(int id)
        {
            BLL.wx_diancai_admin   dBll      = new BLL.wx_diancai_admin();
            Model.wx_diancai_admin shopAdmin = dBll.GetModel(id);

            //餐饮 商铺管理员
            if (shopAdmin != null)
            {
                //Session[MXKeys.WEIXIN_DIANCAI_SHOPID] = shopAdmin.ShopId;
                //Utils.WriteCookie(MXKeys.WEIXIN_DIANCAI_SHOPID, "WeiXinPF", shopAdmin.ShopId.ToString());

                return(true);
            }

            BLL.wx_diancai_shop_user   suBll    = new BLL.wx_diancai_shop_user();
            Model.wx_diancai_shop_user shopUser = suBll.GetModel(id);

            if (shopUser != null)
            {
                //Session[MXKeys.WEIXIN_DIANCAI_SHOPID] = shopUser.ShopId;
                //Utils.WriteCookie(MXKeys.WEIXIN_DIANCAI_SHOPID, "WeiXinPF", shopUser.ShopId.ToString());

                return(true);
            }

            return(false);
        }
Пример #2
0
        public int Add(Model.wx_diancai_shop_user model)
        {
            using (IDbConnection db = DbFactory.GetOpenedConnection())
            {
                StringBuilder queryBuilder = new StringBuilder();

                queryBuilder.Append("Insert Into [dbo].[wx_diancai_shop_user]");
                queryBuilder.Append("   (ManagerId, ShopId,AdminId)");
                queryBuilder.Append("Values");
                queryBuilder.Append("   (@ManagerId,@ShopId,@AdminId)");
                queryBuilder.Append("Select @Id=Scope_Identity()");

                DynamicParameters dynamicParameters = new DynamicParameters();
                dynamicParameters.AddDynamicParams(model);
                dynamicParameters.Add("@Id", dbType: DbType.Int32, direction: ParameterDirection.Output);

                db.Execute(queryBuilder.ToString(), dynamicParameters);

                return(dynamicParameters.Get <int>("@Id"));
            }
        }
Пример #3
0
        public int GetShopId()
        {
            if (IsAdminLogin())
            {
                Model.manager          admin        = GetAdminInfo();
                BLL.wx_diancai_admin   shopAdminBll = new BLL.wx_diancai_admin();
                Model.wx_diancai_admin shopAdmin    = shopAdminBll.GetModel(admin.id);
                if (shopAdmin != null)
                {
                    return(shopAdmin.ShopId);
                }

                BLL.wx_diancai_shop_user   suBll    = new BLL.wx_diancai_shop_user();
                Model.wx_diancai_shop_user shopUser = suBll.GetModel(admin.id);

                if (shopUser != null)
                {
                    return(shopUser.ShopId);
                }
                return(0);
            }
            return(0);
        }
Пример #4
0
        private bool DoAdd()
        {
            Model.manager adminEntity = GetAdminInfo(); //取得管理员信息

            Model.manager model = new Model.manager();
            BLL.manager   bll   = new BLL.manager();

            //固定为餐饮管理员的角色

            model.role_id   = int.Parse(ddlRoleId.SelectedValue);
            model.role_type = new BLL.manager_role().GetModel(model.role_id).role_type;

            model.is_lock = MyCommFun.Str2Int(rblIsLock.SelectedValue);

            //检测用户名是否重复
            if (bll.Exists(txtUserName.Text.Trim()))
            {
                return(false);
            }

            model.user_name = txtUserName.Text.Trim();
            //获得6位的salt加密字符串
            model.salt = Utils.GetCheckCode(6);
            //以随机生成的6位字符串做为密钥加密
            model.password   = DESEncrypt.Encrypt(txtPassword.Text.Trim(), model.salt);
            model.real_name  = txtRealName.Text.Trim();
            model.telephone  = txtTelephone.Text.Trim();
            model.email      = txtEmail.Text.Trim();
            model.add_time   = DateTime.Now;
            model.wxNum      = 0;
            model.agentId    = GetAdminInfo().id;
            model.qq         = string.Empty;
            model.email      = txtEmail.Text;
            model.reg_ip     = MXRequest.GetIP();
            model.agentLevel = -1;
            model.remark     = txtRemark.Text;
            model.agentId    = adminEntity.id;
            int addId = bll.Add(model);

            if (addId > 0)
            {
                //添加商铺与管理人员的关联
                BLL.wx_diancai_shop_user   shopUserBll = new BLL.wx_diancai_shop_user();
                Model.wx_diancai_shop_user shopUser    = new Model.wx_diancai_shop_user();
                shopUser.ManagerId = addId;
                shopUser.ShopId    = shopid;
                shopUser.AdminId   = GetAdminInfo().id;
                int addShopAdminId = shopUserBll.Add(shopUser);

                if (addShopAdminId <= 0)
                {
                    bll.Delete(addId);
                    addId = 0;
                }
            }

            if (addId > 0)
            {
                AddAdminLog(MXEnums.ActionEnum.Add.ToString(), "添加餐饮商铺管理员:" + model.user_name); //记录日志
                return(true);
            }
            return(false);
        }
Пример #5
0
 public int Add(Model.wx_diancai_shop_user model)
 {
     return(_dal.Add(model));
 }