コード例 #1
0
    protected void bt_add_Click(object sender, EventArgs e)
    {
        ModuleListInfo moduleListInfo = new ModuleListInfo(0, this.tb_name.Text, this.tb_tableName.Text, this.tb_description.Text, DateTime.Now);

        moduleListInfo.Insert();
        this.db.RunNonQurey("Create TABLE " + this.tb_tableName.Text + "(Id AutoIncrement primary key,SortId int not null default 0)");
        this.Page.ClientScript.RegisterStartupScript(base.GetType(), "Ok", "alert('添加成功!');", true);
        this.BindData();
    }
コード例 #2
0
    protected void gv_catelist_RowUpdating(object sender, GridViewUpdateEventArgs e)
    {
        ModuleListInfo moduleListInfo = ModuleListInfo.Read((int)this.gv_catelist.DataKeys[e.RowIndex].Value);

        moduleListInfo.ModuleName = ((TextBox)this.gv_catelist.Rows[e.RowIndex].FindControl("tb_name")).Text;
        moduleListInfo.ModuleInfo = ((TextBox)this.gv_catelist.Rows[e.RowIndex].FindControl("tb_description")).Text;
        moduleListInfo.Update();
        this.Page.ClientScript.RegisterStartupScript(base.GetType(), "Ok", "alert('修改成功!');", true);
        this.BindData();
    }
コード例 #3
0
 protected void gv_catelist_RowDeleting(object sender, GridViewDeleteEventArgs e)
 {
     ModuleListInfo.Delete((int)this.gv_catelist.DataKeys[e.RowIndex].Value);
     try
     {
         string text = ((TextBox)this.gv_catelist.Rows[e.RowIndex].FindControl("tb_tableName")).Text;
         this.db.RunNonQurey("drop table " + text);
     }
     catch
     {
     }
     this.BindData();
 }
コード例 #4
0
    public static List <ModuleListInfo> ReadList(string whereStr)
    {
        List <ModuleListInfo> list = new List <ModuleListInfo>();
        Database database          = new Database();
        DataView defaultView       = database.RunProc("select * from ModuleList " + whereStr).Tables[0].DefaultView;

        for (int i = 0; i < defaultView.Count; i++)
        {
            list.Add(ModuleListInfo.Read(int.Parse(defaultView[i]["id"].ToString())));
        }
        database.Dispose();
        return(list);
    }
コード例 #5
0
    public static ModuleListInfo Read(int id)
    {
        ModuleListInfo  result          = null;
        Database        database        = new Database();
        MySqlDataReader mySqlDataReader = database.RunProcGetReader("select * from ModuleList where id=" + id);

        while (mySqlDataReader.Read())
        {
            result = new ModuleListInfo(int.Parse(mySqlDataReader.GetValue(0).ToString()), mySqlDataReader.GetValue(1).ToString(), mySqlDataReader.GetValue(2).ToString(), mySqlDataReader.GetValue(3).ToString(), DateTime.Parse(mySqlDataReader.GetValue(4).ToString()));
        }
        mySqlDataReader.Close();
        database.Dispose();
        return(result);
    }
