public ActionResult AddAnnouncement(int RegionCode, string Content) { var info = new Announcement(); info.RegionCode = RegionCode; info.Content = Content; var r = DAL.M.BaseUpdate.Announcement(info); ViewData["R"] = r; return View(); }
public static R Announcement(Announcement info) { var m = new R(); try { SqlParameter[] param = { new SqlParameter("@RegionCode",info.RegionCode), new SqlParameter("@Content",info.Content) }; //param[0].Direction = ParameterDirection.InputOutput; string SQL = @" DELETE FROM Announcement WHERE RegionCode=@RegionCode INSERT INTO dbo.Announcement ( RegionCode, Content ) VALUES ( @RegionCode, @Content )"; var r = SqlHelper.ExecuteNonQuery(SqlHelper.Local, CommandType.Text, SQL, param); m.Code = 0; m.Value = r; m.Message = "success"; // m.Value = Convert.ToInt32(param[0].Value); } catch (Exception ex) { m.Code = 300; m.Message = ex.Message; log.Fatal("{0},{1}", ex.Message, ex.StackTrace); } return m; }
public static Announcement Announcement(int RegionCode) { var m = new Announcement(); try { SqlParameter[] param = { new SqlParameter("@RegionCode",RegionCode) }; string SQL = "SELECT * FROM dbo.[Announcement] WHERE RegionCode=@RegionCode"; var dr = SqlHelper.ExecuteReader(SqlHelper.Local, CommandType.Text, SQL, param); if (dr.Read()) { m.ID = Convert.ToInt32(dr["ID"]); m.RegionCode = Convert.ToInt32(dr["RegionCode"]); m.Content = Convert.ToString(dr["Content"]); } dr.Close(); } catch (Exception ex) { log.Fatal("{0},{1}",ex.Message,ex.StackTrace); } return m; }