public bool AddJournalInfo(JournalInfoEntity journalInfoEntity) { bool flag = false; StringBuilder sqlCommandText = new StringBuilder(); sqlCommandText.Append("@JournalName"); sqlCommandText.Append(", @SiteUrl"); sqlCommandText.Append(", @ServiceStartDate"); sqlCommandText.Append(", @ServiceEndDate"); sqlCommandText.Append(", @Linkman"); sqlCommandText.Append(", @LinkTel"); sqlCommandText.Append(", @Fax"); sqlCommandText.Append(", @Email"); sqlCommandText.Append(", @Mobile"); sqlCommandText.Append(", @Address"); sqlCommandText.Append(", @ZipCode"); sqlCommandText.Append(", @AuthorizationCode"); sqlCommandText.Append(", @Status"); sqlCommandText.Append(", @Note"); DbCommand cmd = db.GetSqlStringCommand(String.Format("INSERT INTO dbo.JournalInfo ({0}) VALUES ({1})",sqlCommandText.ToString().Replace("@", ""),sqlCommandText.ToString())); db.AddInParameter(cmd,"@JournalName",DbType.AnsiString,journalInfoEntity.JournalName); db.AddInParameter(cmd,"@SiteUrl",DbType.AnsiString,journalInfoEntity.SiteUrl); db.AddInParameter(cmd,"@ServiceStartDate",DbType.DateTime,journalInfoEntity.ServiceStartDate); db.AddInParameter(cmd,"@ServiceEndDate",DbType.DateTime,journalInfoEntity.ServiceEndDate); db.AddInParameter(cmd,"@Linkman",DbType.AnsiString,journalInfoEntity.Linkman); db.AddInParameter(cmd,"@LinkTel",DbType.AnsiString,journalInfoEntity.LinkTel); db.AddInParameter(cmd,"@Fax",DbType.AnsiString,journalInfoEntity.Fax); db.AddInParameter(cmd,"@Email",DbType.AnsiString,journalInfoEntity.Email); db.AddInParameter(cmd,"@Mobile",DbType.AnsiString,journalInfoEntity.Mobile); db.AddInParameter(cmd,"@Address",DbType.AnsiString,journalInfoEntity.Address); db.AddInParameter(cmd,"@ZipCode",DbType.AnsiString,journalInfoEntity.ZipCode); db.AddInParameter(cmd,"@AuthorizationCode",DbType.AnsiString,journalInfoEntity.AuthorizationCode); db.AddInParameter(cmd,"@Status",DbType.Byte,journalInfoEntity.Status); db.AddInParameter(cmd,"@Note",DbType.AnsiString,journalInfoEntity.Note); try { db.ExecuteNonQuery(cmd); flag = true; } catch(SqlException sqlEx) { throw sqlEx; } return flag; }
public ActionResult AddAjax(JournalInfoEntity journalEntity) { try { if (!Request.IsAjaxRequest()) { return Content("{\"result\":\"failure\",\"msg\":\"非法请求\"}"); } string msg = ""; if (ModelState.IsValid) { IJournalInfoService journalService = ServiceContainer.Instance.Container.Resolve<IJournalInfoService>(); JournalInfoQuery queryEntity = new JournalInfoQuery(); queryEntity.JournalName = WKT.Common.Security.SecurityUtils.SafeSqlString(journalEntity.JournalName); IList<JournalInfoEntity> list = journalService.GetJournalInfoList(queryEntity); if (list.Count > 0) { msg = "{\"result\":\"failure\",\"msg\":\"该编辑部已经存在\"}"; } else { bool flag = journalService.AddJournalInfo(journalEntity); if (flag) { msg = "{\"result\":\"success\"}"; } else { msg = "{\"result\":\"failure\",\"msg\":\"添加失败,请检查\"}"; } } } else { msg = "{\"result\":\"failure\",\"msg\":\"" + this.ExpendErrors() + "\"}"; } return Content(msg); } catch (Exception ex) { LogProvider.Instance.Error("添加编辑部异常:" + ex.Message); return Content("{\"result\":\"error\",\"msg\":\"" + ex.Message + "\"}"); } }
public bool UpdateJournalInfo(JournalInfoEntity journalInfoEntity) { bool flag = false; StringBuilder whereCommandText = new StringBuilder(); whereCommandText.Append(" JournalID=@JournalID"); StringBuilder sqlCommandText = new StringBuilder(); sqlCommandText.Append(" JournalName=@JournalName"); sqlCommandText.Append(", SiteUrl=@SiteUrl"); sqlCommandText.Append(", ServiceStartDate=@ServiceStartDate"); sqlCommandText.Append(", ServiceEndDate=@ServiceEndDate"); sqlCommandText.Append(", Linkman=@Linkman"); sqlCommandText.Append(", LinkTel=@LinkTel"); sqlCommandText.Append(", Fax=@Fax"); sqlCommandText.Append(", Email=@Email"); sqlCommandText.Append(", Mobile=@Mobile"); sqlCommandText.Append(", Address=@Address"); sqlCommandText.Append(", ZipCode=@ZipCode"); sqlCommandText.Append(", AuthorizationCode=@AuthorizationCode"); sqlCommandText.Append(", Status=@Status"); sqlCommandText.Append(", Note=@Note"); sqlCommandText.Append(", AddDate=@AddDate"); DbCommand cmd = db.GetSqlStringCommand(String.Format("UPDATE dbo.JournalInfo SET {0} WHERE {1}",sqlCommandText.ToString(),whereCommandText.ToString())); db.AddInParameter(cmd,"@JournalID",DbType.Int64,journalInfoEntity.JournalID); db.AddInParameter(cmd,"@JournalName",DbType.AnsiString,journalInfoEntity.JournalName); db.AddInParameter(cmd,"@SiteUrl",DbType.AnsiString,journalInfoEntity.SiteUrl); db.AddInParameter(cmd,"@ServiceStartDate",DbType.DateTime,journalInfoEntity.ServiceStartDate); db.AddInParameter(cmd,"@ServiceEndDate",DbType.DateTime,journalInfoEntity.ServiceEndDate); db.AddInParameter(cmd,"@Linkman",DbType.AnsiString,journalInfoEntity.Linkman); db.AddInParameter(cmd,"@LinkTel",DbType.AnsiString,journalInfoEntity.LinkTel); db.AddInParameter(cmd,"@Fax",DbType.AnsiString,journalInfoEntity.Fax); db.AddInParameter(cmd,"@Email",DbType.AnsiString,journalInfoEntity.Email); db.AddInParameter(cmd,"@Mobile",DbType.AnsiString,journalInfoEntity.Mobile); db.AddInParameter(cmd,"@Address",DbType.AnsiString,journalInfoEntity.Address); db.AddInParameter(cmd,"@ZipCode",DbType.AnsiString,journalInfoEntity.ZipCode); db.AddInParameter(cmd,"@AuthorizationCode",DbType.AnsiString,journalInfoEntity.AuthorizationCode); db.AddInParameter(cmd,"@Status",DbType.Byte,journalInfoEntity.Status); db.AddInParameter(cmd,"@Note",DbType.AnsiString,journalInfoEntity.Note); db.AddInParameter(cmd,"@AddDate",DbType.DateTime,journalInfoEntity.AddDate); try { db.ExecuteNonQuery(cmd); flag = true; } catch(SqlException sqlEx) { throw sqlEx; } return flag; }
public List<JournalInfoEntity> MakeJournalInfoList(IDataReader dr) { List<JournalInfoEntity> list=new List<JournalInfoEntity>(); while(dr.Read()) { JournalInfoEntity journalInfoEntity=new JournalInfoEntity(); journalInfoEntity.JournalID = (Int64)dr["JournalID"]; journalInfoEntity.JournalName = (String)dr["JournalName"]; journalInfoEntity.SiteUrl = (String)dr["SiteUrl"]; journalInfoEntity.ServiceStartDate = (DateTime)dr["ServiceStartDate"]; journalInfoEntity.ServiceEndDate = (DateTime)dr["ServiceEndDate"]; journalInfoEntity.Linkman = (String)dr["Linkman"]; journalInfoEntity.LinkTel = (String)dr["LinkTel"]; journalInfoEntity.Fax = (String)dr["Fax"]; journalInfoEntity.Email = (String)dr["Email"]; journalInfoEntity.Mobile = (String)dr["Mobile"]; journalInfoEntity.Address = (String)dr["Address"]; journalInfoEntity.ZipCode = (String)dr["ZipCode"]; journalInfoEntity.AuthorizationCode = (String)dr["AuthorizationCode"]; journalInfoEntity.Status = (Byte)dr["Status"]; journalInfoEntity.Note = (String)dr["Note"]; journalInfoEntity.AddDate = (DateTime)dr["AddDate"]; list.Add(journalInfoEntity); } dr.Close(); return list; }
public JournalInfoEntity MakeJournalInfo(DataRow dr) { JournalInfoEntity journalInfoEntity=null; if(dr!=null) { journalInfoEntity=new JournalInfoEntity(); journalInfoEntity.JournalID = (Int64)dr["JournalID"]; journalInfoEntity.JournalName = (String)dr["JournalName"]; journalInfoEntity.SiteUrl = (String)dr["SiteUrl"]; journalInfoEntity.ServiceStartDate = (DateTime)dr["ServiceStartDate"]; journalInfoEntity.ServiceEndDate = (DateTime)dr["ServiceEndDate"]; journalInfoEntity.Linkman = (String)dr["Linkman"]; journalInfoEntity.LinkTel = (String)dr["LinkTel"]; journalInfoEntity.Fax = (String)dr["Fax"]; journalInfoEntity.Email = (String)dr["Email"]; journalInfoEntity.Mobile = (String)dr["Mobile"]; journalInfoEntity.Address = (String)dr["Address"]; journalInfoEntity.ZipCode = (String)dr["ZipCode"]; journalInfoEntity.AuthorizationCode = (String)dr["AuthorizationCode"]; journalInfoEntity.Status = (Byte)dr["Status"]; journalInfoEntity.Note = (String)dr["Note"]; journalInfoEntity.AddDate = (DateTime)dr["AddDate"]; } return journalInfoEntity; }
public bool DeleteJournalInfo(JournalInfoEntity journalInfoEntity) { bool flag = false; StringBuilder sqlCommandText = new StringBuilder(); sqlCommandText.Append("DELETE FROM dbo.JournalInfo"); sqlCommandText.Append(" WHERE JournalID=@JournalID"); DbCommand cmd = db.GetSqlStringCommand(sqlCommandText.ToString()); db.AddInParameter(cmd,"@JournalID",DbType.Int64,journalInfoEntity.JournalID); try { db.ExecuteNonQuery(cmd); flag = true; } catch(SqlException sqlEx) { throw sqlEx; } return flag; }
/// <summary> /// 从存储媒介删除实体数据 /// </summary> /// <param name="journalInfo">JournalInfoEntity实体对象</param> /// <returns>true:删除成功 false:删除失败</returns> public bool DeleteJournalInfo(JournalInfoEntity journalInfo) { return JournalInfoBusProvider.DeleteJournalInfo(journalInfo); }
/// <summary> /// 将实体数据存入存储媒介(持久化一个对象) /// </summary> /// <param name="journalInfo">JournalInfoEntity实体对象</param> /// <returns>true:存储成功 false:存储失败</returns> public bool AddJournalInfo(JournalInfoEntity journalInfo) { return JournalInfoBusProvider.AddJournalInfo(journalInfo); }
/// <summary> /// 更新存储媒介中的实体数据 /// </summary> /// <param name="journalInfo">JournalInfoEntity实体对象</param> /// <returns>true:更新成功 false:更新失败</returns> public bool UpdateJournalInfo(JournalInfoEntity journalInfo) { return JournalInfoBusProvider.UpdateJournalInfo(journalInfo); }
public ActionResult EditAjax(JournalInfoEntity journalEntity) { try { if (!Request.IsAjaxRequest()) { return Content("{\"result\":\"failure\",\"msg\":\"非法请求\"}"); } string msg = ""; if (ModelState.IsValid) { IJournalInfoService journalService = ServiceContainer.Instance.Container.Resolve<IJournalInfoService>(); bool flag = journalService.UpdateJournalInfo(journalEntity); if (flag) { msg = "{\"result\":\"success\"}"; } else { msg = "{\"result\":\"failure\",\"msg\":\"修改失败,请检查\"}"; } } else { msg = "{\"result\":\"failure\",\"msg\":\"" + this.ExpendErrors() + "\"}"; } return Content(msg); } catch (Exception ex) { LogProvider.Instance.Error("修改编辑部信息异常:" + ex.Message); return Content("{\"result\":\"error\",\"msg\":\"" + ex.Message + "\"}"); } }
/// <summary> /// 从存储媒介删除实体数据 /// </summary> /// <param name="journalInfo">JournalInfoEntity实体对象</param> /// <returns>true:删除成功 false:删除失败</returns> public bool DeleteJournalInfo(JournalInfoEntity journalInfo) { return JournalInfoDataAccess.Instance.DeleteJournalInfo(journalInfo); }
/// <summary> /// 将实体数据存入存储媒介(持久化一个对象) /// </summary> /// <param name="journalInfo">JournalInfoEntity实体对象</param> /// <returns>true:存储成功 false:存储失败</returns> public bool AddJournalInfo(JournalInfoEntity journalInfo) { return JournalInfoDataAccess.Instance.AddJournalInfo(journalInfo); }