Ejemplo n.º 1
0
        /// <summary>
        /// 批量删除
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnDelete_Click(object sender, EventArgs e)
        {
            //检查权限
            ChkAdminLevel("plugin_images", DTEnums.ActionEnum.Delete.ToString());
            BLL.images bll = new BLL.images();

            int      sucCount   = 0; //成功数量
            int      errorCount = 0; //失败数量
            Repeater rptList    = new Repeater();

            rptList = this.rptList;
            for (int i = 0; i < rptList.Items.Count; i++)
            {
                int      id = Convert.ToInt32(((HiddenField)rptList.Items[i].FindControl("hidId")).Value);
                CheckBox cb = (CheckBox)rptList.Items[i].FindControl("chkId");
                if (cb.Checked)
                {
                    if (bll.Delete(id))
                    {
                        sucCount++;
                    }
                    else
                    {
                        errorCount++;
                    }
                }
            }
            AddAdminLog(DTEnums.ActionEnum.Edit.ToString(), "删除图片内容成功" + sucCount + "条,失败" + errorCount + "条"); //记录日志
            JscriptMsg("成功删除 " + sucCount + " 条,失败 " + errorCount + " 条!", Utils.CombUrlTxt("index.aspx", "keywords={0}", this.keywords));
        }
Ejemplo n.º 2
0
        private void TreeBind()
        {
            BLL.images bll = new BLL.images();
            DataTable  dt  = bll.GetSign().Tables[0];

            this.ddlCategoryId.Items.Clear();
            this.ddlCategoryId.Items.Add(new ListItem("所有标识", ""));
            foreach (DataRow dr in dt.Rows)
            {
                this.ddlCategoryId.Items.Add(new ListItem(dr["sign"].ToString().Trim(), dr["sign"].ToString().Trim()));
            }
        }
Ejemplo n.º 3
0
        private bool DoEdit(int _id)
        {
            try
            {
                BLL.images   bll   = new BLL.images();
                Model.images model = bll.GetModel(_id);

                model.title      = txtName.Text;
                model.link_url   = txtUrl.Text;
                model.img_url    = txtImgUrl.Text;
                model.is_lock    = int.Parse(rblHide.SelectedValue);
                model.sort_id    = Utils.StrToInt(txtSort.Text, 99);
                model.back_color = txtColor.Text;
                model.content    = txtContent.Value;
                model.sign       = txtSign.Text;
                //判断上传图片
                if (this.imgUpload.HasFile)
                {
                    //上传前先删除原图片
                    if (!string.IsNullOrEmpty(model.img_url))
                    {
                        Utils.DeleteFile(model.img_url);
                    }
                    DTcms.Model.upLoad upfile = new Web.UI.UpLoad().fileSaveAs(this.imgUpload.PostedFile, 0, false, false);
                    if (upfile.status > 0)
                    {
                        model.img_url = upfile.path;
                    }
                }
                else
                {
                    //判断是否需要删除原图
                    if (txtImgUrl.Text.Trim() == "" && !string.IsNullOrEmpty(model.img_url))
                    {
                        Utils.DeleteFile(model.img_url);
                    }
                    model.img_url = txtImgUrl.Text.Trim();
                }
                if (bll.Update(model))
                {
                    AddAdminLog(DTEnums.ActionEnum.Edit.ToString(), "修改图片信息" + model.title); //记录日志
                    return(true);
                }
            }
            catch
            {
                return(false);
            }
            return(false);
        }
Ejemplo n.º 4
0
 /// <summary>
 /// 保存排序
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 protected void btnSave_Click(object sender, EventArgs e)
 {
     ChkAdminLevel("plugin_images", DTEnums.ActionEnum.Edit.ToString()); //检查权限
     BLL.images bll = new BLL.images();
     for (int i = 0; i < rptList.Items.Count; i++)
     {
         int id = Convert.ToInt32(((HiddenField)rptList.Items[i].FindControl("hidId")).Value);
         int sortId;
         if (!int.TryParse(((TextBox)rptList.Items[i].FindControl("txtSortId")).Text.Trim(), out sortId))
         {
             sortId = 99;
         }
         bll.UpdateField(id, "sort_id=" + sortId.ToString());
     }
     JscriptMsg("保存排序成功!", Utils.CombUrlTxt("index.aspx", "keywords={0}&page={1}&sign={2}", this.keywords, "1", sign));
 }
