惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
H
Help Net Security
博客园_首页
P
Privacy International News Feed
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
T
Tenable Blog
Latest news
Latest news
D
Darknet – Hacking Tools, Hacker News & Cyber Security
爱范儿
爱范儿
Cyberwarzone
Cyberwarzone
P
Palo Alto Networks Blog
月光博客
月光博客
有赞技术团队
有赞技术团队
Know Your Adversary
Know Your Adversary
博客园 - 叶小钗
P
Proofpoint News Feed
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
S
Schneier on Security
A
About on SuperTechFans
F
Full Disclosure
The Cloudflare Blog
T
The Exploit Database - CXSecurity.com
S
SegmentFault 最新的问题
Apple Machine Learning Research
Apple Machine Learning Research
Microsoft Security Blog
Microsoft Security Blog
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
N
News and Events Feed by Topic
www.infosecurity-magazine.com
www.infosecurity-magazine.com
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
Webroot Blog
Webroot Blog
量子位
大猫的无限游戏
大猫的无限游戏
小众软件
小众软件
WordPress大学
WordPress大学
Last Week in AI
Last Week in AI
美团技术团队
Help Net Security
Help Net Security
Microsoft Azure Blog
Microsoft Azure Blog
GbyAI
GbyAI
云风的 BLOG
云风的 BLOG
Y
Y Combinator Blog
博客园 - 司徒正美
N
Netflix TechBlog - Medium
S
Security @ Cisco Blogs
B
Blog
P
Privacy & Cybersecurity Law Blog
Security Archives - TechRepublic
Security Archives - TechRepublic
Hacker News - Newest:
Hacker News - Newest: "LLM"
V
Visual Studio Blog
NISL@THU
NISL@THU

博客园 - 夜飞

