javascript调用后台的添、删、改、查

前台:

<%@ Page AutoEventWireup="true" CodeBehind="CustomerBizList.aspx.cs" Inherits="SSMIS.UI.MISUI.CustomerBizList"
    Language="C#" MasterPageFile="/Master/WebAdmin.master" %>


<asp:Content ID="Content1" runat="Server" ContentPlaceHolderID="bcr">
    <%--内容开始--%>
    <script type="text/javascript" language="javascript">
        function SearchTag() {
            var searchKey;
            searchKey = document.getElementById("searchKey").value;
            window.location = "CustomerBizList.aspx?searchKey=" + escape(searchKey);
        }
        function AddTag() {
            var tagAddName;
            tagAddName = document.getElementById("tagAddName").value;
            if(tagAddName!="" )
            {
            PageMethods.AddAlbumTag(tagAddName);
            alert("操作成功!");
            }
            else
            {
            alert("请输入内容!")
            }
            window.location = "CustomerBizList.aspx";
        }
        function EditTag() {
            var tagName;
            var tagId;
            var itemTotal;
            var i;
            itemTotal = document.getElementById("itemNum").value;
            for (i = 0; i < itemTotal; i++) {
                var MytagId = "TagID" + i;
                var MytagName = "TagName" + i;
                tagId = document.getElementById(MytagId).value;
                tagName = document.getElementById(MytagName).value;
                PageMethods.EditAlbumTag(tagId, tagName);
            }
            alert("操作成功!");
            window.location = "CustomerBizList.aspx";
        }
       
        function DelTag() {
            var tagId;
            var itemTotal;
            var i;
            itemTotal = document.getElementById("itemNum").value;
            for (i = 0; i < itemTotal; i++) {
                var MytagId = "TagID" + i;
                tagId = document.getElementById(MytagId).value;
                if (document.getElementById("chk" + i).checked) {
                    PageMethods.DeleteAlbumTag(tagId);                                    
                }
            }
            alert("操作成功!");
            window.location = "CustomerBizList.aspx";
        }
       
        function DelTagSigle(tag) {
            var tagId;
            var MytagId = "TagID" + tag;
            tagId = document.getElementById(MytagId).value;
            PageMethods.DeleteAlbumTag(tagId);                                    
            alert("操作成功!");
            window.location = "CustomerBizList.aspx";
        }  
       
        function EditTagSigle(tag) {
            var tagId;
            var tagName;
            var MytagId = "TagID" + tag;
            var MytagName = "TagName" + tag;
            tagId = document.getElementById(MytagId).value;
            tagName = document.getElementById(MytagName).value;
            PageMethods.EditAlbumTag(tagId, tagName);                                  
            alert("操作成功!");
            window.location = "CustomerBizList.aspx";
        }   
    </script>

    <div class="mcol2">
        <div class="mcol2_cnt">
            <h3 class="t3">
                客户行业管理</h3>
            <div id="Background">
                <div class="large" id="Content">
                    <div class="RightColumn">
                        <div id="formGarden">
                            <table id="dataTable" class="display" width="100%" border="0" cellspacing="0" cellpadding="0">
                                <tr>
                                    <td colspan="6" align="center">
                                        名称查找:
                                        <input type="text" id="searchKey" value="" />
                                        <input type="button" id="searchButton" class="inputbutton" value="搜索" οnmοuseοver="this.className='inputbutton_hover'"
                                            οnmοuseοut="this.className='inputbutton'" οnclick="SearchTag();" />
                                        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;添加客户行业名称:
                                        <input type="text" id="tagAddName" value="" />
                                        <input type="button" id="tagSave" class="inputbutton" value="保存" οnmοuseοver="this.className='inputbutton_hover'"
                                            οnmοuseοut="this.className='inputbutton'" οnclick="AddTag();" />
                                        &nbsp;&nbsp;&nbsp;&nbsp;
                                        <input type="button" id="submitBat" class="inputbutton" value="批量修改" οnclick="if(confirm('您确定要批量修改下列标签吗?')){EditTag();return true;}return false;" />
                                        <input type="button" id="delBat" class="inputbutton" value="批量删除" οnclick="if(confirm('您确定要删除下列标签吗?')){DelTag();return true;}return false;" />
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                        <b>序号</b>
                                    </td>
                                    <td>
                                        <b>选择</b>
                                    </td>
                                    <td>
                                        <b>行业ID</b>
                                    </td>
                                    <td>
                                        <b>信息行业名称</b>
                                    </td>
                                    <td>
                                        <b>修改</b>
                                    </td>
                                    <td>
                                        <b>删除</b>
                                    </td>
                                </tr>
                                <asp:Repeater ID="rpResources" runat="server">
                                    <ItemTemplate>
                                        <tr>
                                            <td>
                                                <%# Container.ItemIndex + 1%>
                                            </td>
                                            <td>
                                                <input id="chk<%# Container.ItemIndex%>" type="checkbox" />
                                            </td>
                                            <td>
                                                <%# Eval("ID")%>
                                                <input id="TagID<%# Container.ItemIndex%>" type="hidden" value="<%# Eval("ID")%>" />
                                            </td>
                                            <td>
                                                <input type="text" id="TagName<%# Container.ItemIndex%>" value="<%# Eval("bizName")%>" />&nbsp;&nbsp;
                                            </td>
                                            <td>
                                                 <img title="编辑" src="/Resources/images/edit.gif" border="0" οnclick="if(confirm('您确定要修改这个吗?')){EditTagSigle(<%# Container.ItemIndex%>);return true;}return false;" />
                                              </td>
                                            <td>
                                                <img title="删除" src="/Resources/images/delete.gif" border="0" οnclick="if(confirm('您确定要删除这个标签吗?')){DelTagSigle(<%# Container.ItemIndex%>);return true;}return false;" />
                                            </td>
                                        </tr>
                                    </ItemTemplate>
                                </asp:Repeater>
                            </table>
                            <input name="itemNum" type="hidden" id="itemNum" value="<%= itemCount%>" />
                            <div class="mis_pager">

                                <script type="text/javascript">Page.SetPager(<%=recordCount %>, <%=pageIndex %>, <%=pageSize %>, window.location.href.split("?")[0], "page", "&searchKey=<%=searchKey%>");</script>

                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <%--内容结束--%>
</asp:Content>

后台:

private static MisService iServiceStatic = new MisService();
        private MisService iService = new MisService();

        public int pageIndex = 1;
        public int pageSize = 13;
        public int recordCount = 0;

        public int itemCount = 0;
        public string searchKey;

        protected void Page_Load(object sender, EventArgs e)
        {
            DisplayData();
        }

        private void DisplayData()
        {
            if (Convert.ToInt32(Request.QueryString["page"]) > 1)
            {
                pageIndex = Convert.ToInt32(Request.QueryString["page"]);
            }
            try
            {
                searchKey = Request.QueryString["searchKey"];
                List<CustomerBiz> list;
                if (searchKey == "" || searchKey == null)
                {
                    list = iService.GetCustomerBizList(pageSize, pageIndex, ref recordCount, CacheTimeOption.None);
                }
                else
                {
                    list = iService.GetCustomerBizListByName(searchKey, pageSize, pageIndex, ref recordCount, CacheTimeOption.None);

                }
                itemCount = list.Count;
                rpResources.DataSource = list;
                rpResources.DataBind();
            }
            catch (Exception ex)
            {
                LogHelper.WriteException("页面: CustomerBizList.aspx.cs,函数: DisplayData().", ex);
                //Page.ClientScript.RegisterStartupScript(GetType(), string.Empty, "<script type=/"text/javascript/">alert('查询失败');</script>");
            }
        }

        [WebMethod(EnableSession = true)]
        public static bool AddAlbumTag(string tagName)
        {
            CustomerBiz infoType = new CustomerBiz();
            infoType.bizName = tagName.Trim();
            try
            {
                iServiceStatic.AddCustomerBiz(infoType);
            }
            catch (Exception ex)
            {
                LogHelper.WriteException("页面: CustomerBizList.aspx.cs,函数: AddAlbumTag().", ex);
            }
            return false;
        }

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值