public CY.GFive.Core.Business.StaffInfo GetUser() { CY.GFive.Core.Business.StaffInfo staff = new CY.GFive.Core.Business.StaffInfo(); staff = null; return staff; }
protected void BtnSubmit_Click(object sender, EventArgs e) { lab_Error.Text = ""; try { CY.GFive.Core.Business.StaffInfo si = CY.GFive.Core.Business.StaffInfo.GetInstance(UserCode.Text.Trim()); if (si == null) { if (UserCode.Text.Trim() == "") { lab_Error.Text = "人员编号不能为空"; return; } CY.GFive.Core.Business.StaffInfo staffInfo = new CY.GFive.Core.Business.StaffInfo(); staffInfo.Code = UserCode.Text.Trim(); staffInfo.Name = UserName.Text.Trim(); staffInfo.Gender = ddl_GenderList.SelectedValue; staffInfo.Nation = Nation.Text.Trim(); staffInfo.Origin = Origin.Text.Trim(); staffInfo.IdentifyCode = IDNumber.Text.Trim(); if (Birth.Text.Trim() != "") { staffInfo.Birthday = Convert.ToDateTime(Birth.Text.Trim());//DateTime.Parse(); } staffInfo.PoliticalCode = ddl_Political.SelectedValue; if (JoinDate.Text.Trim() != "") { staffInfo.JoinDate = Convert.ToDateTime(JoinDate.Text.Trim()); } staffInfo.EducateLvl = ddl_Education.SelectedValue; staffInfo.ScholarLvl = ddl_degree.SelectedValue; staffInfo.TitleLvl = JobTitle.Text.Trim(); staffInfo.QualityLvl = JobLevel.Text.Trim(); staffInfo.TeachSubject = TeachCourse.Text.Trim(); staffInfo.OriginWork = PreWork.Text.Trim(); staffInfo.GraduteSchool = GraduateSchool.Text.Trim(); staffInfo.ProfessName = Profess.Text.Trim(); staffInfo.SchoolTypeCode = SchoolSystem.Text.Trim(); staffInfo.Address = Address.Text.Trim(); staffInfo.CellPhone = CellPhone.Text.Trim(); staffInfo.Phone = Phone.Text.Trim(); staffInfo.StaffCate = ddl_StaffCate.SelectedValue; if (ddl_StaffCate.SelectedValue != "Teacher") { staffInfo.DepartmentCode = ddl_Depart.SelectedValue; } if (txt_Desc.Text.Length > 200) { lab_Error.Text = "履历描述长度不能超过200字符"; return; } staffInfo.Des = txt_Desc.Text.Trim(); staffInfo.Positon = Post.Text.Trim(); if (UpFile.PostedFile.ContentLength != 0) { string webPath = Server.MapPath("~/StaffManagement/upload/"); string upname = UpFile.PostedFile.FileName.Substring(UpFile.PostedFile.FileName.LastIndexOf(".")).ToUpper(); Guid id = System.Guid.NewGuid(); string saname = id + upname; UpFile.PostedFile.SaveAs(webPath + saname);//保存图片 staffInfo.Photo = saname; } // HttpPostedFile phonofile = Request.Files["phonos"]; HttpPostedFile attachfile = Request.Files["attachs"]; //if (phonofile.ContentType != "application/octet-stream") //{ // if (purl.Text != "null") // { // if (phonofile.ContentType != "image/pjpeg" // && phonofile.ContentType != "image/gif" // && phonofile.ContentType != "image/bmp" // && phonofile.ContentType != "image/x-png") // { // lab_Error.Text = "保存失败,上传照片格式不正确,只能是jpg/gif/png/bmp格式!请重新上传照片和履历"; // return; // } // else // { // staffInfo.Photo = CY.GFive.Utility.Extend.FileUpload.SaveFile(phonofile, Server.MapPath(@"..\upload")); // } // } //} if (attachfile.ContentType != "application/octet-stream") { if (aurl.Text != "null") { if (attachfile.ContentType != "application/msword" && attachfile.ContentType != "application/pdf" && attachfile.ContentType != "text/plain") { lab_Error.Text = "保存失败,上传履历格式不正确,只能是doc/pdf/txt格式!请重新上传照片和履历"; return; } else { string webPath = Server.MapPath("~/StaffManagement/upload/"); string nameext = attachs.PostedFile.FileName.Substring(attachs.PostedFile.FileName.LastIndexOf(".")).ToUpper(); Guid attgid = System.Guid.NewGuid(); string name = attgid + nameext; attachs.PostedFile.SaveAs(webPath + name);//保存履历 staffInfo.AttachmentCode = name; } } } staffInfo.Save(); Page.ClientScript.RegisterClientScriptBlock(Page.GetType(), "人员信息保存成功!", "<script>alert('添加成功');</script>"); } else { lab_Error.Text = "该用户已经存在,请修改用户编号"; } } catch (Exception ex) { lab_Error.Text = ex.Message; } }