/// <summary> /// 发表公告 /// </summary> /// <param name="afficheInf">公告信息实体</param> /// <returns></returns> public bool AddAffiche(AfficheInf afficheInf) { SqlParameter[] parms = { MakeInParm(DP_ID, SqlDbType.Char, 2, afficheInf.Dp_Id), MakeInParm(AF_TITLE, SqlDbType.NVarChar, 100, afficheInf.Af_Title), MakeInParm(AF_CONTENT, SqlDbType.Text, 3000, afficheInf.Af_Content), MakeInParm(AF_ENABLETIME, SqlDbType.DateTime, 0, afficheInf.Af_EnableTime), MakeInParm(AF_FILEPATH, SqlDbType.NVarChar, 150, afficheInf.Af_FilePath) }; try { if (ExecProc("Add_Affiche", parms) == 1) { return(true); } else { return(false); } } catch { return(false); } }
/// <summary> /// 修改公告信息 /// </summary> /// <param name="afficheInf">公告实体</param> /// <returns></returns> public void UpdateAffiche(AfficheInf afficheInf) { if (affiche.UpdateAffiche(afficheInf) == false) { JScript.Alert("修改公告信息失败!"); } else { JScript.AlertAndRedirect("修改公告信息成功!", "Default.aspx"); } }
/// <summary> /// 返回公告的行 /// </summary> /// <param name="af_Id">公告编号</param> /// <param name="dp_Id">部门编号</param> /// <returns></returns> public void BindAfForUpdate(int af_Id, string dp_Id, TextBox txtAfTitle, TextBox txtAfContent, TextBox txt_Af_EnableTile) { AfficheInf afficheInf = affiche.GetAfficheForUpdate(af_Id, dp_Id); if (afficheInf != null) { txtAfTitle.Text = afficheInf.Af_Title; txtAfContent.Text = afficheInf.Af_Content; txt_Af_EnableTile.Text = afficheInf.Af_EnableTime.ToString(); } }
protected void btnAddAffiche_Click(object sender, EventArgs e) { try { af_EnableTime = Convert.ToDateTime(txtEnbaleTime.Text); afficheInf = new AfficheInf(HttpContext.Current.User.Identity.Name.ToString(), txtAfficheTitle.Text, txtAfficheContent.Text, af_EnableTime, "..\\AfficheFiles\\" + Get_Af_FileName()); affiche.Add_Affiche(afficheInf); UpLoadFile(); } catch { JScript.AlertAndRedirect("日期格式错误!", "AddAffiche.aspx"); } }
/// <summary> /// 发表公告信息 /// </summary> /// <param name="afficheInf">公告实体</param> public void Add_Affiche(AfficheInf afficheInf) { if (afficheInf.Af_EnableTime < DateTime.Now) { JScript.Alert("输入的有效日期小于了现在日期!"); } else { if (affiche.AddAffiche(afficheInf) == false) { JScript.AlertAndRedirect("发表公告失败!", "AddAffiche.aspx"); } else { JScript.AlertAndRedirect("发表公告成功!", "AddAffiche.aspx"); } } }
/// <summary> /// 获取要更新的 /// </summary> /// <param name="af_Id">公告编号</param> /// <param name="dp_Id">部门ID</param> /// <returns></returns> public AfficheInf GetAfficheForUpdate(int af_Id, string dp_Id) { AfficheInf afficheInf = null; SqlParameter[] parms = { MakeInParm(AF_ID, SqlDbType.Int, 4, af_Id), MakeInParm(DP_ID, SqlDbType.Char, 2, dp_Id), MakOutParm(AF_TITLE, SqlDbType.NVarChar, 100), MakOutParm(AF_CONTENT, SqlDbType.NVarChar, 3000), MakOutParm(AF_ENABLETIME, SqlDbType.DateTime, 0), MakOutParm(AF_FILEPATH, SqlDbType.NVarChar, 150) }; try { ExecProc("GetAfficheForUpdate", parms); afficheInf = new AfficheInf(parms[2].Value.ToString(), parms[3].Value.ToString(), Convert.ToDateTime(parms[4].Value), parms[5].Value.ToString()); return(afficheInf); } catch { return(null); } }