public static Boolean UpdateOne(BLL.CalendarEvent calEvent) { int rows = 0; SqlConnection con = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["DBCalendar"].ToString()); SqlCommand comm = new SqlCommand("CalendarEventUpdateOne", con); comm.CommandType = CommandType.StoredProcedure; comm.Parameters.AddWithValue("@Id", calEvent.GetId()); comm.Parameters.AddWithValue("@Date", calEvent.CalendarDate); comm.Parameters.AddWithValue("@Title", calEvent.Title); comm.Parameters.AddWithValue("@Detail", calEvent.Detail); try { con.Open(); rows = comm.ExecuteNonQuery(); } catch (Exception e) { System.Console.WriteLine(e); } finally { con.Close(); } return(rows > 0); }
public static int InsertOne(BLL.CalendarEvent calEvent) { int id = 0; SqlConnection con = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["DBCalendar"].ToString()); SqlCommand comm = new SqlCommand("CalendarEventInsertOne", con); comm.CommandType = CommandType.StoredProcedure; comm.Parameters.AddWithValue("@Date", calEvent.CalendarDate); comm.Parameters.AddWithValue("@Title", calEvent.Title); comm.Parameters.AddWithValue("@Detail", calEvent.Detail); SqlParameter parId = new SqlParameter("@Id", DbType.Int32); parId.Direction = ParameterDirection.Output; comm.Parameters.Add(parId); try { con.Open(); comm.ExecuteNonQuery(); id = (int)parId.Value; } catch (Exception e) { System.Console.WriteLine(e); } finally { con.Close(); } return(id); }
public static List <BLL.CalendarEvent> GetAllBetweenDates(DateTime start, DateTime end) { List <BLL.CalendarEvent> events = new List <BLL.CalendarEvent>(); SqlConnection con = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["DBCalendar"].ToString()); SqlCommand comm = new SqlCommand("CalendarEventSelectByDate", con); comm.CommandType = CommandType.StoredProcedure; comm.Parameters.AddWithValue("@StartDate", start); comm.Parameters.AddWithValue("@EndDate", end); SqlDataReader reader; try { con.Open(); using (reader = comm.ExecuteReader()) { if (reader.HasRows) { while (reader.Read()) { BLL.CalendarEvent calEvent = new BLL.CalendarEvent((int)reader["Id"]); calEvent.CalendarDate = (DateTime)reader["Date"]; calEvent.Title = reader["Title"].ToString(); calEvent.Detail = reader["Detail"].ToString(); events.Add(calEvent); } } } } catch (Exception e) { System.Console.WriteLine(e); } finally { con.Close(); } return(events); }
public static List<BLL.CalendarEvent> GetAllBetweenDates(DateTime start, DateTime end) { List<BLL.CalendarEvent> events = new List<BLL.CalendarEvent>(); SqlConnection con = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["DBCalendar"].ToString()); SqlCommand comm = new SqlCommand("CalendarEventSelectByDate", con); comm.CommandType = CommandType.StoredProcedure; comm.Parameters.AddWithValue("@StartDate", start); comm.Parameters.AddWithValue("@EndDate", end); SqlDataReader reader; try { con.Open(); using (reader = comm.ExecuteReader()) { if (reader.HasRows) { while (reader.Read()) { BLL.CalendarEvent calEvent = new BLL.CalendarEvent((int)reader["Id"]); calEvent.CalendarDate = (DateTime)reader["Date"]; calEvent.Title = reader["Title"].ToString(); calEvent.Detail = reader["Detail"].ToString(); events.Add(calEvent); } } } } catch (Exception e) { System.Console.WriteLine(e); } finally { con.Close(); } return events; }
public static Boolean Update(BLL.CalendarEvent calEvent) { return(DAL.CalendarEvent.UpdateOne(calEvent)); }
public static int Insert(BLL.CalendarEvent calEvent) { return(DAL.CalendarEvent.InsertOne(calEvent)); }