예제 #1
0
파일: DAL.cs 프로젝트: coolzoom/WoWCalendar
        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);
        }
예제 #2
0
파일: DAL.cs 프로젝트: coolzoom/WoWCalendar
        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);
        }
예제 #3
0
파일: DAL.cs 프로젝트: coolzoom/WoWCalendar
        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);
        }
예제 #4
0
파일: DAL.cs 프로젝트: LanceDH/WoWCalendar
        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;
        }
예제 #5
0
 public static Boolean Update(BLL.CalendarEvent calEvent)
 {
     return(DAL.CalendarEvent.UpdateOne(calEvent));
 }
예제 #6
0
 public static int Insert(BLL.CalendarEvent calEvent)
 {
     return(DAL.CalendarEvent.InsertOne(calEvent));
 }