📄 customer_source_upt.aspx
字号:
<!-- #include virtual="/include/PageDirective.inc" -->
<!-- #include virtual="/include/imports.inc" -->
<!-- #include virtual="/include/common_function.inc" -->
<html>
<head>
<link REL="StyleSheet" HREF="/css/standard.css" >
<script language="C#" runat="server">
/**********************************************************************
* 模块: customer_source_upt.aspx
* 作者: vivid
* 修改: 2/1/2001
* 目的: customer_source_detail table maintain
* 参数: none
* 数据: sel: customer_source;customer_source_detail
* ins: customer_source;customer_source_detail
* del: customer_source;customer_source_detail
* upt: customer_source;customer_source_detail
************************************************************************/
string strSQLMessage="";
private void Page_Load(Object sender, EventArgs E) {
try {
if (IsPostBack){
strSQLMessage="select * from customer_source_detail where customer_source_id='"+customer_source_id.Text+"' order by customer_source_detail_id";
return;
}
SqlConnection myConnection = new SqlConnection(ConfigurationSettings.AppSettings["edu"]);
SqlCommand myCommand = new SqlCommand
("select * from customer_source where customer_source_id='" +
Request["customer_source_id"]+"'", myConnection);
SqlDataReader MyReader;
myConnection.Open();
MyReader=myCommand.ExecuteReader();
while (MyReader.Read()){
customer_source_id.Text=MyReader["customer_source_id"].ToString();
customer_source_name.Text=MyReader["customer_source_name"].ToString();
}
strSQLMessage="select * from customer_source_detail where customer_source_id='"+customer_source_id.Text+"' order by customer_source_detail_id";
BindGrid();
}
catch (System.Exception e){
ErrorHandler(e.ToString());
}
}
private void BackBtn_Click(Object Sender, EventArgs E) {
try {
Response.Redirect("customer_source.aspx");
}
catch (System.Exception e){
ErrorHandler(e.ToString());
}
}
private void SubmitBtn_Click(Object Sender, EventArgs E) {
try {
if (Page.IsValid) {
SqlConnection myConnection = new SqlConnection(ConfigurationSettings.AppSettings["edu"]);;
string updateCmd = "update customer_source set customer_source_name= @customer_source_name"
+" where customer_source_id =@customer_source_id";
SqlCommand myCommand = new SqlCommand(updateCmd, myConnection);
myCommand.Parameters.Add(new SqlParameter("@customer_source_id", SqlDbType.VarChar, 50));
myCommand.Parameters["@customer_source_id"].Value = customer_source_id.Text;
myCommand.Parameters.Add(new SqlParameter("@customer_source_name", SqlDbType.VarChar, 50));
myCommand.Parameters["@customer_source_name"].Value = customer_source_name.Text;
myConnection.Open();
try {
myCommand.ExecuteNonQuery();
MessageSQLUptDone();
}
catch (System.Data.SqlClient.SqlException e) {
SQLErrorHandler(e);
}
myConnection.Close();
}
}
catch (System.Exception e){
ErrorHandler(e.ToString());
}
}
private void Add_Detail_Click(Object sender, EventArgs E) {
try {
SqlConnection myConnection = new SqlConnection(ConfigurationSettings.AppSettings["edu"]);
String insertCmd = "insert into customer_source_detail (customer_source_detail_id,customer_source_id,customer_source_detail_name) values('"+customer_source_detail_id.Value+"','" +customer_source_id.Text +"','" +customer_source_detail_name.Value+"')";
SqlCommand myCommand = new SqlCommand(insertCmd, myConnection);
myConnection.Open();
try {
myCommand.ExecuteNonQuery();
MessageSQLInsDone();
}
catch (System.Data.SqlClient.SqlException e) {
SQLErrorHandler(e);
}
myConnection.Close();
BindGrid();
}
catch (System.Exception e){
ErrorHandler(e.ToString());
}
}
private void MyDataGrid_Delete(Object sender, DataGridCommandEventArgs E) {
try {
SqlConnection myConnection = new SqlConnection(ConfigurationSettings.AppSettings["edu"]);
string deleteCmd = "delete customer_source_detail where customer_source_detail_id='" +MyDataGrid.DataKeys[(int)E.Item.ItemIndex]+"'";
Message.InnerHtml = deleteCmd;
SqlCommand myCommand = new SqlCommand(deleteCmd, myConnection);
myConnection.Open();
try {
myCommand.ExecuteNonQuery();
MessageSQLDelDone();
}
catch (System.Data.SqlClient.SqlException e) {
SQLErrorHandler(e);
}
myConnection.Close();
BindGrid();
}
catch (System.Exception e){
ErrorHandler(e.ToString());
}
}
private void MyDataGrid_Edit(Object sender, DataGridCommandEventArgs E) {
try {
MyDataGrid.EditItemIndex = (int)E.Item.ItemIndex;
BindGrid();
}
catch (System.Exception e){
ErrorHandler(e.ToString());
}
}
private void MyDataGrid_Cancel(Object sender, DataGridCommandEventArgs E) {
try {
MyDataGrid.EditItemIndex = -1;
BindGrid();
}
catch (System.Exception e){
ErrorHandler(e.ToString());
}
}
private void MyDataGrid_Update(Object sender, DataGridCommandEventArgs E) {
try {
if (Page.IsValid) {
SqlConnection myConnection = new SqlConnection(ConfigurationSettings.AppSettings["edu"]);
string updateCmd = "update customer_source_detail set customer_source_detail_name = @customer_source_detail_name where customer_source_detail_id = @customer_source_detail_id ";
SqlCommand myCommand = new SqlCommand(updateCmd, myConnection);
myCommand.Parameters.Add(new SqlParameter("@customer_source_detail_id", SqlDbType.VarChar, 50));
myCommand.Parameters["@customer_source_detail_id"].Value =MyDataGrid.DataKeys[(int)E.Item.ItemIndex];
myCommand.Parameters.Add(new SqlParameter("@customer_source_detail_name", SqlDbType.VarChar,50));
myCommand.Parameters["@customer_source_detail_name"].Value = ((TextBox)E.Item.FindControl("edit_customer_source_detail_name")).Text;
myConnection.Open();
try {
myCommand.ExecuteNonQuery();
MessageSQLUptDone();
MyDataGrid.EditItemIndex = -1;
}
catch (System.Data.SqlClient.SqlException e) {
SQLErrorHandler(e);
}
myConnection.Close();
BindGrid();
}
}
catch (System.Exception e){
ErrorHandler(e.ToString());
}
}
private void BindGrid() {
try {
SqlConnection myConnection = new SqlConnection(ConfigurationSettings.AppSettings["edu"]);
SqlDataAdapter myCommand = new SqlDataAdapter(strSQLMessage, myConnection);
DataSet ds = new DataSet();
myCommand.Fill(ds, "customer_source_detail");
MyDataGrid.DataSource=ds.Tables["customer_source_detail"].DefaultView;
MyDataGrid.DataBind();
}
catch (System.Exception e) {
ErrorHandler(e.ToString());
}
}
</script>
</head>
<body topmargin="0" leftmargin="0" marginwidth="0" marginheight="0">
<!-- #include virtual="/include/header.inc" -->
<table width=100% cellspacing=0 cellpadding=0>
<tr>
<td align="center" class="CONTENTTITLE" width="100%" bgcolor="D3C9C7">
顾客来源明细数据
</td>
</tr>
<tr>
<td>
<span id="Message" EnableViewState="false" class="MESSAGE" runat="server"/>
</td>
</tr>
</table>
<form runat="server" ACTION="customer_source_upt.aspx" NAME="customer_source_upt" METHOD="post">
<TABLE CELLPADDING=0 CELLSPACING=0 BORDER=0>
<TR>
<p>
<div style="padding:15,15,15,15;font-size:10pt;font-family:Verdana">
<TD VALIGN="top" ALIGN="left">
<span class="REQUIREDFIELD">顾客来源代码:</span>
<TD VALIGN="top" ALIGN="left">
<asp:label id="customer_source_id" runat="server"/></b>
<TR style="background-color:#E7E7E7;">
<TD VALIGN="center" ALIGN="left">
<span class="REQUIREDFIELD">顾客来源名称: </span>
<TD VALIGN="top" ALIGN="left"></b>
<asp:textbox type="text" id="customer_source_name" Width="400px" runat="server"/>
<TR >
<TR>
<TD VALIGN="center" ALIGN="left"> <asp:Button OnClick="SubmitBtn_Click" Text="储存修改" Runat="server"/>
<TD VALIGN="center" ALIGN="left"> <asp:LinkButton OnClick="BackBtn_Click" Text="回顾客来源基本数据维护" Runat="server"/>
</div>
</TABLE>
<hr>
<table style="font: 8pt verdana">
<tr>
<td colspan="5" bgcolor="#aaaadd" style="font:10pt verdana">新增顾客来源细目: <br>
顾客来源明细代码:<input type="text" id="customer_source_detail_id" runat="server">
顾客来源明细名称:<input type="text" id="customer_source_detail_name" runat="server">
<input type="submit" OnServerClick="Add_Detail_Click" value="新增" runat="server">
</td>
</tr>
</table>
<table style="font: 8pt verdana" width=100% >
<tr>
<td colspan="5" bgcolor="#aaaadd" style="font:10pt verdana">顾客来源明细一览/删除:</td>
</tr>
</table>
<ASP:DataGrid id="MyDataGrid" runat="server"
BackColor="#F4FFF4"
BorderColor="black"
ShowFooter="false"
CellPadding=3
CellSpacing="0"
Font-Name="Verdana"
Font-Size="8pt"
HeaderStyle-BackColor="lightblue"
OnEditCommand="MyDataGrid_Edit"
OnDeleteCommand="MyDataGrid_Delete"
OnCancelCommand="MyDataGrid_Cancel"
OnUpdateCommand="MyDataGrid_Update"
DataKeyField="customer_source_detail_id"
AutoGenerateColumns="false"
>
<Columns>
<asp:EditCommandColumn EditText="修改" CancelText="取消" UpdateText="储存" ItemStyle-Wrap="false" ButtonType=" PushButton" />
<asp:ButtonColumn Text="删除" CommandName="Delete" ButtonType="PushButton" />
<asp:BoundColumn HeaderText="顾客来源明细代码" SortExpression="customer_source_detail_id" ReadOnly="True" DataField="customer_source_detail_id" ItemStyle-Wrap="false" />
<asp:TemplateColumn HeaderText="顾客来源明细明称" SortExpression="customer_source_detail_name">
<ItemTemplate>
<asp:Label runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "customer_source_detail_name") %>'/>
</ItemTemplate>
<EditItemTemplate>
<nobr>
<asp:TextBox runat="server" id="edit_customer_source_detail_name" Text='<%# DataBinder.Eval(Container.DataItem, "customer_source_detail_name") %>'/>
</EditItemTemplate>
</asp:TemplateColumn>
</Columns>
</ASP:DataGrid>
</form>
<!-- #include virtual="/include/footer.inc" -->
</body>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -