Ejemplo n.º 1
0
        //获取单个栏目信息
        public string SingleJson(int id)
        {
            Song.Entities.KnowledgeSort nc = Business.Do <IKnowledge>().SortSingle(id);
            string json = nc.ToJson();

            return(json);
        }
Ejemplo n.º 2
0
 protected void Page_Load(object sender, EventArgs e)
 {
     //this.Form.DefaultButton = this.btnSear.UniqueID;
     org = Business.Do <IOrganization>().OrganCurrent();
     if (!this.IsPostBack)
     {
         if (state == "add" || state == "edit")
         {
             plEditArea.Visible = true;
             plListArea.Visible = false;
         }
         else
         {
             plEditArea.Visible = false;
             plListArea.Visible = true;
         }
         //栏目名称
         spanColName.Visible = knsid > 0;
         if (knsid != 0)
         {
             Song.Entities.KnowledgeSort col = Business.Do <IKnowledge>().SortSingle(knsid);
             if (col != null)
             {
                 lbColunms.Text = col.Kns_Name;
             }
         }
         BindData(null, null);
     }
 }
Ejemplo n.º 3
0
        /// <summary>
        /// 添加栏目信息
        /// </summary>
        /// <param name="result"></param>
        private void _Add(string result)
        {
            if (result == "" || result == null)
            {
                return;
            }
            XmlDocument resXml = new XmlDocument();

            try
            {
                resXml.LoadXml(result, false);
                XmlNode node = resXml.SelectSingleNode("node");
                int     id   = Convert.ToInt32(((XmlElement)node).Attributes["id"].Value);
                Song.Entities.KnowledgeSort nc = new Song.Entities.KnowledgeSort();
                nc.Kns_Name   = ((XmlElement)node.SelectSingleNode("name")).InnerText;
                nc.Kns_ByName = ((XmlElement)node.SelectSingleNode("byname")).InnerText;
                nc.Kns_PID    = Convert.ToInt32(((XmlElement)node.SelectSingleNode("pid")).InnerText);
                nc.Kns_Intro  = ((XmlElement)node.SelectSingleNode("intro")).InnerText;
                nc.Kns_IsUse  = Convert.ToBoolean(((XmlElement)node.SelectSingleNode("IsUse")).InnerText);
                //添加
                Business.Do <IKnowledge>().SortAdd(nc);
            }
            catch
            {
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 编辑当前数据项
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnEditEnter_Click(object sender, EventArgs e)
        {
            System.Web.UI.WebControls.Button btn = (System.Web.UI.WebControls.Button)sender;
            int index = ((GridViewRow)(btn.Parent.Parent)).RowIndex;
            int id    = int.Parse(this.gvColumns.DataKeys[index].Value.ToString());

            //
            Song.Entities.KnowledgeSort col = Business.Do <IKnowledge>().SortSingle(id);
            if (col != null)
            {
                //名称
                TextBox tb = (TextBox)gvColumns.Rows[index].FindControl("tbTitle");
                col.Kns_Name = tb.Text.Trim();
                //父级
                DropDownTree tree = (DropDownTree)gvColumns.Rows[index].FindControl("ddlColTree");
                col.Kns_PID = Convert.ToInt32(tree.SelectedValue);
                //是否可用
                CheckBox cb = (CheckBox)gvColumns.Rows[index].FindControl("cbIsUse");
                col.Kns_IsUse = cb.Checked;
                //简介
                TextBox tbintro = (TextBox)gvColumns.Rows[index].FindControl("tbIntro");
                col.Kns_Intro = tbintro.Text.Trim();
                //
                Business.Do <IKnowledge>().SortSave(col);
            }
            gvColumns.EditIndex = -1;
            BindData(null, null);
        }
Ejemplo n.º 5
0
        protected override void InitPageTemplate(HttpContext context)
        {
            if (Request.ServerVariables["REQUEST_METHOD"] == "GET")
            {
                Song.Entities.Course course = Business.Do <ICourse>().CourseSingle(couid);
                //是否学习当前课程
                if (this.Account != null)
                {
                    //是否购买当前课程
                    bool isBuy = Business.Do <ICourse>().StudyIsCourse(this.Account.Ac_ID, course.Cou_ID);
                    this.Document.Variables.SetValue("isBuy", isBuy);
                    //是否可以学习,如果是免费或已经选修便可以学习,否则当前课程允许试用且当前章节是免费的,也可以学习
                    bool canStudy = isBuy || course.Cou_IsFree || course.Cou_IsLimitFree;
                    this.Document.Variables.SetValue("canStudy", canStudy);
                }
                //知识库栏目
                Song.Entities.KnowledgeSort[] kns = Business.Do <IKnowledge>().GetSortAll(-1, couid, -1, true);
                DataTable dt = WeiSha.WebControl.Tree.ObjectArrayToDataTable.To(kns);
                WeiSha.WebControl.Tree.DataTableTree tree = new WeiSha.WebControl.Tree.DataTableTree();
                tree.IdKeyName       = "Kns_ID";
                tree.ParentIdKeyName = "Kns_PID";
                tree.TaxKeyName      = "Kns_Tax";
                tree.Root            = 0;
                dt = tree.BuilderTree(dt);
                this.Document.Variables.SetValue("kns", dt);
                this.Document.Variables.SetValue("couid", couid);
                //当前知识库栏目
                int sorts = WeiSha.Common.Request.QueryString["sorts"].Int32 ?? 0;  //栏目分类id
                Song.Entities.KnowledgeSort sort = Business.Do <IKnowledge>().SortSingle(sorts);
                this.Document.Variables.SetValue("sort", sort);
            }
            //此页面的ajax提交,全部采用了POST方式
            if (Request.ServerVariables["REQUEST_METHOD"] == "POST")
            {
                int    size   = WeiSha.Common.Request.Form["size"].Int32 ?? 10; //每页多少条
                int    index  = WeiSha.Common.Request.Form["index"].Int32 ?? 1; //第几页
                string sorts  = WeiSha.Common.Request.Form["sorts"].String;     //栏目分类id
                string search = WeiSha.Common.Request.Form["sear"].String;      //要检索的字符

                int sumcount = 0;
                //信息列表
                Song.Entities.Knowledge[] kls = null;
                kls = Business.Do <IKnowledge>().KnowledgePager(couid, sorts, search, size, index, out sumcount);
                string json = "{\"size\":" + size + ",\"index\":" + index + ",\"sumcount\":" + sumcount + ",";
                json += "\"items\":[";
                for (int n = 0; n < kls.Length; n++)
                {
                    json += kls[n].ToJson("Kn_ID,Kn_Title", "Kn_Details") + ",";
                }
                if (json.EndsWith(","))
                {
                    json = json.Substring(0, json.Length - 1);
                }
                json += "]}";
                Response.Write(json);
                Response.End();
            }
        }
Ejemplo n.º 6
0
        /// 修改是否使用的状态
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void sbUse_Click(object sender, EventArgs e)
        {
            StateButton ub    = (StateButton)sender;
            int         index = ((GridViewRow)(ub.Parent.Parent)).RowIndex;
            int         id    = int.Parse(this.gvColumns.DataKeys[index].Value.ToString());

            //
            Song.Entities.KnowledgeSort entity = Business.Do <IKnowledge>().SortSingle(id);
            entity.Kns_IsUse = !entity.Kns_IsUse;
            Business.Do <IKnowledge>().SortSave(entity);
            BindData(null, null);
        }
Ejemplo n.º 7
0
 /// <summary>
 /// 新增按钮
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 protected void btnAddEnter_Click(object sender, EventArgs e)
 {
     Song.Entities.KnowledgeSort col = new Song.Entities.KnowledgeSort();
     col.Kns_Name  = tbTitle.Text.Trim();
     col.Kns_PID   = Convert.ToInt32(ddlTree.SelectedValue);
     col.Cou_ID    = couid;
     col.Kns_Intro = tbIntro.Text.Trim();
     col.Kns_IsUse = cbIsUse.Checked;
     Business.Do <IKnowledge>().SortAdd(col);
     BindData(null, null);
     gvColumns.EditIndex = -1;
     btnAddBack_Click(null, null);
 }
Ejemplo n.º 8
0
 public void SortSaveOrder(string xml)
 {
     using (DbTrans tran = Gateway.Default.BeginTrans())
     {
         try
         {
             XmlDocument resXml = new XmlDocument();
             resXml.XmlResolver = null;
             resXml.LoadXml(xml, false);
             XmlNodeList nodeList = resXml.SelectSingleNode("nodes").ChildNodes;
             //取rootid
             XmlNode    nodes   = resXml.SelectSingleNode("nodes");
             XmlElement xenodes = (XmlElement)nodes;
             //遍历所有子节点
             foreach (XmlNode xn in nodeList)
             {
                 XmlElement xe  = (XmlElement)xn;
                 int        id  = Convert.ToInt32(xe.Attributes["id"].Value);
                 int        pid = Convert.ToInt32(xe.Attributes["pid"].Value);
                 int        tax = Convert.ToInt32(xe.Attributes["tax"].Value);
                 Song.Entities.KnowledgeSort nc = this.SortSingle(id);
                 if (nc != null)
                 {
                     nc.Kns_PID = pid;
                     nc.Kns_Tax = tax;
                     tran.Save <KnowledgeSort>(nc);
                 }
             }
             tran.Commit();
         }
         catch (Exception ex)
         {
             tran.Rollback();
             throw ex;
         }
         finally
         {
             tran.Close();
         }
     }
 }