public ZhaoHuo GetObjById(string id) { string sql = "select * from Zh_Info where zhId ='{0}'"; sql = string.Format(sql, id); SqlDataReader dr = SQLHelper.GetReader(sql); ZhaoHuo obj = null; if (dr.Read()) { obj = new ZhaoHuo { zhId = Convert.ToInt32(dr["zhId"]), zhTitle = dr["zhTitle"].ToString(), zhUser = dr["zhUser"].ToString(), zhPhone = dr["zhPhone"].ToString(), zhArea = dr["zhArea"].ToString(), zhGz = dr["zhGz"].ToString(), zhDetail = dr["zhDetail"].ToString(), zhAddtime = Convert.ToDateTime(dr["zhAddtime"]), zhNum = Convert.ToInt32(dr["zhNum"]), }; } return(obj); }
public int Add(ZhaoHuo obj) { StringBuilder sqlBuilder = new StringBuilder(); sqlBuilder.Append("insert into Zh_Info (zhTitle, zhUser, zhPhone, zhArea, zhGz, zhDetail, zhAddtime, zhNum) "); sqlBuilder.Append("values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}')"); string sql = string.Format(sqlBuilder.ToString(), obj.zhTitle, obj.zhUser, obj.zhPhone, obj.zhArea, obj.zhGz, obj.zhDetail, DateTime.Now, obj.zhNum); try { return(Convert.ToInt32(SQLHelper.Update(sql))); } catch (SqlException ex) { throw new Exception("数据库操作出现异常!具体信息:\r\n" + ex.Message); } }
//[Authorize] public ActionResult getZhFabu(ZhaoHuo obj) { if (ModelState.IsValid) { obj = new ZhaoHuo { zhTitle = obj.zhTitle, zhUser = obj.zhUser, zhPhone = obj.zhPhone, zhArea = obj.zhArea, zhGz = obj.zhGz, zhNum = obj.zhNum, zhDetail = obj.zhDetail }; int result = new ZhaoHuoBLL().Add(obj); string info = "--->" + obj.zhTitle + "消息已经成功发布!"; return(RedirectToAction("zhFabu", "ZhaoHuo", new { info })); //return this.Content("<script>window.location='" + Url.Action("GetList", "SysAdmin") + "'</script>"); } else { return(View("Reg")); } }
public int Add(ZhaoHuo obj) { return(new ZhaoHuoDAL().Add(obj)); }