Esempio n. 1
0
 public override void Init()
 {
     //逻辑对象赋值
     bll = InformationClassBll.GetInstence();
     //表格对象赋值
     grid = Grid1;
 }
Esempio n. 2
0
        /// <summary>下拉列表改变事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void ddlInformationClassId_SelectedIndexChanged(object sender, EventArgs e)
        {
            int id = ConvertHelper.Cint0(hidId.Text);

            if (id > 0)
            {
                return;
            }

            //如果选择根节点,则将SEO全部置空
            if (ddlInformationClass_Id.SelectedValue == "0")
            {
                txtSeoTitle.Text = "";
                txtSeoKey.Text   = "";
                txtSeoDesc.Text  = "";
            }
            //否则读取分类节点的SEO值
            else
            {
                var icId  = ConvertHelper.Cint0(ddlInformationClass_Id.SelectedValue);
                var model = InformationClassBll.GetInstence().GetModelForCache(x => x.Id == icId);
                if (model != null)
                {
                    txtSeoTitle.Text = model.SeoTitle;
                    txtSeoKey.Text   = model.SeoKey;
                    txtSeoDesc.Text  = model.SeoDesc;
                }
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Grid点击事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void Grid1_RowCommand(object sender, FineUI.GridCommandEventArgs e)
        {
            GridRow gr = Grid1.Rows[e.RowIndex];
            //获取当前点击列的主键ID
            object id = gr.DataKeys[0];

            switch (e.CommandName)
            {
            case "IsShow":
                //更新状态
                InformationClassBll.GetInstence().UpdateIsShow(this, ConvertHelper.Cint0(id), ConvertHelper.Cint0(e.CommandArgument));
                //重新加载
                LoadData();

                break;

            case "IsPage":
                //更新状态
                InformationClassBll.GetInstence().UpdateIsPage(this, ConvertHelper.Cint0(id), ConvertHelper.Cint0(e.CommandArgument));
                //重新加载
                LoadData();

                break;

            case "ButtonEdit":
                //打开编辑窗口
                Window1.IFrameUrl = "InformationClassEdit.aspx?Id=" + id + "&" + MenuInfoBll.GetInstence().PageUrlEncryptStringNoKey(id + "");
                Window1.Hidden    = false;

                break;
            }
        }
Esempio n. 4
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                //绑定下拉框
                InformationClassBll.GetInstence().BandDropDownListShowAll(this, dllInformationClass);

                LoadData();
            }
        }
Esempio n. 5
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                //绑定下拉列表
                InformationClassBll.GetInstence().BandDropDownList(this, ddlParentId);

                LoadData();
            }
        }
Esempio n. 6
0
        /// <summary>删除图片</summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        public void ButtonDeleteImage_Click(object sender, EventArgs e)
        {
            int id = ConvertHelper.Cint0(hidId.Text);

            if (id > 0)
            {
                InformationClassBll.GetInstence().DelClassImg(this, id);

                FineUI.PageContext.RegisterStartupScript("window.location.reload()");
            }
        }
Esempio n. 7
0
        /// <summary>读取数据</summary>
        public override void LoadData()
        {
            int id = ConvertHelper.Cint0(hidId.Text);

            if (id != 0)
            {
                //获取指定ID的信息分类内容
                var model = InformationClassBll.GetInstence().GetModelForCache(x => x.Id == id);
                if (model == null)
                {
                    return;
                }

                //对页面窗体进行赋值
                txtName.Text = model.Name;
                //设置下拉列表选择项
                ddlParentId.SelectedValue = model.ParentId + "";
                //编辑时不能修改父节点
                ddlParentId.Enabled = false;
                //设置父ID
                txtParent.Text = model.ParentId + "";
                //设置排序
                txtSort.Text = model.Sort + "";
                //设置是否显示
                rblIsShow.SelectedValue = model.IsShow + "";
                //设置是否单页
                rblIsPage.SelectedValue = model.IsPage + "";
                //SEO
                txtSeoTitle.Text = model.SeoTitle;
                txtSeoKey.Text   = model.SeoKey;
                txtSeoDesc.Text  = model.SeoDesc;
                //备注
                txtNotes.Text = model.Notes;

                //设置图片
                if (model.ClassImg != null && model.ClassImg.Length > 5)
                {
                    imgClassImg.ImageUrl      = model.ClassImg;
                    ButtonDeleteImage.Enabled = MenuInfoBll.GetInstence().CheckControlPower(this, "ButtonDeleteImage");
                }
                else
                {
                    ButtonDeleteImage.Visible = false;
                    imgClassImg.Visible       = false;
                }
            }
            else
            {
                ButtonDeleteImage.Visible = false;
                imgClassImg.Visible       = false;
            }
        }
