Beispiel #1
0
        protected void btnChangeType_Click(object sender, EventArgs e)
        {
            string selectItems = getSelectedItemsId();

            if (selectItems != "")
            {
                string[] ids     = selectItems.Split(',');
                int[]    typeids = new int[ids.Length];
                int      length  = 0; //不重复的typeid数目
                int      spcId   = 0;
                if (Request.QueryString["spcId"] != null)
                {
                    spcId = Convert.ToInt32(Request.QueryString["spcId"]);
                }
                string strDir = sys.getSpcDir(spcId);
                if (sys.IsStatic)
                {
                    //把相关的类别页面都重新生成,把被移动到的类型页面重新生成
                    //1.获取相关的类型id。 2.修改数据库。 3.重新静态生成前相关的类型id,生成被移动到的类型页面

                    DataTable dt = bllarticle.GetList("id in (" + selectItems + ")").Tables[0];
                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        int  typeid      = Convert.ToInt32(dt.Rows[i]["dbo_typeid"]);
                        bool ExistTypeId = false;
                        for (int j = 0; j < length; j++)
                        {
                            if (typeid == typeids[j])
                            {
                                ExistTypeId = true;
                            }
                        }
                        if (!ExistTypeId)
                        {
                            typeids[length] = typeid;
                            length++;
                        }
                        //articlePtime[i] = Convert.ToDateTime(dt.Rows[i]["ptime"]);
                        // sys.deleteArticleFile(Convert.ToInt32(ids[i]), strDir, Convert.ToDateTime(dt.Rows[i]["ptime"]));
                    }
                }
                bllarticle.UpdateTypeidByIdList(Convert.ToInt32(this.ddlType2.SelectedValue), selectItems);
                if (sys.IsStatic)
                {
                    for (int i = 0; i < length; i++)
                    {
                        sys.ToStaticListWithArticleEdit(typeids[i], strDir);
                    }
                    sys.ToStaticListWithArticleEdit(Convert.ToInt32(this.ddlType2.SelectedValue), strDir);
                }
            }

            this.BindData();
        }