<%@ Page Language="C#" AutoEventWireup="true" CodeFile="ZhuanJiaModify.aspx.cs" Inherits="ZhuanJia_ZhuanJiaModify" %>
<!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="../javascript/x.css" rel="stylesheet" type="text/css">
<link href="../StyleSheet.css" rel="stylesheet" type="text/css">
<script language="javascript" src="../javascript/Area.aspx"></script>
<script language="javascript" src="../javascript/Area.js"></script>
</head>
<body>
<script language="JavaScript" src="../javascript/calendar.js"></script>
<form id="form1" runat="server">
<table border="0" cellpadding="5" cellspacing="0" width="100%">
<tr>
<td>
</td>
<td align="right" bgcolor="#009900" width="100">
<strong><span style="color: #ffffff">
<img align="absMiddle" src="../Images/2.gif" style="font-size: 9pt" />
<span style="font-size: 9pt"><span style="font-size: 8pt">修改信息</span><span> </span></span>
</span></strong>
<img align="absMiddle" height="9" src="../Images/sanjiaotwo.gif" style="font-size: 9pt"
width="10" /></td>
</tr>
</table>
<table border="0" cellpadding="0" cellspacing="0" style="width: 100%">
<tr>
<td bgcolor="#ffffff">
</td>
</tr>
<tr>
<td bgcolor="#4e5a7e">
</td>
</tr>
<tr>
<td bgcolor="#ffffff">
</td>
</tr>
</table>
<table border="0" cellpadding="4" cellspacing="0" width="100%">
<tr>
<td bgcolor="#4e5a7e" colspan="2" style="height: 18px" valign="bottom">
<span style="font-size: 9pt; color: #ffffff; font-family: Times New Roman"><strong>修改信息</strong></span></td>
</tr>
</table>
<table bgcolor="#f3f7fa" border="0" cellpadding="5" style="font-size: 100%; font-family: Verdana"
width="100%" cellspacing="0">
<tr>
<td align="right" colspan="6" style="text-align: center; width: 972px;">
</td>
</tr>
</table>
<table bgcolor="#f3f7fa" border="0" cellpadding="5" style="font-size: 100%; font-family: Verdana"
width="100%" cellspacing="0">
<tr style="font-size: 9pt">
<td align="right" style="width: 250px;">
姓名</td>
<td align="left" colspan="3" style="width: 149px;">
<asp:TextBox ID="NameTextBox" runat="server"></asp:TextBox></td>
<td align="left" colspan="1" style="width: 12px;">
<asp:RequiredFieldValidator ID="NameValidator" runat="server" ControlToValidate="NameTextBox"
ErrorMessage="*" SetFocusOnError="True" Width="1px"></asp:RequiredFieldValidator></td>
<td align="right" style="width: 250px;">
性别</td>
<td style="width: 149px;">
<asp:DropDownList ID="ddlSex" runat="server" Width="46px">
<asp:ListItem Value="男">男</asp:ListItem>
<asp:ListItem Value="男">女</asp:ListItem>
</asp:DropDownList></td>
<td style="width: 50px;">
</td>
<td style="width: 250px; text-align: right;" rowspan="4">
原照片</td>
<td style="width: 575px;" rowspan="4">
<img alt="暂无照片" src="ShowImage.aspx?ZhuanJiaID=<%=strZhuanJiaID %>" style="width: 89px;" height="120" /></td>
</tr>
<tr style="font-size: 9pt">
<td align="right" style="height: 24px">
出生日期</td>
<td align="left" colspan="3" style="height: 24px">
<asp:TextBox ID="BirthdayTextBox" runat="server"></asp:TextBox></td>
<td align="left" colspan="1" style="height: 24px">
</td>
<td align="right" style="height: 24px">
毕业院校</td>
<td style="height: 24px">
<asp:TextBox ID="SchoolTextBox" runat="server" ></asp:TextBox></td>
<td style="width: 50px; height: 24px;">
</td>
</tr>
<tr style="font-size: 9pt">
<td align="right" style="height: 23px">
最高学位</td>
<td align="left" colspan="3" style="height: 23px">
<asp:DropDownList ID="ddlEduLevel" runat="server">
<asp:ListItem Value="0">博士</asp:ListItem>
<asp:ListItem Value="1">硕士</asp:ListItem>
<asp:ListItem Value="6">学士</asp:ListItem>
<asp:ListItem>无</asp:ListItem>
</asp:DropDownList></td>
<td align="left" colspan="1" style="height: 23px">
</td>
<td align="right" style="height: 23px">
研究方向</td>
<td style="height: 23px">
<asp:TextBox ID="ResearchDirectionTextBox" runat="server"></asp:TextBox></td>
<td style="width: 50px; height: 23px">
</td>
</tr>
<tr style="font-size: 9pt">
<td align="right" style="height: 23px;">
职称</td>
<td align="left" colspan="3" style="height: 23px;">
<asp:TextBox ID="OfficialRankTextBox" runat="server" ></asp:TextBox></td>
<td align="left" colspan="1" style="height: 23px;">
</td>
<td align="right" style="height: 23px">
职务</td>
<td style="height: 23px;">
<asp:TextBox ID="JobTextBox" runat="server" ></asp:TextBox></td>
<td style="height: 23px; width: 50px;">
<asp:RequiredFieldValidator ID="JobValidator" runat="server" ControlToValidate="JobTextBox"
Display="Dynamic" ErrorMessage="*" SetFocusOnError="True" Width="1px"></asp:RequiredFieldValidator></td>
</tr>
<tr style="font-size: 9pt">
<td align="right">
工作单位</td>
<td align="left" colspan="3">
<asp:TextBox ID="UnitTextBox" runat="server"></asp:TextBox></td>
<td align="left" colspan="1">
</td>
<td align="right">
<div align="left" class="style3" style="text-align: right">
单位地址
</div>
</td>
<td >
<asp:TextBox ID="UnitAddrTextBox" runat="server"></asp:TextBox></td>
<td style="width: 50px">
</td>
<td style="text-align: right; width: 250px;">
<div align="left" class="style3" style="text-align: right">
修改照片</div>
</td>
<td style="width: 575px">
<asp:FileUpload ID="UploadPic" runat="server" /></td>
</tr>
<tr style="font-size: 9pt">
<td align="right" style="height: 23px;">
办公电话</td>
<td align="left" colspan="3" style="height: 23px;">
<asp:TextBox ID="UnitTelTextBox" runat="server"></asp:TextBox></td>
<td align="left" colspan="1" style="height: 23px;">
</td>
<td align="right" style="height: 23px">
个人电话</td>
<td style="height: 23px;">
<asp:TextBox ID="PrivateTelTextBox" runat="server" ></asp:TextBox></td>
<td style="height: 23px; width: 50px;">
</td>
<td style="height: 23px; text-align: right; width: 250px;">
<div align="left" class="style3" style="text-align: right">
所属区域</div>
</td>
<td style="height: 23px; width: 575px;">
<select id="s1" name="s1" onchange='changeselect2(this.value);document.all("Area").value = document.all("s1").value ;'>
<option selected="selected" value="">省及直辖市</option>
</select>
<select id="s2" name="s2" onchange='changeselect3(document.all("s1").value,this.value);document.all("Area").value = document.all("s2").value ;'>
<option selected="selected" value="">地市级县</option>
</select>
<select id="s3" name="s3" onchange='document.all("Area").value = document.all("s3").value ;'>
<option selected="selected" value="">地区</option>
</select>
<script language="javascript" type="text/javascript">
loadselect1(document.form1);
</script>
<asp:HiddenField ID="Area" runat="server" Value='<%# Bind("Area") %>' />
</td>
</tr>
<tr style="font-size: 9pt">
<td align="right" style="height: 23px">
工作简历
</td>
<td align="left" colspan="9" style="height: 23px">
<asp:TextBox ID="JobResumeTextBox" runat="server" Height="149px" TextMode="MultiLine" Width="80%"></asp:TextBox></td>
</tr>
<tr style="font-size: 9pt">
<td align="right" style="height: 23px">
获奖情况
</td>
<td align="left" colspan="9" style="height: 23px">
<asp:TextBox ID="PrizeTextBox" runat="server" Height="149px" TextMode="MultiLine" Width="80%"></asp:TextBox></td>
</tr>
<tr style="font-size: 9pt">
<td align="right" style="height: 23px">
学术论著</td>
<td align="left" colspan="9" style="height: 23px">
<asp:TextBox ID="DiscourseTextBox" runat="server" Height="149px" TextMode="MultiLine" Width="80%"></asp:TextBox></td>
</tr>
<tr style="font-size: 9pt">
<td align="right" style="height: 23px">
备注</td>
<td align="left" colspan="9" style="height: 23px">
<asp:TextBox ID="MemoTextBox" runat="server" Height="149px" TextMode="MultiLine" Width="80%"></asp:TextBox></td>
</tr>
</table>
<asp:Label ID="ScriptLabel" runat="server" Width="191px"></asp:Label><br />
<asp:Button ID="UpdateButton" runat="server" CausesValidation="True" CommandName="Update"
Text="修改" OnClick="UpdateButton_Click"></asp:Button> <input id="btnReurn" type="button" value="返回" onclick="location.href='ZhuanJiaManage.aspx'"/>
</form>
</body>
</html>
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;
using System.IO;
public partial class ZhuanJia_ZhuanJiaModify : System.Web.UI.Page
{
public static string strZhuanJiaID;
public static int nImageSize;
public static byte[] ImageData;
public SqlConnection myConn= new SqlConnection(ConfigurationManager.ConnectionStrings["food2ConnectionString"].ConnectionString);
public SqlCommand myCmd;
public SqlDataReader myReader;
protected void Page_Load(object sender, EventArgs e)
{
strZhuanJiaID = Page.Request.QueryString["ZhuanJiaID"];
BirthdayTextBox.Attributes.Add("onfocus","calendar()");
if (!IsPostBack)
{
myConn.Open();
myCmd = new SqlCommand("SELECT * FROM YJ_ZhuanJia WHERE ZhuanJiaID ='" + strZhuanJiaID + "'", myConn);
SqlDataReader myReader = myCmd.ExecuteReader();
if (myReader.Read())
{
if (Page.IsPostBack==false)
{
NameTextBox.Text = myReader["Name"].ToString();
ddlSex.SelectedValue = myReader["Sex"].ToString();
BirthdayTextBox.Text = myReader.GetDateTime(3).ToShortDateString();
nImageSize = (int)myReader["ImageSize"];//取出原来的照片大小
ImageData = (byte[])myReader["ImageData"];//取出原来照片数据
SchoolTextBox.Text = myReader["School"].ToString();
ddlEduLevel.SelectedItem.Text = myReader["EduLevel"].ToString();
OfficialRankTextBox.Text = myReader["OfficialRank"].ToString();
JobTextBox.Text = myReader["Job"].ToString();
ResearchDirectionTextBox.Text = myReader["ResearchDirection"].ToString();
UnitTextBox.Text = myReader["Unit"].ToString();
UnitAddrTextBox.Text = myReader["UnitAddr"].ToString();
UnitTelTextBox.Text = myReader["UnitTel"].ToString();
PrivateTelTextBox.Text = myReader["PrivateTel"].ToString();
JobResumeTextBox.Text = myReader["JobResume"].ToString();
PrizeTextBox.Text = myReader["Prize"].ToString();
DiscourseTextBox.Text = myReader["Discourse"].ToString();
MemoTextBox.Text = myReader["Memo"].ToString();
if (myReader["Area"].ToString() != "")//统计列数就从0开始计数
{
//给联动菜单定位
string strAreaNumber;
strAreaNumber = myReader["Area"].ToString();
string strAreaNumber1;
strAreaNumber1 = strAreaNumber.Substring(2, 2);
string strAreaNumber2;
strAreaNumber2 = strAreaNumber.Substring(4, 2);
ScriptLabel.Visible = true;
ScriptLabel.Text = "<script>changeselect2('410000');document.all(/"s1/").value='410000';changeselect3(document.all(/"s1/").value,'41" + strAreaNumber1 + "00');document.all(/"s2/").value='41" + strAreaNumber1 + "00';document.all(/"s3/").value='" + strAreaNumber + "'</script>";
Area.Value = strAreaNumber;
}
}
}
myReader.Close();
myConn.Close();
}
}
protected void UpdateButton_Click(object sender, EventArgs e)
{
//得到用户要上传的文件名
int FileLength = UploadPic.PostedFile.ContentLength;
//上传文件
//图象文件临时储存Byte数组
Byte[] FileByteArray = new Byte[FileLength];
//建立数据流对像
Stream StreamObject = UploadPic.PostedFile.InputStream;
//读取图象文件数据,FileByteArray为数据储存体,0为数据指针位置、FileLnegth为数据长度
StreamObject.Read(FileByteArray, 0, FileLength);
//建立SQL Server链接
string sqlUpdate = "update YJ_ZhuanJia set Name=@Name,Sex=@Sex,Birthday=@Birthday,ImageData=@ImageData,ImageSize=@ImageSize,School=@School,EduLevel=@EduLevel,OfficialRank=@OfficialRank,Job=@Job,";
sqlUpdate += "ResearchDirection=@ResearchDirection,Unit=@Unit,UnitAddr=@UnitAddr,UnitTel=@UnitTel,PrivateTel=@PrivateTel,JobResume=@JobResume,Prize=@Prize,Discourse=@Discourse,Memo=@Memo,Area=@Area where ZhuanJiaID=@ZhuaJiaID";
myCmd = new SqlCommand(sqlUpdate, myConn);
myCmd.Parameters.Add("@Name", SqlDbType.VarChar, 50).Value = NameTextBox.Text.ToString();
myCmd.Parameters.Add("@Sex", SqlDbType.VarChar, 50).Value = ddlSex.SelectedValue.ToString();
myCmd.Parameters.Add("@Birthday", SqlDbType.VarChar, 50).Value = BirthdayTextBox.Text.ToString();
myCmd.Parameters.Add("@School", SqlDbType.VarChar, 50).Value = SchoolTextBox.Text.ToString();
myCmd.Parameters.Add("@EduLevel", SqlDbType.VarChar, 50).Value = ddlEduLevel.SelectedItem.Text.ToString();
myCmd.Parameters.Add("@OfficialRank", SqlDbType.VarChar, 50).Value = OfficialRankTextBox.Text.ToString();
myCmd.Parameters.Add("@Job", SqlDbType.VarChar, 50).Value = JobTextBox.Text.ToString();
myCmd.Parameters.Add("@ResearchDirection", SqlDbType.VarChar, 50).Value = ResearchDirectionTextBox.Text.ToString();
myCmd.Parameters.Add("@Unit", SqlDbType.VarChar, 50).Value = UnitTextBox.Text.ToString();
myCmd.Parameters.Add("@UnitAddr", SqlDbType.VarChar, 50).Value = UnitAddrTextBox.Text.ToString();
myCmd.Parameters.Add("@UnitTel", SqlDbType.VarChar, 50).Value = UnitTelTextBox.Text.ToString();
myCmd.Parameters.Add("@PrivateTel", SqlDbType.VarChar, 50).Value = PrivateTelTextBox.Text.ToString();
myCmd.Parameters.Add("@JobResume", SqlDbType.NText, 2000).Value = JobResumeTextBox.Text.ToString();
myCmd.Parameters.Add("@Prize", SqlDbType.NText, 2000).Value = PrizeTextBox.Text.ToString();
myCmd.Parameters.Add("@Discourse", SqlDbType.NText, 2000).Value = DiscourseTextBox.Text.ToString();
myCmd.Parameters.Add("@Memo", SqlDbType.NText, 2000).Value = MemoTextBox.Text.ToString();
myCmd.Parameters.Add("@ZhuaJiaID", SqlDbType.Int, 4).Value = Convert.ToInt32(strZhuanJiaID);
myCmd.Parameters.Add("@Area", SqlDbType.VarChar, 50).Value = Area.Value.ToString();
if (UploadPic.HasFile)//判断是修改现有照片,若修改了,则上传新照片;否则还保存原照片
{
myCmd.Parameters.Add("@ImageData", SqlDbType.Binary, FileLength).Value = FileByteArray;
myCmd.Parameters.Add("@ImageSize", SqlDbType.BigInt, 8).Value = FileLength;
}
else
{
myCmd.Parameters.Add("@ImageData", SqlDbType.Binary, nImageSize).Value = ImageData;
myCmd.Parameters.Add("@ImageSize", SqlDbType.BigInt, 8).Value = nImageSize;
}
myConn.Open();
myCmd.ExecuteNonQuery();
myConn.Close();
//Response.Write("<script>alert('修改成功!');</script>");
Page.Response.Redirect("ZhuanJiaManage.aspx");
}
}