Ejemplo n.º 1
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.º 2
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;
     }
 }