コード例 #6
0
 public void BindData()
 {
     if (base.Request["action"] == null && base.Request["infoId"] == null)
     {
         ModuleListInfo moduleListInfo = ModuleListInfo.Read(int.Parse(base.Request.QueryString["moduleId"]));
         if (base.Request["sortType"] != null && base.Request["sortType"] == "2")
         {
             MySqlDataReader mySqlDataReader = this.db.RunProcGetReader(string.Concat(new object[]
             {
                 "select * from [",
                 moduleListInfo.ModuleTableName,
                 "] where sortId=",
                 int.Parse(base.Request["sortId"].Trim()),
                 " order by id limit 1"
             }));
             if (mySqlDataReader.Read())
             {
                 this.sb.AppendLine("<tr><Th colspan=2>" + moduleListInfo.ModuleName + "</th></tr>");
                 List <ModuleFieldInfo> list = ModuleFieldInfo.ReadList(" where ModuleId=" + moduleListInfo.Id + " order by FieldOrder");
                 for (int i = 0; i < list.Count; i++)
                 {
                     this.sb.AppendLine(string.Concat(new string[]
                     {
                         "<tr><Td width=18% id=tdr>",
                         list[i].FieldInfo,
                         "</td><td id=tdl>",
                         this.GetHtmlStr(list[i].FieldName, list[i].HtmlType, list[i].DefaultValue, list[i].Width, list[i].Height, base.Server.HtmlEncode(mySqlDataReader[list[i].FieldName].ToString())),
                         " ",
                         list[i].FieldInfoA,
                         " </td></tr>"
                     }));
                 }
                 this.sb.AppendLine(string.Concat(new string[]
                 {
                     "<tr><td></td><td id=tdl><input type=\"submit\" id=\"s_add\" name=\"s_add\" value=\" 修 改 \" onclick=\"form.action='?moduleId=",
                     base.Request["moduleId"],
                     "&sortId=",
                     base.Request["sortId"],
                     "&action=edit&sortType=",
                     base.Request["sortType"],
                     "&infoId=",
                     mySqlDataReader["id"].ToString(),
                     "';\" /></td></tr>"
                 }));
             }
             else
             {
                 this.sb.AppendLine("<tr><Th colspan=2>" + moduleListInfo.ModuleName + "</th></tr>");
                 List <ModuleFieldInfo> list2 = ModuleFieldInfo.ReadList(" where ModuleId=" + moduleListInfo.Id + " order by FieldOrder");
                 for (int j = 0; j < list2.Count; j++)
                 {
                     this.sb.AppendLine(string.Concat(new string[]
                     {
                         "<tr><Td width=18% id=tdr>",
                         list2[j].FieldInfo,
                         "</td><td id=tdl>",
                         this.GetHtmlStr(list2[j].FieldName, list2[j].HtmlType, list2[j].DefaultValue, list2[j].Width, list2[j].Height, ""),
                         " ",
                         list2[j].FieldInfoA,
                         " </td></tr>"
                     }));
                 }
                 this.sb.AppendLine(string.Concat(new string[]
                 {
                     "<tr><td></td><td id=tdl><input type=\"submit\" id=\"s_add\" name=\"s_add\" value=\" 修 改 \" onclick=\"form.action='?moduleId=",
                     base.Request["moduleId"],
                     "&sortId=",
                     base.Request["sortId"],
                     "&action=add&sortType=",
                     base.Request["sortType"],
                     "';\" /></td></tr>"
                 }));
             }
             mySqlDataReader.Close();
             this.db.Dispose();
         }
         else
         {
             this.sb.AppendLine("<tr><Th colspan=2>" + moduleListInfo.ModuleName + "</th></tr>");
             List <ModuleFieldInfo> list3 = ModuleFieldInfo.ReadList(" where ModuleId=" + moduleListInfo.Id + " order by FieldOrder");
             for (int k = 0; k < list3.Count; k++)
             {
                 string readValue = (list3[k].FieldDataType.ToLower() == "date") ? DateTime.Now.ToString() : "";
                 this.sb.AppendLine(string.Concat(new string[]
                 {
                     "<tr><Td width=18% id=tdr>",
                     list3[k].FieldInfo,
                     "</td><td id=tdl>",
                     this.GetHtmlStr(list3[k].FieldName, list3[k].HtmlType, list3[k].DefaultValue, list3[k].Width, list3[k].Height, readValue),
                     " ",
                     list3[k].FieldInfoA,
                     " </td></tr>"
                 }));
             }
             this.sb.AppendLine(string.Concat(new string[]
             {
                 "<tr><td></td><td id=tdl><input type=\"submit\" id=\"s_add\" name=\"s_add\" value=\" 添 加 \" onclick=\"form.action='?moduleId=",
                 base.Request["moduleId"],
                 "&sortId=",
                 base.Request["sortId"],
                 "&action=add';\" /></td></tr>"
             }));
         }
     }
     if (base.Request["action"] == null && base.Request["infoId"] != null && base.Request["infoId"].Length > 0)
     {
         ModuleListInfo  moduleListInfo2  = ModuleListInfo.Read(int.Parse(base.Request.QueryString["moduleId"]));
         MySqlDataReader mySqlDataReader2 = this.db.RunProcGetReader(string.Concat(new object[]
         {
             "select * from [",
             moduleListInfo2.ModuleTableName,
             "] where id=",
             int.Parse(base.Request["infoId"])
         }));
         if (mySqlDataReader2.Read())
         {
             this.sb.AppendLine("<tr><Th colspan=2>" + moduleListInfo2.ModuleName + "</th></tr>");
             List <ModuleFieldInfo> list4 = ModuleFieldInfo.ReadList(" where ModuleId=" + moduleListInfo2.Id + " order by FieldOrder");
             for (int l = 0; l < list4.Count; l++)
             {
                 this.sb.AppendLine(string.Concat(new string[]
                 {
                     "<tr><Td width=18% id=tdr>",
                     list4[l].FieldInfo,
                     "</td><td id=tdl>",
                     this.GetHtmlStr(list4[l].FieldName, list4[l].HtmlType, list4[l].DefaultValue, list4[l].Width, list4[l].Height, base.Server.HtmlEncode(mySqlDataReader2[list4[l].FieldName].ToString())),
                     " ",
                     list4[l].FieldInfoA,
                     " </td></tr>"
                 }));
             }
             this.sb.AppendLine(string.Concat(new string[]
             {
                 "<tr><td></td><td id=tdl><input type=\"submit\" id=\"s_add\" name=\"s_add\" value=\" 修改 \" onclick=\"form.action='?moduleId=",
                 base.Request["moduleId"],
                 "&sortId=",
                 base.Request["sortId"],
                 "&action=edit&infoId=",
                 base.Request["infoId"],
                 "';\" /></td></tr>"
             }));
         }
         mySqlDataReader2.Close();
         this.db.Dispose();
     }
     if (base.Request["action"] != null && base.Request.QueryString["action"].Trim() == "add")
     {
         ModuleListInfo         moduleListInfo3 = ModuleListInfo.Read(int.Parse(base.Request.QueryString["moduleId"]));
         List <ModuleFieldInfo> list5           = ModuleFieldInfo.ReadList(" where ModuleId=" + moduleListInfo3.Id + " order by FieldOrder");
         string text  = "";
         string text2 = "";
         for (int m = 0; m < list5.Count; m++)
         {
             text  = text + "[" + list5[m].FieldName + "],";
             text2 = text2 + "@" + list5[m].FieldName + ",";
         }
         text = text.Trim().TrimEnd(new char[]
         {
             ','
         });
         text2 = text2.Trim().TrimEnd(new char[]
         {
             ','
         });
         MySqlCommand mySqlCommand = this.db.CreateCmd(string.Concat(new string[]
         {
             "insert into [",
             moduleListInfo3.ModuleTableName,
             "]([sortId],",
             text,
             ")values(@sortId,",
             text2,
             ")"
         }));
         mySqlCommand.Parameters.Add("@sortId", MySqlDbType.Int16).Value = int.Parse(base.Request["sortId"].Trim());
         for (int n = 0; n < list5.Count; n++)
         {
             mySqlCommand.Parameters.Add("@" + list5[n].FieldName, this.GetDbType(list5[n].FieldDataType)).Value = base.Request["g_" + list5[n].FieldName].ToString();
         }
         mySqlCommand.ExecuteNonQuery();
         this.db.Dispose();
         base.Response.Write(string.Concat(new string[]
         {
             "<script>alert('添加成功');location.href='InfoEdit.aspx?moduleId=",
             base.Request["moduleId"],
             "&sortId=",
             base.Request["sortId"],
             "&sortType=",
             base.Request["sortType"],
             "';</script>"
         }));
     }
     if (base.Request["action"] != null && base.Request.QueryString["action"].Trim() == "edit" && base.Request["infoId"] != null && base.Request["infoId"].Trim().Length > 0)
     {
         ModuleListInfo         moduleListInfo4 = ModuleListInfo.Read(int.Parse(base.Request.QueryString["moduleId"]));
         List <ModuleFieldInfo> list6           = ModuleFieldInfo.ReadList(" where ModuleId=" + moduleListInfo4.Id + " order by FieldOrder");
         string text3 = "";
         for (int num = 0; num < list6.Count; num++)
         {
             string text4 = text3;
             text3 = string.Concat(new string[]
             {
                 text4,
                 "[",
                 list6[num].FieldName,
                 "]=@",
                 list6[num].FieldName,
                 ","
             });
         }
         text3 = text3.Trim().TrimEnd(new char[]
         {
             ','
         });
         MySqlCommand mySqlCommand2 = this.db.CreateCmd(string.Concat(new object[]
         {
             "update [",
             moduleListInfo4.ModuleTableName,
             "] set ",
             text3,
             " where id=",
             int.Parse(base.Request["infoId"].Trim())
         }));
         for (int num2 = 0; num2 < list6.Count; num2++)
         {
             mySqlCommand2.Parameters.Add("@" + list6[num2].FieldName, this.GetDbType(list6[num2].FieldDataType)).Value = base.Request["g_" + list6[num2].FieldName].ToString();
         }
         mySqlCommand2.ExecuteNonQuery();
         this.db.Dispose();
         base.Response.Write(string.Concat(new string[]
         {
             "<script>alert('修改成功');location.href='InfoEdit.aspx?moduleId=",
             base.Request["moduleId"],
             "&infoId=",
             base.Request["infoId"].Trim(),
             "';</script>"
         }));
     }
 }
