public static string GetDataList(string Name, string GradeTerm, string Subject, string Resource_Version, string Book_Type, int PageIndex, int PageSize)
        {
            try
            {
                BLL_S_KnowledgePoint bll        = new BLL_S_KnowledgePoint();
                DataTable            dt         = new DataTable();
                List <object>        listReturn = new List <object>();
                string strWhere = " Parent_Id='0' ";
                if (!string.IsNullOrEmpty(Name))
                {
                    strWhere += " and (KPName like '%" + Name.Filter() + "%' or KPCode like '%" + Name.Filter() + "%') ";
                }
                if (!string.IsNullOrEmpty(GradeTerm))
                {
                    strWhere += " and GradeTerm='" + GradeTerm.Filter() + "' ";
                }
                if (!string.IsNullOrEmpty(Subject))
                {
                    strWhere += " and Subject='" + Subject.Filter() + "' ";
                }
                if (!string.IsNullOrEmpty(Resource_Version))
                {
                    strWhere += " and Resource_Version='" + Resource_Version.Filter() + "' ";
                }
                if (!string.IsNullOrEmpty(Book_Type))
                {
                    strWhere += " and Book_Type='" + Book_Type.Filter() + "' ";
                }

                dt = bll.GetListByPageJoinDict(strWhere, "KPCode", ((PageIndex - 1) * PageSize + 1), (PageIndex * PageSize)).Tables[0];
                int       rCount = bll.GetRecordCount(strWhere);
                DataTable dtAll  = bll.GetList(" ").Tables[0];
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    DataRow[] drSub = dtAll.Select("Parent_Id='" + dt.Rows[i]["S_KnowledgePoint_Id"].ToString() + "'");
                    listReturn.Add(new
                    {
                        S_KnowledgePoint_Id = dt.Rows[i]["S_KnowledgePoint_Id"].ToString(),
                        Parent_Id           = dt.Rows[i]["Parent_Id"].ToString().Trim(),
                        KPName      = string.IsNullOrEmpty(dt.Rows[i]["KPNameBasic"].ToString()) ? dt.Rows[i]["KPName"].ToString() : dt.Rows[i]["KPNameBasic"].ToString(),
                        KPCode      = dt.Rows[i]["KPCode"].ToString(),
                        KPLevel     = dt.Rows[i]["KPLevel"].ToString(),
                        KPLevelName = dt.Rows[i]["KPLevelName"].ToString(),
                        IsLast      = dt.Rows[i]["IsLast"].ToString(),
                        parentIdStr = "",
                        paddingLeft = "",
                        hasChildren = drSub.Length
                    });
                }

                if (dt.Rows.Count > 0)
                {
                    return(JsonConvert.SerializeObject(new
                    {
                        err = "null",
                        PageIndex = PageIndex,
                        PageSize = PageSize,
                        TotalCount = rCount,
                        list = listReturn
                    }));
                }
                else
                {
                    return(JsonConvert.SerializeObject(new
                    {
                        err = "暂无数据"
                    }));
                }
            }
            catch (Exception ex)
            {
                return(JsonConvert.SerializeObject(new
                {
                    err = ex.Message.ToString()
                }));
            }
        }
