コード例 #1
0
        public static string GetDataList(string Name, string GradeTerm, string Subject, string Syllabus, string Test_Category, int PageIndex, int PageSize)
        {
            try
            {
                BLL_S_TestingPoint bll        = new BLL_S_TestingPoint();
                DataTable          dt         = new DataTable();
                List <object>      listReturn = new List <object>();
                string             strWhere   = " Parent_Id='0' ";//考点
                if (!string.IsNullOrEmpty(Name))
                {
                    strWhere += " and (TPName like '%" + Name.Filter() + "%' or TPCode like '%" + Name.Filter() + "%') ";
                }
                if (!string.IsNullOrEmpty(GradeTerm))
                {
                    strWhere += " and GradeTerm='" + GradeTerm.Filter() + "' ";
                }
                if (!string.IsNullOrEmpty(GradeTerm))
                {
                    strWhere += " and Subject='" + Subject.Filter() + "' ";
                }
                if (!string.IsNullOrEmpty(GradeTerm))
                {
                    strWhere += " and Syllabus='" + Syllabus.Filter() + "' ";
                }
                if (!string.IsNullOrEmpty(GradeTerm))
                {
                    strWhere += " and Test_Category='" + Test_Category.Filter() + "' ";
                }

                dt = bll.GetListByPageJoinDict(strWhere, "TPCode", ((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_TestingPoint_Id"].ToString() + "'");
                    listReturn.Add(new
                    {
                        S_KnowledgePoint_Id = dt.Rows[i]["S_TestingPoint_Id"].ToString(),
                        Parent_Id           = dt.Rows[i]["Parent_Id"].ToString().Trim(),
                        KPName      = string.IsNullOrEmpty(dt.Rows[i]["TPNameBasic"].ToString()) ? dt.Rows[i]["TPName"].ToString() : dt.Rows[i]["TPNameBasic"].ToString(),
                        KPCode      = dt.Rows[i]["TPCode"].ToString(),
                        KPLevel     = dt.Rows[i]["TPLevel"].ToString(),
                        KPLevelName = dt.Rows[i]["TPLevelName"].ToString(),
                        parentIdStr = "",
                        paddingLeft = "",
                        hasChildren = drSub.Length,
                        IsLast      = dt.Rows[i]["IsLast"].ToString(),
                    });
                }

                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()
                }));
            }
        }
コード例 #2
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                bool flag = false;
                Model_S_TestingPoint model = new Model_S_TestingPoint();
                if (string.IsNullOrEmpty(kpId))
                {
                    #region 添加
                    #region 验证TPCode是否已存在
                    string strWhereCount = " TPCode='" + txtTPCode.Text.Trim()
                                           + "' and GradeTerm='" + GradeTerm
                                           + "' and Subject='" + Subject
                                           + "' and Syllabus='" + Syllabus
                                           + "' and Test_Category='" + Exam_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(hidTPNameBasic_Id.Value)))
                    {
                        #region  是最后一级 或 是最后一级且基本考点已存在
                        #region 考点数据表
                        model.S_TestingPoint_Id      = Guid.NewGuid().ToString();
                        model.GradeTerm              = GradeTerm;
                        model.Subject                = Subject;
                        model.Syllabus               = Syllabus;
                        model.Test_Category          = Exam_Type;
                        model.Parent_Id              = parentId;
                        model.IsLast                 = "0";
                        model.S_TestingPointBasic_Id = "";
                        model.TPName                 = txtTPName.Text.Trim();
                        if (rbtIsLast1.Checked)//是最后一级
                        {
                            model.IsLast = "1";
                            model.S_TestingPointBasic_Id = hidTPNameBasic_Id.Value;
                            model.TPName = "";
                        }
                        if (rbt0.Checked)
                        {
                            model.Importance = "1";
                        }
                        else
                        {
                            model.Importance = "0";
                        }
                        model.TPCode          = txtTPCode.Text.Trim();
                        model.TPLevel         = 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_TestingPointBasic modelBasic = new Model_S_TestingPointBasic();
                        string S_TestingPointBasic_Id        = Guid.NewGuid().ToString();
                        modelBasic.S_TestingPointBasic_Id = S_TestingPointBasic_Id;
                        modelBasic.GradeTerm   = GradeTerm;
                        modelBasic.Subject     = Subject;
                        modelBasic.TPNameBasic = hidTPNameBasic.Value.Trim();
                        modelBasic.CreateTime  = DateTime.Now;
                        modelBasic.CreateUser  = loginUser.SysUser_ID;
                        #endregion
                        #region 考点数据表
                        model.S_TestingPoint_Id = Guid.NewGuid().ToString();
                        model.GradeTerm         = GradeTerm;
                        model.Subject           = Subject;
                        model.Syllabus          = Syllabus;
                        model.Test_Category     = Exam_Type;
                        model.Parent_Id         = parentId;
                        model.IsLast            = "1";
                        if (rbt0.Checked)
                        {
                            model.Importance = "1";
                        }
                        else
                        {
                            model.Importance = "0";
                        }
                        model.S_TestingPointBasic_Id = S_TestingPointBasic_Id;
                        model.TPName          = "";
                        model.TPCode          = txtTPCode.Text.Trim();
                        model.TPLevel         = 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(hidTPNameBasic_Id.Value)))
                    {
                        #region  是最后一级 或 是最后一级且基本考点已存在
                        #region 考点数据表
                        model        = bll.GetModel(kpId);
                        model.IsLast = "0";
                        model.S_TestingPointBasic_Id = "";
                        model.TPName = txtTPName.Text.Trim();
                        if (rbtIsLast1.Checked)//是最后一级
                        {
                            model.IsLast = "1";
                            model.S_TestingPointBasic_Id = hidTPNameBasic_Id.Value;
                            model.TPName = "";
                        }
                        if (rbt0.Checked)
                        {
                            model.Importance = "1";
                        }
                        else
                        {
                            model.Importance = "0";
                        }
                        model.TPCode          = txtTPCode.Text.Trim();
                        model.TPLevel         = 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_TestingPointBasic modelBasic = new Model_S_TestingPointBasic();
                        string S_TestingPointBasic_Id        = Guid.NewGuid().ToString();
                        modelBasic.S_TestingPointBasic_Id = S_TestingPointBasic_Id;
                        modelBasic.GradeTerm   = model.GradeTerm;
                        modelBasic.Subject     = model.Subject;
                        modelBasic.TPNameBasic = hidTPNameBasic.Value.Trim();
                        modelBasic.CreateTime  = DateTime.Now;
                        modelBasic.CreateUser  = loginUser.SysUser_ID;
                        #endregion
                        #region 考点数据表
                        model.IsLast = "1";
                        if (rbt0.Checked)
                        {
                            model.Importance = "1";
                        }
                        else
                        {
                            model.Importance = "0";
                        }
                        model.S_TestingPointBasic_Id = S_TestingPointBasic_Id;
                        model.TPName          = "";
                        model.TPCode          = txtTPCode.Text.Trim();
                        model.TPLevel         = 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>");
            }
        }