报表功能实现

1645人阅读 评论(0) 收藏 举报

 

1

 

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="CaiXiaoCunSouJia.aspx.cs" Inherits="InterFace_Reports_CaiXiaoCunSouJia" ValidateRequest="false" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    
<title>主要产品产、销、存、售价情况信息页面</title>
    
<script type="text/javascript" src="../../js/popcalendar.js"></script>
    
<link href="../../css/style.css" rel="stylesheet" type="text/css" />
</head>
<body>
    
<form id="formKeHuXinXi" runat="server">
    
<div>
    
<table>
                
<tr>
                    
<td>
                        
<asp:Label ID="LabelStatus" runat="server" Font-Size="10pt" Text="当前状态:"></asp:Label></td>
                    
<td>
                        
<asp:Menu ID="MenuCaidan" runat="server" BackColor="#FFFFC0" DynamicHorizontalOffset="2"
                            Font-Names
="Verdana" Font-Size="0.8em" ForeColor="#990000" OnMenuItemClick="MenuCaidan_MenuItemClick"
                            Orientation
="Horizontal" StaticSubMenuIndent="10px">
                            
<StaticMenuItemStyle Font-Size="10pt" HorizontalPadding="5px" VerticalPadding="2px" />
                            
<DynamicHoverStyle BackColor="#990000" ForeColor="White" />
                            
<DynamicMenuStyle BackColor="#FFFBD6" />
                            
<StaticSelectedStyle BackColor="Gold" />
                            
<DynamicSelectedStyle BackColor="#FFCC66" />
                            
<DynamicMenuItemStyle HorizontalPadding="5px" VerticalPadding="2px" />
                            
<Items>
                                
<asp:MenuItem Text="报表导航" Value="报表导航"></asp:MenuItem>
                                
<asp:MenuItem Selected="True" Text="报表基本信息栏" Value="报表基本信息栏"></asp:MenuItem>
                                
<asp:MenuItem Text="报表详细信息" Value="报表详细信息"></asp:MenuItem>
                                
<asp:MenuItem Text="添加报表基本信息" Value="添加报表基本信息"></asp:MenuItem>
                                
<asp:MenuItem Text="编辑报表基本信息" Value="编辑报表基本信息"></asp:MenuItem>
                            
</Items>
                            
<StaticItemTemplate>
                                