コード例 #7
0
    public void BindData()
    {
        int recordConnt = 0;
        int num         = this.page = ((base.Request["page"] != null) ? int.Parse(base.Request.QueryString["page"]) : 1);

        this.moduleId = int.Parse(base.Request["moduleId"]);
        this.sortId   = int.Parse(base.Request["sortId"]);
        ModuleListInfo moduleListInfo = ModuleListInfo.Read(this.moduleId);

        this.pager.PageSize = 15;
        DataView dataView = this.db.RunProcGetDataView(string.Concat(new object[]
        {
            "select * from [",
            moduleListInfo.ModuleTableName,
            "] where sortId=",
            this.sortId,
            " order by id desc"
        }), (num - 1) * this.pager.PageSize, this.pager.PageSize, out recordConnt);
        List <ModuleFieldInfo> list = ModuleFieldInfo.ReadList("where moduleId=" + this.moduleId + " and isShow=1 order by fieldOrder");

        this.sb.AppendLine("<table width=100% border=1><tr>");
        this.sb.AppendLine("<th width=60>编号</th>");
        for (int i = 0; i < list.Count; i++)
        {
            this.sb.AppendLine(string.Concat(new string[]
            {
                "<th width=",
                list[i].ListWidth,
                ">",
                list[i].FieldInfo,
                "</th>"
            }));
        }
        this.sb.AppendLine("<th width=120>查看</th>");
        this.sb.AppendLine("<th width=60>选择</th>");
        this.sb.AppendLine("</tr>");
        for (int j = 0; j < dataView.Count; j++)
        {
            this.sb.AppendLine("<tr>");
            this.sb.AppendLine("<td align=center>" + dataView[j]["id"].ToString() + "</td>");
            for (int k = 0; k < list.Count; k++)
            {
                this.sb.AppendLine("<td align=center>" + this.GetFieldStr(dataView[j][list[k].FieldName].ToString(), list[k].DefaultValue, list[k].HtmlType) + "</td>");
            }
            this.sb.AppendLine(string.Concat(new object[]
            {
                "<td align=center><a href='InfoEdit.aspx?moduleId=",
                this.moduleId,
                "&infoId=",
                dataView[j]["id"].ToString(),
                "'>查看详细</a></td><td align=center><input id=\"selectId\" type=\"checkbox\" name=\"selectId\" value=\"",
                dataView[j]["id"].ToString(),
                "\" /></td>"
            }));
            this.sb.AppendLine("</tr>");
        }
        this.sb.AppendLine("</table>");
        this.pager.RecordConnt = recordConnt;
        this.pager.CurrentPage = num;
        this.pager.UrlFormat   = string.Concat(new object[]
        {
            "InfoList.aspx?moduleId=",
            this.moduleId,
            "&sortId=",
            this.sortId,
            "&page={0}"
        });
        this.sb.AppendLine("<table width=100%><Tr><Td id=pager> " + this.pager.CreaterHtml() + "</td>");
        this.sb.AppendLine("<td align=right width=183><input id=\"CheckAll\" type=\"checkbox\" onClick=\"mm()\" /> 全选 <input type=\"submit\" name=\"bt_delete\" value=\" 删除选中 \" onclick=\"return confirm('确定要删除吗');\" id=\"bt_delete\" /> </td></tr></table>");
        if (base.Request["action"] != null && base.Request["action"] == "delete")
        {
            if (base.Request["selectId"] != null && base.Request["selectId"].Trim().Length > 0)
            {
                this.db.RunNonQurey(string.Concat(new string[]
                {
                    "delete from [",
                    moduleListInfo.ModuleTableName,
                    "] where id in(",
                    base.Request["selectId"].Trim().Replace("'", "").Replace("\"", ""),
                    ")"
                }));
                this.db.Dispose();
            }
            base.Response.Redirect(string.Concat(new object[]
            {
                "InfoList.aspx?moduleId=",
                this.moduleId,
                "&sortId=",
                this.sortId,
                "&page=",
                this.page
            }));
        }
    }