/// <summary> /// 获得数据列表 /// </summary> public List <Entity.PlacardEntity> DataTableToList(DataTable dt) { List <Entity.PlacardEntity> modelList = new List <Entity.PlacardEntity>(); int rowsCount = dt.Rows.Count; if (rowsCount > 0) { Entity.PlacardEntity model; for (int n = 0; n < rowsCount; n++) { model = new Entity.PlacardEntity(); if (dt.Rows[n]["Pid"].ToString() != "") { model.Pid = int.Parse(dt.Rows[n]["Pid"].ToString()); } model.Ptitle = dt.Rows[n]["Ptitle"].ToString(); model.Pauthor = dt.Rows[n]["Pauthor"].ToString(); if (dt.Rows[n]["Pdate"].ToString() != "") { model.Pdate = DateTime.Parse(dt.Rows[n]["Pdate"].ToString()); } model.Ptext = dt.Rows[n]["Ptext"].ToString(); modelList.Add(model); } } return(modelList); }
/// <summary> /// 更新一条数据 /// </summary> public void Update(Entity.PlacardEntity model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update [OA_Placard] set "); strSql.Append("Ptitle=@Ptitle,"); strSql.Append("Pauthor=@Pauthor,"); strSql.Append("Pdate=@Pdate,"); strSql.Append("Ptext=@Ptext"); strSql.Append(" where Pid=@Pid "); SqlParameter[] parameters = { new SqlParameter("@Pid", SqlDbType.Int, 4), new SqlParameter("@Ptitle", SqlDbType.VarChar, 30), new SqlParameter("@Pauthor", SqlDbType.VarChar, 10), new SqlParameter("@Pdate", SqlDbType.DateTime), new SqlParameter("@Ptext", SqlDbType.NText) }; parameters[0].Value = model.Pid; parameters[1].Value = model.Ptitle; parameters[2].Value = model.Pauthor; parameters[3].Value = model.Pdate; parameters[4].Value = model.Ptext; DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); }
/// <summary> /// ��������б� /// </summary> public List<Entity.PlacardEntity> DataTableToList(DataTable dt) { List<Entity.PlacardEntity> modelList = new List<Entity.PlacardEntity>(); int rowsCount = dt.Rows.Count; if (rowsCount > 0) { Entity.PlacardEntity model; for (int n = 0; n < rowsCount; n++) { model = new Entity.PlacardEntity(); if(dt.Rows[n]["Pid"].ToString()!="") { model.Pid=int.Parse(dt.Rows[n]["Pid"].ToString()); } model.Ptitle=dt.Rows[n]["Ptitle"].ToString(); model.Pauthor=dt.Rows[n]["Pauthor"].ToString(); if(dt.Rows[n]["Pdate"].ToString()!="") { model.Pdate=DateTime.Parse(dt.Rows[n]["Pdate"].ToString()); } model.Ptext=dt.Rows[n]["Ptext"].ToString(); modelList.Add(model); } } return modelList; }
/// <summary> /// 增加一条数据 /// </summary> public int Add(Entity.PlacardEntity model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into [OA_Placard]("); strSql.Append("Ptitle,Pauthor,Pdate,Ptext)"); strSql.Append(" values ("); strSql.Append("@Ptitle,@Pauthor,@Pdate,@Ptext)"); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@Ptitle", SqlDbType.VarChar, 30), new SqlParameter("@Pauthor", SqlDbType.VarChar, 10), new SqlParameter("@Pdate", SqlDbType.DateTime), new SqlParameter("@Ptext", SqlDbType.NText) }; parameters[0].Value = model.Ptitle; parameters[1].Value = model.Pauthor; parameters[2].Value = model.Pdate; parameters[3].Value = model.Ptext; object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters); if (obj == null) { return(1); } else { return(Convert.ToInt32(obj)); } }
/// <summary> /// 得到一个对象实体 /// </summary> public Entity.PlacardEntity GetEntity(int Pid) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 Pid,Ptitle,Pauthor,Pdate,Ptext from [OA_Placard] "); strSql.Append(" where Pid=@Pid "); SqlParameter[] parameters = { new SqlParameter("@Pid", SqlDbType.Int, 4) }; parameters[0].Value = Pid; Entity.PlacardEntity model = new Entity.PlacardEntity(); DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { if (ds.Tables[0].Rows[0]["Pid"].ToString() != "") { model.Pid = int.Parse(ds.Tables[0].Rows[0]["Pid"].ToString()); } model.Ptitle = ds.Tables[0].Rows[0]["Ptitle"].ToString(); model.Pauthor = ds.Tables[0].Rows[0]["Pauthor"].ToString(); if (ds.Tables[0].Rows[0]["Pdate"].ToString() != "") { model.Pdate = DateTime.Parse(ds.Tables[0].Rows[0]["Pdate"].ToString()); } model.Ptext = ds.Tables[0].Rows[0]["Ptext"].ToString(); return(model); } else { return(null); } }
void Msgbind() { int id = Str2Int(q("id"), 0); Entity.PlacardEntity model = new Entity.PlacardEntity(); model = new JumbotOA.BLL.PlacardBLL().GetEntity(id); this.lblTitle.Text = model.Ptitle; text = model.Ptext; }
/// <summary> /// 分页获取数据列表 /// </summary> public List <Entity.PlacardEntity> getpage(int pageSize, int pageNum, out int count, string str) { string select, table, where, order; select = " * "; table = "OA_Placard "; StringBuilder sb = new StringBuilder(); sb.Append(" ( 1 = 1 ) " + str); where = sb.ToString(); order = "Pid"; string sql = "exec Pagination @select, @table, @where, @orderField, @orderType, @pageSize, @pageNum "; SqlParameter[] paras = { new SqlParameter("@select", select), new SqlParameter("@table", table), new SqlParameter("@where", where), new SqlParameter("@orderField", order), new SqlParameter("@orderType", '1'), new SqlParameter("@pageSize", pageSize), new SqlParameter("@pageNum", pageNum) }; DataSet ds = DbHelperSQL.Query(sql, paras); count = Convert.ToInt32(ds.Tables[1].Rows[0][0]); List <Entity.PlacardEntity> list = new List <Entity.PlacardEntity>(); Entity.PlacardEntity model; for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { model = new Entity.PlacardEntity(); if (ds.Tables[0].Rows[i]["Pid"].ToString() != "") { model.Pid = int.Parse(ds.Tables[0].Rows[i]["Pid"].ToString()); } model.Pauthor = ds.Tables[0].Rows[i]["Pauthor"].ToString(); model.Pdate = Convert.ToDateTime(ds.Tables[0].Rows[i]["Pdate"].ToString()); model.Ptitle = ds.Tables[0].Rows[i]["Ptitle"].ToString(); model.Ptext = ds.Tables[0].Rows[i]["Ptext"].ToString(); list.Add(model); } return(list); }
//修改信息 protected void ImageButton1_Click(object sender, ImageClickEventArgs e) { Entity.PlacardEntity model = new Entity.PlacardEntity(); model.Pid = Str2Int(q("id")); model.Pauthor = UserName; model.Ptitle = this.txtTitle.Text; model.Pdate = DateTime.Now; model.Ptext = this.FCKeditor1.Value; new JumbotOA.BLL.PlacardBLL().Update(model); string addtype = "修改通知公告"; Addlog(addtype); }
//添加信息 protected void ImageButton1_Click(object sender, ImageClickEventArgs e) { Entity.PlacardEntity model = new Entity.PlacardEntity(); model.Pauthor = UserName; model.Ptitle = this.txtTitle.Text; model.Pdate = DateTime.Now; model.Ptext = this.FCKeditor1.Value; int i = new JumbotOA.BLL.PlacardBLL().Add(model); if (i > 0) { JumbotOA.BLL.UserBLL user = new JumbotOA.BLL.UserBLL(); DataTable dt=user.GetList("").Tables[0]; string aa = ""; for (int j = 0; j <dt.Rows.Count ; j++) { aa += dt.Rows[j]["Uid"].ToString()+","; } JumbotOA.BLL.OA_SysMessageIn.ADDsysMessage(1, "," + aa, "[新通知]" + txtTitle.Text, JumbotOA.Utils.Strings.Left(JumbotOA.Utils.Strings.delhtml(FCKeditor1.Value.ToString()), 53), "My_Placard_Show.aspx?id=" + i.ToString()); aa = ""; string addtype = "添加通知公告"; Addlog(addtype); } }
//添加信息 protected void ImageButton1_Click(object sender, ImageClickEventArgs e) { Entity.PlacardEntity model = new Entity.PlacardEntity(); model.Pauthor = UserName; model.Ptitle = this.txtTitle.Text; model.Pdate = DateTime.Now; model.Ptext = this.FCKeditor1.Value; int i = new JumbotOA.BLL.PlacardBLL().Add(model); if (i > 0) { JumbotOA.BLL.UserBLL user = new JumbotOA.BLL.UserBLL(); DataTable dt = user.GetList("").Tables[0]; string aa = ""; for (int j = 0; j < dt.Rows.Count; j++) { aa += dt.Rows[j]["Uid"].ToString() + ","; } JumbotOA.BLL.OA_SysMessageIn.ADDsysMessage(1, "," + aa, "[新通知]" + txtTitle.Text, JumbotOA.Utils.Strings.Left(JumbotOA.Utils.Strings.delhtml(FCKeditor1.Value.ToString()), 53), "My_Placard_Show.aspx?id=" + i.ToString()); aa = ""; string addtype = "添加通知公告"; Addlog(addtype); } }
/// <summary> /// 更新一条数据 /// </summary> public void Update(Entity.PlacardEntity model) { dal.Update(model); }
/// <summary> /// 增加一条数据 /// </summary> public int Add(Entity.PlacardEntity model) { return(dal.Add(model)); }
/// <summary> /// ��ҳ��ȡ�����б� /// </summary> public List<Entity.PlacardEntity> getpage(int pageSize, int pageNum, out int count, string str) { string select, table, where, order; select = " * "; table = "OA_Placard "; StringBuilder sb = new StringBuilder(); sb.Append(" ( 1 = 1 ) " + str); where = sb.ToString(); order = "Pid"; string sql = "exec Pagination @select, @table, @where, @orderField, @orderType, @pageSize, @pageNum "; SqlParameter[] paras ={ new SqlParameter("@select", select), new SqlParameter("@table", table), new SqlParameter("@where", where), new SqlParameter("@orderField", order), new SqlParameter("@orderType", '1'), new SqlParameter("@pageSize", pageSize), new SqlParameter("@pageNum", pageNum) }; DataSet ds = DbHelperSQL.Query(sql, paras); count = Convert.ToInt32(ds.Tables[1].Rows[0][0]); List<Entity.PlacardEntity> list = new List<Entity.PlacardEntity>(); Entity.PlacardEntity model; for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { model = new Entity.PlacardEntity(); if (ds.Tables[0].Rows[i]["Pid"].ToString() != "") { model.Pid = int.Parse(ds.Tables[0].Rows[i]["Pid"].ToString()); } model.Pauthor = ds.Tables[0].Rows[i]["Pauthor"].ToString(); model.Pdate = Convert.ToDateTime(ds.Tables[0].Rows[i]["Pdate"].ToString()); model.Ptitle = ds.Tables[0].Rows[i]["Ptitle"].ToString(); model.Ptext = ds.Tables[0].Rows[i]["Ptext"].ToString(); list.Add(model); } return list; }
/// <summary> /// �õ�һ������ʵ�� /// </summary> public Entity.PlacardEntity GetEntity(int Pid) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 Pid,Ptitle,Pauthor,Pdate,Ptext from [OA_Placard] "); strSql.Append(" where Pid=@Pid "); SqlParameter[] parameters = { new SqlParameter("@Pid", SqlDbType.Int,4)}; parameters[0].Value = Pid; Entity.PlacardEntity model = new Entity.PlacardEntity(); DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { if (ds.Tables[0].Rows[0]["Pid"].ToString() != "") { model.Pid = int.Parse(ds.Tables[0].Rows[0]["Pid"].ToString()); } model.Ptitle = ds.Tables[0].Rows[0]["Ptitle"].ToString(); model.Pauthor = ds.Tables[0].Rows[0]["Pauthor"].ToString(); if (ds.Tables[0].Rows[0]["Pdate"].ToString() != "") { model.Pdate = DateTime.Parse(ds.Tables[0].Rows[0]["Pdate"].ToString()); } model.Ptext = ds.Tables[0].Rows[0]["Ptext"].ToString(); return model; } else { return null; } }