Esempio n. 8
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                //获取ID值
                hidId.Text = RequestHelper.GetInt0("Id") + "";

                //绑定下拉列表
                InformationClassBll.GetInstence().BandDropDownListShowAll(this, ddlParentId);

                //加载数据
                LoadData();
            }
        }
Esempio n. 9
0
        /// <summary>
        /// 删除记录
        /// </summary>
        /// <returns></returns>
        public override string Delete()
        {
            //获取要删除的ID
            int id = ConvertHelper.Cint0(GridViewHelper.GetSelectedKey(Grid1, true));

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

            try
            {
                //删除前判断一下
                if (InformationClassBll.GetInstence().Exist(x => x.ParentId == id))
                {
                    return("删除失败,本信息分类下面存在子信息分类,不能直接删除!");
                }
                //删除前判断一下
                if (InformationBll.GetInstence().Exist(x => x.InformationClass_Id == id))
                {
                    return("删除失败,本信息分类已被信息表的记录引用,不能直接删除!");
                }

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

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

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

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

            try
            {
                #region 数据验证

                if (string.IsNullOrEmpty(txtTitle.Text.Trim()))
                {
                    return(txtTitle.Label + "不能为空!");
                }
                if (ddlInformationClass_Id.SelectedValue == "0")
                {
                    return(ddlInformationClass_Id.Label + "为必选项,请选择!");
                }
                //判断是否重复
                var sTitle = StringHelper.FilterSql(txtTitle.Text, true);
                var icId   = ConvertHelper.Cint0(ddlInformationClass_Id.SelectedValue);
                if (
                    DataAccess.DataModel.Information.Exists(
                        x => x.Title == sTitle && x.InformationClass_Id == icId && x.Id != id))
                {
                    return(txtTitle.Label + "已存在!请重新输入!");
                }

                #endregion

                #region 赋值

                //获取实体
                var model = new Information(x => x.Id == id);

                //------------------------------------------
                //设置名称
                model.Title = StringHelper.Left(txtTitle.Text, 100);
                //取得分类
                model.InformationClass_Id = ConvertHelper.Cint0(ddlInformationClass_Id.SelectedValue);

                model.InformationClass_Root_Id =
                    ConvertHelper.Cint0(InformationClassBll.GetInstence()
                                        .GetFieldValue(model.InformationClass_Id, InformationClassTable.ParentId));
                if (model.InformationClass_Root_Id > 0)
                {
                    model.InformationClass_Root_Name = InformationClassBll.GetInstence()
                                                       .GetName(this, model.InformationClass_Root_Id);
                }
                model.InformationClass_Name = StringHelper.Left(ddlInformationClass_Id.SelectedText, 20);

                //重定向
                model.RedirectUrl = StringHelper.Left(txtRedirectUrl.Text, 250);

                //------------------------------------------
                //编辑器
                model.Content = StringHelper.Left(txtText.Text, 0, true, false);
                model.Upload  = StringHelper.Left(txtUpload.Text, 0, true, false);
                //这里必须用回前端存放的Key,不然删除时无法同步删除编辑器上传的图片
                RndKey = StringHelper.Left(txtRndKey.Text, 0);

                //检查用户上传的文件和最后保存的文件是否有出入,
                //如果上传的文件大于保存的文件,把不保存,但本次操作已经上传的文件删除。
                model.Upload = UploadFileBll.GetInstence().FCK_BatchDelPic(model.Content, model.Upload);

                //------------------------------------------
                //其它值
                model.NewsTime = dpNewsTime.SelectedDate ?? DateTime.Now;
                model.AddYear  = model.NewsTime.Year;
                model.AddMonth = model.NewsTime.Month;
                model.AddDay   = model.NewsTime.Day;

                model.Notes = StringHelper.Left(txtNotes.Text, 200);

                model.Keywords = StringHelper.Left(txtKeywords.Text, 50);
                model.Author   = StringHelper.Left(txtAuthor.Text, 50);
                model.FromName = StringHelper.Left(txtFromName.Text, 50);


                model.SeoTitle = StringHelper.Left(txtSeoTitle.Text, 100);
                model.SeoKey   = StringHelper.Left(txtSeoKey.Text, 100);
                model.SeoDesc  = StringHelper.Left(txtSeoDesc.Text, 200);
                model.Sort     = 0;

                //设定当前项是否显示
                model.IsDisplay = ConvertHelper.StringToByte(rblIsDisplay.SelectedValue);
                model.IsHot     = ConvertHelper.StringToByte(rblIsHot.SelectedValue);
                model.IsTop     = ConvertHelper.StringToByte(rblIsTop.SelectedValue);

                //------------------------------------------
                //判断是否是新增
                if (model.Id == 0)
                {
                    //添加时间与用户
                    model.AddDate = DateTime.Now;
                    //修改时间与用户
                    model.UpdateDate = DateTime.Now;
                }
                else
                {
                    //修改时间与用户
                    model.UpdateDate = DateTime.Now;
                }
                model.Manager_Id    = OnlineUsersBll.GetInstence().GetManagerId();
                model.Manager_CName = OnlineUsersBll.GetInstence().GetManagerCName();

                #endregion

                //------------------------------------------

                #region   图片

                if (this.filePhoto.HasFile && this.filePhoto.FileName.Length > 3)
                {
                    int vid = 3; //3	文章封面
                    //---------------------------------------------------
                    var upload = new UploadFile();
                    result = new UploadFileBll().Upload_AspNet(this.filePhoto.PostedFile, vid, RndKey,
                                                               OnlineUsersBll.GetInstence().GetManagerId(), OnlineUsersBll.GetInstence().GetManagerCName(),
                                                               upload);
                    this.filePhoto.Dispose();
                    //---------------------------------------------------
                    if (result.Length == 0) //上传成功
                    {
                        model.FrontCoverImg = upload.Path;
                    }
                    else
                    {
                        CommonBll.WriteLog("上传出错:" + result); //收集异常信息
                        return("上传出错!" + result);
                    }
                }
                //如果是修改,检查用户是否重新上传过封面图片,如果是删除旧的图片
                if (model.Id > 0)
                {
                    UploadFileBll.GetInstence()
                    .Upload_DiffFile(InformationTable.Id, InformationTable.FrontCoverImg, InformationTable.TableName,
                                     model.Id, model.FrontCoverImg);

                    //同步UploadFile上传表
                    UploadFileBll.GetInstence().Upload_UpdateRs(RndKey, InformationTable.TableName, model.Id);
                }

                #endregion

                //----------------------------------------------------------
                //存储到数据库
                InformationBll.GetInstence().Save(this, model);

                #region  步更新上传图片表绑定Id
                if (id == 0)
                {
                    //同步UploadFile上传表记录,绑定刚刚上传成功的文件Id为当前记录Id
                    UploadFileBll.GetInstence().Upload_UpdateRs(RndKey, InformationTable.TableName, model.Id);
                }
                #endregion
            }
            catch (Exception e)
            {
                result = "保存失败!";

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

            return(result);
        }
Esempio n. 11
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 (InformationClassBll.GetInstence().Exist(x => x.Name == sName && x.Id != id))
                {
                    return(txtName.Label + "已存在!请重新输入!");
                }

                #endregion

                #region 赋值
                //定义是否更新其他关联表变量
                bool isUpdate    = false;
                var  oldParentId = ConvertHelper.Cint0(txtParent.Text);

                //获取实体
                var model = new InformationClass(x => x.Id == id);
                //判断是否有改变名称
                if (id > 0 && sName != model.Name)
                {
                    isUpdate = true;
                }
                //修改时间与管理员
                model.UpdateDate    = DateTime.Now;
                model.Manager_Id    = OnlineUsersBll.GetInstence().GetManagerId();
                model.Manager_CName = OnlineUsersBll.GetInstence().GetManagerCName();

                //设置名称
                model.Name = sName;
                //对应的父类id
                model.ParentId = oldParentId;
                //设置备注
                model.Notes = StringHelper.Left(txtNotes.Text, 100);

                //由于限制了编辑时不能修改父节点,所以这里只对新建记录时处理
                if (id == 0)
                {
                    //设定当前的深度与设定当前的层数级
                    if (model.ParentId == 0)
                    {
                        //设定当前的层数级
                        model.Depth = 0;
                        //父Id为0时,根Id也为0
                        model.RootId = 0;
                    }
                    else
                    {
                        //设定当前的层数
                        model.Depth = ConvertHelper.Cint0(InformationClassBll.GetInstence().GetFieldValue(ConvertHelper.Cint0(ddlParentId.SelectedValue), InformationClassTable.Depth)) + 1;
                        //获取父类的父Id
                        model.RootId = ConvertHelper.Cint0(InformationClassBll.GetInstence().GetFieldValue(model.ParentId, InformationClassTable.ParentId));
                    }

                    //限制分类层数只能为3层
                    if (model.Depth > 3)
                    {
                        return("信息分类只能创建3层分类!");
                    }
                }

                //设置排序
                model.Sort = ConvertHelper.Cint0(txtSort.Text);
                if (model.Sort == 0)
                {
                    model.Sort = InformationClassBll.GetInstence().GetSortMax(model.ParentId) + 1;
                }

                //设定当前项是否显示
                model.IsShow = ConvertHelper.StringToByte(rblIsShow.SelectedValue);
                //设定当前项是否单页
                model.IsPage = ConvertHelper.StringToByte(rblIsPage.SelectedValue);

                //SEO
                model.SeoTitle = StringHelper.Left(txtSeoTitle.Text, 100);
                model.SeoKey   = StringHelper.Left(txtSeoKey.Text, 100);
                model.SeoDesc  = StringHelper.Left(txtSeoDesc.Text, 200);
                #endregion


                #region   图片
                //上传分类大图
                if (this.fuClassImg.HasFile && this.fuClassImg.FileName.Length > 3)
                {
                    int vid = 2; //2	信息(新闻)分类图
                    //---------------------------------------------------
                    var upload = new UploadFile();
                    result = new UploadFileBll().Upload_AspNet(this.fuClassImg.PostedFile, vid, RndKey, OnlineUsersBll.GetInstence().GetManagerId(), OnlineUsersBll.GetInstence().GetManagerCName(), upload);
                    this.fuClassImg.Dispose();
                    //---------------------------------------------------
                    if (result.Length == 0)//上传成功
                    {
                        model.ClassImg = upload.Path;
                    }
                    else
                    {
                        CommonBll.WriteLog("上传出错:" + result, null);//收集异常信息
                        return("上传出错!" + result);
                    }
                }
                //如果是修改,检查用户是否重新上传过新图片,如果是删除旧的图片
                if (model.Id > 0)
                {
                    UploadFileBll.GetInstence().Upload_DiffFile(InformationClassTable.Id, InformationClassTable.ClassImg, InformationClassTable.TableName, model.Id, model.ClassImg);

                    //同步UploadFile上传表
                    UploadFileBll.GetInstence().Upload_UpdateRs(RndKey, InformationClassTable.TableName, model.Id);
                }

                #endregion


                //----------------------------------------------------------
                //存储到数据库
                InformationClassBll.GetInstence().Save(this, model);

                #region  步更新上传图片表绑定Id
                if (id == 0)
                {
                    //同步UploadFile上传表记录,绑定刚刚上传成功的文件Id为当前记录Id
                    UploadFileBll.GetInstence().Upload_UpdateRs(RndKey, InformationClassTable.TableName, model.Id);
                }

                #endregion

                //如果本次修改改变了相关名称,则同步更新其他关联表的对应名称
                if (isUpdate)
                {
                    InformationBll.GetInstence().UpdateValue_For_InformationClass_Id(this, model.Id, InformationTable.InformationClass_Name, model.Name);
                    InformationBll.GetInstence().UpdateValue_For_InformationClass_Root_Id(this, model.Id, InformationTable.InformationClass_Root_Name, model.Name);
                }
            }
            catch (Exception e)
            {
                result = "保存失败!";

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

            return(result);
        }