<%Eval("Text"%>
                            
</StaticItemTemplate>
                            
<StaticHoverStyle BackColor="#FFC0C0" Font-Overline="False" Font-Underline="True"
                                ForeColor
="White" />
                        
</asp:Menu>
                    
</td>
                
</tr>
            
</table>
            
<table style="border-top-width: 0px">
                
<tr valign="top">
                    
<td style="height: 7px">
                        
<img alt="图象" height="5" src="../../Images/funcLine.JPG" width="933" /></td>
                
</tr>
            
</table>
            
<asp:MultiView ID="MultiViewXinXiGuanLi" runat="server" ActiveViewIndex="0">
                
<asp:View ID="ViewXinXiLan" runat="server">
                    
<table>
                        
<tr>
                            
<td>
                                
<table>
                                    
<tr>
                                        
<td>
                                            
<asp:Image ID="ImageShouYe" runat="server" ImageUrl="~/DatabaseImg/100.jpg" /></td>
                                    
</tr>
                                
</table>
                            
</td>
                            
<td>
                                
<table>
                                    
<tr>
                                        
<td style="width: 99px">
                                            选择类别名称
                                        
</td>
                                        
<td>
                                            条件
                                        
</td>
                                        
<td>
                                            输入要查询的条件值
                                        
</td>
                                    
</tr>
                                    
<tr>
                                        
<td style="width: 99px">
                                            
<asp:DropDownList ID="DropDownListLeiBeiOne" runat="server" Width="100px">
                                            
</asp:DropDownList></td>
                                        
<td>
                                            
<asp:DropDownList ID="DropDownListTiaoJianOne" runat="server" Width="80px">
                                            
</asp:DropDownList></td>
                                        
<td>
                                            
<asp:TextBox ID="TextBoxOne" runat="server" class="smallInput"></asp:TextBox></td>
                                    
</tr>
                                    
<tr>
                                        
<td style="width: 99px">
                                            
<asp:DropDownList ID="DropDownListLeiBeiTwo" runat="server" Width="100px">
                                            
</asp:DropDownList></td>
                                        
<td>
                                            
<asp:DropDownList ID="DropDownListTiaoJianTwo" runat="server" Width="80px">
                                            
</asp:DropDownList></td>
                                        
<td>
                                            
<asp:TextBox ID="TextBoxTwo" runat="server" class="smallInput"></asp:TextBox></td>
                                    
</tr>
                                    
<tr>
                                        
<td style="width: 99px">
                                            
<asp:DropDownList ID="DropDownListLeiBeiThree" runat="server" Width="100px">
                                            
</asp:DropDownList></td>
                                        
<td>
                                            
<asp:DropDownList ID="DropDownListTiaoJianThree" runat="server" Width="80px">
                                            
</asp:DropDownList></td>
                                        
<td>
                                            
<asp:TextBox ID="TextBoxThree" runat="server" class="smallInput"></asp:TextBox></td>
                                    
</tr>
                                    
<tr>
                                        
<td style="width: 99px">
                                            
<asp:DropDownList ID="DropDownListLeiBeiFour" runat="server" Width="100px">
                                            
</asp:DropDownList></td>
                                        
<td>
                                            
<asp:DropDownList ID="DropDownListTiaoJianFour" runat="server" Width="80px">
                                            
</asp:DropDownList></td>
                                        
<td>
                                            
<asp:TextBox ID="TextBoxFour" runat="server" class="smallInput"></asp:TextBox></td>
                                    
</tr>
                                    
<tr>
                                        
<td style="width: 99px">
                                            
<font color="blue">
                                                
<asp:Label ID="Labelchaxunfangshi" runat="server" Text="查询排序方式:"></asp:Label></font></td>
                                        
<td>
                                            
<asp:DropDownList ID="DropDownListPaiXuFangShi" runat="server" BackColor="Transparent"
                                                ForeColor
="Blue" Width="80px">
                                            
</asp:DropDownList></td>
                                        
<td>
                                        
</td>
                                    
</tr>
                                
</table>
                            
</td>
                            
<td style="height: 176px">
                                
<table>
                                    
<tr>
                                        
<td style="height: 50px">
                                            
<asp:Button ID="ButtonTiJianChaXun" runat="server" Height="50px" OnClick="ButtonTiJianChaXun_Click"
                                                Text
="条件查询" /></td>
                                    
</tr>
                                
</table>
                            
</td>
                        
</tr>
                    
</table>
                    
<img alt="图象" height="5" src="../../Images/funcLine.JPG" width="933" /><br />
                    
<table>
                        
<tr>
                            
<td>
                                
<asp:Button ID="ButtonTianJia" runat="server" Font-Size="12pt" OnClick="ButtonTianJia_Click"
                                    Text
="添加" />
                                
<asp:Button ID="ButtonBianJi" runat="server" Font-Size="12pt" OnClick="ButtonBianJi_Click"
                                    Text
="编辑" />
                                
<asp:Button ID="ButtonShanChu" runat="server" Font-Size="12pt" OnClick="ButtonShanChu_Click"
                                    OnClientClick
="return confirm('确认要删除吗?');" Text="删除" />
                                
<asp:Button ID="ButtonChaYue" runat="server" Font-Size="12pt" OnClick="ButtonChaYue_Click"
                                    Text
="报表详细信息" />
                                
<asp:Button ID="ButtonChaKan" runat="server" Font-Size="12pt" OnClick="ButtonChaKan_Click"
                                    Text
="查看报表详细信息" />
                            
</td>
                        
</tr>
                    
</table>
                    
<asp:GridView ID="GridViewXinXiLan" runat="server" AllowPaging="True" AutoGenerateColumns="False"
                        CellPadding
="4" DataKeyNames="SN" ForeColor="#333333" GridLines="None" OnPageIndexChanging="GridViewXinXiLan_PageIndexChanging" OnSelectedIndexChanged="GridViewXinXiLan_SelectedIndexChanged">
                        
<FooterStyle BackColor="#507CD1" Font-Bold="True" Font-Size="Small" ForeColor="White" />
                        
<RowStyle BackColor="#EFF3FB" />
                        
<EditRowStyle BackColor="#2461BF" />
                        
<SelectedRowStyle BackColor="DodgerBlue" Font-Bold="False" ForeColor="#333333" />
                        
<PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
                        
<HeaderStyle BackColor="#507CD1" Font-Bold="True" Font-Size="10pt" ForeColor="White" />
                        
<AlternatingRowStyle BackColor="White" />
                        
<Columns>
                            
<asp:TemplateField>
                                
<EditItemTemplate>
                                    
<asp:CheckBox ID="CheckBox1" runat="server" />
                                
</EditItemTemplate>
                                
<ItemTemplate>
                                    
<asp:CheckBox ID="CheckBoxFuXuan" runat="server" />
                                
</ItemTemplate>
                            
</asp:TemplateField>
                            
<asp:TemplateField HeaderText="选择" ShowHeader="False">
                                
<ItemTemplate>
                                    
<asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="False" CommandName="Select"
                                        Text
="选择"></asp:LinkButton>
                                
</ItemTemplate>
                                
<ItemStyle Wrap="False" />
                            
</asp:TemplateField>
                            
<asp:BoundField DataField="报表日期" HeaderText="报表日期">
                                
<ItemStyle Wrap="False" />
                                
<HeaderStyle Wrap="False" />
                            
</asp:BoundField>
                            
<asp:BoundField DataField="报表编号" HeaderText="报表编号">
                                
<ItemStyle Wrap="False" />
                                
<HeaderStyle Wrap="False" />
                            
</asp:BoundField>
                            
<asp:BoundField DataField="报表名称" HeaderText="报表名称" NullDisplayText=" ">
                                
<ItemStyle Wrap="False" />
                                
<HeaderStyle Wrap="False" />
                            
</asp:BoundField>
                            
<asp:BoundField DataField="编制单位" HeaderText="编制单位">
                                
<ItemStyle Wrap="False" />
                                
<HeaderStyle Wrap="False" />
                            
</asp:BoundField>
                            
<asp:BoundField DataField="企业负责人" HeaderText="企业负责人" HtmlEncode="False">
                                
<ItemStyle Wrap="False" />
                                
<HeaderStyle Wrap="False" />
                            
</asp:BoundField>
                            
<asp:BoundField DataField="统计负责人" HeaderText="统计负责人" NullDisplayText=" ">
                                
<HeaderStyle Wrap="False" />
                            
</asp:BoundField>
                            
<asp:BoundField DataField="填表人" HeaderText="填表人">
                                
<HeaderStyle Wrap="False" />
                            
</asp:BoundField>
                            
<asp:BoundField DataField="联系电话" HeaderText="联系电话">
                                
<HeaderStyle Wrap="False" />
                            
</asp:BoundField>
                            
<asp:BoundField DataField="报出日期" HeaderText="报出日期" >
                                
<ItemStyle Wrap="False" />
                            
</asp:BoundField>
                            
<asp:BoundField DataField="主管领导" HeaderText="主管领导" />
                            
<asp:BoundField DataField="录入人" HeaderText="录入人">
                                
<ItemStyle Wrap="False" />
                            
</asp:BoundField>
                            
<asp:BoundField DataField="备注" HeaderText="备注">
                                
<ItemStyle Wrap="False" />
                            
</asp:BoundField>
                            
<asp:BoundField DataField="SN" HeaderText="SN" Visible="False" />
                        
</Columns>
                        
<PagerSettings Visible="False" />
                    
</asp:GridView>
                    
<table>
                        
<tr>
                            
<td>
                                
<asp:CheckBox ID="CheckBoxAll" runat="server" AutoPostBack="True" OnCheckedChanged="CheckBoxAll_CheckedChanged"
                                    Text
="选择全部" />
                                
<asp:LinkButton ID="lnkbtnFirst" runat="server" OnClick="PagerButtonClick">首页</asp:LinkButton>
                                
<asp:LinkButton ID="lnkbtnPre" runat="server" OnClick="PagerButtonClick">上一页</asp:LinkButton>
                                
<asp:LinkButton ID="lnkbtnNext" runat="server" OnClick="PagerButtonClick">下一页</asp:LinkButton>
                                
<asp:LinkButton ID="lnkbtnLast" runat="server" OnClick="PagerButtonClick">尾页</asp:LinkButton>
                                
<asp:Label ID="lblCurrentIndex" runat="server" Text="第?页"></asp:Label>
                                
<asp:Label ID="lblPageCount" runat="server" Text="共?页"></asp:Label>
                                
<asp:Label ID="lblRecordCount" runat="server" Text="记录数"></asp:Label>
                                
<asp:TextBox ID="txtJumpPage" runat="server" Width="24px">1</asp:TextBox>
                                
<asp:LinkButton ID="lnkbtnJumpPage" runat="server" OnClick="lnkbtnJumpPage_Click">跳转</asp:LinkButton></td>
                        
</tr>
                    
</table>
                
</asp:View>
                
<asp:View ID="ViewXiangXiXinXi" runat="server">
                    
<table>
                        
<tr>
                            
<td style="width: 65px; height: 405px" valign="top">
                                
<asp:Image ID="ImageXiangXi" runat="server" ImageUrl="~/DatabaseImg/he.jpg" /></td>
                            
<td style="height: 405px">
                                
<table>
                                    
<tr>
                                        
<td align="right">
                                            
<asp:Label ID="LabelBaoBiaoRiQi" runat="server" Text="报表日期"></asp:Label></td>
                                        
<td style="width: 553px">
                                            
<asp:TextBox ID="TextBoxBaoBiaoRiQi" runat="server" class="smallInput" value="" Width="132px"></asp:TextBox>
                                            
<img id="Image_blqx1" alt="图像" onclick="popUpCalendar(this,document.forms[0].TextBoxBaoBiaoRiQi,'yyyy-mm-dd')"
                                                src
="../../images/calendar.gif" style="cursor: hand" /></td>
                                    
</tr>
                                    
<tr>
                                        
<td align="right" style="height: 15px">
                                            
<asp:Label ID="LabelBaoBiaoBianHao" runat="server" Text="报表编号"></asp:Label></td>
                                        
<td style="width: 553px; height: 15px">
                                            
<asp:TextBox ID="TextBoxBaoBiaoBianHao" runat="server" class="smallInput" value=""
                                                Width
="132px"></asp:TextBox></td>
                                    
</tr>
                                    
<tr valign="top">
                                        
<td align="right" style="height: 18px" >
                                            
<asp:Label ID="LabelBaoBiaoMingCheng" runat="server" Text="报表名称"></asp:Label></td>
                                        
<td style="height: 18px" >
                                            
<asp:TextBox ID="TextBoxBaoBiaoMingCheng" runat="server" class="smallInput" Width="300px" ReadOnly="True">主要产品产、销、存及售价情况统计表 </asp:TextBox></td>
                                    
</tr>
                                    
<tr>
                                        
<td align="right">
                                            
<asp:Label ID="LabelBianZhiDanWei" runat="server" Text="编制单位"></asp:Label></td>
                                        
<td><asp:DropDownList ID="DropDownListBianZhiDanWei" runat="server" class="smallInput"
                                                Width
="300px">
                                        
</asp:DropDownList></td>
                                    
</tr>
                                    
<tr>
                                        
<td align="right" style="height: 19px">
                                            
<asp:Label ID="LabelQiYeFuZeRen" runat="server" Text="企业负责人"></asp:Label></td>
                                        
<td style="height: 19px">
                                            
<asp:TextBox ID="TextBoxQiYeFuZeRen" runat="server" class="smallInput"></asp:TextBox></td>
                                    
</tr>
                                    
<tr>
                                        
<td align="right">
                                            
<asp:Label ID="LabelTongJiFuZeRen" runat="server" Text="统计负责人"></asp:Label></td>
                                        
<td>
                                            
<asp:TextBox ID="TextBoxTongJiFuZeRen" runat="server" class="smallInput"></asp:TextBox></td>
                                    
</tr>
                                    
<tr>
                                        
<td align="right">
                                            
<asp:Label ID="LabelTianBiaoRen" runat="server" Text="填表人"></asp:Label></td>
                                        
<td>
                                            
<asp:TextBox ID="TextBoxTianBiaoRen" runat="server" class="smallInput"></asp:TextBox></td>
                                    
</tr>
                                    
<tr>
                                        
<td align="right">
                                            
<asp:Label ID="LabelLianXiDianHua" runat="server" Text="联系电话"></asp:Label></td>
                                        
<td>
                                            
<asp:TextBox ID="TextBoxLianXiDianHua" runat="server" class="smallInput"></asp:TextBox></td>
                                    
</tr>
                                    
<tr>
                                        
<td align="right">
                                            
<asp:Label ID="LabelBaoChuRiQi" runat="server" Text="报出日期"></asp:Label></td>
                                        
<td>
                                            
<asp:TextBox ID="TextBoxBaoChuRiQi" runat="server" class="smallInput"></asp:TextBox>
                                            
<img id="Img1" alt="图像" onclick="popUpCalendar(this,document.forms[0].TextBoxBaoChuRiQi,'yyyy-mm-dd')"
                                                src
="../../images/calendar.gif" style="cursor: hand" /></td>
                                    
</tr>
                                    
<tr>
                                        
<td align="right">
                                            
<asp:Label ID="LabelZhuGuanLingDao" runat="server" Text="主管领导"></asp:Label></td>
                                        
<td>
                                            
<asp:TextBox ID="TextBoxZhuGuanLingDao" runat="server" class="smallInput"></asp:TextBox></td>
                                    
</tr>
                                    
<tr>
                                        
<td align="right">
                                            
<asp:Label ID="LabelLuRuRen" runat="server" Text="录入人"></asp:Label></td>
                                        
<td>
                                            
<asp:TextBox ID="TextBoxLuRuRen" runat="server" class="smallInput"></asp:TextBox></td>
                                    
</tr>
                                     
<tr>
                                        
<td align="right" valign="top">
                                            
<asp:Label ID="LabelBeiZhu" runat="server" Text="备注"></asp:Label></td>
                                        
<td>
                                            
<asp:TextBox ID="TextBoxBeiZhu" runat="server" class="smallInput" Height="100px" TextMode="MultiLine" Width="400px"></asp:TextBox></td>
                                    
</tr>
                                
</table>
                            
</td>
                        
</tr>
                        
<tr>
                            
<td style="width: 65px">
                            
</td>
                            
<td align="center">
                                
<asp:Button ID="ButtonCaoZuo" runat="server" OnClick="ButtonCaoZuo_Click" Text="操作类型" />
                            
</td>
                        
</tr>
                    
</table>
                    
<asp:Label ID="LabelZhuJian" runat="server" Text="隐藏主键" Visible="False"></asp:Label>
                    
&nbsp;&nbsp;
                
</asp:View>
                
<asp:View ID="ViewReports" runat="server">
                    
<asp:Label ID="LabelReportTitle" runat="server" Text="报表名称"></asp:Label><br />
                    
<asp:GridView ID="GridViewTianJia" runat="server" AutoGenerateColumns="False" DataKeyNames="SN"
                        OnRowCancelingEdit
="GridViewTianJia_RowCancelingEdit" OnRowDataBound="GridViewTianJia_RowDataBound"
                        OnRowDeleting
="GridViewTianJia_RowDeleting" OnRowEditing="GridViewTianJia_RowEditing"
                        OnRowUpdating
="GridViewTianJia_RowUpdating">
                        
<Columns>
                            
<asp:TemplateField HeaderText="编辑" ShowHeader="False">
                                
<EditItemTemplate>
                                    
<asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="True" CommandName="Update"
                                         Text
="更新"></asp:LinkButton>
                                    
<asp:LinkButton ID="LinkButton2" runat="server" CausesValidation="False" CommandName="Cancel"
                                         Text
="取消"></asp:LinkButton>
                                
</EditItemTemplate>
                                
<ItemStyle Wrap="False" />
                                
<ItemTemplate>
                                    
<asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="False" CommandName="Edit"
                                        Text
="编辑"></asp:LinkButton>&nbsp;
                                
</ItemTemplate>
                            
</asp:TemplateField>
                            
<asp:TemplateField HeaderText="操作" ShowHeader="False">
                                
<ItemStyle Wrap="False" />
                                
<ItemTemplate>
                                    
<asp:LinkButton ID="LinkButton3" runat="server" CausesValidation="False" CommandName="Delete"
                                        Text
="删除"></asp:LinkButton>
                                    
<asp:LinkButton ID="LinkButtonTianJia" runat="server"
                                        Visible
="False">添加保存</asp:LinkButton>
                                    
<asp:LinkButton ID="LinkButtonQuXiao" runat="server" OnClick="LinkButtonQuXiao_Click"
                                        Visible
="False">取消</asp:LinkButton>
                                
</ItemTemplate>
                            
</asp:TemplateField>
                            
<asp:BoundField DataField="ID" HeaderText="ID" Visible="False">
                                
<ItemStyle Wrap="False" />
                            
</asp:BoundField>
                            
<asp:TemplateField HeaderText="编号">
                                
<EditItemTemplate>
                                    
<asp:TextBox ID="TextBoxBianHao" runat="server" Text='<%# Eval("编号") %>' Width="20px"></asp:TextBox>
                                
</EditItemTemplate>
                                
<ItemTemplate>
                                    
<asp:Label ID="LabelBianHao" runat="server" Text='<%# Bind("编号") %>'></asp:Label>
                                
</ItemTemplate>
                            
</asp:TemplateField>
                            
<asp:TemplateField HeaderText="生产企业">
                                
<EditItemTemplate>
                                    
<asp:TextBox ID="TextBoxShenChanQiYe" runat="server" Text='<%# Eval("生产企业") %>' Width="100px"></asp:TextBox>
                                
</EditItemTemplate>
                                
<ItemTemplate>
                                    
<asp:Label ID="LabelShenChanQiYi" runat="server" Text='<%# Bind("生产企业") %>'></asp:Label>
                                
</ItemTemplate>
                            
</asp:TemplateField>
                            
<asp:TemplateField HeaderText="产品名称">
                                
<EditItemTemplate>
                                    
<asp:TextBox ID="TextBoxChanPinMingChen" runat="server" Text='<%# Eval("产品名称") %>' Width="100px"></asp:TextBox>
                                
</EditItemTemplate>
                                
<ItemTemplate>
                                    
<asp:Label ID="LabelChanPinMingChen" runat="server" Text='<%# Bind("产品名称") %>' ></asp:Label>
                                
</ItemTemplate>
                            
</asp:TemplateField>
                            
<asp:TemplateField HeaderText="计量单位">
                                
<EditItemTemplate>
                                    
<asp:TextBox ID="TextBoxJiLiangDanWei" runat="server" Text='<%# Eval("计量单位") %>'
                                        Width="50px">
</asp:TextBox>
                                
</EditItemTemplate>
                                
<ItemStyle Wrap="False" />
                                
<ItemTemplate>
                                    
<asp:Label ID="LabelJiLiangDanWei" runat="server" Text='<%# Bind("计量单位") %>'></asp:Label>
                                
</ItemTemplate>
                            
</asp:TemplateField>
                            
<asp:TemplateField HeaderText="生产量本年实际">
                                
<EditItemTemplate>
                                    
<asp:TextBox ID="TextBoxShenChanLiangBenNian" runat="server" Text='<%# Eval("生产量本年实际") %>'
                                        Width="70px">
</asp:TextBox>
                                
</EditItemTemplate>
                                
<ItemStyle Wrap="False" />
                                
<ItemTemplate>
                                    
<asp:Label ID="LabelShenChanLiangBenNian" runat="server" Text='<%# Bind("生产量本年实际") %>'></asp:Label>
                                
</ItemTemplate>
                            
</asp:TemplateField>
                            
<asp:TemplateField HeaderText="生产量去年实际">
                                
<EditItemTemplate>
                                    
<asp:TextBox ID="TextBoxShenChanLiangQuNian" runat="server" Text='<%# Eval("生产量去年实际") %>'
                                        Width="70">
</asp:TextBox>
                                
</EditItemTemplate>
                                
<ItemStyle Wrap="False" />
                                
<ItemTemplate>
                                    
<asp:Label ID="LabelShenChanLiangQuNian" runat="server" Text='<%# Bind("生产量去年实际") %>'></asp:Label>
                                
</ItemTemplate>
                            
</asp:TemplateField>
                            
<asp:TemplateField HeaderText="销售量本年实际">
                                
<EditItemTemplate>
                                    
<asp:TextBox ID="TextBoxXiaoShouLiangBenNian" runat="server" Text='<%# Eval("销售量本年实际") %>'
                                        Width="70px">
</asp:TextBox>
                                
</EditItemTemplate>
                                
<ItemStyle Wrap="False" />
                                
<ItemTemplate>
                                    
<asp:Label ID="LabelXiaoShouLiangBenNian" runat="server" Text='<%# Bind("销售量本年实际") %>'></asp:Label>
                                
</ItemTemplate>
                            
</asp:TemplateField>
                            
<asp:TemplateField HeaderText="销售量去年实际">
                                
<EditItemTemplate>
                                    
<asp:TextBox ID="TextBoxXiaoShouLiangQuNian" runat="server" Text='<%# Eval("销售量去年实际") %>' Width="70"></asp:TextBox>
                                
</EditItemTemplate>
                                
<ItemStyle Wrap="False" />
                                
<ItemTemplate>
                                    
<asp:Label ID="LabelXiaoShouLiangQuNian" runat="server" Text='<%# Bind("销售量去年实际") %>' ></asp:Label>
                                
</ItemTemplate>
                            
</asp:TemplateField>
                            
<asp:TemplateField HeaderText="库存量年初库存">
                                
<EditItemTemplate>
                                    
<asp:TextBox ID="TextBoxKuCunLiangNianChu" runat="server" Text='<%# Eval("库存量年初库存") %>'  Width="70"></asp:TextBox>
                                
</EditItemTemplate>
                                
<ItemStyle Wrap="False" />
                                
<ItemTemplate>
                                    
<asp:Label ID="LabelKuCunLiangNianChu" runat="server" Text='<%# Bind("库存量年初库存") %>'></asp:Label>
                                
</ItemTemplate>
                            
</asp:TemplateField>
                            
<asp:TemplateField HeaderText="库存量期末库存">
                                
<EditItemTemplate>
                                    
<asp:TextBox ID="TextBoxKuCunLiangQiMo" runat="server" Text='<%# Eval("库存量期末库存") %>'  Width="70"></asp:TextBox>
                                
</EditItemTemplate>
                                
<ItemStyle Wrap="False" />
                                
<ItemTemplate>
                                    
<asp:Label ID="LabelKuCunLiangQiMo" runat="server" Text='<%# Bind("库存量期末库存") %>'></asp:Label>
                                
</ItemTemplate>
                            
</asp:TemplateField>
                            
<asp:TemplateField HeaderText="平均售价本年实际(元)">
                                
<EditItemTemplate>
                                    
<asp:TextBox ID="TextBoxPingJunShouJiaBenNian" runat="server" Text='<%# Eval("平均售价本年实际") %>'  Width="70"></asp:TextBox>
                                
</EditItemTemplate>
                                
<ItemStyle Wrap="False" />
                                
<ItemTemplate>
                                    
<asp:Label ID="LabelPingJunShouJiaBenNian" runat="server" Text='<%# Bind("平均售价本年实际") %>' Width="70"></asp:Label>
                                
</ItemTemplate>
                            
</asp:TemplateField>
                            
<asp:TemplateField HeaderText="平均售价去年实际(元)">
                                
<EditItemTemplate>
                                    
<asp:TextBox ID="TextBoxPingJunShouJiaQuNian" runat="server" Text='<%# Eval("平均售价去年实际") %>' Width="70"> </asp:TextBox>
                                
</EditItemTemplate>
                                
<ItemStyle Wrap="False" />
                                
<ItemTemplate>
                                    
<asp:Label ID="LabelPingJunShouJiaQuNian" runat="server" Text='<%# Bind("平均售价去年实际") %>'></asp:Label>
                                
</ItemTemplate>
                            
</asp:TemplateField>
                            
<asp:TemplateField HeaderText="产销率本年实际(%)">
                                
<EditItemTemplate>
                                    
<asp:TextBox ID="TextBoxChanXiaoLvBenNian" runat="server" Text='<%# Eval("产销率本年实际") %>' Width="70"></asp:TextBox>
                                
</EditItemTemplate>
                                
<ItemStyle Wrap="False" />
                                
<ItemTemplate>
                                    
<asp:Label ID="LabelChanXiaoLvBenNian" runat="server" Text='<%# Bind("产销率本年实际") %>'></asp:Label>
                                
</ItemTemplate>
                            
</asp:TemplateField>
                            
<asp:TemplateField HeaderText="产销率去年实际(%)">
                                
<EditItemTemplate>
                                    
<asp:TextBox ID="TextBoxChanXiaoLvQuNian" runat="server" Text='<%# Eval("产销率去年实际") %>'  Width="70"></asp:TextBox>
                                
</EditItemTemplate>
                                
<ItemStyle Wrap="False" />
                                
<ItemTemplate>
                                    
<asp:Label ID="LabelChanXiaoLvQuNian" runat="server" Text='<%# Bind("产销率去年实际") %>'></asp:Label>
                                
</ItemTemplate>
                            
</asp:TemplateField>
                            
<asp:TemplateField HeaderText="市场占有率本年实际(%)">
                                
<EditItemTemplate>
                                    
<asp:TextBox ID="TextBoxShiChangBenNian" runat="server" Text='<%# Eval("市场占有率本年实际") %>' Width="70"></asp:TextBox>
                                
</EditItemTemplate>
                                
<ItemStyle Wrap="False" />
                                
<ItemTemplate>
                                    
<asp:Label ID="LabelShiChangBenNian" runat="server" Text='<%# Bind("市场占有率本年实际") %>'></asp:Label>
                                
</ItemTemplate>
                            
</asp:TemplateField>
                            
<asp:TemplateField HeaderText="市场占有率去年实际(%)">
                                
<EditItemTemplate>
                                    
<asp:TextBox ID="TextBoxShiChangQuNian" runat="server" Text='<%# Eval("市场占有率去年实际") %>' Width="70"></asp:TextBox>
                                
</EditItemTemplate>
                                
<ItemStyle Wrap="False" />
                                
<ItemTemplate>
                                    
<asp:Label ID="LabelShiChangQuNian" runat="server" Text='<%# Bind("市场占有率去年实际") %>'></asp:Label>
                                
</ItemTemplate>
                            
</asp:TemplateField>
                            
<asp:BoundField DataField="SN" HeaderText="SN" Visible="False" />
                        
</Columns>
                        
<EmptyDataTemplate>
                            建立日期 生产企业 产品名称 计量单位 生产量本年实际 生产量去年实际 销售量本年实际 销售量去年实际 库存量年初库存 库库存量期末库存 平均售价本年实际 平均售价去年实际
                            产效率本年实际 产效率去年实际 市场占有率本年实际 市场占有率去年实际
                        
</EmptyDataTemplate>
                        
<HeaderStyle Font-Size="10pt" />
                        
<RowStyle HorizontalAlign="Right" />
                        
<EditRowStyle HorizontalAlign="Right" />
                    
</asp:GridView>
                    
<asp:Button ID="ButtonXinZen" runat="server" OnClick="ButtonXinZen_Click" Text="新增" />
                    
<asp:Button ID="ButtonCal" runat="server" OnClick="ButtonCal_Click" Text="计算" />&nbsp;
                    
<asp:Button ID="ButtonClear" runat="server" OnClick="ButtonClear_Click" Text="清除多余表格" />
                    
<asp:Button ID="ButtonExcel" runat="server" OnClick="ButtonExcel_Click" Text="导出到Excel" />
                    
<asp:Label ID="Label1" runat="server" Visible="False"></asp:Label></asp:View>
     
</asp:MultiView>
     
</div>
    
</form>
</body>
</html>

 2

 

/*----------------------------------------------------------------
// Copyright (C) 2007 
// 作者:马如林
// 时间:2007/09/20
// 文件名:
// 文件功能描述:
//                 主要产品产、销、存、售价情况信息页面
//                  
// 
// 修改标识:
// 修改描述:
// 
//----------------------------------------------------------------
*/

using System.Globalization;
using System.Data.OracleClient;
using System.IO;
using System.Text;

using Hhxx.App_Code.DatabaseOperate;
using Hhxx.App_Code.Database;
using Hhxx.App_Code.Common;

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;

public partial class InterFace_Reports_CaiXiaoCunSouJia : System.Web.UI.Page
{
    
// 报表信息查询
    private static String baoBiaoMingCheng = "主要产品产、销、存及售价情况统计表";

    
// 报表查询语句
    private String querySql = "SELECT * FROM baobiaoxinxi where 报表名称='" + baoBiaoMingCheng + "'" ;

    
// 统计使用参数
    private decimal totalstock = 0;

    
protected void Page_Load(object sender, EventArgs e)
    
{
        
this.MenuCaidan.Items[0].Enabled = true;
        
this.MenuCaidan.Items[1].Enabled = true;
        
this.MenuCaidan.Items[2].Enabled = false;
        
this.MenuCaidan.Items[3].Enabled = false;
        
this.MenuCaidan.Items[4].Enabled = false;

        
if (!Page.IsPostBack)
        
{

            dropDownListInit();
            
// 初始化默认Gridview的SQL语句
        
            fillGridView(querySql);
        }


        
// gridview 换行控制
        this.GridViewXinXiLan.Attributes.Add("style""word-break:keep-all;word-wrap:normal");

    }


    
/// <summary>
    
/// 点击菜单
    
/// </summary>
    
/// <param name="sender"></param>
    
/// <param name="e"></param>

    protected void MenuCaidan_MenuItemClick(object sender, MenuEventArgs e)
    
{
        
switch (MenuCaidan.SelectedItem.Text.Trim())
        
{
            
case "报表导航":
                
{
                    Server.Transfer(
"~/InterFace/zonggongsi.aspx");
                }

                
break;
            
case "报表基本信息栏":
                
{
                    MultiViewXinXiGuanLi.ActiveViewIndex 
= 0;
                    
                    fillGridView(querySql);
                    
break;
                }


            
case "报表详细信息": MultiViewXinXiGuanLi.ActiveViewIndex = 2;
                
break;

            
case "添加报表基本信息": MultiViewXinXiGuanLi.ActiveViewIndex = 1;
                
break;

            
case "编辑报表基本信息": MultiViewXinXiGuanLi.ActiveViewIndex = 1;
                
break;

            
defaultbreak;
        }

    }


    
/// <summary>
    
/// 条件查询
    
/// </summary>
    
/// <param name="sender"></param>
    
/// <param name="e"></param>

    protected void ButtonTiJianChaXun_Click(object sender, EventArgs e)
    
{
        String strCondition 
= "";
        String strChoose 
= "";

        
if (TextBoxOne.Text.Trim().Length != 0)
        
{
            String tempStr 
= DropDownListTiaoJianOne.SelectedItem.Value;
            
switch (tempStr)
            
{
                
case "包含": strChoose = " LIKE ";
                    
break;
                
case "不包含": strChoose = " NOT LIKE ";
                    
break;
            }


            
if (strCondition.Length == 0)
            
{
                strCondition 
= strCondition + DropDownListLeiBeiOne.SelectedItem.Value + strChoose + "'%" + TextBoxOne.Text.Trim() + "%'";
            }

            
else
            
{
                strCondition 
= strCondition + "AND " + DropDownListLeiBeiOne.SelectedItem.Value + strChoose + "'%" + TextBoxOne.Text.Trim() + "%'";
            }

        }


        
if (TextBoxTwo.Text.Trim().Length != 0)
        
{
            String tempStr 
= DropDownListTiaoJianTwo.SelectedItem.Value;
            
switch (tempStr)
            
{
                
case "包含": strChoose = " LIKE ";
                    
break;
                
case "不包含": strChoose = " NOT LIKE ";
                    
break;
            }


            
if (strCondition.Length == 0)
            
{
                strCondition 
= strCondition + DropDownListLeiBeiTwo.SelectedItem.Value + strChoose + "'%" + TextBoxTwo.Text.Trim() + "%'";
            }

            
else
            
{
                strCondition 
= strCondition + "AND " + DropDownListLeiBeiTwo.SelectedItem.Value + strChoose + "'%" + TextBoxTwo.Text.Trim() + "%'";
            }

        }


        
if (TextBoxThree.Text.Trim().Length != 0)
        
{
            String tempStr 
= DropDownListTiaoJianThree.SelectedItem.Value;
            
switch (tempStr)
            
{
                
case "等于": strChoose = "=";
                    
break;
                
case "大于": strChoose = ">";
                    
break;
                
case "小于": strChoose = "<";
                    
break;
            }


            
if (strCondition.Length == 0)
            
{
                strCondition 
= strCondition + DropDownListLeiBeiThree.SelectedItem.Value + strChoose + TextBoxThree.Text.Trim();
            }

            
else
            
{
                strCondition 
= strCondition + "AND " + DropDownListLeiBeiThree.SelectedItem.Value + strChoose + TextBoxThree.Text.Trim();
            }

        }


        
if (TextBoxFour.Text.Trim().Length != 0)
        
{
            String tempStr 
= DropDownListTiaoJianFour.SelectedItem.Value;
            
switch (tempStr)
            
{
                
case "等于": strChoose = "=";
                    
break;
                
case "大于": strChoose = ">";
                    
break;
                
case "小于": strChoose = "<";
                    
break;
            }

            
if (strCondition.Length == 0)
            
{
                strCondition 
= strCondition + DropDownListLeiBeiFour.SelectedItem.Value + strChoose + TextBoxFour.Text.Trim();
            }

            
else
            
{
                strCondition 
= strCondition + "AND " + DropDownListLeiBeiFour.SelectedItem.Value + strChoose + TextBoxFour.Text.Trim();
            }

        }


        
if (strCondition.Length != 0)
        
{
            strCondition 
= " where " + strCondition;
        }


        strCondition 
= strCondition + " ORDER BY " + DropDownListPaiXuFangShi.SelectedItem.Value.Trim();
        String strSql 
= querySql + strCondition;
        String mQuerySql 
= strSql;
        
// 填充表格
        fillGridView(mQuerySql);
        
// 保存SQL语句
        ViewState["sql"= mQuerySql;
    }



    
/// <summary>
    
/// 初始化DropDownList
    
/// </summary>

    private void dropDownListInit()
    
{

        GetTableInformation getTableInformation 
= new GetTableInformation();

        
// 获取表结构信息
        Hashtable tableInfor = getTableInformation.getTableInfor("baobiaoxinxi");

        
// 移除SN
        tableInfor.Remove("SN");
        tableInfor.Remove(
"报表名称");

        
foreach (DictionaryEntry de in tableInfor)
        
{
            String key 
= de.Key.ToString();
            String value 
= de.Value.ToString();

            
switch (value)
            
{
                
case "CHAR":
                    DropDownListLeiBeiOne.Items.Add(key);
                    DropDownListLeiBeiTwo.Items.Add(key);
                    
// 排序方式下拉框添加数据字段
                    DropDownListPaiXuFangShi.Items.Add(key);
                    
break;

                
case "VARCHAR2":
                    DropDownListLeiBeiOne.Items.Add(key);
                    DropDownListLeiBeiTwo.Items.Add(key);
                    
// 排序方式下拉框添加数据字段
                    DropDownListPaiXuFangShi.Items.Add(key);
                    
break;

                
case "NUMBER":
                    DropDownListLeiBeiThree.Items.Add(key);
                    DropDownListLeiBeiFour.Items.Add(key);
                    
// 排序方式下拉框添加数据字段
                    DropDownListPaiXuFangShi.Items.Add(key);
                    
break;
            }


        }


        DropDownListTiaoJianOne.Items.Add(
"包含");
        DropDownListTiaoJianOne.Items.Add(
"不包含");

        DropDownListTiaoJianTwo.Items.Add(
"包含");
        DropDownListTiaoJianTwo.Items.Add(
"不包含");

        DropDownListTiaoJianThree.Items.Add(
"等于");
        DropDownListTiaoJianThree.Items.Add(
"小于");
        DropDownListTiaoJianThree.Items.Add(
"大于");

        DropDownListTiaoJianFour.Items.Add(
"等于");
        DropDownListTiaoJianFour.Items.Add(
"小于");
        DropDownListTiaoJianFour.Items.Add(
"大于");

        
if (DropDownListLeiBeiOne.Items.Count == 0)
        
{
            
this.DropDownListLeiBeiOne.Visible = false;
            
this.DropDownListTiaoJianOne.Visible = false;
            
this.TextBoxOne.Visible = false;

        }


        
if (DropDownListLeiBeiTwo.Items.Count == 0)
        
{
            
this.DropDownListLeiBeiTwo.Visible = false;
            
this.DropDownListTiaoJianTwo.Visible = false;
            
this.TextBoxTwo.Visible = false;

        }


        
if (DropDownListLeiBeiThree.Items.Count == 0)
        
{
            
this.DropDownListLeiBeiThree.Visible = false;
            
this.DropDownListTiaoJianThree.Visible = false;
            
this.TextBoxThree.Visible = false;
        }


        
if (DropDownListLeiBeiFour.Items.Count == 0)
        
{
            
this.DropDownListLeiBeiFour.Visible = false;
            
this.DropDownListTiaoJianFour.Visible = false;
            
this.TextBoxFour.Visible = false;

        }


    }


    
/// <summary>
    
/// 填充GridView
    
/// </summary>

    private void fillGridView(String querySql)
    
{
        DataSet ds 
= new DataSet();
        ds 
= GetData(querySql);

        
// 清空以前的数据源
        GridViewXinXiLan.DataSource = null;

        
// 将ds作为信息栏GridView的数据源
        GridViewXinXiLan.DataSource = ds;

        
// 绑定数据
        GridViewXinXiLan.DataBind();

        
// 分页的相关参数设置
        getRefSet(ds);

        
// 保存数据源 防止丢失 VS的破Bug
        ViewState["GridViewXinXiLan_DataSource"= GridViewXinXiLan.DataSource;
        
// 保存SQL语句
        ViewState["sql"= querySql;
    }


    
/// <summary>
    
/// 转换SQL查询结果为DataSet
    
/// </summary>
    
/// <returns>ds</returns>

    private DataSet GetData(String querySql)
    
{
        String connStr 
= OracleHelper.DatabaseConnStr;

        
// 创建数据集
        DataSet ds = OracleHelper.ExeSqlForDataSet(connStr, CommandType.Text, querySql, null);

        
return ds;
    }



    
/// <summary>
    
/// 首页,上一页,下一页,尾页公用的点击程序
    
/// </summary>
    
/// <param name="sender"></param>
    
/// <param name="e"></param>

    protected void PagerButtonClick(object sender, EventArgs e)
    
{
        
        
// CommandArgument对应该对象在页面初始化后的设定值
        
// 减1 是因为系统默认首页的PageIndex为0,为了符合人们的正常思维而使用
        
// 重新绑定
        GridViewXinXiLan.DataSource = ViewState["GridViewXinXiLan_DataSource"];
        GridViewXinXiLan.PageIndex 
= Convert.ToInt32(((LinkButton)sender).CommandArgument) - 1;
        GridViewXinXiLan.DataBind();
        
// 更新当前页面显示值
        lblCurrentIndex.Text = "第 " + (GridViewXinXiLan.PageIndex + 1).ToString() + " 页";

        
// 更新参数
        lnkbtnPre.CommandArgument = (GridViewXinXiLan.PageIndex == 0 ? "1" : GridViewXinXiLan.PageIndex.ToString());
        lnkbtnNext.CommandArgument 
= (GridViewXinXiLan.PageCount == 1 ? GridViewXinXiLan.PageCount.ToString() : (GridViewXinXiLan.PageIndex + 2).ToString());

    }


    
/// <summary>
    
/// 分页的相关参数设置
    
/// </summary>
    
/// <param name="ds"></param>

    protected void getRefSet(DataSet ds)
    
{
        lblCurrentIndex.Text 
= "第 " + (GridViewXinXiLan.PageIndex + 1).ToString() + " 页";
        lblPageCount.Text 
= "共 " + GridViewXinXiLan.PageCount.ToString() + " 页";
        lblRecordCount.Text 
= "总共 " + ds.Tables[0].Rows.Count.ToString() + " 条";

        
if (ds.Tables[0].Rows.Count == 0)
        
{
            lnkbtnFirst.Visible 
= false;
            lnkbtnPre.Visible 
= false;
            lnkbtnNext.Visible 
= false;
            lnkbtnLast.Visible 
= false;

            lblCurrentIndex.Visible 
= false;
            lblPageCount.Visible 
= false;
            lblRecordCount.Visible 
= false;
            
this.lnkbtnJumpPage.Visible = false;
            
this.txtJumpPage.Visible = false;

            
this.CheckBoxAll.Visible = false;
        }

        
else if (GridViewXinXiLan.PageCount == 1)
        
{
            lnkbtnFirst.Visible 
= false;
            lnkbtnPre.Visible 
= false;
            lnkbtnNext.Visible 
= false;
            lnkbtnLast.Visible 
= false;
            
this.CheckBoxAll.Visible = true;
        }


        
// 设置LinkButton此时对应的参数
        lnkbtnFirst.CommandArgument = "1";
        lnkbtnPre.CommandArgument 
= (GridViewXinXiLan.PageIndex == 0 ? "1" : GridViewXinXiLan.PageIndex.ToString());
        lnkbtnNext.CommandArgument 
= (GridViewXinXiLan.PageCount == 1 ? GridViewXinXiLan.PageCount.ToString() : (GridViewXinXiLan.PageIndex + 2).ToString());
        lnkbtnLast.CommandArgument 
= GridViewXinXiLan.PageCount.ToString();

    }


    
/// <summary>
    
/// 跳转到指定页面,页面参数由txtJumpPage获取
    
/// </summary>
    
/// <param name="sender"></param>
    
/// <param name="e"></param>

    protected void lnkbtnJumpPage_Click(object sender, EventArgs e)
    
{
        
// 减1 是因为系统默认首页的PageIndex为0,为了符合人们的正常思维而使用
        
// 重新绑定
        GridViewXinXiLan.DataSource = ViewState["GridViewXinXiLan_DataSource"];
        GridViewXinXiLan.PageIndex 
= int.Parse(txtJumpPage.Text) - 1;
        GridViewXinXiLan.DataBind();
        
// 更新当前页面显示值
        lblCurrentIndex.Text = "第 " + (GridViewXinXiLan.PageIndex + 1).ToString() + " 页";

        
// 更新参数
        lnkbtnPre.CommandArgument = (GridViewXinXiLan.PageIndex == 0 ? "1" : GridViewXinXiLan.PageIndex.ToString());
        lnkbtnNext.CommandArgument 
= (GridViewXinXiLan.PageCount == 1 ? GridViewXinXiLan.PageCount.ToString() : (GridViewXinXiLan.PageIndex + 2).ToString());
    }


    
/// <summary>
    
/// 解决数据源不能分页的问题
    
/// </summary>
    
/// <param name="sender"></param>
    
/// <param name="e"></param>

    protected void GridViewXinXiLan_PageIndexChanging(object sender, GridViewPageEventArgs e)
    
{
        
// 读取数据源 设定显示值 并绑定
        GridViewXinXiLan.DataSource = ViewState["GridViewXinXiLan_DataSource"];
        GridViewXinXiLan.PageIndex 
= e.NewPageIndex;
        GridViewXinXiLan.DataBind();
    }


    
/// <summary>
    
/// 复选框选择
    
/// </summary>
    
/// <param name="sender"></param>
    
/// <param name="e"></param>

    protected void CheckBoxAll_CheckedChanged(object sender, EventArgs e)
    
{
        
for (int i = 0; i <= GridViewXinXiLan.Rows.Count - 1; i++)
        
{
            CheckBox cbox 
= (CheckBox)GridViewXinXiLan.Rows[i].FindControl("CheckBoxFuXuan");
            
if (CheckBoxAll.Checked == true)
            
{
                cbox.Checked 
= true;
                
this.CheckBoxAll.Text = "取消全选";
            }

            
else
            
{
                cbox.Checked 
= false;
                
this.CheckBoxAll.Text = "全部选择";
            }


        }

    }


    
/// <summary>
    
/// 返回首页面
    
/// </summary>

    private void BackIndex()
    
{
        MultiViewXinXiGuanLi.ActiveViewIndex 
= 0;
        MenuCaidan.Items[
1].Enabled = true;
        MenuCaidan.Items[
1].Selected = true;
        fillGridView(querySql);
    }



    
/// <summary>
    
/// 选择
    
/// </summary>
    
/// <param name="sender"></param>
    
/// <param name="e"></param>

    protected void GridViewXinXiLan_SelectedIndexChanged(object sender, EventArgs e)
    
{
        CheckBox cb 
= this.GridViewXinXiLan.SelectedRow.FindControl("CheckBoxFuXuan"as CheckBox;
        cb.Checked 
= true;
    }


    
/// <summary>
    
/// 相关下拉列表复原
    
/// </summary>

    private void dropDownListRecover()
    
{
        
// 编制单位
        String conn = OracleHelper.DatabaseConnStr;
        
this.DropDownListBianZhiDanWei.Items.Clear();
        String queryBianZhiDanWei 
= "SELECT 名称 FROM XITONGZIDIAN WHERE ID='05010101' ORDER BY 序号";
        OracleDataReader drBianZhiDanWei 
= OracleHelper.ExecuteReader(conn, CommandType.Text, queryBianZhiDanWei, null);
        
while (drBianZhiDanWei.Read())
        
{
            
this.DropDownListBianZhiDanWei.Items.Add(drBianZhiDanWei.GetString(0).Trim());
        }

        drBianZhiDanWei.Close();

    }


    
/// <summary>
    
/// 添加
    
/// </summary>
    
/// <param name="sender"></param>
    
/// <param name="e"></param>

    protected void ButtonTianJia_Click(object sender, EventArgs e)
    
{
        
this.MenuCaidan.Items[3].Enabled = true;
        MenuCaidan.Items[
3].Selected = true;
        MultiViewXinXiGuanLi.ActiveViewIndex 
= 1;
        
// 建立日期
        
// 生成GUID 
        String tempGuid = System.Guid.NewGuid().ToString().Replace("-""");
        
this.LabelZhuJian.Text = tempGuid;

        
//操作
        this.ButtonCaoZuo.Visible = true;
        
this.ButtonCaoZuo.Enabled = true;
        
this.ButtonCaoZuo.Text = "下一步";

        TextBoxBaoBiaoRiQi.Text 
= "";
        TextBoxBaoBiaoBianHao.Text 
= "";
        TextBoxQiYeFuZeRen.Text 
= "";
        TextBoxTongJiFuZeRen.Text 
= "";
        TextBoxTianBiaoRen.Text 
= "";
        TextBoxLianXiDianHua.Text 
= "";
        TextBoxBaoChuRiQi.Text 
= "";
        TextBoxZhuGuanLingDao.Text 
= "";
        TextBoxLuRuRen.Text 
= "";
        TextBoxBeiZhu.Text 
= "";

        
// 初始化下拉框
        dropDownListRecover();

    }


    
/// <summary>
    
/// 编辑
    
/// </summary>
    
/// <param name="sender"></param>
    
/// <param name="e"></param>

    protected void ButtonBianJi_Click(object sender, EventArgs e)
    
{
        
if (this.GridViewXinXiLan.SelectedRow != null)
        
{
            
// 主键 
            this.LabelZhuJian.Text = this.GridViewXinXiLan.DataKeys[this.GridViewXinXiLan.SelectedRow.RowIndex][0].ToString();
            
this.MenuCaidan.Items[4].Enabled = true;
            MenuCaidan.Items[
4].Selected = true;
            MultiViewXinXiGuanLi.ActiveViewIndex 
= 1;

            
this.ButtonCaoZuo.Text = "保存更新";
            
this.ButtonCaoZuo.Enabled = true;
            
this.ButtonCaoZuo.Visible = true;

            dropDownListRecover();

            TextBoxBaoBiaoRiQi.Text 
= this.GridViewXinXiLan.Rows[this.GridViewXinXiLan.SelectedRow.RowIndex].Cells[2].Text.ToString();
            TextBoxBaoBiaoBianHao.Text 
= this.GridViewXinXiLan.Rows[this.GridViewXinXiLan.SelectedRow.RowIndex].Cells[3].Text.ToString();
            DropDownListBianZhiDanWei.Items.Remove(
this.GridViewXinXiLan.Rows[this.GridViewXinXiLan.SelectedRow.RowIndex].Cells[5].Text.ToString().Trim());
            DropDownListBianZhiDanWei.Items.Insert(
0this.GridViewXinXiLan.Rows[this.GridViewXinXiLan.SelectedRow.RowIndex].Cells[5].Text.ToString().Trim());
            TextBoxQiYeFuZeRen.Text 
= this.GridViewXinXiLan.Rows[this.GridViewXinXiLan.SelectedRow.RowIndex].Cells[6].Text.ToString();
            TextBoxTongJiFuZeRen.Text 
= this.GridViewXinXiLan.Rows[this.GridViewXinXiLan.SelectedRow.RowIndex].Cells[7].Text.ToString();
            TextBoxTianBiaoRen.Text 
= this.GridViewXinXiLan.Rows[this.GridViewXinXiLan.SelectedRow.RowIndex].Cells[8].Text.ToString();
            TextBoxLianXiDianHua.Text 
= this.GridViewXinXiLan.Rows[this.GridViewXinXiLan.SelectedRow.RowIndex].Cells[9].Text.ToString();
            TextBoxBaoChuRiQi.Text 
= this.GridViewXinXiLan.Rows[this.GridViewXinXiLan.SelectedRow.RowIndex].Cells[10].Text.ToString();
            TextBoxZhuGuanLingDao.Text 
= this.GridViewXinXiLan.Rows[this.GridViewXinXiLan.SelectedRow.RowIndex].Cells[11].Text.ToString();
            TextBoxLuRuRen.Text 
= this.GridViewXinXiLan.Rows[this.GridViewXinXiLan.SelectedRow.RowIndex].Cells[12].Text.ToString();
            TextBoxBeiZhu.Text 
= this.GridViewXinXiLan.Rows[this.GridViewXinXiLan.SelectedRow.RowIndex].Cells[13].Text.ToString();

        }

        
else
        
{
            
// 错误信息提示
            String tip = "请选择行!";
            Response.Write(
"<script>alert('" + tip + "')</script>");
        }

          
    }


    
/// <summary>
    
/// 删除
    
/// </summary>
    
/// <param name="sender"></param>
    
/// <param name="e"></param>

    protected void ButtonShanChu_Click(object sender, EventArgs e)
    
{
        
// 选择数组
        ArrayList selectedItems = new ArrayList();

        
for (int i = 0; i < this.GridViewXinXiLan.Rows.Count; i++)
        
{
            
string id = this.GridViewXinXiLan.DataKeys[i][0].ToString();
            CheckBox cb 
= this.GridViewXinXiLan.Rows[i].FindControl("CheckBoxFuXuan"as CheckBox;
            
if (selectedItems.Contains(id) && !cb.Checked)
            
{
                selectedItems.Remove(id);
            }

            
if (!selectedItems.Contains(id) && cb.Checked)
            
{
                selectedItems.Add(id);
            }

        }


        
// 判断是否有复选框被选择
        if (selectedItems.Count == 0)
        
{
            
// 错误信息提示
            String tip = "请选择行!";
            Response.Write(
"<script>alert('" + tip + "')</script>");
            
return;
        }

        
// 一个个删除
        foreach (object tmp in selectedItems)
        
{
            
// 删除 需要开启事务
            
// 删除主表
            String delSql = "DELETE FROM baobiaoxinxi WHERE SN = " + "'" + tmp.ToString().Trim() + "'";
            
// 删除子表
            String delSubSql = "DELETE FROM cxcs Where ID = " + "'" + tmp.ToString().Trim() + "'";

            OracleConnection conn 
= new OracleConnection(OracleHelper.DatabaseConnStr);
            conn.Open();
            OracleTransaction trans 
= conn.BeginTransaction(IsolationLevel.ReadCommitted);

            
try
            
{
                OracleHelper.ExecuteNonQuery(trans, CommandType.Text, delSql, 
null);
                OracleHelper.ExecuteNonQuery(trans, CommandType.Text, delSubSql, 
null);
                trans.Commit();
            }

            
catch (Exception ex)
            
{
                trans.Rollback();
                ex.ToString();
            }

            
finally
            
{
                conn.Close();
            }


        }


        
// 刷新删除页面
        
// 读取数据源 设定显示值 并绑定
        
// 保存SQL语句
        String sql = ViewState["sql"].ToString();
        fillGridView(ViewState[
"sql"].ToString());
        
// 获取字符串中的字符正则表达式 并转换为整形 
        this.GridViewXinXiLan.PageIndex = Convert.ToInt32(System.Text.RegularExpressions.Regex.Replace(this.lblCurrentIndex.Text, @"[^d]*""")) - 1;

    }


    
/// <summary>
    
/// 报表详细信息
    
/// </summary>
    
/// <param name="sender"></param>
    
/// <param name="e"></param>

    protected void ButtonChaYue_Click(object sender, EventArgs e)
    
{
        
if (this.GridViewXinXiLan.SelectedRow != null)
        
{

            
this.LabelZhuJian.Text = this.GridViewXinXiLan.DataKeys[this.GridViewXinXiLan.SelectedRow.RowIndex][0].ToString();
            
this.MenuCaidan.Items[2].Enabled = true;
            MenuCaidan.Items[
2].Selected = true;
            MultiViewXinXiGuanLi.ActiveViewIndex 
= 2;

            LabelReportTitle.Text 
= this.GridViewXinXiLan.Rows[this.GridViewXinXiLan.SelectedRow.RowIndex].Cells[4].Text.ToString(); 

            
// 初始化默认Gridview的SQL语句
            RecoveryGridView();

            showButton();
        }

        
else
        
{
            
// 错误信息提示
            String tip = "请选择行!";
            Response.Write(
"<script>alert('" + tip + "')</script>");
        }


    }


    
/// <summary>
    
/// 操作
    
/// </summary>
    
/// <param name="sender"></param>
    
/// <param name="e"></param>

    protected void ButtonCaoZuo_Click(object sender, EventArgs e)
    
{
        
switch (this.ButtonCaoZuo.Text)
        
{
            
case "下一步":
                
{
                    
if (validTerm())
                    
{
                        
if (MainTable() == 1
                        
{
                            
this.MenuCaidan.Items[2].Enabled = true;
                            MenuCaidan.Items[
2].Selected = true;
                            MultiViewXinXiGuanLi.ActiveViewIndex 
= 2;
                            
// 初始化表格
                            InitTable(20);
                            ShowTable();
                            showButton();
                            LabelReportTitle.Text 
= baoBiaoMingCheng;
                        }

                    }

                }

                
break;
            
case "保存更新":
                
{

                    UpdateInformation();
                }

                
break;
            
defaultbreak;
        }


    }


    
/// <summary>
    
/// 初始化表结构
    
/// </summary>
    
/// <param name="rowsNum">行数</param>
    
/// <returns></returns>

    protected int InitTable(int rowsNum)
    
{
        
int result = 1;

        String sqlInsert 
= "INSERT INTO cxcs(ID,编号,生产企业,产品名称,计量单位,生产量本年实际,生产量去年实际,销售量本年实际,销售量去年实际,"
                            
+"库存量年初库存,库存量期末库存,平均售价本年实际,平均售价去年实际,产销率本年实际,产销率去年实际,市场占有率本年实际,"
                            
+"市场占有率去年实际,SN) "
                            
+ "VALUES(:id,:bh,:scqy,:cpmc,:jldw,:sclbnsj,:sclqnsj,:xslbnsj,:xslqnsj,:kclnckc,:kclqmkc,:pjsjbnsj,:pjsjqnsj,:cxlbnsj,:cxlqnsj,"
                            
+":sczylbnsj,:sczylqnsj,:sn)";

        OracleParameter[] parms 
= {
            
new OracleParameter(":id", OracleType.Char, 32),
            
new OracleParameter(":bh", OracleType.Number, 8),
            
new OracleParameter(":scqy", OracleType.VarChar, 512),
            
new OracleParameter(":cpmc", OracleType.VarChar, 512),
            
new OracleParameter(":jldw", OracleType.Char, 32),
            
new OracleParameter(":sclbnsj", OracleType.Char, 32),
            
new OracleParameter(":sclqnsj", OracleType.Char, 32),
            
new OracleParameter(":xslbnsj", OracleType.Char, 32),
            
new OracleParameter(":xslqnsj", OracleType.Char, 32),
            
new OracleParameter(":kclnckc", OracleType.Char, 32),
            
new OracleParameter(":kclqmkc", OracleType.Char, 32),
            
new OracleParameter(":pjsjbnsj", OracleType.Char, 32),
            
new OracleParameter(":pjsjqnsj", OracleType.Char, 32),
            
new OracleParameter(":cxlbnsj", OracleType.Char, 32),
            
new OracleParameter(":cxlqnsj", OracleType.Char, 32),
            
new OracleParameter(":sczylbnsj", OracleType.Char, 32),
            
new OracleParameter(":sczylqnsj", OracleType.Char, 32),
            
new OracleParameter(":sn", OracleType.Char, 32)
          }
;

        parms[
0].Value = this.LabelZhuJian.Text.Trim();
        parms[
1].Value = 1.0;
        parms[
2].Value = "";
        parms[
3].Value = "";
        parms[
4].Value = "";
        parms[
5].Value = "";
        parms[
6].Value = "";
        parms[
7].Value = "";
        parms[
8].Value = "";
        parms[
9].Value = "";
        parms[
10].Value = "";
        parms[
11].Value = "";
        parms[
12].Value = "";
        parms[
13].Value = "";
        parms[
14].Value = "";
        parms[
15].Value = "";
        parms[
16].Value = "";
        parms[
17].Value = "";
    
        OracleConnection conn 
= new OracleConnection(OracleHelper.DatabaseConnStr);
        
        
for (int i = 0; i < rowsNum; i++)
        
{
            parms[
1].Value = Convert.ToDouble(i+1);
            parms[
17].Value = System.Guid.NewGuid().ToString().Replace("-""");
            conn.Open();
            OracleTransaction trans 
= conn.BeginTransaction(IsolationLevel.ReadCommitted);
            
try
            
{
                OracleHelper.ExecuteNonQuery(trans, CommandType.Text, sqlInsert, parms);
                trans.Commit();
            }

            
catch (Exception ex)
            
{
                trans.Rollback();
                ex.ToString();
                result 
= 0;
            }

            
finally
            
{
                conn.Close();
            }


        }

        
return result;
    }


    
/// <summary>
    
/// 显示表
    
/// </summary>

    protected void ShowTable()
    
{
        GridViewTianJia.EditIndex 
= -1;
        RecoveryGridView();
    }


    
/// <summary>
    
/// 填充GridView
    
/// </summary>

    private void fillGridViewTianJia(String querySql)
    
{
        DataSet ds 
= new DataSet();
        ds 
= GetData(querySql);

        
// 清空以前的数据源
        GridViewTianJia.DataSource = null;

        
// 将ds作为信息栏GridView的数据源
        GridViewTianJia.DataSource = ds;

        
// 绑定数据
        GridViewTianJia.DataBind();

        
// 保存数据源 防止丢失 VS的破Bug
        ViewState["GridViewTianJia_DataSource"= this.GridViewTianJia.DataSource;
        
// 保存SQL语句
        ViewState["sql"= querySql;
        
// gridview 换行控制
        this.GridViewTianJia.Attributes.Add("style""word-break:keep-all;word-wrap:normal");
       
// GridViewTianJia.FooterRow.Visible = false;
    }


    
/// <summary>
    
/// 添加到主表
    
/// </summary>

    protected int MainTable()
    
{
        
int result = 1;

        
// 保存到Label
        LabelZhuJian.Text = System.Guid.NewGuid().ToString().Replace("-"""); 

        String sqlInsert 
= "INSERT INTO baobiaoxinxi(报表日期,报表编号,报表名称,编制单位,企业负责人,统计负责人,填表人,联系电话,报出日期,主管领导,备注,录入人,SN) "
                                
+ "VALUES(:bbrq,:bbbh,:bbmc,:bzdw,:qyfzr,:tjfzr,:tbr,:lxdh,:bcrq,:zgld,:bz,:lrr,:sn)";

        OracleParameter[] parms 
= {
            
new OracleParameter(":bbrq", OracleType.Char, 10),
            
new OracleParameter(":bbbh", OracleType.Char, 128),
            
new OracleParameter(":bbmc", OracleType.VarChar, 512),
            
new OracleParameter(":bzdw", OracleType.VarChar, 512),
            
new OracleParameter(":qyfzr", OracleType.Char, 20),
            
new OracleParameter(":tjfzr", OracleType.Char, 20),
            
new OracleParameter(":tbr", OracleType.Char, 20),
            
new OracleParameter(":lxdh", OracleType.Char, 32),
            
new OracleParameter(":bcrq", OracleType.Char, 20),
            
new OracleParameter(":zgld", OracleType.Char, 20),
            
new OracleParameter(":bz", OracleType.VarChar, 1024),
            
new OracleParameter(":lrr", OracleType.Char, 20),
            
new OracleParameter(":sn", OracleType.Char, 32)
          }
;

        parms[
0].Value = this.TextBoxBaoBiaoRiQi.Text.Trim();
        parms[
1].Value = this.TextBoxBaoBiaoBianHao.Text.Trim();
        parms[
2].Value = this.TextBoxBaoBiaoMingCheng.Text.Trim();
        parms[
3].Value = this.DropDownListBianZhiDanWei.SelectedItem.Text.Trim();
        parms[
4].Value = this.TextBoxQiYeFuZeRen.Text.Trim();
        parms[
5].Value = this.TextBoxTongJiFuZeRen.Text.Trim();
        parms[
6].Value = this.TextBoxTianBiaoRen.Text.Trim();
        parms[
7].Value = this.TextBoxLianXiDianHua.Text.Trim();
        parms[
8].Value = this.TextBoxBaoChuRiQi.Text.Trim();
        parms[
9].Value = this.TextBoxZhuGuanLingDao.Text.Trim();
        parms[
10].Value = this.TextBoxBeiZhu.Text.Trim();
        parms[
11].Value = this.TextBoxLuRuRen.Text.Trim();
        parms[
12].Value = this.LabelZhuJian.Text.Trim();
           
        OracleConnection conn 
= new OracleConnection(OracleHelper.DatabaseConnStr);
        conn.Open();
        OracleTransaction trans 
= conn.BeginTransaction(IsolationLevel.ReadCommitted);

        
try
        
{
            OracleHelper.ExecuteNonQuery(trans, CommandType.Text, sqlInsert, parms);
            trans.Commit();
        }

        
catch (Exception ex)
        
{          
            trans.Rollback();
            ex.ToString();
            result 
= 0;
        }

        
finally
        
{
            conn.Close();
        }


        
return result;
    }



    
/// <summary>
    
/// 验证项是否正确输入
    
/// </summary>
    
/// <returns></returns>

    private Boolean validTerm()
    
{
        
if (this.TextBoxBaoBiaoBianHao.Text.Length == 0)
        
{
            
// 错误信息提示
            String tip = "报表编号不可为空";
            Response.Write(
"<script>alert('" + tip + "')</script>");
            
return false;
        }


        
return true;
    }


    
/// <summary>
    
/// 更新信息
    
/// </summary>
    
/// <param name="sender"></param>
    
/// <param name="e"></param>

    protected void UpdateInformation()
    
{

        String sqlUpdate 
= "UPDATE baobiaoxinxi SET 报表日期=:bbrq,报表编号=:bbbh,报表名称=:bbmc,编制单位=:bzdw,企业负责人=:qyfzr,统计负责人=:tjfzr,"
                            
+ "填表人=:tbr,联系电话=:lxdh,"
                            
+ "报出日期=:bcrq,主管领导=:zgld,备注=:bz,录入人=:lrr"
                            
+ " WHERE SN=:sn";

        OracleParameter[] parms 
= {
            
new OracleParameter(":bbrq", OracleType.Char, 10),
            
new OracleParameter(":bbbh", OracleType.Char, 128),
            
new OracleParameter(":bbmc", OracleType.VarChar, 512),
            
new OracleParameter(":bzdw", OracleType.VarChar, 512),
            
new OracleParameter(":qyfzr", OracleType.Char, 20),
            
new OracleParameter(":tjfzr", OracleType.Char, 20),
            
new OracleParameter(":tbr", OracleType.Char, 20),
            
new OracleParameter(":lxdh", OracleType.Char, 32),
            
new OracleParameter(":bcrq", OracleType.Char, 20),
            
new OracleParameter(":zgld", OracleType.Char, 20),
            
new OracleParameter(":bz", OracleType.VarChar, 1024),
            
new OracleParameter(":lrr", OracleType.Char, 20),
            
new OracleParameter(":sn", OracleType.Char, 32)
          }
;

        parms[
0].Value = this.TextBoxBaoBiaoRiQi.Text.Trim();
        parms[
1].Value = this.TextBoxBaoBiaoBianHao.Text.Trim();
        parms[
2].Value = this.TextBoxBaoBiaoMingCheng.Text.Trim();
        parms[
3].Value = this.DropDownListBianZhiDanWei.SelectedItem.Text.Trim();
        parms[
4].Value = this.TextBoxQiYeFuZeRen.Text.Trim();
        parms[
5].Value = this.TextBoxTongJiFuZeRen.Text.Trim();
        parms[
6].Value = this.TextBoxTianBiaoRen.Text.Trim();
        parms[
7].Value = this.TextBoxLianXiDianHua.Text.Trim();
        parms[
8].Value = this.TextBoxBaoChuRiQi.Text.Trim();
        parms[
9].Value = this.TextBoxZhuGuanLingDao.Text.Trim();
        parms[
10].Value = this.TextBoxBeiZhu.Text.Trim();
        parms[
11].Value = this.TextBoxLuRuRen.Text.Trim();
        parms[
12].Value = this.LabelZhuJian.Text.Trim();

        OracleConnection conn 
= new OracleConnection(OracleHelper.DatabaseConnStr);
        conn.Open();
        OracleTransaction trans 
= conn.BeginTransaction(IsolationLevel.ReadCommitted);

        
try
        
{
            OracleHelper.ExecuteNonQuery(trans, CommandType.Text, sqlUpdate, parms);
            trans.Commit();
        }

        
catch (Exception ex)
        
{
            trans.Rollback();
            ex.ToString();
        }

        
finally
        
{
            conn.Close();
        }


        BackIndex();
    }


    
/// <summary>
    
/// 行更新
    
/// </summary>
    
/// <param name="sender"></param>
    
/// <param name="e"></param>

    protected void GridViewTianJia_RowUpdating(object sender, GridViewUpdateEventArgs e)
    
{

        String sqlUpdate 
= "UPDATE cxcs SET 编号=:bh,生产企业=:scqy,产品名称=:cpmc,计量单位=:jldw,生产量本年实际=:sclbnsj,生产量去年实际=:sclqnsj,"
                            
+ "销售量本年实际=:xslbnsj,销售量去年实际=:xslqnsj,库存量年初库存=:kclnckc,库存量期末库存=:kclqmkc,平均售价本年实际=:pjsjbnsj, "
                            
+ "平均售价去年实际=:pjsjqnsj,产销率本年实际=:cxlbnsj,产销率去年实际=:cxlqnsj,市场占有率本年实际=:sczylbnsj,"
                            
+ "市场占有率去年实际=:sczylqnsj "
                            
+ " WHERE SN=:sn";

        OracleParameter[] parms 
= {
            
new OracleParameter(":bh", OracleType.Number, 8),
            
new OracleParameter(":scqy", OracleType.VarChar, 512),
            
new OracleParameter(":cpmc", OracleType.VarChar, 512),
            
new OracleParameter(":jldw", OracleType.Char, 32),
            
new OracleParameter(":sclbnsj", OracleType.Char, 32),
            
new OracleParameter(":sclqnsj", OracleType.Char, 32),
            
new OracleParameter(":xslbnsj", OracleType.Char, 32),
            
new OracleParameter(":xslqnsj", OracleType.Char, 32),
            
new OracleParameter(":kclnckc", OracleType.Char, 32),
            
new OracleParameter(":kclqmkc", OracleType.Char, 32),
            
new OracleParameter(":pjsjbnsj", OracleType.Char, 32),
            
new OracleParameter(":pjsjqnsj", OracleType.Char, 32),
            
new OracleParameter(":cxlbnsj", OracleType.Char, 32),
            
new OracleParameter(":cxlqnsj", OracleType.Char, 32),
            
new OracleParameter(":sczylbnsj", OracleType.Char, 32),
            
new OracleParameter(":sczylqnsj", OracleType.Char, 32),
            
new OracleParameter(":sn", OracleType.Char, 32)
          }
;

        parms[
0].Value = ((TextBox)GridViewTianJia.Rows[e.RowIndex].FindControl("TextBoxBianHao")).Text.Trim();
        parms[
1].Value = ((TextBox)GridViewTianJia.Rows[e.RowIndex].FindControl("TextBoxShenChanQiYe")).Text.Trim();
        parms[
2].Value = ((TextBox)GridViewTianJia.Rows[e.RowIndex].FindControl("TextBoxChanPinMingChen")).Text.Trim();
        parms[
3].Value = ((TextBox)GridViewTianJia.Rows[e.RowIndex].FindControl("TextBoxJiLiangDanWei")).Text.Trim();
        parms[
4].Value = ((TextBox)GridViewTianJia.Rows[e.RowIndex].FindControl("TextBoxShenChanLiangBenNian")).Text.Trim();
        parms[
5].Value = ((TextBox)GridViewTianJia.Rows[e.RowIndex].FindControl("TextBoxShenChanLiangQuNian")).Text.Trim();
        parms[
6].Value = ((TextBox)GridViewTianJia.Rows[e.RowIndex].FindControl("TextBoxXiaoShouLiangBenNian")).Text.Trim();
        parms[
7].Value = ((TextBox)GridViewTianJia.Rows[e.RowIndex].FindControl("TextBoxXiaoShouLiangQuNian")).Text.Trim();
        parms[
8].Value = ((TextBox)GridViewTianJia.Rows[e.RowIndex].FindControl("TextBoxKuCunLiangNianChu")).Text.Trim();
        parms[
9].Value = ((TextBox)GridViewTianJia.Rows[e.RowIndex].FindControl("TextBoxKuCunLiangQiMo")).Text.Trim();
        parms[
10].Value = ((TextBox)GridViewTianJia.Rows[e.RowIndex].FindControl("TextBoxPingJunShouJiaBenNian")).Text.Trim();
        parms[
11].Value = ((TextBox)GridViewTianJia.Rows[e.RowIndex].FindControl("TextBoxPingJunShouJiaQuNian")).Text.Trim();
        parms[
12].Value = ((TextBox)GridViewTianJia.Rows[e.RowIndex].FindControl("TextBoxChanXiaoLvBenNian")).Text.Trim();
        parms[
13].Value = ((TextBox)GridViewTianJia.Rows[e.RowIndex].FindControl("TextBoxChanXiaoLvQuNian")).Text.Trim();
        parms[
14].Value = ((TextBox)GridViewTianJia.Rows[e.RowIndex].FindControl("TextBoxShiChangBenNian")).Text.Trim();
        parms[
15].Value = ((TextBox)GridViewTianJia.Rows[e.RowIndex].FindControl("TextBoxShiChangQuNian")).Text.Trim();
        parms[
16].Value = GridViewTianJia.DataKeys[e.RowIndex].Values[0].ToString().Trim();

        OracleConnection conn 
= new OracleConnection(OracleHelper.DatabaseConnStr);
        conn.Open();
        OracleTransaction trans 
= conn.BeginTransaction(IsolationLevel.ReadCommitted);

        
try
        
{
            OracleHelper.ExecuteNonQuery(trans, CommandType.Text, sqlUpdate, parms);
            trans.Commit();
        }

        
catch (Exception ex)
        
{
            trans.Rollback();
            ex.ToString();
        }

        
finally
        
{
            conn.Close();
        }


        GridViewTianJia.EditIndex 
= -1;
        RecoveryGridView();
    }



    
/// <summary>
    
/// 取消
    
/// </summary>
    
/// <param name="sender"></param>
    
/// <param name="e"></param>

    protected void LinkButtonQuXiao_Click(object sender, EventArgs e)
    
{
        GridViewTianJia.EditIndex 
= -1;
        RecoveryGridView();

    }

           
    
/// <summary>
    
/// 取消编辑
    
/// </summary>
    
/// <param name="sender"></param>
    
/// <param name="e"></param>

    protected void GridViewTianJia_RowCancelingEdit(object sender, GridViewCancelEditEventArgs e)
    
{
        GridViewTianJia.EditIndex 
= -1;
        RecoveryGridView();
    }


    
/// <summary>
    
/// 绑定
    
/// </summary>
    
/// <param name="sender"></param>
    
/// <param name="e"></param>

    protected void GridViewTianJia_RowDataBound(object sender, GridViewRowEventArgs e)
    
{
        
if (e.Row.RowType == DataControlRowType.DataRow)
        
{
            
if (DataBinder.Eval(e.Row.DataItem, "生产量本年实际").ToString().Length != 0)
            
{
                totalstock 
+= Convert.ToDecimal(DataBinder.Eval(e.Row.DataItem, "生产量本年实际"));
            }
          

        }

        
else if (e.Row.RowType == DataControlRowType.Footer)
        
{
            e.Row.Cells[
3].Text = "统计";
            e.Row.Cells[
3].HorizontalAlign = HorizontalAlign.Right;
            e.Row.Cells[
7].Text = totalstock.ToString();
            e.Row.Cells[
7].HorizontalAlign = HorizontalAlign.Right;

        }

    }


    
/// <summary>
    
/// 删除
    
/// </summary>
    
/// <param name="sender"></param>
    
/// <param name="e"></param>

    protected void GridViewTianJia_RowDeleting(object sender, GridViewDeleteEventArgs e)
    
{
        String sn 
= GridViewTianJia.DataKeys[e.RowIndex].Values[0].ToString().Trim();

        String delSql 
= "DELETE FROM cxcs WHERE SN = '" + sn + "'";

        OracleConnection conn 
= new OracleConnection(OracleHelper.DatabaseConnStr);
        conn.Open();
        OracleTransaction trans 
= conn.BeginTransaction(IsolationLevel.ReadCommitted);

        
try
        
{
            OracleHelper.ExecuteNonQuery(trans, CommandType.Text, delSql, 
null);
            trans.Commit();
        }

        
catch (Exception ex)
        
{
            trans.Rollback();
            ex.ToString();
        }

        
finally
        
{
            conn.Close();
        }


        GridViewTianJia.EditIndex 
= -1;
        RecoveryGridView();
    }


    
protected void GridViewTianJia_RowEditing(object sender, GridViewEditEventArgs e)
    
{
        GridViewTianJia.EditIndex 
= e.NewEditIndex;

        RecoveryGridView();
    }


    
/// <summary>
    
/// 新增一行 
    
/// </summary>
    
/// <param name="sender"></param>
    
/// <param name="e"></param>

    protected void ButtonXinZen_Click(object sender, EventArgs e)
    
{
        String sqlInsert 
= "INSERT INTO cxcs(ID,编号,生产企业,产品名称,计量单位,生产量本年实际,生产量去年实际,销售量本年实际,销售量去年实际,"
                        
+ "库存量年初库存,库存量期末库存,平均售价本年实际,平均售价去年实际,产销率本年实际,产销率去年实际,市场占有率本年实际,"
                        
+ "市场占有率去年实际,SN) "
                        
+ "VALUES(:id,:bh,:scqy,:cpmc,:jldw,:sclbnsj,:sclqnsj,:xslbnsj,:xslqnsj,:kclnckc,:kclqmkc,:pjsjbnsj,:pjsjqnsj,:cxlbnsj,:cxlqnsj,"
                        
+ ":sczylbnsj,:sczylqnsj,:sn)";

        OracleParameter[] parms 
= {
            
new OracleParameter(":id", OracleType.Char, 32),
            
new OracleParameter(":bh", OracleType.Number, 8),
            
new OracleParameter(":scqy", OracleType.VarChar, 512),
            
new OracleParameter(":cpmc", OracleType.VarChar, 512),
            
new OracleParameter(":jldw", OracleType.Char, 32),
            
new OracleParameter(":sclbnsj", OracleType.Char, 32),
            
new OracleParameter(":sclqnsj", OracleType.Char, 32),
            
new OracleParameter(":xslbnsj", OracleType.Char, 32),
            
new OracleParameter(":xslqnsj", OracleType.Char, 32),
            
new OracleParameter(":kclnckc", OracleType.Char, 32),
            
new OracleParameter(":kclqmkc", OracleType.Char, 32),
            
new OracleParameter(":pjsjbnsj", OracleType.Char, 32),
            
new OracleParameter(":pjsjqnsj", OracleType.Char, 32),
            
new OracleParameter(":cxlbnsj", OracleType.Char, 32),
            
new OracleParameter(":cxlqnsj", OracleType.Char, 32),
            
new OracleParameter(":sczylbnsj", OracleType.Char, 32),
            
new OracleParameter(":sczylqnsj", OracleType.Char, 32),
            
new OracleParameter(":sn", OracleType.Char, 32)
          }
;

        parms[
0].Value = this.LabelZhuJian.Text.Trim();
        parms[
1].Value = Math.Ceiling(getMaxSeq() + 1.0);
        parms[
2].Value = "";
        parms[
3].Value = "";
        parms[
4].Value = "";
        parms[
5].Value = "";
        parms[
6].Value = "";
        parms[
7].Value = "";
        parms[
8].Value = "";
        parms[
9].Value = "";
        parms[
10].Value = "";
        parms[
11].Value = "";
        parms[
12].Value = "";
        parms[
13].Value = "";
        parms[
14].Value = "";
        parms[
15].Value = "";
        parms[
16].Value = "";
        parms[
17].Value = System.Guid.NewGuid().ToString().Replace("-"""); 

        OracleConnection conn 
= new OracleConnection(OracleHelper.DatabaseConnStr);

        conn.Open();
        OracleTransaction trans 
= conn.BeginTransaction(IsolationLevel.ReadCommitted);
        
try
        
{
            OracleHelper.ExecuteNonQuery(trans, CommandType.Text, sqlInsert, parms);
            trans.Commit();
        }

        
catch (Exception ex)
        
{
            trans.Rollback();
            ex.ToString();
        }

        
finally
        
{
            conn.Close();
        }


        GridViewTianJia.EditIndex 
= -1;

        RecoveryGridView();
    }


    
/// <summary>
    
/// 获取当前编号的最大值
    
/// </summary>
    
/// <returns></returns>

    private double getMaxSeq()
    
{
        
double result = 1.0;

        String conn 
= OracleHelper.DatabaseConnStr;
        String queryBiaoTou 
= "SELECT MAX(编号) FROM cxcs WHERE ID='" + LabelZhuJian.Text.Trim() + "";
        OracleDataReader drBiaoTou 
= OracleHelper.ExecuteReader(conn, CommandType.Text, queryBiaoTou, null);
        
while (drBiaoTou.Read())
        
{
            result 
= drBiaoTou.GetDouble(0);
        }

        drBiaoTou.Close();

        
return result;
    }



    
/// <summary>
    
/// 导出到Excel
    
/// </summary>
    
/// <param name="sender"></param>
    
/// <param name="e"></param>

    protected void ButtonExcel_Click(object sender, EventArgs e)
    
{
        Response.ClearContent();

        
string fileName = Server.UrlEncode("主要产品产销存统计表.xls");
        Response.AddHeader(
"Content-Disposition""attachment; filename=" + fileName);

        Response.ContentType 
= "application/excel";

        StringWriter sw 
= new StringWriter();
        ExportHead();
        HtmlTextWriter htw 
= new HtmlTextWriter(sw);
        
// 去除第1第2列
        GridViewTianJia.Columns[0].Visible = false;
        GridViewTianJia.Columns[
1].Visible = false;
        
        GridViewTianJia.RenderControl(htw);
        Response.Write(sw);
        ExportFoot();
       
        Response.End();
    }


    
/// <summary>
    
/// 导出表头
    
/// </summary>

    private void ExportHead()
    
{
        String conn 
= OracleHelper.DatabaseConnStr;
        String queryBiaoTou 
= "SELECT * FROM baobiaoxinxi WHERE SN='"+ LabelZhuJian.Text.Trim()+ "";
        OracleDataReader drBiaoTou 
= OracleHelper.ExecuteReader(conn, CommandType.Text, queryBiaoTou, null);
        
while (drBiaoTou.Read())
        
{
            Response.Write(
"<table><tr><td>报表日期:</td><td>" + drBiaoTou.GetString(0)+"</td></tr>");
            Response.Write(
"<table><tr><td>报表编号:</td><td>" + drBiaoTou.GetString(1)+"</td></tr></table>");
            Response.Write(
"<table><tr><td>报表名称:</td><td>" + drBiaoTou.GetString(2+ "</td></tr></table>");
            Response.Write(
"<table><tr><td>编制单位:</td><td>" + drBiaoTou.GetString(3+ "</td></tr></table>");
            Response.Write(
"<table><tr><td>企业负责人:</td><td>" + drBiaoTou.GetString(4+ "</td></tr></table>");
            Response.Write(
"<table><tr><td>统计负责人:</td><td>" + drBiaoTou.GetString(5+ "</td></tr></table>");
            Response.Write(
"<table><tr><td>填表人:</td><td>" + drBiaoTou.GetString(6+ "</td></tr></table>");
            Response.Write(
"<table><tr><td>联系电话:</td><td>" + drBiaoTou.GetString(7+ "</td></tr></table>");
            Response.Write(
"<table><tr><td>报出日期:</td><td>" + drBiaoTou.GetString(8+ "</td></tr></table>");
            Response.Write(
"<table><tr><td>主管领导:</td><td>" + drBiaoTou.GetString(9+ "</td></tr></table>");
            Response.Write(
"<table><tr><td>备注:</td><td>" + drBiaoTou.GetString(10+ "</td></tr></table>");
            Response.Write(
"<table><tr><td>录入人:</td><td>" + drBiaoTou.GetString(11+ "</td></tr></table>");

            Response.Write(
"<br> ");
        }

        drBiaoTou.Close();
    }


    
/// <summary>
    
/// 导出表尾
    
/// </summary>

    private void ExportFoot()
    
{
        
// 示例
        
// Response.Write("<table><tr><td>单位负责人:</td><td> </td><td>统计负责人:</td><td></td><td>填报人:</td></tr></table>");
    }


    
/// <summary>
    
/// 必须要的
    
/// </summary>
    
/// <param name="control"></param>

    public override void VerifyRenderingInServerForm(Control control)
    
{

    }




    
protected void ButtonClear_Click(object sender, EventArgs e)
    
{
        String delStr 
= "生产企业 is null ";

        String delSql 
= "DELETE FROM cxcs WHERE ID = '" + this.LabelZhuJian.Text.Trim() + "' AND " + delStr;

        OracleConnection conn 
= new OracleConnection(OracleHelper.DatabaseConnStr);
        conn.Open();
        OracleTransaction trans 
= conn.BeginTransaction(IsolationLevel.ReadCommitted);

        
try
        
{
            OracleHelper.ExecuteNonQuery(trans, CommandType.Text, delSql, 
null);
            trans.Commit();
        }

        
catch (Exception ex)
        
{
            trans.Rollback();
            ex.ToString();
        }

        
finally
        
{
            conn.Close();
        }


        GridViewTianJia.EditIndex 
= -1;
        RecoveryGridView();
    }


    
/// <summary>
    
/// 恢复GridView显示
    
/// </summary>

    private void RecoveryGridView()
    
{
        
// 初始化默认Gridview的SQL语句
        String querySql = "SELECT ID,编号,生产企业,产品名称,计量单位,生产量本年实际,生产量去年实际,销售量本年实际,销售量去年实际,"
                            
+ "库存量年初库存,库存量期末库存,平均售价本年实际,平均售价去年实际,产销率本年实际,产销率去年实际,市场占有率本年实际,"
                            
+ "市场占有率去年实际,SN"
                            
+ " FROM cxcs WHERE ID='" + this.LabelZhuJian.Text.Trim() + "' ORDER BY 编号";
        fillGridViewTianJia(querySql);
    }


    
/// <summary>
    
/// 计算
    
/// </summary>
    
/// <param name="sender"></param>
    
/// <param name="e"></param>

    protected void ButtonCal_Click(object sender, EventArgs e)
    
{
        GridViewTianJia.FooterRow.Visible 
= true;
    }


    
/// <summary>
    
/// 查看按钮
    
/// </summary>
    
/// <param name="sender"></param>
    
/// <param name="e"></param>

    protected void ButtonChaKan_Click(object sender, EventArgs e)
    
{
        
if (this.GridViewXinXiLan.SelectedRow != null)
        
{
            
this.LabelZhuJian.Text = this.GridViewXinXiLan.DataKeys[this.GridViewXinXiLan.SelectedRow.RowIndex][0].ToString();
            
this.MenuCaidan.Items[2].Enabled = true;
            MenuCaidan.Items[
2].Selected = true;
            MultiViewXinXiGuanLi.ActiveViewIndex 
= 2;

            LabelReportTitle.Text 
= this.GridViewXinXiLan.Rows[this.GridViewXinXiLan.SelectedRow.RowIndex].Cells[4].Text.ToString();
            RecoveryGridView();
            hiddenButton();
            
        }

        
else
        
{
            
// 错误信息提示
            String tip = "请选择行!";
            Response.Write(
"<script>alert('" + tip + "')</script>");
        }

    }


    
/// <summary>
    
/// 隐藏按钮
    
/// </summary>

    private void hiddenButton()
    
{
        
// 隐藏前2列
        GridViewTianJia.Columns[0].Visible = false;
        GridViewTianJia.Columns[
1].Visible = false;

        ButtonXinZen.Visible 
= false;
        ButtonXinZen.Enabled 
= false;

        ButtonClear.Visible 
= false;
        ButtonClear.Enabled 
= false;
    }


    
/// <summary>
    
/// 显示按钮
    
/// </summary>

    private void showButton()
    
{

        GridViewTianJia.Columns[
0].Visible = true;
        GridViewTianJia.Columns[
1].Visible = true;

        ButtonXinZen.Visible 
= true;
        ButtonXinZen.Enabled 
= true;

        ButtonClear.Visible 
= true;
        ButtonClear.Enabled 
= true;

    }


}

 

3 演示效果

 下次贴

0
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:1959953次
    • 积分:27762
    • 等级:
    • 排名:第201名
    • 原创:903篇
    • 转载:69篇
    • 译文:0篇
    • 评论:585条
    最新评论