Ejemplo n.º 5
0
 private void ShowInfo(int _id)
 {
     BLL.images   bll   = new BLL.images();
     Model.images model = bll.GetModel(_id);
     txtName.Text          = model.title;
     txtUrl.Text           = model.link_url;
     txtSort.Text          = model.sort_id.ToString();
     rblHide.SelectedValue = model.is_lock.ToString();
     txtSign.Text          = model.sign;
     txtColor.Text         = model.back_color;
     txtContent.Value      = model.content;
     txtName.Focus(); //设置焦点,防止JS无法提交
     //图片
     txtImgUrl.Text = model.img_url;
     if (!string.IsNullOrEmpty(model.img_url))
     {
         ImgDiv.Visible  = true;
         ImgUrl.ImageUrl = model.img_url;
     }
 }
Ejemplo n.º 6
0
        private bool DoAdd()
        {
            try
            {
                BLL.images   bll   = new BLL.images();
                Model.images model = new Model.images();

                model.title      = txtName.Text;
                model.link_url   = txtUrl.Text;
                model.img_url    = txtImgUrl.Text;
                model.is_lock    = int.Parse(rblHide.SelectedValue);
                model.sort_id    = Utils.StrToInt(txtSort.Text, 99);
                model.add_time   = DateTime.Now;
                model.back_color = txtColor.Text;
                model.content    = txtContent.Value;
                model.sign       = txtSign.Text;
                //判断上传图片
                if (this.imgUpload.HasFile)
                {
                    DTcms.Model.upLoad upfile = new Web.UI.UpLoad().fileSaveAs(this.imgUpload.PostedFile, 0, false, false);
                    if (upfile.status > 0)
                    {
                        model.img_url = upfile.path;
                    }
                }
                else
                {
                    model.img_url = txtImgUrl.Text.Trim();
                }
                if (bll.Add(model) > 0)
                {
                    AddAdminLog(DTEnums.ActionEnum.Edit.ToString(), "添加图片信息" + model.title); //记录日志
                    return(true);
                }
            }
            catch
            {
                return(false);
            }
            return(false);
        }
Ejemplo n.º 7
0
        protected void Page_Load(object sender, EventArgs e)
        {
            this.keywords = DTRequest.GetQueryString("keywords", true);
            this.sign     = DTRequest.GetQueryString("sign", true);
            this.page     = DTRequest.GetQueryIntValue("page", 1);
            this.pageSize = GetPageSize(10); //每页数量

            if (!Page.IsPostBack)
            {
                //读取用户
                DTcms.Model.manager model = GetAdminInfo();

                //检查权限
                ChkAdminLevel("plugin_images", DTEnums.ActionEnum.Show.ToString());

                //绑定标记
                TreeBind();
                if (!string.IsNullOrEmpty(sign))
                {
                    ddlCategoryId.SelectedValue = this.sign;
                }

                //绑定数据
                BLL.images bll   = new BLL.images();
                DataSet    _list = bll.GetList(CombSqlTxt(this.keywords, this.sign), "sort_id asc,id asc", page, pageSize, out totalCount);
                this.rptList.DataSource = _list;
                this.rptList.DataBind();

                //插入关键词
                this.txtKeywords.Text = Utils.Htmls(this.keywords);

                //绑定页码
                this.txtPageNum.Text = pageSize.ToString();
                string pageUrl = Utils.CombUrlTxt("index.aspx", "keywords={0}&page={1}", keywords, "__id__");
                PageContent.InnerHtml = Utils.OutPageList(this.pageSize, this.page, this.totalCount, pageUrl, 8);
            }
        }
Ejemplo n.º 8
0
        protected void Page_Load(object sender, EventArgs e)
        {
            BLL.images bll = new BLL.images();
            this.reurl = DTRequest.GetQueryString("reurl");

            string _action = DTRequest.GetQueryString("action");

            if (!string.IsNullOrEmpty(_action) && _action == DTEnums.ActionEnum.Edit.ToString())
            {
                this.id     = DTRequest.GetQueryInt("id");
                this.action = DTEnums.ActionEnum.Edit.ToString();//修改类型
                if (id == 0)
                {
                    JscriptMsg("传输参数不正确!", "back");
                    return;
                }
                if (!bll.Exists(this.id))
                {
                    JscriptMsg("记录不存在或已被删除!", "back");
                    return;
                }
            }
            if (!Page.IsPostBack)
            {
                //检查权限
                ChkAdminLevel("plugin_images", DTEnums.ActionEnum.Show.ToString());

                //绑定标记
                TreeBind();

                if (action == DTEnums.ActionEnum.Edit.ToString()) //修改
                {
                    ShowInfo(this.id);
                }
            }
        }