添加代码问题
想在系统考勤页面添加数据,其中休假分类这个字段是在表:休假表中,和其它字段都在考勤表中,这应该怎么添加啊,public partial class adminmofiy : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
} protected void btn_modify_Click(object sender, EventArgs e)
{
if (Page.IsValid)
{
string str = ConfigurationSettings.AppSettings["dsn"];
SqlConnection cn = new SqlConnection(str);
cn.Open();
string mysql = " insert from kaoqin,xiujia SET kid='" + T_kid.Text + "',uid='" + T_kid.Text + "',uname = '" + T_aname.Text + "', xid='"+Textbox2.text+"',lx='"+Textbox1.text+"')";
SqlCommand cm = new SqlCommand(mysql, cn);
cm.ExecuteNonQuery();
cn.Close();
Response.Redirect("kqmanage.aspx");
}
}
protected void btn_detele_Click(object sender, EventArgs e)
{
if (Page.IsValid)
{
string str = ConfigurationSettings.AppSettings["dsn"];
SqlConnection cn = new SqlConnection(str);
cn.Open();
string mysql = "delete kaoqin WHERE (kid = '" + T_kid.Text + "') ";
SqlCommand cm = new SqlCommand(mysql, cn);
cm.ExecuteNonQuery();
cn.Close();
Response.Redirect("kqmanage.aspx");
}
}
不知道代码对不对啊。
<form id="form1" runat="server">
<div>
<asp:Table ID="Table1" runat="server" Height="109px" Style="z-index: 100; left: 30px;
position: absolute; top: 10px" Width="656px">
<asp:TableRow runat="server">
<asp:TableCell runat="server"><asp:Label ID="Label1" runat="server" Style="z-index: 102; left: 203px; position: absolute;
top: 44px" Text="考勤管理系统" Width="216px" Font-Size="20pt"></asp:Label>
</asp:TableCell>
</asp:TableRow>
<asp:TableRow runat="server">
<asp:TableCell runat="server"><asp:Label ID="Label2" runat="server" Style="z-index: 102; left: 253px; position: absolute;
top: 80px" Text="-----考勤管理" Width="154px"></asp:Label>
</asp:TableCell>
</asp:TableRow>
</asp:Table>
<asp:Table ID="Table2" runat="server" Height="280px" Style="z-index: 101; left: 24px;
position: absolute; top: 119px" Width="662px">
<asp:TableRow runat="server">
<asp:TableCell runat="server"></asp:TableCell>
</asp:TableRow>
</asp:Table>
<asp:Table ID="Table4" runat="server" Height="312px" Style="z-index: 102; left: 132px;
position: absolute; top: 122px" Width="545px">
</asp:Table>
<asp:TextBox ID="TextBox2" runat="server" Style="z-index: 103; left: 368px; position: absolute;
top: 123px" Width="75px"></asp:TextBox>
<asp:Label ID="Label7" runat="server" Height="21px" Style="z-index: 104; left: 318px;
position: absolute; top: 124px" Text="姓名:" Width="48px"></asp:Label>
<asp:Button ID="Button1" runat="server" Style="z-index: 105; left: 454px; position: absolute;
top: 122px" Text="查询" OnClick="Button1_Click" />
<asp:LinkButton ID="LinkButton8" runat="server" Height="24px" Style="z-index: 106;
left: 526px; position: absolute; top: 127px">添加员工考勤信息</asp:LinkButton>
<asp:GridView ID="GridView1" runat="server" AllowPaging="True" AllowSorting="True"
AutoGenerateColumns="False" BackColor="White" BorderColor="#CC9966" BorderStyle="None"
BorderWidth="1px" CellPadding="4" DataSourceID="SqlDataSource1"
onpageindexchanging="GridView1_PageIndexChanging" PageSize="5" Style="z-index: 107;
left: 140px; position: absolute; top: 148px" Width="396px" HorizontalAlign="Left">
<FooterStyle BackColor="#FFFFCC" ForeColor="#330099" />
<Columns>
<asp:BoundField DataField="kid" HeaderText="考勤编号" ReadOnly="True" SortExpression="kid" />
<asp:BoundField DataField="uid" HeaderText="用户编号" SortExpression="uid" />
<asp:BoundField DataField="uname" HeaderText="用户姓名" SortExpression="uname" />
<asp:BoundField DataField="kqdate" HeaderText="考勤日期" SortExpression="kqdate" />
<asp:BoundField DataField="dgdate" HeaderText="到岗日期" SortExpression="dgdate" />
<asp:BoundField DataField="sj" HeaderText="事假" SortExpression="sj" />
<asp:BoundField DataField="bj" HeaderText="病假" SortExpression="bj" />
<asp:BoundField DataField="gj" HeaderText="公假" SortExpression="gj" />
<asp:BoundField DataField="kg" HeaderText="旷工" SortExpression="kg" />
<asp:BoundField DataField="cq" HeaderText="出勤" SortExpression="cq" />
<asp:BoundField DataField="hj" HeaderText="婚嫁" SortExpression="hj" />
<asp:BoundField DataField="sj1" HeaderText="丧假" SortExpression="sj1" />
<asp:BoundField DataField="gxj" HeaderText="干休假" SortExpression="gxj" />
<asp:BoundField DataField="tqj" HeaderText="探亲假" SortExpression="tqj" />
<asp:BoundField DataField="pc" HeaderText="陪产假" SortExpression="pc" />
<asp:BoundField DataField="cc" HeaderText="出差" SortExpression="cc" />
<asp:BoundField DataField="dx" HeaderText="倒休" SortExpression="dx" />
<asp:CommandField ShowEditButton="True" />
<asp:CommandField ShowDeleteButton="True" />
</Columns>
<RowStyle BackColor="White" ForeColor="#330099" />
<SelectedRowStyle BackColor="#FFCC66" Font-Bold="True" ForeColor="#663399" />
<PagerStyle BackColor="#FFFFCC" ForeColor="#330099" HorizontalAlign="Center" />
<HeaderStyle BackColor="#990000" Font-Bold="True" ForeColor="#FFFFCC" />
</asp:GridView>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:kqConnectionString %>"
SelectCommand="SELECT [kid], [uid], [uname], [kqdate], [dgdate], [cq], [sj], [bj], [gj], [kg], [hj], [sj1], [gxj], [tqj], [pc], [cc], [dx] FROM [kaoqin]" DeleteCommand="DELETE FROM [kaoqin] WHERE [kid] = @kid" InsertCommand="INSERT INTO [kaoqin] ([kid], [uid], [uname], [kqdate], [dgdate], [cq], [sj], [bj], [gj], [kg], [hj], [sj1], [gxj], [tqj], [pc], [cc], [dx]) VALUES (@kid, @uid, @uname, @kqdate, @dgdate, @cq, @sj, @bj, @gj, @kg, @hj, @sj1, @gxj, @tqj, @pc, @cc, @dx)" UpdateCommand="UPDATE [kaoqin] SET [uid] = @uid, [uname] = @uname, [kqdate] = @kqdate, [dgdate] = @dgdate, [cq] = @cq, [sj] = @sj, [bj] = @bj, [gj] = @gj, [kg] = @kg, [hj] = @hj, [sj1] = @sj1, [gxj] = @gxj, [tqj] = @tqj, [pc] = @pc, [cc] = @cc, [dx] = @dx WHERE [kid] = @kid">
</asp:SqlDataSource>
<asp:Table ID="Table3" runat="server" Height="368px" Style="z-index: 109; left: 26px;
position: absolute; top: 125px" Width="112px" HorizontalAlign="Left" GridLines="Horizontal">
<asp:TableRow runat="server">
<asp:TableCell runat="server" Height="20px" HorizontalAlign="Center" VerticalAlign="Middle">
<asp:LinkButton ID="LinkButton1" runat="server" PostBackUrl="adminmassage.aspx">人员管理信息</asp:LinkButton>
</asp:TableCell>
休假分类指的就是“事假,出勤啊等。