protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { if (familyId != 0)//修改 { btn_Add.Text = "确认修改"; //回填 try { FamilyOfStudent fam = FamilyOfStudent.FindById(familyId); tb_PeriodicalName.Text = fam.Name; radio_1.SelectedValue = (bool)fam.Sex ? "2" : "1"; //input_RegisterDate.Value = fam.Birthday.ToString().Substring(0, 9); input_RegisterDate.Value = DateTime.Compare((DateTime)fam.Birthday, new DateTime(1900, 1, 1)) > 0 ? ((DateTime)fam.Birthday).ToString("yyyy/MM/dd") : ""; tb_PublishCount.Text = fam.Relationship; tb_EIC_Name.Text = fam.Company; tb_EO_Address.Text = fam.Tip; } catch (Exception ex) { text(ex.ToString()); Page.ClientScript.RegisterStartupScript(this.GetType(), "alter", "alert('数据加载错误,请重新再试!')", true); } } } }
public static bool deleteFamilyOfStudent(int stuId) { try { DbEntry.UsingTransaction(delegate { FamilyOfStudent stu = FamilyOfStudent.FindById(stuId); stu.IsDelete = true; stu.Save(); }); } catch { return(false); } return(true); }
public static bool UpdateFamilyOfStudent(int family_id, string name, bool sex, DateTime birthday, String relationship, String company, String tip) { try { DbEntry.UsingTransaction(delegate { FamilyOfStudent stu = FamilyOfStudent.FindById(family_id); stu.Name = name; stu.Sex = sex; stu.Birthday = birthday; stu.Relationship = relationship; stu.Company = company; stu.Tip = tip; stu.Save(); }); } catch { return(false); } return(true); }
public static bool AddFamilyOfStudent(int student_id, string name, bool sex, DateTime birthday, String relationship, String company, String tip) { try { DbEntry.UsingTransaction(delegate { FamilyOfStudent stu = new FamilyOfStudent(); stu.Student_Id = student_id; stu.Name = name; stu.Sex = sex; stu.Birthday = birthday; stu.Relationship = relationship; stu.Company = company; stu.Tip = tip; stu.IsDelete = false; stu.Save(); }); } catch { return(false); } return(true); }
public void Output_Word_zdts() { try { if (id == 0) { ScriptManager.RegisterStartupScript(UpdatePanel1, this.GetType(), "alter", "alert('数据加载错误,请重新再试!')", true); return; } Student stu = Student.FindById(id); string basePath = Server.MapPath("../../"); Document doc = new Document(basePath + "Template/在读台生情况信息表.doc"); //姓名 Bookmark bookmark = doc.Range.Bookmarks["Name"]; bookmark.Text = stu.Name == null ? "" : stu.Name; //性别 bookmark = doc.Range.Bookmarks["Sex"]; bookmark.Text = stu.Sex == null ? "" : (bool)stu.Sex ? "女" : "男"; //出生年月 bookmark = doc.Range.Bookmarks["Birth"]; bookmark.Text = stu.Birthday == null ? "" : ((DateTime)stu.Birthday).ToString("yyyy.MM.dd"); //证件号码 bookmark = doc.Range.Bookmarks["CertificateNum"]; bookmark.Text = stu.IdentityNo == null ? "" : stu.IdentityNo; //就读学校 bookmark = doc.Range.Bookmarks["School"]; bookmark.Text = stu.School == null ? "" : stu.School; //专业 bookmark = doc.Range.Bookmarks["Subject"]; bookmark.Text = stu.Major == null ? "" : stu.Major; //学制 bookmark = doc.Range.Bookmarks["StudyYear"]; bookmark.Text = stu.SystemOfEdu == null ? "" : stu.SystemOfEdu; //联系电话 bookmark = doc.Range.Bookmarks["Phone"]; bookmark.Text = stu.PhoneNo == null ? "" : stu.PhoneNo; //就读类别 bookmark = doc.Range.Bookmarks["StudyTypeText"]; bookmark.Text = StudyType.FindOne(CK.K["StudyTypeId"] == stu.StudyTypeId && CK.K["IsDelete"] == false).StudyTypeText; //入学日期 bookmark = doc.Range.Bookmarks["JoinSchoolDate"]; bookmark.Text = stu.JoinSchoolDate == null ? "" : ((DateTime)stu.JoinSchoolDate).ToString("yyyy.MM.dd"); //在沪居住地 bookmark = doc.Range.Bookmarks["SHAddress"]; bookmark.Text = stu.AddressOfH == null ? "" : stu.AddressOfH; //备注 bookmark = doc.Range.Bookmarks["Memo"]; bookmark.Text = stu.Tip == null ? "" : stu.Tip; //家庭主要成员 DataTable dt_fa = FamilyOfStudent.Find(CK.K["Student_Id"] == id && CK.K["IsDelete"] == false).ToDataTable(); if (dt_fa.Rows.Count > 0) { int fa_count = dt_fa.Rows.Count <= 5 ? dt_fa.Rows.Count : 5; for (int i = 0; i < fa_count; i++) { //姓名 bookmark = doc.Range.Bookmarks["Fa_" + i + "_Name"]; bookmark.Text = dt_fa.Rows[i]["Name"].ToString(); //性别 bookmark = doc.Range.Bookmarks["Fa_" + i + "_Sex"]; bookmark.Text = dt_fa.Rows[i]["Sex"].ToString().IsNullOrEmpty() ? "" : Convert.ToBoolean(dt_fa.Rows[i]["Sex"].ToString()) ? "女" : "男";; //出生年月 bookmark = doc.Range.Bookmarks["Fa_" + i + "_Birth"]; bookmark.Text = dt_fa.Rows[i]["Birthday"].ToString().IsNullOrEmpty() ? "" : Convert.ToDateTime(dt_fa.Rows[i]["Birthday"].ToString()).ToString("yyyy.MM.dd"); //与本人关系 bookmark = doc.Range.Bookmarks["Fa_" + i + "_Relation"]; bookmark.Text = dt_fa.Rows[i]["Relationship"].ToString(); //工作单位 bookmark = doc.Range.Bookmarks["Fa_" + i + "_Department"]; bookmark.Text = dt_fa.Rows[i]["Company"].ToString(); //备注 bookmark = doc.Range.Bookmarks["Fa_" + i + "_Memo"]; bookmark.Text = dt_fa.Rows[i]["Tip"].ToString(); } } //学习经历 DataTable dt_Exp = Experience.Find(CK.K["Student_Id"] == id && CK.K["IsDelete"] == false).ToDataTable(); if (dt_Exp.Rows.Count > 0) { int exp_count = dt_Exp.Rows.Count <= 10 ? dt_Exp.Rows.Count : 10; for (int i = 0; i < exp_count; i++) { //姓名 bookmark = doc.Range.Bookmarks["Exp_" + i + "_Start"]; bookmark.Text = dt_Exp.Rows[i]["StartTime"].ToString().IsNullOrEmpty() ? "" : Convert.ToDateTime(dt_Exp.Rows[i]["StartTime"].ToString()).ToString("yyyy.MM.dd"); //性别 bookmark = doc.Range.Bookmarks["Exp_" + i + "_End"]; bookmark.Text = dt_Exp.Rows[i]["EndTime"].ToString().IsNullOrEmpty() ? "" : Convert.ToDateTime(dt_Exp.Rows[i]["EndTime"].ToString()).ToString("yyyy.MM.dd"); //出生年月 bookmark = doc.Range.Bookmarks["Exp_" + i + "_School"]; bookmark.Text = dt_Exp.Rows[i]["School"].ToString(); } } ////插入图片 //DocumentBuilder builder = new DocumentBuilder(doc); //builder.MoveToBookmark("Photo"); //var img = builder.InsertImage(basePath + "upload/photos/" + photoName); //img.Width = 165; //img.Height = 240; //img.HorizontalAlignment = Aspose.Words.Drawing.HorizontalAlignment.Center; string fileNameWithOutExtention = Guid.NewGuid().ToString(); doc.Save(basePath + "upload/word_zdts/" + fileNameWithOutExtention + ".pdf", SaveFormat.Pdf); FileStream fs = new FileStream(basePath + "upload/word_zdts/" + fileNameWithOutExtention + ".pdf", FileMode.Open); byte[] file = new byte[fs.Length]; fs.Read(file, 0, file.Length); fs.Close(); Response.AppendHeader("Content-Disposition", "attachment;filename=" + HttpUtility.UrlEncode("在读台生情况信息表-" + stu.Name + ".pdf", System.Text.Encoding.UTF8)); Response.ContentEncoding = System.Text.Encoding.GetEncoding("utf-8"); Response.ContentType = "application/octet-stream"; Response.BinaryWrite(file); Response.End(); } catch (Exception ex) { ScriptManager.RegisterStartupScript(UpdatePanel1, this.GetType(), "alter", "alert('数据加载失败,请重新再试!')", true); return; } }