public ActionResult Delete(int id, Sys_NoticeVO collection) { try { Sys_NoticeDAC boardMgt = new Sys_NoticeDAC(); if (boardMgt.DeleteSys_Notice(id)) { return(RedirectToAction("Index")); //인서트가 성공적으로 됐다면. 목록으로 가라 indexview가 목록임. } else { return(View("Delete", collection)); //인서트가성공안되면 내가 써논 값을 가지고 create를 하기위해서 } } catch { return(View()); } }
public bool InsertSys_Notice(Sys_NoticeVO notice) { string sql = "Insert into Sys_Notice (Notice_Date, Notice_End, Title,Description,Ins_Emp) values(@Notice_Date, @Notice_End, @Title,@Description,@Ins_Emp)"; using (SqlConnection conn = new SqlConnection(Connstr)) { SqlCommand cmd = new SqlCommand(sql, conn); cmd.Parameters.AddWithValue("@Notice_Date", notice.Notice_Date); cmd.Parameters.AddWithValue("@Notice_End", notice.Notice_End); cmd.Parameters.AddWithValue("@Title", notice.Title); cmd.Parameters.AddWithValue("@Description", notice.Description); cmd.Parameters.AddWithValue("@Ins_Emp", UserInfo.User_Name); conn.Open(); int iResult = cmd.ExecuteNonQuery(); conn.Close(); return(iResult > 0); } }
public ActionResult Edit(int id, Sys_NoticeVO collection) { try { // TODO: Add insert logic here Sys_NoticeDAC dac = new Sys_NoticeDAC(); if (dac.UpdateSys_Notice(collection)) { return(RedirectToAction("Index")); //인서트가 성공적으로 됐다면. 목록으로 가라 indexview가 목록임. } else { return(View("Edit", collection)); //인서트가성공안되면 내가 써논 값을 가지고 create를 하기위해서 } } catch { return(View()); } }
public ActionResult Create(Sys_NoticeVO notice) { try { // TODO: Add insert logic here Sys_NoticeDAC dac = new Sys_NoticeDAC(); if (dac.InsertSys_Notice(notice)) { return(RedirectToAction("Index")); //인서트가 성공적으로 됐다면. 목록으로 가라 indexview가 목록임. } else { return(View("Create", notice)); //인서트가성공안되면 내가 써논 값을 가지고 create를 하기위해서 } } catch { return(View()); } }
public string GetCurrentSysNotice() { Sys_NoticeService service = new Sys_NoticeService(); Sys_NoticeVO notice = service.GetCurrentSysNotice(sysnoticeseq); if (notice != null) { return(notice.Description); } else { if (sysnoticeseq == 1) { runNotice = false; return("~공지사항~"); } sysnoticeseq = 1; return(service.GetCurrentSysNotice(1).Description); } }
public bool UpdateSys_Notice(Sys_NoticeVO notice) { string sql = "update Sys_Notice set Notice_Date=@Notice_Date, Notice_End=@Notice_End, Title=@Title,Description=@Description where Seq=@Seq"; using (SqlConnection conn = new SqlConnection(Connstr)) { SqlCommand cmd = new SqlCommand(sql, conn); cmd.Parameters.AddWithValue("@SEQ", notice.Seq); cmd.Parameters.AddWithValue("@Notice_Date", notice.Notice_Date); cmd.Parameters.AddWithValue("@Notice_End", notice.Notice_End); cmd.Parameters.AddWithValue("@Title", notice.Title); cmd.Parameters.AddWithValue("@Description", notice.Description); conn.Open(); int iResult = cmd.ExecuteNonQuery(); conn.Close(); return(iResult > 0); } }
/// <summary> /// 현재 공지사항 가져오기 /// </summary> /// <param name="Seq"></param> /// <returns></returns> public Sys_NoticeVO GetCurrentSysNotice(int Seq) { Sys_NoticeVO item = null; using (SqlCommand comm = new SqlCommand()) { comm.Connection = new SqlConnection(Connstr); comm.CommandText = @" SELECT * FROM ( SELECT ROW_NUMBER() OVER(ORDER BY [Seq] DESC) AS SEQ ,[Notice_Date] ,[Notice_End] ,[Title] ,[Description] FROM [dbo].[Sys_Notice] WHERE (getdate() between [Notice_Date] and DATEADD(DAY, 1, [Notice_End])) ) AS NOTICE WHERE NOTICE.SEQ = @Seq; "; comm.CommandType = CommandType.Text; comm.Parameters.AddWithValue("@Seq", Seq); comm.Connection.Open(); SqlDataReader reader = comm.ExecuteReader(); if (reader.Read()) { item = new Sys_NoticeVO() { Req = reader[0].ToString(), Notice_Date = reader[1].ToString(), Notice_End = reader[2].ToString(), Title = reader[3].ToString(), Description = reader[4].ToString(), }; } comm.Connection.Close(); return(item); } }
public Sys_NoticeVO GetDetailsSys_Notice(int id, bool bDetail) { Sys_NoticeVO list = new Sys_NoticeVO(); string sql = string.Empty; if (bDetail) { sql = "update Sys_Notice set Notice_Date=@Notice_Date, Notice_End=@Notice_End, Title=@Title,Description=@Description where Seq=@Seq"; } else //수정일경우에는 조회수 + x { sql = @"select Seq, Notice_Date, Notice_End, Title,Description,Ins_Emp, (select min(Seq) from Sys_Notice where Seq >a.Seq) nextNum, (select max(Seq) from Sys_Notice where Seq<a.Seq) notnext from Sys_Notice a where Seq=@Seq"; } using (SqlConnection conn = new SqlConnection(Connstr)) { SqlCommand cmd = new SqlCommand(sql, conn); conn.Open(); cmd.Parameters.AddWithValue("@SEQ", id); SqlDataReader reader = cmd.ExecuteReader(); while (reader.Read()) { list.Seq = Convert.ToInt32(reader["Seq"]); list.Notice_Date = Convert.ToDateTime(reader["Notice_Date"]); list.Notice_End = Convert.ToDateTime(reader["Notice_End"]); list.Title = reader["Title"].ToString(); list.Description = reader["Description"].ToString(); list.Ins_Emp = reader["Ins_Emp"].ToString(); list.nextNum = reader["nextNum"].ToString(); list.notnext = reader["notnext"].ToString(); } reader.Close(); conn.Close(); } return(list); }