protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                btnClose.OnClientClick = ActiveWindow.GetHideReference();
                BindGrid();

                if (!String.IsNullOrEmpty(Request.QueryString["tyId"]))
                {
                    ddlfatherId.SelectedValue = Request.QueryString["tyId"];
                    ddlfatherId.Enabled       = false;
                }
                if (!String.IsNullOrEmpty(Request.QueryString["Id"]))
                {
                    ddlfatherId.Enabled = true;
                    Maticsoft.BLL.tPicture   bll   = new Maticsoft.BLL.tPicture();
                    Maticsoft.Model.tPicture model = bll.GetModel(int.Parse(Request.QueryString["Id"]));

                    txtTile.Text   = model.Name;
                    txtRemark.Text = model.Remark;

                    ddlfatherId.SelectedValue = model.PicTyID.ToString();
                    txtSort.Text           = model.Sort.ToString();
                    hfEditorInitValue.Text = "<img src=" + "'" + model.Code + "'" + "/>";
                }
            }
        }
예제 #2
0
        protected void Grid_RowCommand(object sender, GridCommandEventArgs e)
        {
            int artId = GetSelectedDataKeyID(Grid);


            if (e.CommandName == "Delete")
            {
                Maticsoft.BLL.tPicture BLL = new Maticsoft.BLL.tPicture();

                Maticsoft.Model.tPicture model = BLL.GetModel(artId);

                string directoryPath = Server.MapPath(model.Code);
                File.Delete(directoryPath);

                BLL.Delete(artId);
                GetView();
            }
            if (e.CommandName == "Edit")
            {
                PageContext.RegisterStartupScript(Window1.GetShowReference("PicturesEdit.aspx?Id=" + artId));
            }
        }
        protected void btnSave_Click(object sender, EventArgs e)
        {
            Maticsoft.BLL.tPicture bll = new Maticsoft.BLL.tPicture();

            string content = Request.Form["editor1"] == null ? "" : Request.Form["editor1"];

            if (string.IsNullOrEmpty(content))
            {
                Alert.ShowInTop("图片为空!"); return;
            }
            string[] picList = GetHtmlImageUrlList(content);
            if (picList.Length <= 0)
            {
                Alert.ShowInTop("图片为空!"); return;
            }


            if (!String.IsNullOrEmpty(Request.QueryString["tyId"]))
            {
                int k = 0;
                for (int i = 0; i < picList.Length; i++)
                {
                    Maticsoft.Model.tPicture model = new Maticsoft.Model.tPicture();
                    model.Code     = picList[i];
                    model.Name     = txtTile.Text;
                    model.Remark   = txtRemark.Text;
                    model.ImageUrl = txtUrl.Text;
                    model.PicTyID  = int.Parse(ddlfatherId.SelectedValue);
                    model.Sort     = int.Parse(txtSort.Text);

                    if (bll.Add(model) > 0)
                    {
                        k++;
                    }
                }
                if (k > 0)
                {
                    PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference());
                }
                else
                {
                    Alert.ShowInTop("添加失败!"); return;
                }
            }
            if (!String.IsNullOrEmpty(Request.QueryString["Id"]))
            {
                if (picList.Length > 1)
                {
                    Alert.ShowInTop("请上传一张图片!"); return;
                }
                Maticsoft.Model.tPicture model = bll.GetModel(int.Parse(Request.QueryString["Id"]));
                if (picList[0] != model.Code)
                {
                    string directoryPath = Server.MapPath(model.Code);
                    File.Delete(directoryPath);
                }
                model.Code     = picList[0];
                model.Name     = txtTile.Text;
                model.Remark   = txtRemark.Text;
                model.ImageUrl = txtUrl.Text;
                model.PicTyID  = int.Parse(ddlfatherId.SelectedValue);
                model.Sort     = int.Parse(txtSort.Text);
                bll.Update(model);
                PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference());
            }
        }