Esempio n. 1
0
 public override void Init()
 {
     //逻辑对象赋值
     bll = UploadTypeBll.GetInstence();
     //表格对象赋值
     grid = Grid1;
 }
Esempio n. 2
0
        /// <summary>读取数据</summary>
        public override void LoadData()
        {
            int id = ConvertHelper.Cint0(hidId.Text);

            if (id != 0)
            {
                //获取指定ID的菜单内容,如果不存在,则创建一个菜单实体
                var model = UploadTypeBll.GetInstence().GetModelForCache(x => x.Id == id);
                if (model == null)
                {
                    return;
                }

                //名称
                txtName.Text = model.Name;
                //关键字
                txtTypeKey.Text = model.TypeKey;
                //编辑时,关键字不能修改
                txtTypeKey.Enabled = false;
                //绑定扩展名
                txtExt.Text = model.Ext;
                //是否系统默认
                //rblIsSys.SelectedValue = model.IsSys + "";
            }
        }
Esempio n. 3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                //获取ID值
                hidId.Text = RequestHelper.GetInt0("Id") + "";
                //绑定下拉列表
                UploadTypeBll.GetInstence().BandDropDownList(this, ddlUploadTypeId);

                //加载数据
                LoadData();
            }
        }
Esempio n. 4
0
        /// <summary>
        /// 删除记录
        /// </summary>
        /// <returns></returns>
        public override string Delete()
        {
            //获取要删除的Id组
            var id = GridViewHelper.GetSelectedKeyIntArray(Grid1);

            //如果没有选择记录,则直接退出
            if (id == null)
            {
                return("请选择要删除的记录。");
            }

            try
            {
                //逐个判断是否可以删除
                foreach (var i in id)
                {
                    //检查是否是系统默认记录,是的话不能删除
                    if (UploadTypeBll.GetInstence().Exist(x => x.Id == i && x.IsSys == 1))
                    {
                        return("删除失败,Id为【" + i + "】的记录是系统默认记录,不能删除!");
                    }

                    //删除前检查
                    if (UploadConfigBll.GetInstence().Exist(x => x.UploadType_Id == i))
                    {
                        return("删除失败,Id为【" + i + "】的记录已被引用,不能直接删除!");
                    }
                }

                //删除记录
                bll.Delete(this, id);

                return("删除编号Id为[" + string.Join(",", id) + "]的数据记录成功。");
            }
            catch (Exception e)
            {
                string result = "尝试删除编号ID为[" + string.Join(",", id) + "]的数据记录失败!";

                //出现异常,保存出错日志信息
                CommonBll.WriteLog(result, e);

                return(result);
            }
        }
