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

change.aspx的内容:

 

 

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="change.aspx.cs" Inherits="change" %>
<!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 id="Head1" 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="changeName" 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="changecustomer" 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="changestaus" runat="server"
                                    Checked="True" GroupName="staus" Style="position: relative" Text="完成" />
                                <asp:RadioButton ID="changestaus2" runat="server"
                                    GroupName="staus" 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="changeDate" 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="changeRemark" 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>

 

 

 

 

 

change.cs的内容:

 

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;
using System.Data.SqlClient;


public partial class change : System.Web.UI.Page
{
  
    string username;
    int userID;
    string Staus;
    protected void Page_Load(object sender, EventArgs e)
    {
        username = Request.QueryString["username"];
        userID = Convert.ToInt32(username);
        if (!IsPostBack)
        {
            Boolean mystring;
            SqlConnection nowcon = DB.createCon();
            SqlCommand nowcmd = new SqlCommand();
            nowcmd.Connection = nowcon;
            nowcmd.CommandText = " Select * from Prjinfo  WHERE ID='" + userID + "'";
            SqlDataAdapter sda = new SqlDataAdapter();
            sda.SelectCommand = nowcmd;
            DataSet ds = new DataSet();
            sda.Fill(ds, "Prjinfo");
            changeName.Text = ds.Tables["Prjinfo"].Rows[0].ItemArray[1].ToString();
            changecustomer.Text = ds.Tables["Prjinfo"].Rows[0].ItemArray[2].ToString();
            changeDate.Text = ds.Tables["Prjinfo"].Rows[0].ItemArray[4].ToString();
             mystring= Convert.ToBoolean(ds.Tables["Prjinfo"].Rows[0].ItemArray[3].ToString());
            changeRemark.Text = ds.Tables["Prjinfo"].Rows[0].ItemArray[5].ToString();
            if (mystring)
            {
                changestaus.Checked = true;
            }
            else
            {
                changestaus2.Checked = true;
            }

        }

    }
    protected void Button1_Click(object sender, EventArgs e)
    {
            ///string Staus;
            string ProjName = this.changeName.Text;
            string Customer = this.changecustomer.Text;
            string CompleteDate = this.changeDate.Text;
            string Remark = this.changeRemark.Text;

            if (this.changestaus.Checked == true)
            {
                Staus = "true";

            }
            else
            {
                Staus = "false";
            }

            SqlConnection conn = DB.createCon();
            SqlCommand cmd = new SqlCommand();
            cmd.Connection = conn;
            cmd.CommandText = "Update Prjinfo Set ProjName='" + ProjName + "',Staus='" + Staus + "',Customer='" + Customer + "',CompleteDate='" + CompleteDate + "',Remark='" + Remark + "' WHERE ID='" + userID + "'";
            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.changeName.Text = "";
        this.changecustomer.Text = "";
        this.changeRemark.Text = "";
        this.changeDate.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、付费专栏及课程。

余额充值