📄 accounts_useredit.aspx.cs
字号:
this.DropDownListProfessionalLevelID.SelectedIndex=0;
this.DropDownListState.SelectedIndex=0;
//this.DropDownListDepartmentID.SelectedIndex=0;
}
/// <summary>
/// 激活保存按钮及各输入框
/// </summary>
private void Stimulate()
{
this.TextBoxAddress.ReadOnly=false;
this.TextBoxContent.ReadOnly=false;
this.TextBoxEmail.ReadOnly=false;
this.TextBoxIDCard.ReadOnly=false;
this.TextBoxMobile.ReadOnly=false;
this.TextBoxNationality.ReadOnly=false;
this.TextBoxNativePlace.ReadOnly=false;
this.TextBoxSchool.ReadOnly=false;
this.TextBoxSpeciality.ReadOnly=false;
this.TextBoxTelephone.ReadOnly=false;
this.TextBoxUserName.ReadOnly=false;
this.TextBoxZipCode.ReadOnly=false;
this.DropDownListBirthdayD.Enabled=true;
this.DropDownListBirthdayM.Enabled=true;
this.DropDownListBirthdayY.Enabled=true;
this.DropDownListContractDateD.Enabled=true;
this.DropDownListContractDateM.Enabled=true;
this.DropDownListContractDateY.Enabled=true;
this.DropDownListContractEndDateD.Enabled=true;
this.DropDownListContractEndDateM.Enabled=true;
this.DropDownListContractEndDateY.Enabled=true;
//this.DropDownListDepartmentID.Enabled=true;
this.DropDownListIsMarried.Enabled=true;
this.DropDownListJobLevelID.Enabled=true;
this.DropDownListJoinDateD.Enabled=true;
this.DropDownListJoinDateM.Enabled=true;
this.DropDownListJoinDateY.Enabled=true;
this.DropDownListPoliticalFeature.Enabled=true;
this.DropDownListProfessionalLevelID.Enabled=true;
this.DropDownListSex.Enabled=true;
this.DropDownListState.Enabled=true;
}
///summary>
/// 计算闰年
/// </summary>
/// <param name="year"></param>
/// <param name="month"></param>
/// <returns></returns>
private ArrayList getDays(int year,int month)
{
ArrayList dayArray=new ArrayList ();
if((year%4==0)&&(year%100!=0)||(year%400==0))
for(int i=0;i<daysLeap[month-1];i++)
dayArray.Add (i+1);
else
for(int i=0;i<daysCommon[month-1];i++)
dayArray.Add (i+1);
return dayArray;
}
/// <summary>
/// 获取年份
/// </summary>
/// <param name="initYear"></param>
/// <returns></returns>
private ArrayList getYear(int initYear)
{
ArrayList years=new ArrayList ();
DateTime tempYear=DateTime.Now ;
for(int i=tempYear.Year-initYear;i<=tempYear.Year;i++)
years.Add (i);
return years;
}
/// <summary>
/// 绑定出生日期,进公司日期,合同开始日期,合同结束日期列表框
/// </summary>
private void initDate()
{
this.DropDownListBirthdayY.DataSource=this.getYear(60);
this.DropDownListBirthdayY.SelectedIndex=0;
this.DropDownListBirthdayY.DataBind();
this.DropDownListBirthdayM.SelectedIndex =0;
this.DropDownListBirthdayD.DataSource =this.getDays (Convert.ToInt32 (this.DropDownListBirthdayY.SelectedItem .Value .Trim ()),
Convert.ToInt32 (this.DropDownListBirthdayM.SelectedItem.Value .Trim ()));
this.DropDownListBirthdayD.DataBind ();
}
/// <summary>
/// 绑定部门、职务、职称下拉列表框
/// </summary>
private void Bind()
{
string strCom1="select * from ProfessionalLevel";
DataSet ds1=dc.getBinding(strCom1,"ProfessionalLevel");
this.DropDownListProfessionalLevelID.DataSource =ds1.Tables ["ProfessionalLevel"];
DropDownListProfessionalLevelID.DataTextField=ds1.Tables[0].Columns["ProfessionalLevelName"].ToString ();;
DropDownListProfessionalLevelID.DataValueField= ds1.Tables[0].Columns["ProfessionalLevelID"].ToString ();;
this.DropDownListProfessionalLevelID.DataBind ();
string strCom2= "SELECT * FROM JobLevels";
DataSet ds2=dc.getBinding(strCom2,"JobLevels");
this.DropDownListJobLevelID.DataSource =ds2.Tables ["JobLevels"];
DropDownListJobLevelID.DataTextField=ds2.Tables[0].Columns["Description"].ToString ();;
DropDownListJobLevelID.DataValueField= ds2.Tables[0].Columns["JobLevelID"].ToString ();;
this.DropDownListJobLevelID.DataBind ();
//string strCom3= "SELECT * FROM departments";
//DataSet ds3=dc.getBinding(strCom3,"departments");
//this.DropDownListDepartmentID.DataSource =ds3.Tables ["departments"];
//DropDownListDepartmentID.DataTextField=ds3.Tables[0].Columns["DepartmentName"].ToString ();;
//DropDownListDepartmentID.DataValueField= ds3.Tables[0].Columns["DepartmentID"].ToString ();;
//this.DropDownListDepartmentID.DataBind ();
//绑定单位
// this.UnitID.Items.Clear();
//
// OI.NjObjCheck.DataClass.b_unit_infos obs =new OI.NjObjCheck.DataClass.b_unit_infos();
// obs.GetData();
// foreach(OI.NjObjCheck.DataClass.b_unit_infos.b_unit_info ob in obs )
// {
// this.UnitID.Items.Add(new System.Web.UI.WebControls.ListItem(ob.UnitName,ob.UnitID));
// }
}
/// <summary>
/// 修改人员信息
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void ImageButtonSave_Click(object sender, System.Web.UI.ImageClickEventArgs e)
{
if(Page.IsValid)
{
dc=new DatabaseConnect ();
string texUserName=this.TextBoxUserName.Text.Trim().Replace ("'","''");
string texIDCard=this.TextBoxIDCard.Text.Trim().Replace ("'","''");
string texNationality=this.TextBoxNationality.Text.Trim().Replace ("'","''");
string texNativePlace=this.TextBoxNativePlace.Text.Trim().Replace ("'","''");
string texSchool=this.TextBoxSchool.Text.Trim().Replace ("'","''");
string texSpeciality=this.TextBoxSpeciality.Text.Trim().Replace ("'","''");
string texTelephone=this.TextBoxTelephone.Text.Trim().Replace ("'","''");
string texMobile=this.TextBoxMobile.Text.Trim().Replace ("'","''");
string texEmail=this.TextBoxEmail.Text.Trim().Replace ("'","''");
string texZipCode=this.TextBoxZipCode.Text.Trim().Replace ("'","''");
string texAddress=this.TextBoxAddress.Text.Trim().Replace ("'","''");
string texContent=this.TextBoxContent.Text.Trim().Replace ("'","''");
string strBirthday=this.DropDownListBirthdayY.SelectedItem.Value+"-"+
this.DropDownListBirthdayM.SelectedItem.Value+"-"+
this.DropDownListBirthdayD.SelectedItem.Value;
int intProfessionalLevelID=Convert.ToInt32(this.DropDownListProfessionalLevelID.SelectedItem.Value);
int intJobLevelID=Convert.ToInt32(this.DropDownListJobLevelID.SelectedItem.Value);
int intDepartmentID=Convert.ToInt32 (DeptID.Value .Trim ()) ;//Modifier: wu,Time:2004-1-31
char charSex=Convert.ToChar(this.DropDownListSex.SelectedItem.Value);
char charIsMarried=Convert.ToChar(this.DropDownListIsMarried.SelectedItem.Value);
string charPoliticalFeature=this.DropDownListPoliticalFeature.SelectedItem.Value;
char charState=Convert.ToChar(this.DropDownListState.SelectedItem.Value);
//获取各项的值
if (texUserName=="")//检查姓名项是否为空
{
this.RegisterClientScriptBlock("","<script>alert(\"请输入姓名\");</script>");
return;
}
else
{
OI.Manage.checkUser cu=new checkUser ();
if (cu.ExistUser( texUserName,int.Parse (intUserID)))
{
Page.RegisterStartupScript ("","<script>alert('"+texUserName+"己经存在!');Form1.TextBoxUserName.focus();</script>");
return;
}
string sql="update Accounts_Users set ProfessionalLevelID='"+intProfessionalLevelID+"',JobLevelID='"+intJobLevelID+"',DepartmentID='"+intDepartmentID+"',UserName='"+texUserName+"',Sex='"+charSex+"',School='"+texSchool+"',Speciality='"+texSpeciality+"',IsMarried='"+charIsMarried+"',Nationality='"+texNationality+"',NativePlace='"+texNativePlace+"',PoliticalFeature='"+charPoliticalFeature+"',IDCard='"+texIDCard+"',Birthday='"+strBirthday+"',Telephone='"+texTelephone+"',Mobile='"+texMobile+"',Email='"+texEmail+"',ZipCode='"+texZipCode+"',Address='"+texAddress+"',State='"+charState+"',Content='"+texContent+"',UnitID='"+this.UnitID.Text +"'where userID='"+intUserID+"'";
//Upfile();
System.Data.SqlClient.SqlConnection cn=dc.GetConn();
System.Data .SqlClient .SqlTransaction trans=cn.BeginTransaction ();
System.Data.SqlClient .SqlCommand command=new System.Data.SqlClient.SqlCommand ();
command.Connection=cn;
command.Transaction =trans;
command.CommandText =sql;
command.ExecuteNonQuery ();
// if (upfileLength >0)
// {
//
// command.CommandText ="update Accounts_Users set personSign=@sign where userID="+intUserID;
// command.Parameters.Add (new SqlParameter("@sign",SqlDbType.Image ,upfileLength,"personSign"));
// command.Parameters["@sign"].Value =bytes;
// command.ExecuteNonQuery ();
// }
try
{
trans.Commit ();
}
catch(Exception er)
{
Response.Write (er.Message );
Response.End ();
}
cn.Close ();
if (ViewState["modify"].ToString ()=="1")
{
Response.Redirect ("Accounts_UserEdit.aspx");
}
else
{
Response.Redirect("Accounts_Users.aspx",true);
}
}
}
}
/// <summary>
/// 清空文本框中的内容
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void ImageButtonCancel_Click(object sender, System.Web.UI.ImageClickEventArgs e)
{
if (ViewState["modify"].ToString ()=="1")
{
Response.Redirect ("Accounts_UserEdit.aspx");
}
else
{
Response.Redirect("Accounts_UserEdit.aspx?UserID="+intUserID+"");
}
}
// private void Upfile()
// {
// System.Web .HttpPostedFile files= upfile.PostedFile ;
// upfileLength=files.ContentLength ;
// if (upfileLength >0)
// {
// bytes=new byte [upfileLength ];
// System.IO.Stream filestream =files.InputStream ;
// filestream.Read (bytes,0,upfileLength);
// }
//
// }
public void Displayimg()
{
OI.cs.personalSign sign=new OI.cs.personalSign ();
sign.UserID =int.Parse (intUserID);
displaySign=sign.Displayimg ();
// string sql="select personSign from accounts_users where UserID="+intUserID;
// object o=dc.GetObjectBySql(sql);
// if (o==null || o.ToString ()=="")
// {
// displaySign="";
//
// }
// else
// {
// displaySign="<img border=0 id=persionSign src=displayimg.aspx?id="+intUserID +">";
// }
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -