public static bool DeleteExperience(int experienceId) { try { DbEntry.UsingTransaction(delegate { Experience exp = Experience.FindById(experienceId); exp.IsDelete = true; exp.Save(); }); } catch { return(false); } return(true); }
public static bool UpdateExperience(int experienceId, DateTime startTime, DateTime endTime, string school) { try { DbEntry.UsingTransaction(delegate { Experience exp = Experience.FindById(experienceId); exp.StartTime = startTime; exp.EndTime = endTime; exp.School = school; exp.Save(); }); } catch { return(false); } return(true); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { if (idExperience != 0)//修改 { btn_Add.Text = "确认修改"; //回填 try { Experience exp = Experience.FindById(idExperience); input_RegisterDate.Value = DateTime.Compare((DateTime)exp.StartTime, new DateTime(1900, 1, 1)) > 0 ? ((DateTime)exp.StartTime).ToString("yyyy年MM月") : ""; Text1.Value = DateTime.Compare((DateTime)exp.EndTime, new DateTime(1900, 1, 1)) > 0 ? ((DateTime)exp.EndTime).ToString("yyyy年MM月") : ""; tb_PublishPeriod.Text = exp.School; } catch (Exception ex) { text(ex.ToString()); Page.ClientScript.RegisterStartupScript(this.GetType(), "alter", "alert('数据加载错误,请重新再试!')", true); } } } }