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 addSer : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
if (Session["userId"] == null)
{
Response.Write("<script>alert('你还没有登陆');window.target='main';window.location.href='logic.aspx'</script>");
}
else
{
// DetailsView1.DefaultMode = DetailsViewMode.Insert;
}
}
}
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
DropDownList dr = (DropDownList)FormView1.FindControl("DropDownList1");
SqlDataSource1.InsertParameters[1].DefaultValue = dr.SelectedValue;
}
protected void DropDownList2_SelectedIndexChanged(object sender, EventArgs e)
{
DropDownList dr = (DropDownList)FormView1.FindControl("DropDownList2");
SqlDataSource1.InsertParameters[7].DefaultValue = dr.SelectedValue;
}
protected void DropDownList3_SelectedIndexChanged(object sender, EventArgs e)
{
DropDownList dr = (DropDownList)FormView1.FindControl("DropDownList3");
SqlDataSource1.InsertParameters[8].DefaultValue = dr.SelectedValue;
}
protected void DropDownList4_SelectedIndexChanged(object sender, EventArgs e)
{
DropDownList dr = (DropDownList)FormView1.FindControl("DropDownList4");
SqlDataSource1.InsertParameters[10].DefaultValue = dr.SelectedValue;
}
protected void FormView1_ItemInserting(object sender, FormViewInsertEventArgs e)
{
if (SqlDataSource1.InsertParameters[1].DefaultValue == null)
{
DropDownList dr = (DropDownList)FormView1.FindControl("DropDownList1");
SqlDataSource1.InsertParameters[1].DefaultValue = dr.Text;
}
if (SqlDataSource1.InsertParameters[7].DefaultValue == null)
{
DropDownList dr = (DropDownList)FormView1.FindControl("DropDownList2");
SqlDataSource1.InsertParameters[7].DefaultValue = dr.Text;
}
if (SqlDataSource1.InsertParameters[8].DefaultValue == null)
{
DropDownList dr = (DropDownList)FormView1.FindControl("DropDownList3");
SqlDataSource1.InsertParameters[8].DefaultValue = dr.Text;
}
if (SqlDataSource1.InsertParameters[10].DefaultValue == null)
{
DropDownList dr = (DropDownList)FormView1.FindControl("DropDownList4");
SqlDataSource1.InsertParameters[10].DefaultValue = dr.Text;
}
}
protected void FormView1_ItemInserted(object sender, FormViewInsertedEventArgs e)
{
Response.Write("<script>alert('插入成功,请继续添加');</script>");
}
}
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="addSer.aspx.cs" Inherits="addSer" %>
<!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>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:gpCustomerConnectionString %>"
DeleteCommand="DELETE FROM [mendRecordTable] WHERE [mendFileId] = @mendFileId"
InsertCommand="INSERT INTO [mendRecordTable] ([creatTime], [creatEmployId], [proId], [proCode], [customerId], [stateBeforeMend], [mendRecord], [mendEmployId], [quchEmployId], [outTime], [outDoEmployId], [receiveCom], [receiveMen], [receiveAdd], [receiveTel], [outDemo]) VALUES (@creatTime, @creatEmployId, @proId, @proCode, @customerId, @stateBeforeMend, @mendRecord, @mendEmployId, @quchEmployId, @outTime, @outDoEmployId, @receiveCom, @receiveMen, @receiveAdd, @receiveTel, @outDemo)"
SelectCommand="SELECT * FROM [mendRecordTable]" UpdateCommand="UPDATE [mendRecordTable] SET [creatTime] = @creatTime, [creatEmployId] = @creatEmployId, [proId] = @proId, [proCode] = @proCode, [customerId] = @customerId, [stateBeforeMend] = @stateBeforeMend, [mendRecord] = @mendRecord, [mendEmployId] = @mendEmployId, [quchEmployId] = @quchEmployId, [outTime] = @outTime, [outDoEmployId] = @outDoEmployId, [receiveCom] = @receiveCom, [receiveMen] = @receiveMen, [receiveAdd] = @receiveAdd, [receiveTel] = @receiveTel, [outDemo] = @outDemo WHERE [mendFileId] = @mendFileId">
<DeleteParameters>
<asp:Parameter Name="mendFileId" Type="Int32" />
</DeleteParameters>
<UpdateParameters>
<asp:Parameter Name="creatTime" Type="DateTime" />
<asp:Parameter Name="creatEmployId" Type="String" />
<asp:Parameter Name="proId" Type="String" />
<asp:Parameter Name="proCode" Type="String" />
<asp:Parameter Name="customerId" Type="String" />
<asp:Parameter Name="stateBeforeMend" Type="String" />
<asp:Parameter Name="mendRecord" Type="String" />
<asp:Parameter Name="mendEmployId" Type="String" />
<asp:Parameter Name="quchEmployId" Type="String" />
<asp:Parameter Name="outTime" Type="DateTime" />
<asp:Parameter Name="outDoEmployId" Type="String" />
<asp:Parameter Name="receiveCom" Type="String" />
<asp:Parameter Name="receiveMen" Type="String" />
<asp:Parameter Name="receiveAdd" Type="String" />
<asp:Parameter Name="receiveTel" Type="String" />
<asp:Parameter Name="outDemo" Type="String" />
<asp:Parameter Name="mendFileId" Type="Int32" />
</UpdateParameters>
<InsertParameters>
<asp:Parameter Name="creatTime" Type="DateTime" />
<asp:Parameter Name="creatEmployId" Type="String" />
<asp:Parameter Name="proId" Type="String" />
<asp:Parameter Name="proCode" Type="String" />
<asp:Parameter Name="customerId" Type="String" />
<asp:Parameter Name="stateBeforeMend" Type="String" />
<asp:Parameter Name="mendRecord" Type="String" />
<asp:Parameter Name="mendEmployId" Type="String" />
<asp:Parameter Name="quchEmployId" Type="String" />
<asp:Parameter Name="outTime" Type="DateTime" />
<asp:Parameter Name="outDoEmployId" Type="String" />
<asp:Parameter Name="receiveCom" Type="String" />
<asp:Parameter Name="receiveMen" Type="String" />
<asp:Parameter Name="receiveAdd" Type="String" />
<asp:Parameter Name="receiveTel" Type="String" />
<asp:Parameter Name="outDemo" Type="String" />
</InsertParameters>
</asp:SqlDataSource>
</div>
<asp:FormView ID="FormView1" runat="server" DefaultMode="Insert" DataKeyNames="mendFileId" DataSourceID="SqlDataSource1" OnItemInserting="FormView1_ItemInserting" Width="360px" OnItemInserted="FormView1_ItemInserted">
<EditItemTemplate>
mendFileId:
<asp:TextBox ID="mendFileIdTextBox1" runat="server" Text='<%# Eval("mendFileId") %>'>
</asp:TextBox><br />
creatTime:
<asp:TextBox ID="creatTimeTextBox" runat="server" Text='<%# Bind("creatTime") %>'>
</asp:TextBox><br />
creatEmployId:
<asp:TextBox ID="creatEmployIdTextBox" runat="server" Text='<%# Bind("creatEmployId") %>'>
</asp:TextBox><br />
proId:
<asp:TextBox ID="proIdTextBox" runat="server" Text='<%# Bind("proId") %>'>
</asp:TextBox><br />
proCode:
<asp:TextBox ID="proCodeTextBox" runat="server" Text='<%# Bind("proCode") %>'>
</asp:TextBox><br />
customerId:
<asp:TextBox ID="customerIdTextBox" runat="server" Text='<%# Bind("customerId") %>'>
</asp:TextBox><br />
stateBeforeMend:
<asp:TextBox ID="stateBeforeMendTextBox" runat="server" Text='<%# Bind("stateBeforeMend") %>'>
</asp:TextBox><br />
mendRecord:
<asp:TextBox ID="mendRecordTextBox" runat="server" Text='<%# Bind("mendRecord") %>'>
</asp:TextBox><br />
mendEmployId:
<asp:TextBox ID="mendEmployIdTextBox" runat="server" Text='<%# Bind("mendEmployId") %>'>
</asp:TextBox><br />
quchEmployId:
<asp:TextBox ID="quchEmployIdTextBox" runat="server" Text='<%# Bind("quchEmployId") %>'>
</asp:TextBox><br />
outTime:
<asp:TextBox ID="outTimeTextBox" runat="server" Text='<%# Bind("outTime") %>'>
</asp:TextBox><br />
outDoEmployId:
<asp:TextBox ID="outDoEmployIdTextBox" runat="server" Text='<%# Bind("outDoEmployId") %>'>
</asp:TextBox><br />
receiveCom:
<asp:TextBox ID="receiveComTextBox" runat="server" Text='<%# Bind("receiveCom") %>'>
</asp:TextBox><br />
receiveMen:
<asp:TextBox ID="receiveMenTextBox" runat="server" Text='<%# Bind("receiveMen") %>'>
</asp:TextBox><br />
receiveAdd:
<asp:TextBox ID="receiveAddTextBox" runat="server" Text='<%# Bind("receiveAdd") %>'>
</asp:TextBox><br />
receiveTel:
<asp:TextBox ID="receiveTelTextBox" runat="server" Text='<%# Bind("receiveTel") %>'>
</asp:TextBox><br />
outDemo:
<asp:TextBox ID="outDemoTextBox" runat="server" Text='<%# Bind("outDemo") %>'>
</asp:TextBox><br />
<asp:LinkButton ID="UpdateButton" runat="server" CausesValidation="True" CommandName="Update"
Text="更新">
</asp:LinkButton>
<asp:LinkButton ID="UpdateCancelButton" runat="server" CausesValidation="False" CommandName="Cancel"
Text="取消">
</asp:LinkButton>
</EditItemTemplate>
<InsertItemTemplate>
<table>
<tr><td> 建档日期:</td><td>
<asp:TextBox ID="creatTimeTextBox" runat="server" Text='<%# Bind("creatTime") %>'>
</asp:TextBox></td></tr>
<tr><td> 建档人工号:</td><td>
<asp:DropDownList ID="DropDownList1" runat="server" DataSourceID="SqlDataSource2" DataTextField="Name" DataValueField="employId" OnSelectedIndexChanged="DropDownList1_SelectedIndexChanged" >
</asp:DropDownList></td></tr>
<tr><td> 产品ID:</td><td>
<asp:TextBox ID="proIdTextBox" runat="server" Text='<%# Bind("proId") %>'>
</asp:TextBox></td></tr>
<tr><td> 产品编号:</td><td>
<asp:TextBox ID="proCodeTextBox" runat="server" Text='<%# Bind("proCode") %>'>
</asp:TextBox></td></tr>
<tr><td> 客户ID:</td><td>
<asp:TextBox ID="customerIdTextBox" runat="server" Text='<%# Bind("customerId") %>'>
</asp:TextBox></td></tr>
<tr><td> 维修前情况:</td><td>
<asp:TextBox ID="stateBeforeMendTextBox" runat="server" Text='<%# Bind("stateBeforeMend") %>' TextMode="MultiLine">
</asp:TextBox></td></tr>
<tr><td> 维修记录:</td><td>
<asp:TextBox ID="mendRecordTextBox" runat="server" Text='<%# Bind("mendRecord") %>' TextMode="MultiLine">
</asp:TextBox></td></tr>
<tr><td> 维修人工号:</td><td>
<asp:DropDownList ID="DropDownList2" runat="server" DataSourceID="SqlDataSource2" DataTextField="Name" DataValueField="employId" OnSelectedIndexChanged="DropDownList2_SelectedIndexChanged" >
</asp:DropDownList></td></tr>
<tr><td>质检人工号:</td><td><asp:DropDownList ID="DropDownList3" runat="server" DataSourceID="SqlDataSource2" DataTextField="Name" DataValueField="employId" OnSelectedIndexChanged="DropDownList3_SelectedIndexChanged" >
</asp:DropDownList>
</td></tr>
<tr><td>发货日期:</td><td>
<asp:TextBox ID="outTimeTextBox" runat="server" Text='<%# Bind("outTime") %>'>
</asp:TextBox></td></tr>
<tr><td> 发货经办人工号:</td><td><asp:DropDownList ID="DropDownList4" runat="server" DataSourceID="SqlDataSource2" DataTextField="Name" DataValueField="employId" OnSelectedIndexChanged="DropDownList4_SelectedIndexChanged" >
</asp:DropDownList>
</td></tr>
<tr><td> 收货单位 :</td><td>
<asp:TextBox ID="receiveComTextBox" runat="server" Text='<%# Bind("receiveCom") %>'>
</asp:TextBox></td></tr>
<tr><td>收货人:</td><td>
<asp:TextBox ID="receiveMenTextBox" runat="server" Text='<%# Bind("receiveMen") %>'>
</asp:TextBox></td></tr>
<tr><td> 收货人地址:</td><td>
<asp:TextBox ID="receiveAddTextBox" runat="server" Text='<%# Bind("receiveAdd") %>'>
</asp:TextBox></td></tr>
<tr><td>收货人电话:</td><td>
<asp:TextBox ID="receiveTelTextBox" runat="server" Text='<%# Bind("receiveTel") %>'>
</asp:TextBox></td></tr>
<tr><td>发货备注:</td><td>
<asp:TextBox ID="outDemoTextBox" runat="server" Text='<%# Bind("outDemo") %>' TextMode="MultiLine">
</asp:TextBox></td></tr>
<asp:LinkButton ID="InsertButton" runat="server" CausesValidation="True" CommandName="Insert"
Text="插入">
</asp:LinkButton><asp:LinkButton ID="InsertCancelButton" runat="server" CausesValidation="False" CommandName="Cancel"
Text="取消">
</asp:LinkButton></table>
</InsertItemTemplate>
<ItemTemplate>
mendFileId:
<asp:TextBox ID="mendFileIdTextBox" runat="server" Text='<%# Eval("mendFileId") %>'>
</asp:TextBox><br />
creatTime:
<asp:TextBox ID="creatTimeTextBox" runat="server" Text='<%# Bind("creatTime") %>'></asp:TextBox><br />
creatEmployId:
<asp:TextBox ID="creatEmployIdTextBox" runat="server" Text='<%# Bind("creatEmployId") %>'>
</asp:TextBox><br />
proId:
<asp:TextBox ID="proIdTextBox" runat="server" Text='<%# Bind("proId") %>'></asp:TextBox><br />
proCode:
<asp:TextBox ID="proCodeTextBox" runat="server" Text='<%# Bind("proCode") %>'></asp:TextBox><br />
customerId:
<asp:TextBox ID="customerIdTextBox" runat="server" Text='<%# Bind("customerId") %>'>
</asp:TextBox><br />
stateBeforeMend:
<asp:TextBox ID="stateBeforeMendTextBox" runat="server" Text='<%# Bind("stateBeforeMend") %>'>
</asp:TextBox><br />
mendRecord:
<asp:TextBox ID="mendRecordTextBox" runat="server" Text='<%# Bind("mendRecord") %>'>
</asp:TextBox><br />
mendEmployId:
<asp:TextBox ID="mendEmployIdTextBox" runat="server" Text='<%# Bind("mendEmployId") %>'>
</asp:TextBox><br />
quchEmployId:
<asp:TextBox ID="quchEmployIdTextBox" runat="server" Text='<%# Bind("quchEmployId") %>'>
</asp:TextBox><br />
outTime:
<asp:TextBox ID="outTimeTextBox" runat="server" Text='<%# Bind("outTime") %>'></asp:TextBox><br />
outDoEmployId:
<asp:TextBox ID="outDoEmployIdTextBox" runat="server" Text='<%# Bind("outDoEmployId") %>'>
</asp:TextBox><br />
receiveCom:
<asp:TextBox ID="receiveComTextBox" runat="server" Text='<%# Bind("receiveCom") %>'>
</asp:TextBox><br />
receiveMen:
<asp:TextBox ID="receiveMenTextBox" runat="server" Text='<%# Bind("receiveMen") %>'>
</asp:TextBox><br />
receiveAdd:
<asp:TextBox ID="receiveAddTextBox" runat="server" Text='<%# Bind("receiveAdd") %>'>
</asp:TextBox><br />
receiveTel:
<asp:TextBox ID="receiveTelTextBox" runat="server" Text='<%# Bind("receiveTel") %>'>
</asp:TextBox><br />
outDemo:
<asp:TextBox ID="outDemoTextBox" runat="server" Text='<%# Bind("outDemo") %>'></asp:TextBox><br />
<asp:LinkButton ID="EditButton" runat="server" CausesValidation="False" CommandName="Edit"
Text="编辑">
</asp:LinkButton>
<asp:LinkButton ID="DeleteButton" runat="server" CausesValidation="False" CommandName="Delete"
Text="删除">
</asp:LinkButton>
<asp:LinkButton ID="NewButton" runat="server" CausesValidation="False" CommandName="New"
Text="新建">
</asp:LinkButton>
</ItemTemplate>
</asp:FormView>
<asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:gpCustomerConnectionString %>"
SelectCommand="SELECT * FROM [employTable]"></asp:SqlDataSource>
<br />
</form>
</body>
</html>