滚动DATAGRID数据 和股票一样滚动 vs.2005 中对COOKIES 加密解密 例子 - 夜飞 asp.net(c#) datelist DataGrid 中截取字符串加"..." 和 鼠标放上去字符全部显示 - 夜飞 vs.2005 比较时间大小 可精确到秒 - 夜飞 VS.2005 子窗体提交数据刷新父窗体 GRIDVIEW 子窗体(2) gridview中加弹出窗口用例 创建数据库连接对象 ASP.NET程序员笔试最常见问题 海量数据库的查询优化及分页算法方案 表格列头加菜单(datagrid) 实现无刷新DropdownList联动效果 实现的不让同一个用户登陆 GridView控件修改、删除示例(修改含有DropDownList控件) asp.net打印 Web打印控制技术的几种方案: ASP.NET中弹出窗口技术 在asp.net中读取XML文件信息的4种方法 Asp.Net 动态生成验证码 ----- 把DataGrid1的一列的统计显示在页脚
VS.2005 子窗体提交数据刷新父窗体 GRIDVIEW 父窗体(1) - 夜飞
夜飞 · 2006-07-12 · via 博客园 - 夜飞

父窗题ASPX
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="AddChance.aspx.cs" Inherits="BaseOperation_AddChance"%>
<%@ Register Assembly="Microsoft.Web.UI.WebControls" Namespace="Microsoft.Web.UI.WebControls"
    TagPrefix="iewc" %>
<%@ Register Assembly="WebPager" Namespace="Hooyee.WebControls" TagPrefix="cc1" %>
<%@ Register Assembly="ZoneSoft.Web.UI" Namespace="ZoneSoft.Web.UI" TagPrefix="ZoneSoft" %>

<html>
<head runat="server">
    <title>添加渠道信息</title>
    <link href="../css/CRM.css" type="text/css" rel="stylesheet" />
    <script language="javascript" src="../css/Calendar.js"></script>
     <script language="javascript">

    function viewCustomer_onclick()
    {
        if ((document.all["listCompany"].value != '') && (document.all["listCompany"].value != '0'))
        {
            window.open('AddCustomer.aspx?id=' + document.all["listCompany"].value ,'','height=550,width=700,top=100,left=100,toolbar=no,menubar=no,scrollbars=yes, resizable=yes,location=no, status=yes');
        }
    }

    function viewContact_onclick()
    {
        if ((document.all["listContact"].value != '') && (document.all["listContact"].value != '0'))
        {
            window.open('AddContact.aspx?id=' + document.all["listContact"].value ,'','height=500,width=700,top=100,left=100,toolbar=no,menubar=no,scrollbars=yes, resizable=yes,location=no, status=yes');
        }
    }
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    </div>
    <iewc:Toolbar ID="topToolBar" runat="server" DefaultStyle="background-repeat:repeat;border:0;background-image:url(../images/menu/silver.gif);"
                                            Height="28px" OnButtonClick="Toolbar_ButtonClick" Style="border-right: #466094 1px solid;
                                            border-top: #466094 1px solid; font-size: 12px; border-left: #466094 1px solid;
                                            width: 100%; border-bottom: #466094 1px; font-family: 宋体">
            <iewc:ToolbarButton ID="chanceInfo" DefaultStyle="background-image:url(../images/menu/silver.gif);"
                                                HoverStyle="background-image:url(../images/menu/2k3OlBarOver.gif);border:solid 1px #000080;"
                                                ImageUrl="../Images/ico/ico_18_service.gif" SelectedStyle="background-image:url(../images/menu/2k3OlBarDown.gif);"
                                                Text="渠道信息" />
            <iewc:ToolbarSeparator />
            <iewc:ToolbarButton ID="chanceListInfo" DefaultStyle="background-image:url(../images/menu/silver.gif);"
                                                HoverStyle="background-image:url(../images/menu/2k3OlBarOver.gif);border:solid 1px #000080;"
                                                ImageUrl="../Images/ico/ico_16_changestatus.gif" SelectedStyle="background-image:url(../images/menu/2k3OlBarDown.gif);"
                                                Text="渠道明细" />
            <iewc:ToolbarSeparator />
            <iewc:ToolbarLabel DefaultStyle="background-image:url(../images/menu/silver.gif);width:100%;" />
        </iewc:Toolbar>
        <asp:MultiView ID="MultiView1" runat="server" ActiveViewIndex="0">
     
            <asp:View ID="vChanceListInfo" runat="server">
                <table style="width: auto; height: 100%">
                    <tr>
                        <td colspan="3" style="font-weight: bold; font-size: 20px; color: white; font-family: 楷体_GB2312;
                            height: 27px; background-color: #63769b">
                            渠道明细</td>
                    </tr>
                    <tr>
                        <td colspan="3" style="height: 277px">
                            <table style="left: 10px; width: 100%; height: 100%">
                                <tr>
                                    <td style="width: 928px; height: 24px">
                                        <iewc:Toolbar ID="Toolbar2" runat="server" DefaultStyle="background-repeat:repeat;border:0;background-image:url(../images/menu/silver.gif);"
                                            Height="28px" OnButtonClick="Toolbar_ButtonClick" Style="border-right: #466094 1px solid;
                                            border-top: #466094 1px solid; font-size: 12px; border-left: #466094 1px solid;
                                            width: 100%; border-bottom: #466094 1px; font-family: 宋体">
                                            <iewc:ToolbarButton ID="newChanceList" DefaultStyle="background-image:url(../images/menu/silver.gif);"
                                                HoverStyle="background-image:url(../images/menu/2k3OlBarOver.gif);border:solid 1px #000080;"
                                                ImageUrl="../Images/ico/18_addResources.gif" SelectedStyle="background-image:url(../images/menu/2k3OlBarDown.gif);"
                                                Text="新建渠道明细" />
                                            <iewc:ToolbarSeparator />
                                        <iewc:ToolbarButton Text="导出到Excel" ImageUrl="../Images/ico/16_excel.gif" DefaultStyle="background-image:url(../images/menu/silver.gif);"
        ID="ChanceExcel" HoverStyle="background-image:url(../images/menu/2k3OlBarOver.gif);border:solid 1px #000080;"
        SelectedStyle="background-image:url(../images/menu/2k3OlBarDown.gif);"></iewc:ToolbarButton>
       <iewc:ToolbarSeparator></iewc:ToolbarSeparator>
                                            <iewc:ToolbarLabel DefaultStyle="background-image:url(../images/menu/silver.gif);width:100%;" />
                                        </iewc:Toolbar>
                                    </td>
                                </tr>
                                <tr>
                                    <td align="center" style="border-right: #ff9966 1px solid; border-top: #ff9966 1px solid;
                                        border-left: #ff9966 1px solid; width: 928px; border-bottom: #ff9966 1px solid;
                                        height: 371px" valign="top">
                                        <asp:GridView ID="GridView1" runat="server" AllowPaging="false" AutoGenerateColumns="False"
                                            CellPadding="4" CssClass="Grid" DataKeyNames="CHANCEDETAILID" EnableTheming="False"
                                            ForeColor="#333333" GridLines="None" OnRowCreated="GridView1_RowCreated" OnRowDeleting="GridView1_RowDeleting"
                                            PageSize="15" Style="word-break: keep-all" Width="100%">
                                            <FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
                                            <Columns>
                                                <asp:HyperLinkField DataNavigateUrlFields="PRODUCTID" DataNavigateUrlFormatString="AddProduct.aspx?id={0}"
                                                    DataTextField="PRODUCTNAME" HeaderText="产品名称" ItemStyle-HorizontalAlign=Center>
                                                    <%--<ItemStyle Wrap="False" />--%>
                                                    <HeaderStyle Wrap="False" />
                                                </asp:HyperLinkField>
                                                <asp:BoundField DataField="AMOUNT" HeaderText="数量" ItemStyle-HorizontalAlign=Center>
                                                    <HeaderStyle Wrap="False" />
                                                </asp:BoundField>
                                                <asp:BoundField DataField="AGIO" HeaderText="折扣" ItemStyle-HorizontalAlign=Center>
                                                    <%--<ItemStyle Wrap="False" />--%>
                                                    <HeaderStyle Wrap="False" />
                                                </asp:BoundField>
                                                <asp:BoundField DataField="MONEYSUM" HeaderText="总金额" DataFormatString="{0:N}" HtmlEncode="False" ItemStyle-HorizontalAlign=Center>
                                                    <%--<ItemStyle Wrap="False" />--%>
                                                    <HeaderStyle Wrap="False" />
                                                </asp:BoundField>
                                                <asp:CommandField CausesValidation="False" HeaderText="删除" InsertVisible="False" ItemStyle-HorizontalAlign=Center
                                                    ShowCancelButton="False" ShowDeleteButton="True" />
                                            </Columns>
                                            <RowStyle BackColor="#EFF3FB" />
                                            <EditRowStyle BackColor="#2461BF" />
                                            <SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
                                            <PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
                                            <HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
                                            <AlternatingRowStyle BackColor="White" />
                                            <PagerSettings Visible="False" />
                                            <EmptyDataTemplate>
                                                <font color="Navy">暂时无数据内容。</font>
                                            </EmptyDataTemplate>
                                        </asp:GridView>
                                    </td>
                                </tr>
                            </table>
                        </td>
                    </tr>
                </table>
            </asp:View>
       
        </asp:MultiView>
    </form>
</body>
</html>


父窗提.CS
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Text;
using System.Data.SqlClient;
using Microsoft.Web.UI.WebControls;

public partial class BaseOperation_AddChance : System.Web.UI.Page
{
    private static string strSqlQuery;//存储查询串,带格式的,可配置参
    protected void Page_Load(object sender, EventArgs e)
    {
        if ((Request.QueryString["id"] != null)
            && (!string.IsNullOrEmpty(Request.QueryString["id"].Trim())))
        {
            this.sTitle.Text = this.Title = "查看/修改渠道信息";
        }

        if (!IsPostBack)
        {
            if (JS.isCookiesAvailabile())
            {
                if ((null == Request.QueryString["type"])
                    || (string.IsNullOrEmpty(Request.QueryString["type"].Trim())))
                {
                    JS.Alert("缺少类型字段。");
                    return;
                }

                if ((Request.QueryString["id"] != null)
                    && (!string.IsNullOrEmpty(Request.QueryString["id"].Trim()))
                    && initChanceInfo(Request.QueryString["id"].Trim()))
                {
                    this.GridView1.PageIndex = 0;
                    initChanceListInfoList();

                  
                }
             
            }
        }
    }

    #region 工具条事件(新建、打印)
    protected void Toolbar_ButtonClick(object sender, EventArgs e)
    {
        if (sender is Microsoft.Web.UI.WebControls.ToolbarButton)
        {
            ToolbarButton button = (ToolbarButton)sender;

            switch (button.ID)
            {
                case "newChanceList"://新建渠道明细
                    {
                        JS.OpenNewWindow("ChanceList.aspx?backindex=1&type=1&Chanceid=" + Request.QueryString["id"].Trim(), "", 300, 220, 400, 270);
                        break;
                    }
                case "printList"://打印查询结果
                    {
                        break;
                    }
                case "chanceInfo"://渠道信息
                    {
                        if (this.MultiView1.ActiveViewIndex != 0)
                        {
                            this.MultiView1.ActiveViewIndex = 0;
                        }
                        break;
                    }
                case "chanceListInfo"://渠道明细
                    {
                        if (this.MultiView1.ActiveViewIndex != 1)
                        {
                            this.MultiView1.ActiveViewIndex = 1;
                        }
                        break;
                    }
                case "ChanceExcel"://导出渠道列表
                    {
                        if (this.GridView1.Rows.Count == 0)
                        {
                            return;
                        }

                        DataTable ToExcelDataTable = DbHelperSQL.gettable(string.Format(strSqlQuery, "", "").Replace("TOP", ""));//导出Excel的DataTable

                        string[] listname = { "产品名称", "数量", "折扣", "总金额" };
                        string[] cols = { "PRODUCTNAME", "AMOUNT", "AGIO","MONEYSUM" };
                        ToExcel.tableToExcel(ToExcelDataTable, listname, cols);


                        break;
                    }
                default:
                    {
                        return;
                    }
             }
        }
    }
    #endregion 工具条事件(新建、打印)
    #region 初始化表格行事件
    protected void GridView1_RowCreated(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            int index = e.Row.RowIndex;
            if (index >= 0)
            {
                string cid = this.GridView1.DataKeys[index][0].ToString();


                string s1 = "window.open('ChanceList.aspx?Chanceid={0}&id={1}&backindex=1','','height=470,width=700,top=100,left=250,toolbar=no,menubar=no,scrollbars=yes, resizable=yes,location=no, status=yes')";

                e.Row.Attributes.Add("ondblclick", string.Format(s1, Request.QueryString["id"].Trim(), cid));
                e.Row.Cells[e.Row.Cells.Count - 1].Attributes.Add("onclick", "return confirm('确定要永久删除该条记录吗?');");
            }
        }
    }
    #endregion 初始化表格行事件

    #region 表格记录的删除事件
    protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
    {
        if ((!JS.isCookiesAvailabile()))
        {
            return;
        }

        //this.GridView1.Rows[e.RowIndex].ToString()
        try
        {
            if (DbHelperSQL.ExecuteSql("DELETE FROM CHANCELIST WHERE CHANCEDETAILID = " + this.GridView1.DataKeys[e.RowIndex].Value) > 0)
            {
                this.initChanceListInfoList();
            }
            else
            {
                JS.Alert("删除记录失败,请稍候再试。");
            }
        }
        catch (Exception ex)
        {
            JS.Alert("删除记录失败,详细信息:" + ex.Message.Replace("\r\n", "").Replace("'", ""));
        }
    }
    #endregion 表格记录的删除事件

    #region 初始化渠道明细页面内容


    protected void initChanceListInfoList()
    {
        
        StringBuilder strSql = new StringBuilder("SELECT CHANCELIST.CHANCEDETAILID, CHANCELIST.AMOUNT, CHANCELIST.AGIO, CHANCELIST.MONEYSUM, PRODUCTS.PRODUCTNAME, CHANCELIST.PRODUCTID FROM PRODUCTS INNER JOIN CHANCELIST ON PRODUCTS.PRODUCTID = CHANCELIST.PRODUCTID WHERE CHANCELIST.CHANCEID =").Append(Request.QueryString["id"].Trim()).Append(" AND CHANCELIST.BCHANCE=").Append(Request.QueryString["type"].Trim());

        String strLevel = Request.Cookies["askCRM"]["LEVELID"];
        string strUid = Request.Cookies["askCRM"]["USERID"];

        if (string.IsNullOrEmpty(strLevel)
            || string.IsNullOrEmpty(strUid))
        {
            return;
        }

        strUid = Tools.Decrypt(strUid, Tools.myKey);
        strLevel = Tools.Decrypt(strLevel, Tools.myKey);

        switch (Convert.ToInt32(strLevel))
        {
            case 0://超级用户
                break;
            default://其他用户
                strSql.Append(" AND CHANCELIST.OPERATOR = '").Append(strUid).Append("'");
                break;
        }

        try
        {
            strSqlQuery = strSql.ToString();
            this.GridView1.DataSource = DbHelperSQL.gettable(strSql.ToString());
            this.GridView1.DataBind();
        }
        catch (Exception ex)
        {
            JS.Alert("初始化数据失败。详细信息:" + ex.Message.Replace("\r\n", "").Replace("'", ""));
            return;
        }
    }
    #endregion 初始化渠道明细页面内容
}