public static bool ExistMothYear(HotelRevenue hotelEntry) { var hdc = new HotelDataEntryDataContext(); var count = hdc.HotelRevenues.Count(item => item.Month == hotelEntry.Month && item.Year == hotelEntry.Year && item.PropertyId == hotelEntry.PropertyId); return(count != 0); }
public static HotelRevenue GetHotelEntry(HotelRevenue hotelEntry) { var hdc = new HotelDataEntryDataContext(); var hEntry = hdc.HotelRevenues.Single(item => item.Month == hotelEntry.Month && item.Year == hotelEntry.Year && item.PropertyId == hotelEntry.PropertyId); return(hEntry); }
public static HotelDataEntryLib.HotelRevenue AddHotelEntryListByMonthYear(HotelRevenue hotelEntry) { HotelRevenue hotelEntrySubmit; using (var hdc = new HotelDataEntryDataContext()) { hotelEntrySubmit = new HotelRevenue() { PropertyId = hotelEntry.PropertyId, Month = hotelEntry.Month, Year = hotelEntry.Year, UpdateDateTime = DateTime.Now }; hdc.HotelRevenues.InsertOnSubmit(hotelEntrySubmit); try { hdc.SubmitChanges(); } catch (SqlException ex) { if (ex.Number == 2601 || ex.Number == 2627) { throw; } } } return(hotelEntrySubmit); }
public static HotelDataEntryLib.HotelRevenue AddHotelEntryListByMonthYear(HotelRevenue hotelEntry) { HotelRevenue hotelEntrySubmit; using (var hdc = new HotelDataEntryDataContext()) { hotelEntrySubmit = new HotelRevenue() { PropertyId = hotelEntry.PropertyId, Month = hotelEntry.Month, Year =hotelEntry.Year, UpdateDateTime = DateTime.Now }; hdc.HotelRevenues.InsertOnSubmit(hotelEntrySubmit); try { hdc.SubmitChanges(); } catch (SqlException ex) { if (ex.Number == 2601 || ex.Number == 2627) { throw; } } } return hotelEntrySubmit; }
public static void AddRevenueEntryListByMonthYear(HotelRevenue hotelEntry, string username) { var dates = GetLastDayOfMonth(hotelEntry.Month, hotelEntry.Year); using (var hdc = new HotelDataEntryDataContext()) { for (var i = 0; i < dates; i++) { hdc.RevenueEntries.InsertOnSubmit(new RevenueEntry() { HotelRevenueId = hotelEntry.HotelRevenueId, OccupancyRoom = 0, RoomRevenue = 0.00, FBRevenue = 0.00, SpaRevenue = 0.00, Others = 0.00, Total = 0.00, UpdateDateTime = DateTime.Now, UpdateUser = username, PositionDate = new DateTime(hotelEntry.Year, hotelEntry.Month, (i + 1)) }); try { hdc.SubmitChanges(); } catch (SqlException ex) { if (ex.Number == 2601 || ex.Number == 2627) { throw; } } } } }
public static HotelRevenue GetHotelEntry(HotelRevenue hotelEntry) { var hdc = new HotelDataEntryDataContext(); var hEntry = hdc.HotelRevenues.Single(item => item.Month == hotelEntry.Month && item.Year == hotelEntry.Year && item.PropertyId == hotelEntry.PropertyId); return hEntry; }
public static bool ExistMothYear(HotelRevenue hotelEntry) { var hdc = new HotelDataEntryDataContext(); var count = hdc.HotelRevenues.Count(item => item.Month == hotelEntry.Month &&item.Year==hotelEntry.Year && item.PropertyId == hotelEntry.PropertyId); return count != 0; }
public static List <HotelDataEntryLib.Helper.Revenue> ListRevenueEntryByMonthYear(HotelRevenue hotelEntry) { var dates = GetLastDayOfMonth(hotelEntry.Month, hotelEntry.Year); var positionMonth = hotelEntry.Month + "/" + hotelEntry.Year; var hdc = new HotelDataEntryDataContext(); var list = (from revenueEntry in hdc.RevenueEntries join hotelRevenue in hdc.HotelRevenues on revenueEntry.HotelRevenueId equals hotelRevenue.HotelRevenueId join hotelBudget in hdc.HotelBudgets on new { hotelRevenue.Year, hotelRevenue.PropertyId } equals new { hotelBudget.Year, hotelBudget.PropertyId } join budgetEntry in hdc.BudgetEntries on hotelBudget.HotelBudgetId equals budgetEntry.HotelBudgetId where revenueEntry.HotelRevenueId == hotelEntry.HotelRevenueId && budgetEntry.PositionMonth == positionMonth orderby revenueEntry.PositionDate select new Revenue() { RevenueId = revenueEntry.RevenueId, PositionDate = revenueEntry.PositionDate, HotelRevenueId = revenueEntry.HotelRevenueId, OccupancyRoom = revenueEntry.OccupancyRoom, RoomRevenue = revenueEntry.RoomRevenue, FBRevenue = revenueEntry.FBRevenue, SpaRevenue = revenueEntry.SpaRevenue, Others = revenueEntry.Others, Total = revenueEntry.Total, Budget = revenueEntry.Total <= 0?0:budgetEntry.Total / dates, Day = revenueEntry.PositionDate.DayOfWeek.ToString(), UpdateDateTime = revenueEntry.UpdateDateTime, DateNowMillisecond = DateTime.Now.Ticks, UpdateDateTimeMillisecond = Convert.ToDateTime(revenueEntry.UpdateDateTime).Ticks }).ToList(); return(list); }