/// <summary> /// 得到一个对象实体 /// </summary> public static EtNet_Models.AnnouncementLog GetModel(int id) { StringBuilder strSql = new StringBuilder(); strSql.Append("select * "); strSql.Append(" from AnnouncementLog "); strSql.Append(" where id=@id"); SqlParameter[] parameters = { new SqlParameter("@id", SqlDbType.Int, 4) }; parameters[0].Value = id; EtNet_Models.AnnouncementLog model = new EtNet_Models.AnnouncementLog(); DataTable tbl = EtNet_DAL.DBHelper.GetDataSet(strSql.ToString(), parameters); if (tbl.Rows.Count > 0) { model.id = int.Parse(tbl.Rows[0]["id"].ToString()); model.announcementid = int.Parse(tbl.Rows[0]["announcementid"].ToString()); model.ipaddress = tbl.Rows[0]["ipaddress"].ToString(); model.operatecode = int.Parse(tbl.Rows[0]["operatecode"].ToString()); model.operatetxt = tbl.Rows[0]["operatetxt"].ToString(); model.createtime = DateTime.Parse(tbl.Rows[0]["createtime"].ToString()); model.founderid = int.Parse(tbl.Rows[0]["founderid"].ToString()); return(model); } else { return(null); } }
/// <summary> /// 操作日志 /// </summary> /// <param name="id">公告的id值</param> private void OperationRecord(int id) { EtNet_Models.AnnouncementLog model = new EtNet_Models.AnnouncementLog(); model.announcementid = id; model.createtime = DateTime.Now; model.founderid = ((EtNet_Models.LoginInfo)Session["login"]).Id; model.ipaddress = Request.UserHostAddress; model.operatecode = 3; model.operatetxt = "查看"; EtNet_BLL.AnnouncementLogManager.Add(model); }
/// <summary> /// 操作日志 /// </summary> /// <param name="id">公告的id值</param> /// <param name="sort">操作的分类值(1创建/2编辑/3查看/4隐藏/5显示)</param> private void OperationRecord(int id, int sort) { EtNet_Models.AnnouncementLog model = new EtNet_Models.AnnouncementLog(); model.announcementid = id; model.createtime = DateTime.Now; model.founderid = ((EtNet_Models.LoginInfo)Session["login"]).Id; model.ipaddress = Request.UserHostAddress; if (sort == 1) { model.operatecode = 1; model.operatetxt = "创建"; } else { model.operatecode = 2; model.operatetxt = "编辑"; } EtNet_BLL.AnnouncementLogManager.Add(model); }
/// <summary> /// 更新一条数据 /// </summary> public static bool Update(EtNet_Models.AnnouncementLog model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update AnnouncementLog set "); strSql.Append(" announcementid = @announcementid , "); strSql.Append(" ipaddress = @ipaddress , "); strSql.Append(" operatecode = @operatecode , "); strSql.Append(" operatetxt = @operatetxt , "); strSql.Append(" createtime = @createtime , "); strSql.Append(" founderid = @founderid "); strSql.Append(" where id=@id "); SqlParameter[] parameters = { new SqlParameter("@id", SqlDbType.Int, 4), new SqlParameter("@announcementid", SqlDbType.Int, 4), new SqlParameter("@ipaddress", SqlDbType.VarChar, 40), new SqlParameter("@operatecode", SqlDbType.Int, 4), new SqlParameter("@operatetxt", SqlDbType.VarChar, 40), new SqlParameter("@createtime", SqlDbType.DateTime), new SqlParameter("@founderid", SqlDbType.Int, 4) }; parameters[0].Value = model.id; parameters[1].Value = model.announcementid; parameters[2].Value = model.ipaddress; parameters[3].Value = model.operatecode; parameters[4].Value = model.operatetxt; parameters[5].Value = model.createtime; parameters[6].Value = model.founderid; int result = EtNet_DAL.DBHelper.ExecuteCommand(strSql.ToString(), parameters); if (result >= 1) { return(true); } else { return(false); } }
/// <summary> /// 增加一条数据 /// </summary> public static bool Add(EtNet_Models.AnnouncementLog model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into AnnouncementLog("); strSql.Append("announcementid,ipaddress,operatecode,operatetxt,createtime,founderid"); strSql.Append(") values ("); strSql.Append("@announcementid,@ipaddress,@operatecode,@operatetxt,@createtime,@founderid"); strSql.Append(") "); SqlParameter[] parameters = { new SqlParameter("@announcementid", SqlDbType.Int, 4), new SqlParameter("@ipaddress", SqlDbType.VarChar, 40), new SqlParameter("@operatecode", SqlDbType.Int, 4), new SqlParameter("@operatetxt", SqlDbType.VarChar, 40), new SqlParameter("@createtime", SqlDbType.DateTime), new SqlParameter("@founderid", SqlDbType.Int, 4) }; parameters[0].Value = model.announcementid; parameters[1].Value = model.ipaddress; parameters[2].Value = model.operatecode; parameters[3].Value = model.operatetxt; parameters[4].Value = model.createtime; parameters[5].Value = model.founderid; int result = EtNet_DAL.DBHelper.ExecuteCommand(strSql.ToString(), parameters); if (result >= 1) { return(true); } else { return(false); } }
/// <summary> /// 更新一条数据 /// </summary> public static bool Update(EtNet_Models.AnnouncementLog model) { return(EtNet_DAL.AnnouncementLogService.Update(model)); }
/// <summary> /// 增加一条数据 /// </summary> public static bool Add(EtNet_Models.AnnouncementLog model) { return(EtNet_DAL.AnnouncementLogService.Add(model)); }