예제 #1
0
        protected void GetView()
        {
            int Tid = 0;

            if (string.IsNullOrEmpty(TMailList.SelectedNodeID))
            {
                Tid = 0;
            }
            else
            {
                Tid = int.Parse(TMailList.SelectedNodeID);
            }

            Maticsoft.BLL.tPicture BLL = new Maticsoft.BLL.tPicture();
            if (Tid == 0)
            {
                Grid.RecordCount = BLL.GetRecordCount("");
                Grid.DataSource  = BLL.GetListByPage("", " Sort desc,Id desc ", Grid.PageIndex * Grid.PageSize, (Grid.PageIndex + 1) * Grid.PageSize);
            }
            else
            {
                Grid.RecordCount = BLL.GetRecordCount(" PicTyID=" + Tid);
                Grid.DataSource  = BLL.GetListByPage(" PicTyID=" + Tid, " Sort desc, Id desc ", Grid.PageIndex * Grid.PageSize, (Grid.PageIndex + 1) * Grid.PageSize);
            }
            Grid.DataBind();
        }
예제 #2
0
        protected void btnSelect_Click(object sender, EventArgs e)
        {
            string txtVal = this.txtValue.Text.Trim();

            if (txtVal == "")
            {
                GetView();
            }


            int Tid = 0;

            if (string.IsNullOrEmpty(TMailList.SelectedNodeID))
            {
                Tid = 0;
            }
            else
            {
                Tid = int.Parse(TMailList.SelectedNodeID);
            }

            Maticsoft.BLL.tPicture BLL = new Maticsoft.BLL.tPicture();
            if (Tid == 0)
            {
                Grid.RecordCount = BLL.GetRecordCount(String.Format(" Name like '%{0}%' ", txtVal));
                Grid.DataSource  = BLL.GetListByPage(String.Format(" Name like '%{0}%' ", txtVal), " Sort desc,Id desc ", Grid.PageIndex * Grid.PageSize, (Grid.PageIndex + 1) * Grid.PageSize);
            }
            else
            {
                Grid.RecordCount = BLL.GetRecordCount(String.Format(" Name like '%{0}%' and PicTyID=" + Tid, txtVal));
                Grid.DataSource  = BLL.GetListByPage(String.Format(" Name like '%{0}%' and PicTyID=" + Tid, txtVal), " Sort desc, Id desc ", Grid.PageIndex * Grid.PageSize, (Grid.PageIndex + 1) * Grid.PageSize);
            }

            Grid.DataBind();
        }
        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 + "'" + "/>";
                }
            }
        }
예제 #4
0
 protected void BindGridByTid(int Tid)
 {
     Maticsoft.BLL.tPicture BLL = new Maticsoft.BLL.tPicture();
     if (Tid == 0)
     {
         Grid.RecordCount = BLL.GetRecordCount("");
         Grid.DataSource  = BLL.GetListByPage("", " Sort desc,Id desc ", Grid.PageIndex * Grid.PageSize, (Grid.PageIndex + 1) * Grid.PageSize);
     }
     else
     {
         Grid.RecordCount = BLL.GetRecordCount(" PicTyID=" + Tid);
         Grid.DataSource  = BLL.GetListByPage(" PicTyID=" + Tid, " Sort desc, Id desc ", Grid.PageIndex * Grid.PageSize, (Grid.PageIndex + 1) * Grid.PageSize);
     }
     Grid.DataBind();
 }
예제 #5
0
        public string GetPic(int tid, int top)
        {
            Maticsoft.BLL.tPicture BLL = new Maticsoft.BLL.tPicture();
            DataTable     dt           = BLL.GetListByPage(" PicTyID=" + tid, " Sort desc,Id desc ", 0, top).Tables[0];
            StringBuilder sb           = new StringBuilder();

            for (int i = 0; i < dt.Rows.Count; i++)
            {
                sb.Append("<li>");
                sb.Append("<img src=" + dt.Rows[i]["Code"].ToString().Replace("~/", "../") + " />");
                sb.Append("</li>");
            }

            return(sb.ToString());
        }
예제 #6
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());
            }
        }