示例#1
0
        public void RetreiveAllHolidays()
        {
            StaticHolidayCollection.staticHolidayList.Clear();
            using (var db = DBConnection.CreateConnection())
            {
                db.Open();

                var sql    = "dbo.spGetHolidays";
                var cmd    = new SqlCommand(sql, db);
                var reader = cmd.ExecuteReader();

                if (!reader.HasRows)
                {
                    return;
                }

                while (reader.Read())
                {
                    var item = new HolidayItem();

                    item._HOLIDAY_ID   = (int)reader["HOLIDAY_ID"];
                    item._HOLIDAY_NAME = (string)reader["HOLIDAY_NAME"];
                    item._HOLIDAY_DATE = (DateTime)reader["HOLIDAY_DATE"];
                    item._HOLIDAY_TYPE = (string)reader["HOLIDAY_TYPE"];

                    StaticHolidayCollection.staticHolidayList.Add(item);
                }

                db.Close();
            }
        }
示例#2
0
        public void getUpcoming()
        {
            using (var db = DBConnection.CreateConnection())
            {
                db.Open();
                var sql = "dbo.GET_HOLIDAY";
                var cmd = new SqlCommand(sql, db);
                cmd.CommandType = CommandType.StoredProcedure;
                var reader = cmd.ExecuteReader();

                if (!reader.HasRows)
                {
                    return;
                }
                while (reader.Read())
                {
                    var item = new HolidayItem();
                    item._HOLIDAY_ID   = (int)reader["HOLIDAY_ID"];
                    item._HOLIDAY_NAME = (string)reader["HOLIDAY_NAME"];
                    item._HOLIDAY_DATE = (DateTime)reader["HOLIDAY_DATE"];
                    item._HOLIDAY_TYPE = (string)reader["HOLIDAY_TYPE"];
                    holidays.holitem   = item;
                }
                db.Close();
            }
        }
示例#3
0
        public void SaveHoliday(HolidayItem myItem)
        {
            using (var db = DBConnection.CreateConnection())
            {
                db.Open();

                var sql = "dbo.spInsertHoliday";
                var cmd = new SqlCommand(sql, db);
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.Add(new SqlParameter("@HOLIDAY_NAME", myItem._HOLIDAY_NAME));
                cmd.Parameters.Add(new SqlParameter("@HOLIDAY_DATE", myItem._HOLIDAY_DATE));
                cmd.Parameters.Add(new SqlParameter("@HOLIDAY_TYPE", myItem._HOLIDAY_TYPE));
                cmd.ExecuteNonQuery();
                db.Close();
            }
        }