Example #2
0
 protected void btnSave_Click(object sender, EventArgs e)
 {
     try
     {
         if (string.IsNullOrEmpty(kpId))
         {
             #region 添加
             //验证KPCode是否已存在
             string strWhereCount = " KPCode='" + txtKPCode.Text.Trim()
                                    + "' and GradeTerm='" + GradeTerm
                                    + "' and Subject='" + Subject
                                    + "' and Syllabus='" + Syllabus
                                    + "' and Test_Category='" + Exam_Type
                                    + "' and Data_Type='3'";
             if (bll.GetRecordCount(strWhereCount) > 0)
             {
                 ClientScript.RegisterStartupScript(this.GetType(), "save", "<script>layer.msg('编码已存在。', { time: 2000, icon: 4})</script>");
                 return;
             }
             model.S_KnowledgePoint_Id = Guid.NewGuid().ToString();
             model.Data_Type           = "3";
             model.GradeTerm           = GradeTerm;
             model.Subject             = Subject;
             model.Syllabus            = Syllabus;
             model.Test_Category       = Exam_Type;
             model.Parent_Id           = parentId;
             model.KPName     = txtKPName.Text.Trim();
             model.KPCode     = txtKPCode.Text.Trim();
             model.KPLevel    = ddlKPLevel.SelectedValue;
             model.Importance = hidImportance.Value;
             model.CreateTime = DateTime.Now;
             model.CreateUser = loginUser.SysUser_ID;
             if (bll.Add(model))
             {
                 if (parentId == "0")
                 {
                     ClientScript.RegisterStartupScript(this.GetType(), "update", "<script type='text/javascript'>layer.msg('新增成功!',{ time: 2000,icon:1},function(){parent.loadData();parent.layer.close(index);});</script>");
                 }
                 else
                 {
                     ClientScript.RegisterStartupScript(this.GetType(), "save", "<script type='text/javascript'>layer.msg('新增成功!',{ time: 2000,icon:1},function(){parent.loadSubData2('0');parent.layer.close(index)});</script>");
                     return;
                 }
             }
             else
             {
                 ClientScript.RegisterStartupScript(this.GetType(), "save", "<script type='text/javascript'>layer.msg('新增失败!',{ time: 2000,icon:2});</script>");
                 return;
             }
             Rc.Common.SystemLog.SystemLog.AddLogFromBS(loginUser.SysUser_ID, "", "新增同步知识点");
             #endregion
         }
         else
         {
             #region 修改
             model            = bll.GetModel(kpId);
             model.Data_Type  = "3";
             model.KPName     = txtKPName.Text.Trim();
             model.KPCode     = txtKPCode.Text.Trim();
             model.KPLevel    = ddlKPLevel.SelectedValue;
             model.UpdateTime = DateTime.Now;
             model.UpdateUser = loginUser.SysUser_ID;
             if (bll.Update(model))
             {
                 if (parentId == "0")
                 {
                     ClientScript.RegisterStartupScript(this.GetType(), "update", "<script type='text/javascript'>layer.msg('修改成功!',{ time: 2000,icon:1},function(){parent.loadData();parent.layer.close(index);});</script>");
                 }
                 else
                 {
                     ClientScript.RegisterStartupScript(this.GetType(), "update", "<script type='text/javascript'>layer.msg('修改成功!',{ time: 2000,icon:1},function(){parent.loadSubData2('0');parent.layer.close(index);});</script>");
                 }
             }
             else
             {
                 ClientScript.RegisterStartupScript(this.GetType(), "save", "<script type='text/javascript'>layer.msg('修改失败!',{ time: 2000,icon:2});</script>");
                 return;
             }
             Rc.Common.SystemLog.SystemLog.AddLogFromBS(loginUser.SysUser_ID, "", "修改同步知识点");
             #endregion
         }
     }
     catch (Exception)
     {
         ClientScript.RegisterStartupScript(this.GetType(), "save", "<script type='text/javascript'>layer.ready(function(){layer.msg('操作失败!',{ time: 2000,icon:2});});</script>");
     }
 }
        protected void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                bool flag = false;
                Model_S_KnowledgePoint model = new Model_S_KnowledgePoint();
                if (string.IsNullOrEmpty(kpId))
                {
                    #region 添加
                    #region 验证KPCode是否已存在
                    string strWhereCount = " KPCode='" + txtKPCode.Text.Trim()
                                           + "' and GradeTerm='" + GradeTerm
                                           + "' and Subject='" + Subject
                                           + "' and Resource_Version='" + Resource_Version
                                           + "' and Book_Type='" + Book_Type + "'";
                    if (bll.GetRecordCount(strWhereCount) > 0)
                    {
                        ClientScript.RegisterStartupScript(this.GetType(), "save", "<script>layer.msg('编码已存在。', { time: 2000, icon: 4})</script>");
                        return;
                    }
                    #endregion

                    if (rbtIsLast0.Checked || (rbtIsLast1.Checked && !string.IsNullOrEmpty(hidKPNameBasic_Id.Value)))
                    {
                        #region  是最后一级 或 是最后一级且基本知识点已存在
                        #region 知识点数据表
                        model.S_KnowledgePoint_Id = Guid.NewGuid().ToString();
                        model.GradeTerm           = GradeTerm;
                        model.Subject             = Subject;
                        model.Resource_Version    = Resource_Version;
                        model.Book_Type           = Book_Type;
                        model.Parent_Id           = parentId;
                        model.IsLast = "0";
                        model.S_KnowledgePointBasic_Id = "";
                        model.KPName = txtKPName.Text.Trim();
                        if (rbtIsLast1.Checked)//是最后一级
                        {
                            model.IsLast = "1";
                            model.S_KnowledgePointBasic_Id = hidKPNameBasic_Id.Value;
                            model.KPName = "";
                        }
                        model.KPCode          = txtKPCode.Text.Trim();
                        model.KPLevel         = ddlKPLevel.SelectedValue;
                        model.Cognitive_Level = ddlCognitive_Level.SelectedValue;
                        model.CreateTime      = DateTime.Now;
                        model.CreateUser      = loginUser.SysUser_ID;
                        flag = bll.Add(model);
                        #endregion
                        #endregion
                    }
                    else
                    {
                        #region 是最后一级 且 基本知识点不存在
                        #region 基本知识点表
                        Model_S_KnowledgePointBasic modelBasic = new Model_S_KnowledgePointBasic();
                        string S_KnowledgePointBasic_Id        = Guid.NewGuid().ToString();
                        modelBasic.S_KnowledgePointBasic_Id = S_KnowledgePointBasic_Id;
                        modelBasic.GradeTerm   = GradeTerm;
                        modelBasic.Subject     = Subject;
                        modelBasic.KPNameBasic = hidKPNameBasic.Value.Trim();
                        modelBasic.CreateTime  = DateTime.Now;
                        modelBasic.CreateUser  = loginUser.SysUser_ID;
                        #endregion
                        #region 知识点数据表
                        model.S_KnowledgePoint_Id = Guid.NewGuid().ToString();
                        model.GradeTerm           = GradeTerm;
                        model.Subject             = Subject;
                        model.Resource_Version    = Resource_Version;
                        model.Book_Type           = Book_Type;
                        model.Parent_Id           = parentId;
                        model.IsLast = "1";
                        model.S_KnowledgePointBasic_Id = S_KnowledgePointBasic_Id;
                        model.KPName          = "";
                        model.KPCode          = txtKPCode.Text.Trim();
                        model.KPLevel         = ddlKPLevel.SelectedValue;
                        model.Cognitive_Level = ddlCognitive_Level.SelectedValue;
                        model.CreateTime      = DateTime.Now;
                        model.CreateUser      = loginUser.SysUser_ID;
                        #endregion
                        flag = bll.AddBasic(model, modelBasic);
                        #endregion
                    }

                    if (flag)
                    {
                        if (parentId == "0")
                        {
                            ClientScript.RegisterStartupScript(this.GetType(), "update", "<script type='text/javascript'>layer.msg('新增成功!',{ time: 2000,icon:1},function(){parent.loadData();parent.layer.close(index);});</script>");
                        }
                        else
                        {
                            ClientScript.RegisterStartupScript(this.GetType(), "save", "<script type='text/javascript'>layer.msg('新增成功!',{ time: 2000,icon:1},function(){parent.loadSubData2('0');parent.layer.close(index)});</script>");
                            return;
                        }
                    }
                    else
                    {
                        ClientScript.RegisterStartupScript(this.GetType(), "save", "<script type='text/javascript'>layer.msg('新增失败!',{ time: 2000,icon:2});</script>");
                        return;
                    }
                    Rc.Common.SystemLog.SystemLog.AddLogFromBS(loginUser.SysUser_ID, "", "新增同步知识点");
                    #endregion
                }
                else
                {
                    #region 修改
                    if (rbtIsLast0.Checked || (rbtIsLast1.Checked && !string.IsNullOrEmpty(hidKPNameBasic_Id.Value)))
                    {
                        #region  是最后一级 或 是最后一级且基本知识点已存在
                        #region 知识点数据表
                        model        = bll.GetModel(kpId);
                        model.IsLast = "0";
                        model.S_KnowledgePointBasic_Id = "";
                        model.KPName = txtKPName.Text.Trim();
                        if (rbtIsLast1.Checked)//是最后一级
                        {
                            model.IsLast = "1";
                            model.S_KnowledgePointBasic_Id = hidKPNameBasic_Id.Value;
                            model.KPName = "";
                        }
                        model.KPCode          = txtKPCode.Text.Trim();
                        model.KPLevel         = ddlKPLevel.SelectedValue;
                        model.Cognitive_Level = ddlCognitive_Level.SelectedValue;
                        model.UpdateTime      = DateTime.Now;
                        model.UpdateUser      = loginUser.SysUser_ID;
                        flag = bll.Update(model);
                        #endregion
                        #endregion
                    }
                    else
                    {
                        #region 是最后一级 且 基本知识点不存在
                        model = bll.GetModel(kpId);
                        #region 基本知识点表
                        Model_S_KnowledgePointBasic modelBasic = new Model_S_KnowledgePointBasic();
                        string S_KnowledgePointBasic_Id        = Guid.NewGuid().ToString();
                        modelBasic.S_KnowledgePointBasic_Id = S_KnowledgePointBasic_Id;
                        modelBasic.GradeTerm   = model.GradeTerm;
                        modelBasic.Subject     = model.Subject;
                        modelBasic.KPNameBasic = hidKPNameBasic.Value.Trim();
                        modelBasic.CreateTime  = DateTime.Now;
                        modelBasic.CreateUser  = loginUser.SysUser_ID;
                        #endregion
                        #region 知识点数据表
                        model.IsLast = "1";
                        model.S_KnowledgePointBasic_Id = S_KnowledgePointBasic_Id;
                        model.KPName          = "";
                        model.KPCode          = txtKPCode.Text.Trim();
                        model.KPLevel         = ddlKPLevel.SelectedValue;
                        model.Cognitive_Level = ddlCognitive_Level.SelectedValue;
                        model.UpdateTime      = DateTime.Now;
                        model.UpdateUser      = loginUser.SysUser_ID;
                        #endregion
                        flag = bll.UpdateBasic(model, modelBasic);
                        #endregion
                    }



                    if (flag)
                    {
                        if (parentId == "0")
                        {
                            ClientScript.RegisterStartupScript(this.GetType(), "update", "<script type='text/javascript'>layer.msg('修改成功!',{ time: 2000,icon:1},function(){parent.loadData();parent.layer.close(index);});</script>");
                        }
                        else
                        {
                            ClientScript.RegisterStartupScript(this.GetType(), "update", "<script type='text/javascript'>layer.msg('修改成功!',{ time: 2000,icon:1},function(){parent.loadSubData2('0');parent.layer.close(index);});</script>");
                        }
                    }
                    else
                    {
                        ClientScript.RegisterStartupScript(this.GetType(), "save", "<script type='text/javascript'>layer.msg('修改失败!',{ time: 2000,icon:2});</script>");
                        return;
                    }
                    Rc.Common.SystemLog.SystemLog.AddLogFromBS(loginUser.SysUser_ID, "", "修改同步知识点");
                    #endregion
                }
            }
            catch (Exception)
            {
                ClientScript.RegisterStartupScript(this.GetType(), "save", "<script type='text/javascript'>layer.ready(function(){layer.msg('操作失败!',{ time: 2000,icon:2});});</script>");
            }
        }