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">
修改记录</td>
</tr>
<tr>
<td style="width: 111px; text-align: right; height: 29px;" >
项目名:</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">
<asp:Button ID="Button1" runat="server" Style="position: relative" Text="修改" OnClick="Button1_Click" Width="51px" />
<asp:Button ID="Button2" runat="server" Style="position: relative" Text="清空" OnClick="Button2_Click" Width="52px" />
<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>");
}
}