新手测试题目的add.aspx与add.cs的内容。

add.aspx的内容:

 

 

 

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="add.aspx.cs" Inherits="add" %>
<!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>
    <link href="style.css" rel="stylesheet" type="text/css" />
   
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <table border="0" cellpadding="0" cellspacing="0" style="width: 760px; position: relative;
            text-align: center">
        
            <tr>
                <td style="height: 476px">
                    <table border="0" cellpadding="0" cellspacing="0" style="width: 100%; position: relative;
                        height: 94%; border-right: activeborder 1px solid; border-top: activeborder 1px solid; left: 0px; border-left: activeborder 1px solid; border-bottom: activeborder 1px solid; top: 0px;">
                        <tr>
                            <td colspan="2" style="font-weight: bold; color: red; height: 32px" align="left">
                                &nbsp;&nbsp;添加新记录</td>
                        </tr>
                        <tr>
                            <td style="width: 111px; text-align: right; height: 29px;">
                                &nbsp;项目名:</td>
                            <td style="text-align: left; height: 29px;">
                                <asp:TextBox ID="txtUserName" runat="server" Style="position: relative"></asp:TextBox></td>
                        </tr>
                        <tr>
                            <td style="width: 111px; text-align: right; height: 29px;">
                                客户:</td>
                            <td style="text-align: left; height: 29px;">
                                <asp:TextBox ID="txtcustomer" runat="server" Style="position: relative"></asp:TextBox>
                                </td>
                        </tr>
                        <tr>
                            <td style="width: 111px; text-align: right">
                                状态:</td>
                            <td style="text-align: left" height="29">
                                <asp:RadioButton ID="rbtnNv" runat="server"
                                    Checked="True" GroupName="sex" Style="position: relative" Text="完成" />
                                <asp:RadioButton ID="rbtnNan" runat="server"
                                    GroupName="sex" Style="position: relative" Text="进行中" /></td>
                        </tr>
                        <tr>
                            <td style="width: 111px; text-align: right; height: 29px;">
                                完成日期:</td>
                            <td style="text-align: left; height: 29px;">
                                <asp:TextBox ID="txtDate" runat="server" Style="position: relative"></asp:TextBox></td>
                        </tr>
                        <tr>
                            <td style="width: 111px; height: 15px; text-align: right">
                                描述:</td>
                            <td style="text-align: left" height="29">
                                <asp:TextBox ID="txtRemark" runat="server" Style="position: relative"></asp:TextBox></td>
                        </tr>
                       
                       
                        <tr>
                            <td style="width: 111px; height: 32px; text-align: right" valign="top">
                            </td>
                            <td style="height: 32px; text-align: left">
                                &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
                                <asp:Button ID="Button1" runat="server" Style="position: relative" Text="添加" OnClick="Button1_Click" Width="51px" />
                                &nbsp; &nbsp;
                                <asp:Button ID="Button2" runat="server" Style="position: relative" Text="清空" OnClick="Button2_Click" Width="52px" />
                                 &nbsp; &nbsp;
                                <asp:Button ID="Button3" runat="server" Style="position: relative" οnclick="Button3_Click" Text="返回" Width="52px" />
                            </td>
                        </tr>
                    </table>
                </td>
            </tr>
       
        </table>
   
    </div>
    </form>
</body>
</html>

 

 

 

 

add.cs的内容:

 

 

public partial class add : System.Web.UI.Page
{
   
    protected void Page_Load(object sender, EventArgs e)
    {
       
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        string Staus;
        string ProjName = this.txtUserName.Text;
        string Customer = this.txtcustomer.Text;
        string CompleteDate = this.txtDate.Text;
        string Remark = this.txtRemark.Text;


        if (this.rbtnNv.Checked == true)
        {
            Staus = "true";
        }
        else
        {
            Staus = "false";
        }
       
        SqlConnection conn = DB.createCon();
        SqlCommand cmd = new SqlCommand();
        cmd.Connection = conn;
        cmd.CommandText = "insert into Prjinfo(ProjName,Customer,Staus,CompleteDate,Remark) values('" + ProjName + "','" + Customer + "','" + Staus + "','" + CompleteDate + "','" + Remark + "')";
        if (cmd.ExecuteNonQuery() > 0)
        {
            Response.Write("<script>alert('添加成功!');location.href='default.aspx';</script>");
        }
        else
        {
            Response.Write("<script>alert('添加失败!');window.location = window.location;</script>");
        }
    }
 
   
    protected void Button2_Click(object sender, EventArgs e)
    {
        this.txtUserName.Text = "";
        this.txtcustomer.Text = "";
        this.txtRemark.Text = "";
        this.txtDate.Text = "";
       
    }
    protected void Button3_Click(object sender, EventArgs e)
    {
        Response.Write("<script>location.href='default.aspx';</script>");
    }
}

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值