Esempio n. 5
0
        /// <summary>
        /// 数据保存
        /// </summary>
        /// <returns></returns>
        public override string Save()
        {
            string result = string.Empty;
            int    id     = ConvertHelper.Cint0(hidId.Text);

            try
            {
                #region 数据验证

                if (string.IsNullOrEmpty(txtName.Text.Trim()))
                {
                    return(txtName.Label + "不能为空!");
                }
                var sName = StringHelper.Left(txtName.Text, 20);
                if (UploadConfigBll.GetInstence().Exist(x => x.Name == sName && x.Id != id))
                {
                    return(txtName.Label + "已存在!请重新输入!");
                }
                if (string.IsNullOrEmpty(txtJoinName.Text.Trim()))
                {
                    return(txtJoinName.Label + "不能为空!");
                }
                if (ddlUploadTypeId.SelectedValue == "0")
                {
                    return(ddlUploadTypeId.Label + "为必选项,请选择后再保存!");
                }
                if (string.IsNullOrEmpty(txtPicSize.Text.Trim()))
                {
                    return(txtPicSize.Label + "不能为空!");
                }
                if (string.IsNullOrEmpty(txtFileSize.Text.Trim()))
                {
                    return(txtFileSize.Label + "不能为空!");
                }
                if (string.IsNullOrEmpty(txtSaveDir.Text.Trim()))
                {
                    return(txtSaveDir.Label + "不能为空!");
                }
                #endregion

                #region 赋值
                //获取实体
                var model = new UploadConfig(x => x.Id == id);

                model.Name     = sName;
                model.JoinName = StringHelper.Left(txtJoinName.Text, 30);
                model.UserType = (byte)ConvertHelper.Cint1(rblUserType.SelectedValue);
                //读取上传类型
                model.UploadType_Id = ConvertHelper.Cint0(ddlUploadTypeId.SelectedValue);
                var uploadTypeModel = UploadTypeBll.GetInstence().GetModelForCache(model.UploadType_Id);
                if (uploadTypeModel != null)
                {
                    model.UploadType_Name    = uploadTypeModel.Name;
                    model.UploadType_TypeKey = uploadTypeModel.TypeKey;
                }

                //上传限制
                model.PicSize  = ConvertHelper.Cint0(txtPicSize.Text);
                model.FileSize = ConvertHelper.Cint0(txtFileSize.Text);

                model.SaveDir      = StringHelper.Left(txtSaveDir.Text, 50);
                model.IsPost       = ConvertHelper.Ctinyint(rblIsPost.SelectedValue);
                model.IsEditor     = ConvertHelper.Ctinyint(rblIsEditor.SelectedValue);
                model.IsSwf        = ConvertHelper.Ctinyint(rblIsSwf.SelectedValue);
                model.IsChkSrcPost = ConvertHelper.Ctinyint(brlIsChkSrcPost.SelectedValue);

                //按比例生成
                model.IsFixPic   = ConvertHelper.Ctinyint(rblIsFixPic.SelectedValue);
                model.CutType    = ConvertHelper.Cint0(ddlCutType.SelectedValue);
                model.PicWidth   = ConvertHelper.Cint0(txtPicWidth.Text);
                model.PicHeight  = ConvertHelper.Cint0(txtPicHeight.Text);
                model.PicQuality = ConvertHelper.Cint0(txtPicQuality.Text);

                //大图
                model.IsBigPic   = ConvertHelper.Ctinyint(rblIsBigPic.SelectedValue);
                model.BigWidth   = ConvertHelper.Cint0(txtBigWidth.Text);
                model.BigHeight  = ConvertHelper.Cint0(txtBigHeight.Text);
                model.BigQuality = ConvertHelper.Cint0(txtBigQuality.Text);

                //中图
                model.IsMidPic  = ConvertHelper.Ctinyint(rblIsMidPic.SelectedValue);
                model.MidWidth  = ConvertHelper.Cint0(txtMidWidth.Text);
                model.MidWidth  = ConvertHelper.Cint0(txtMidWidth.Text);
                model.MidHeight = ConvertHelper.Cint0(txtMidHeight.Text);

                //小图
                model.IsMinPic  = ConvertHelper.Ctinyint(rblIsMinPic.SelectedValue);
                model.MinWidth  = ConvertHelper.Cint0(txtMinWidth.Text);
                model.MinWidth  = ConvertHelper.Cint0(txtMinWidth.Text);
                model.MinHeight = ConvertHelper.Cint0(txtMinHeight.Text);

                //推荐图
                model.IsHotPic  = ConvertHelper.Ctinyint(rblIsHotPic.SelectedValue);
                model.HotWidth  = ConvertHelper.Cint0(txtHotWidth.Text);
                model.HotWidth  = ConvertHelper.Cint0(txtHotWidth.Text);
                model.HotHeight = ConvertHelper.Cint0(txtHotHeight.Text);

                //加水印
                model.IsWaterPic = ConvertHelper.Ctinyint(rblIsWaterPic.SelectedValue);

                //修改时间与管理员
                model.UpdateDate    = DateTime.Now;
                model.Manager_Id    = OnlineUsersBll.GetInstence().GetManagerId();
                model.Manager_CName = OnlineUsersBll.GetInstence().GetManagerCName();

                #endregion

                //----------------------------------------------------------
                //存储到数据库
                UploadConfigBll.GetInstence().Save(this, model);
            }
            catch (Exception e)
            {
                result = "保存失败!";

                //出现异常,保存出错日志信息
                CommonBll.WriteLog(result, e);
            }

            return(result);
        }
Esempio n. 6
0
        /// <summary>
        /// 数据保存
        /// </summary>
        /// <returns></returns>
        public override string Save()
        {
            string result = string.Empty;
            int    id     = ConvertHelper.Cint0(hidId.Text);

            try
            {
                #region 数据验证

                if (string.IsNullOrEmpty(txtName.Text.Trim()))
                {
                    return(txtName.Label + "不能为空!");
                }
                var sName = StringHelper.Left(txtName.Text, 50);
                if (UploadTypeBll.GetInstence().Exist(x => x.Name == sName && x.Id != id))
                {
                    return(txtName.Label + "已存在!请重新输入!");
                }
                if (string.IsNullOrEmpty(txtTypeKey.Text.Trim()))
                {
                    return(txtTypeKey.Label + "不能为空!");
                }
                if (string.IsNullOrEmpty(txtExt.Text.Trim()))
                {
                    return(txtExt.Label + "不能为空!");
                }

                #endregion

                #region 赋值
                //获取实体
                var model = new UploadType(x => x.Id == id);

                //系统默认
                //model.IsSys = ConvertHelper.StringToByte(rblIsSys.SelectedValue);

                //判断是否有改变关键字
                var sTypeKey = StringHelper.Left(txtTypeKey.Text, 20);
                if (id > 0 && model.IsSys == 1 && sTypeKey != model.TypeKey)
                {
                    return("当前记录为系统默认,不能修改关键字!");
                }

                //设置名称
                model.Name = sName;
                //设置关键字
                model.TypeKey = sTypeKey;
                //扩展名
                model.Ext = StringHelper.Left(txtExt.Text, 0);

                //修改时间与管理员
                model.UpdateDate    = DateTime.Now;
                model.Manager_Id    = OnlineUsersBll.GetInstence().GetManagerId();
                model.Manager_CName = OnlineUsersBll.GetInstence().GetManagerCName();

                #endregion

                //----------------------------------------------------------
                //存储到数据库
                UploadTypeBll.GetInstence().Save(this, model);
            }
            catch (Exception e)
            {
                result = "保存失败!";

                //出现异常,保存出错日志信息
                CommonBll.WriteLog(result, e);
            }

            return(result);
        }