protected void btnSubmit_Click(object sender, EventArgs e) { //1.验证当前用户页面权限 //if (!this.Master.A_Edit) //{ // Response.Write("你没有权限访问此功能!"); // Response.End(); // return; //} //2.取得用户变量 string companyId = this.ddlCompany.SelectedItem.Value; string realName = this.txtRealName.Text.Trim(); string idCard = this.txtIDCard.Text.Trim(); string birthday = this.txtBirthday.Text; string mobile = this.txtMobile.Text.Trim(); bool sex = rblSex.SelectedValue == "1" ? true : false; //if (this.rblSex.SelectedItem.Value == "1") //{ // sex = false; //} string qq = this.txtQQNumber.Text.Trim(); string email = this.txtEmail.Text.Trim(); string telephone = this.txtTelephone.Text.Trim(); string address = this.txtAddress.Text.Trim(); string sort = this.txtSort.Text.Trim(); string content = this.txtContent.Text.Trim(); string userId = Request.QueryString["id"]; //3.验证用户变量,包含Request.QueryString及Request.Form string fileExtension = null; if (this.FileUpload1.HasFile) { fileExtension = System.IO.Path.GetExtension(FileUpload1.FileName).ToLower(); if (!".gif.png.bmp.jpg".Contains(fileExtension)) { ULCode.Debug.Alert(this, "照片格式必须为图片格式!"); return; } } //4.业务处理过程 Employee.MODEL employee = WX.Request.rEmpolyee; //Employee.GetModel("SELECT * FROM TU_Employees WHERE UserID='" + userId + "'"); WX.Model.User.MODEL usermodel = WX.Model.User.GetCache(userId); #region string filePath=.. string filePath = null; if (FileUpload1.HasFile) { if (employee.UserFace.isEmpty) { string fileDir = "/UploadFiles/UserPhotos/"; string fileName = usermodel.RealName.ToString(); //DateTime.Now.ToString("yyyyMMddHHmmss"); filePath = String.Format("{0}{1}{2}", fileDir, fileName, fileExtension); } else { //如果原文件有则覆盖原文件 filePath = employee.UserFace.ToString(); } try { FileUpload1.SaveAs(Server.MapPath(filePath)); } catch { ULCode.Debug.Alert(this, "照片上传失败,可能是没有写的权限,请与管理员联系!"); filePath = null; } } #endregion usermodel.CompanyID.value = companyId; usermodel.RealName.value = realName; int iR = usermodel.Update(); //5.(用户及业务对象)统计与状态 if (iR > 0) { employee.IDCard.value = idCard; employee.Sex.value = sex; employee.Birthday.value = birthday; employee.Mobile.value = mobile; employee.QQ.value = qq; employee.Email.value = email; employee.Tel.value = telephone; if (!String.IsNullOrEmpty(filePath)) { employee.UserFace.value = filePath; } employee.Sort.value = sort; employee.Introduction.value = content; employee.Titles.value = this.ui_Titles.Text; employee.Ethnic.value = this.ui_Ethnic.Text; employee.Edu.value = ui_edu.SelectedValue; employee.Prof.value = ui_Prof.Text; employee.ForeignL.value = ui_ForeignL.Text; employee.Rating.value = ui_Rating.Text; employee.Marital.value = ui_Marital.Text; employee.Health.value = ui_Health.Text; employee.Address.value = address + "|" + ui_jg.Text + "|" + ui_hkd.Text; employee.Update(); //6.登记日志 WX.Model.Company.AddLogs(Convert.ToInt32(usermodel.CompanyID.ToString()), 6, usermodel.RealName.ToString() + "的档案信息修改成功!" + "[" + ui_logcontent.Text + "]", WX.Main.CurUser.UserID, ui_logmanage.Value, Request.UserHostAddress); //7.返回处理结果或返回其它页面。 ULCode.Debug.Alert(this, "档案信息修改成功!", "User_Skill.aspx?UserID=" + usermodel.UserID.ToString() + "&companyid=" + usermodel.CompanyID.ToString()); } else { usermodel.RestoreInitial(); } }
protected void btnSubmit_Click(object sender, EventArgs e) { //1.验证当前用户页面权限 if (!this.Master.A_Edit) { Response.Write("你没有权限访问此功能!"); Response.End(); return; } //2.取得用户变量 //string companyId = this.ddlCompany.SelectedItem.Value; //string departmentId = this.departmentId.Value; string realName = this.txtRealName.Text.Trim(); string idCard = this.txtIDCard.Text.Trim(); //string position = this.ddlPosition.SelectedItem.Value; string birthday = Request.Form["ctl00$ContentPlaceHolder$txtBirthday"];// this.txtBirthday.Text; if (!ULCode.Validation.IsDateTime(birthday)) { ULCode.Debug.Alert(this, "日期格式不正确,请正确使用日期控件!"); return; } string mobile = this.txtMobile.Text.Trim(); bool sex = rblSex.SelectedValue == "1" ? true : false; string qq = this.txtQQNumber.Text.Trim(); string email = Request.Form["ctl00$ContentPlaceHolder$txtEmail"];//this.txtEmail.Text.Trim(); string telephone = this.txtTelephone.Text.Trim(); string address = this.txtAddress.Text.Trim() + ":" + this.txtaddresscode.Text.Trim() + "|" + this.txtaddress2.Text.Trim() + ":" + this.txtaddress2code.Text.Trim(); string sort = this.txtSort.Text.Trim(); string content = this.txtContent.Text.Trim(); //3.验证用户变量,包含Request.QueryString及Request.Form string fileExtension = null; if (this.FileUpload1.HasFile) { fileExtension = System.IO.Path.GetExtension(FileUpload1.FileName).ToLower(); if (!".gif.png.bmp.jpg".Contains(fileExtension)) { ULCode.Debug.Alert(this, "照片格式必须为图片格式!"); return; } } //4.业务处理过程 if (FileUpload2.HasFile) { WX.Main.ExecuteDelete("TU_Employees_Credentials", "UserId='" + WX.Main.CurUser.UserID + "' and Name", "身份证扫描件"); WX.Model.EmployeeCredential.MODEL model = WX.Model.EmployeeCredential.NewDataModel(); model.Name.value = "身份证扫描件"; model.Unit.value = "公安局"; model.Ctime.value = (Convert.ToInt32(idCard.Substring(6, 4)) + 18) + "-01-01"; string filepath = "/UploadFiles/cmp/" + DateTime.Now.ToString("yyyyMMddhhmmssfff") + System.IO.Path.GetExtension(FileUpload2.FileName); FileUpload2.SaveAs(Server.MapPath(filepath)); model.Annex.value = filepath; model.UserId.value = WX.Main.CurUser.UserID; model.Save(); } if (FileUpload3.HasFile) { WX.Main.ExecuteDelete("TU_Employees_Credentials", "UserId='" + WX.Main.CurUser.UserID + "' and Name", ui_edu.SelectedItem.Text + "毕业证扫描件"); WX.Model.EmployeeCredential.MODEL model = WX.Model.EmployeeCredential.NewDataModel(); model.Name.value = ui_edu.SelectedItem.Text + "毕业证扫描件"; model.Unit.value = "教育部"; model.Ctime.value = (Convert.ToInt32(idCard.Substring(6, 4)) + 22) + "-01-01"; string filepath = "/UploadFiles/cmp/" + DateTime.Now.ToString("yyyyMMddhhmmssfff") + System.IO.Path.GetExtension(FileUpload3.FileName); FileUpload3.SaveAs(Server.MapPath(filepath)); model.Annex.value = filepath; model.UserId.value = WX.Main.CurUser.UserID; model.Save(); } if (FileUpload4.HasFile) { WX.Main.ExecuteDelete("TU_Employees_Credentials", "UserId='" + WX.Main.CurUser.UserID + "' and Name", "健康证扫描件"); WX.Model.EmployeeCredential.MODEL model = WX.Model.EmployeeCredential.NewDataModel(); model.Name.value = "健康证扫描件"; model.Unit.value = "卫生部"; model.Ctime.value = (Convert.ToInt32(idCard.Substring(6, 4)) + 20) + "-01-01"; string filepath = "/UploadFiles/cmp/" + DateTime.Now.ToString("yyyyMMddhhmmssfff") + System.IO.Path.GetExtension(FileUpload4.FileName); FileUpload4.SaveAs(Server.MapPath(filepath)); model.Annex.value = filepath; model.UserId.value = WX.Main.CurUser.UserID; model.Save(); } WX.Main.CurUser.LoadEmployeeUser(false); WX.Main.CurUser.LoadUserModel(false); WX.Model.User.MODEL usermodel = WX.Main.CurUser.UserModel; usermodel.RealName.value = realName; usermodel.Update(); Employee.MODEL employee = WX.Main.CurUser.EmployeeUser; #region string filePath=.. string filePath = null; if (FileUpload1.HasFile) { if (employee.UserFace.isEmpty) { string fileDir = "/UploadFiles/UserPhotos/"; string fileName = usermodel.RealName.ToString(); //DateTime.Now.ToString("yyyyMMddHHmmss"); filePath = String.Format("{0}{1}{2}", fileDir, fileName, fileExtension); } else { //如果原文件有则覆盖原文件 filePath = employee.UserFace.ToString(); } try { FileUpload1.SaveAs(Server.MapPath(filePath)); } catch { ULCode.Debug.Alert(this, "照片上传失败,可能是没有写的权限,请与管理员联系!"); filePath = null; } } #endregion //employee.CompanyID.value = companyId; //employee.DepartmentID.value = departmentId; //employee.DutyId.value = position; employee.IDCard.value = idCard; employee.Sex.value = sex; employee.Birthday.value = birthday; employee.Mobile.value = mobile; employee.QQ.value = qq; employee.Email.value = email; employee.Tel.value = telephone; if (!String.IsNullOrEmpty(filePath)) { employee.UserFace.value = filePath; } employee.Sort.value = sort; employee.Introduction.value = content; employee.Titles.value = this.ui_Titles.Text; employee.Ethnic.value = this.ui_Ethnic.Text; employee.Edu.value = ui_edu.SelectedValue; employee.Prof.value = ui_Prof.Text; employee.ForeignL.value = ui_ForeignL.Text; employee.Rating.value = ui_Rating.Text; employee.Marital.value = ui_Marital.SelectedValue; employee.Health.value = ui_Health.Text; employee.Address.value = address + "|" + ui_jg.Text + "|" + ui_hkd.Text; //教育经历 string[] items = System.Configuration.ConfigurationManager.AppSettings["Priv-Edu"].ToString().Split('|'); ULCode.KeyXmlString kxs0 = new ULCode.KeyXmlString(); if (employee.DFields["Education"].ToString().IndexOf("<KeyXmlString>") > -1) { kxs0.LoadData(employee.Education.ToString().Replace(" ", "")); } if (employee.Education.ToString().IndexOf("<学历>" + ui_edu.SelectedItem.Text + "</学历>") == -1) { ULCode.KeyXmlString kxs = new ULCode.KeyXmlString(); kxs.SetItemValue("时间", ""); kxs.SetItemValue("学历", ui_edu.SelectedItem.Text); kxs.SetItemValue("专业", employee.Prof.ToString()); kxs.SetItemValue("学校", ""); kxs0.AddItem("Node", kxs.GetSavedData()); employee.Education.value = kxs0.GetSavedData(); } employee.DepartmentID.value = ddlDepartment.SelectedValue; employee.DutyId.value = ui_jobname.SelectedValue; employee.Salary.value = ui_salary.Text; int iR = employee.Update(); //5.(用户及业务对象)统计与状态 //6.登记日志 //7.返回处理结果或返回其它页面。 if (iR > 0) { WX.Main.AddLog(WX.LogType.Default, "修改个人信息成功!", ""); ULCode.Debug.Alert(Page, "个人信息修改成功!请完善下一步“个人技能”", "Priv_Skill.aspx"); } else { usermodel.RestoreInitial(); ULCode.Debug.Alert(Page, "个人信息修改失败!"); } }