Beispiel #1
0
 public static void UpdateRevenueEntry(RevenueEntry revenueEntry)
 {
     using (var hdc = new HotelDataEntryDataContext())
     {
         try
         {
             var entry = hdc.RevenueEntries.Single(item => item.RevenueId == revenueEntry.RevenueId);
             entry.OccupancyRoom  = revenueEntry.OccupancyRoom;
             entry.FBRevenue      = revenueEntry.FBRevenue;
             entry.SpaRevenue     = revenueEntry.SpaRevenue;
             entry.RoomRevenue    = revenueEntry.RoomRevenue;
             entry.Others         = revenueEntry.Others;
             entry.Total          = revenueEntry.Total;
             entry.UpdateDateTime = DateTime.Now;
             entry.UpdateUser     = revenueEntry.UpdateUser;
             hdc.SubmitChanges();
         }
         catch (SqlException ex)
         {
             if (ex.Number == 2601 || ex.Number == 2627)
             {
                 throw;
             }
         }
     }
 }
        public static HotelDataEntryLib.HotelBudget AddHotelEntryListByYear(HotelBudget hotelEntry)
        {
            HotelBudget hotelEntrySubmit;
            using (var hdc = new HotelDataEntryDataContext())
            {
                hotelEntrySubmit = new HotelBudget()
                                           {
                                               PropertyId = hotelEntry.PropertyId,
                                               Year =hotelEntry.Year,
                                               UpdateDateTime = DateTime.Now
                                           };
                hdc.HotelBudgets.InsertOnSubmit(hotelEntrySubmit);

                try
                {
                    hdc.SubmitChanges();
                }
                catch (SqlException ex)
                {
                    if (ex.Number == 2601 || ex.Number == 2627)
                    {
                        throw;
                    }
                }
            }
            return hotelEntrySubmit;
        }
Beispiel #3
0
        public static void UpdateProperty(Property property)
        {
            using (var hdc = new HotelDataEntryDataContext())
            {
                var prop = hdc.Properties.Single(item => item.PropertyId == property.PropertyId);

                prop.PropertyName   = property.PropertyName;
                prop.PropertyCode   = property.PropertyCode;
                prop.CurrencyId     = property.CurrencyId;
                prop.Status         = property.Status;
                prop.UpdateDateTime = DateTime.Now;

                try
                {
                    hdc.SubmitChanges();
                }
                catch (SqlException ex)
                {
                    if (ex.Number == 2601 || ex.Number == 2627)
                    {
                        throw;
                    }
                }
            }
        }
Beispiel #4
0
 public static void UpdateUserProfile(User user)
 {
     using (var hdc = new HotelDataEntryDataContext())
     {
         var getUser = (from dataItem in hdc.Users
                        where dataItem.UserId == user.UserId
                        select dataItem).First();
         getUser.FirstName        = user.FirstName;
         getUser.LastName         = user.LastName;
         getUser.Email            = user.Email;
         getUser.PropertyId       = user.PropertyId;
         getUser.UpdateDateTime   = DateTime.Now;
         getUser.PermissionId     = user.PermissionId;
         getUser.Status           = user.Status;
         getUser.Position         = user.Position;
         getUser.AccessProperties = user.AccessProperties;
         getUser.Username         = user.Username;
         try
         {
             hdc.SubmitChanges();
         }
         catch (SqlException ex)
         {
             if (ex.Number == 2601 || ex.Number == 2627)
             {
                 throw;
             }
         }
     }
 }
Beispiel #5
0
        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);
        }
Beispiel #6
0
        public static void StoreError(string errMsg, string stacktrace, string Url)
        {
            try
            {
                using (var hdc = new HotelDataEntryDataContext())
                {
                    hdc.Logs.InsertOnSubmit(new HotelDataEntryLib.Log()
                    {
                       ErrorDate = DateTime.Now,
                       ClientIP = HttpContext.Current.Request.UserHostAddress,
                       Detail = stacktrace,
                       Message = errMsg,
                       Url = Url
                    });

                    try
                    {
                        hdc.SubmitChanges();
                    }
                    catch (SqlException ex)
                    {
                        if (ex.Number == 2601 || ex.Number == 2627)
                        {
                            throw;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public static void AddCurrency(Currency currency)
        {
            if (currency.IsBase == 1)
            {
                UpdateIsBaseCurrency();
            }
            using (var hdc = new HotelDataEntryDataContext())
            {
                hdc.Currencies.InsertOnSubmit(new HotelDataEntryLib.Currency
                {
                    CurrencyCode   = currency.CurrencyCode,
                    CurrencyName   = currency.CurrencyName,
                    UpdateDateTime = DateTime.Now,
                    Status         = currency.Status,
                    ConversionRate = currency.ConversionRate,
                    IsBase         = currency.IsBase
                });

                try
                {
                    hdc.SubmitChanges();
                }
                catch (SqlException ex)
                {
                    if (ex.Number == 2601 || ex.Number == 2627)
                    {
                        throw;
                    }
                }
            }
        }
        public static void UpdateCurrency(Currency currency)
        {
            if (currency.IsBase == 1)
            {
                UpdateIsBaseCurrency();
            }
            using (var hdc = new HotelDataEntryDataContext())
            {
                var cur = hdc.Currencies.Single(item => item.CurrencyId == currency.CurrencyId);
                cur.CurrencyName   = currency.CurrencyName;
                cur.CurrencyCode   = currency.CurrencyCode;
                cur.Status         = currency.Status;
                cur.ConversionRate = currency.ConversionRate;
                cur.UpdateDateTime = DateTime.Now;
                cur.IsBase         = currency.IsBase;

                try
                {
                    hdc.SubmitChanges();
                }
                catch (SqlException ex)
                {
                    if (ex.Number == 2601 || ex.Number == 2627)
                    {
                        throw;
                    }
                }
            }
        }
Beispiel #9
0
 public static void UpdateBudgetEntry(BudgetEntry budgetEntry)
 {
     using (var hdc = new HotelDataEntryDataContext())
     {
         try
         {
             var entry = hdc.BudgetEntries.Single(item => item.BudgetId == budgetEntry.BudgetId);
             entry.OccupancyRoom  = budgetEntry.OccupancyRoom;
             entry.RoomBudget     = budgetEntry.RoomBudget;
             entry.FBBudget       = budgetEntry.FBBudget;
             entry.SpaBudget      = budgetEntry.SpaBudget;
             entry.Others         = budgetEntry.Others;
             entry.Total          = budgetEntry.Total;
             entry.UpdateDateTime = DateTime.Now;
             entry.UpdateUser     = budgetEntry.UpdateUser;
             hdc.SubmitChanges();
         }
         catch (SqlException ex)
         {
             if (ex.Number == 2601 || ex.Number == 2627)
             {
                 throw;
             }
         }
     }
 }
        public static void AddCurrency(Currency currency)
        {
            if (currency.IsBase == 1)
            {
                UpdateIsBaseCurrency();
            }
            using (var hdc = new HotelDataEntryDataContext())
            {
                hdc.Currencies.InsertOnSubmit(new HotelDataEntryLib.Currency
                                                  {
                                                      CurrencyCode = currency.CurrencyCode,
                                                      CurrencyName = currency.CurrencyName,
                                                      UpdateDateTime = DateTime.Now,
                                                      Status = currency.Status,
                                                      ConversionRate = currency.ConversionRate,
                                                      IsBase = currency.IsBase
                                                  });

                try
                {
                    hdc.SubmitChanges();
                }
                catch (SqlException ex)
                {
                    if (ex.Number == 2601 || ex.Number == 2627)
                    {
                        throw;
                    }
                }
            }
        }
        public static void AddProperty(Property property)
        {
            using (var hdc = new HotelDataEntryDataContext())
            {
                hdc.Properties.InsertOnSubmit(new Property
                {
                    PropertyCode = property.PropertyCode,
                    PropertyName = property.PropertyName,
                    CurrencyId = property.CurrencyId,
                    UpdateDateTime = DateTime.Now,
                    Status = property.Status
                });

                try
                {
                    hdc.SubmitChanges();
                }
                catch (SqlException ex)
                {
                    if (ex.Number == 2601 || ex.Number == 2627)
                    {
                        throw;
                    }
                }
            }
        }
Beispiel #12
0
        public static void AddBudgetEntryListByYear(HotelBudget hotelEntry, string username)
        {
            using (var hdc = new HotelDataEntryDataContext())
            {
                for (var i = 0; i < 12; i++)
                {
                    hdc.BudgetEntries.InsertOnSubmit(new BudgetEntry()
                    {
                        HotelBudgetId  = hotelEntry.HotelBudgetId,
                        OccupancyRoom  = 0,
                        RoomBudget     = 0.00,
                        FBBudget       = 0.00,
                        SpaBudget      = 0.00,
                        Others         = 0.00,
                        Total          = 0.00,
                        UpdateDateTime = DateTime.Now,
                        UpdateUser     = username,
                        PositionMonth  = (i + 1) + "/" + hotelEntry.Year
                    });

                    try
                    {
                        hdc.SubmitChanges();
                    }
                    catch (SqlException ex)
                    {
                        if (ex.Number == 2601 || ex.Number == 2627)
                        {
                            throw;
                        }
                    }
                }
            }
        }
Beispiel #13
0
        public static void AddBudgetEntryListByYear(HotelBudget hotelEntry, string username)
        {
            using (var hdc = new HotelDataEntryDataContext())
             {
                 for (var i = 0; i < 12; i++)
                 {
                     hdc.BudgetEntries.InsertOnSubmit(new BudgetEntry()
                     {
                         HotelBudgetId = hotelEntry.HotelBudgetId,
                         OccupancyRoom = 0,
                         RoomBudget = 0.00,
                         FBBudget = 0.00,
                         SpaBudget = 0.00,
                         Others = 0.00,
                         Total = 0.00,
                         UpdateDateTime = DateTime.Now,
                         UpdateUser = username,
                         PositionMonth = (i+1)+"/"+hotelEntry.Year
                     });

                     try
                     {
                         hdc.SubmitChanges();
                     }
                     catch (SqlException ex)
                     {
                         if (ex.Number == 2601 || ex.Number == 2627)
                         {
                             throw;
                         }
                     }
                 }
             }
        }
Beispiel #14
0
        public static void StoreError(string errMsg, string stacktrace, string Url)
        {
            try
            {
                using (var hdc = new HotelDataEntryDataContext())
                {
                    hdc.Logs.InsertOnSubmit(new HotelDataEntryLib.Log()
                    {
                        ErrorDate = DateTime.Now,
                        ClientIP  = HttpContext.Current.Request.UserHostAddress,
                        Detail    = stacktrace,
                        Message   = errMsg,
                        Url       = Url
                    });

                    try
                    {
                        hdc.SubmitChanges();
                    }
                    catch (SqlException ex)
                    {
                        if (ex.Number == 2601 || ex.Number == 2627)
                        {
                            throw;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Beispiel #15
0
        public static void AddProperty(Property property)
        {
            using (var hdc = new HotelDataEntryDataContext())
            {
                hdc.Properties.InsertOnSubmit(new Property
                {
                    PropertyCode   = property.PropertyCode,
                    PropertyName   = property.PropertyName,
                    CurrencyId     = property.CurrencyId,
                    UpdateDateTime = DateTime.Now,
                    Status         = property.Status
                });

                try
                {
                    hdc.SubmitChanges();
                }
                catch (SqlException ex)
                {
                    if (ex.Number == 2601 || ex.Number == 2627)
                    {
                        throw;
                    }
                }
            }
        }
Beispiel #16
0
 public static void DeleteUserProfile(int userId)
 {
     using (var hdc = new HotelDataEntryDataContext())
     {
         var user = hdc.Users.Single(item => item.UserId == userId);
         hdc.Users.DeleteOnSubmit(user);
         try
         {
             hdc.SubmitChanges();
         }
         catch (SqlException ex)
         {
             if (ex.Number == 2601 || ex.Number == 2627)
             {
                 throw;
             }
         }
     }
 }
Beispiel #17
0
 public static void AddUserProfile(User user)
 {
     using (var hdc = new HotelDataEntryDataContext())
     {
         user.UpdateDateTime = DateTime.Now;
         hdc.Users.InsertOnSubmit(user);
         try
         {
             hdc.SubmitChanges();
         }
         catch (SqlException ex)
         {
             if (ex.Number == 2601 || ex.Number == 2627)
             {
                 throw;
             }
         }
     }
 }
Beispiel #18
0
 public static void AddUserProfile(User user)
 {
     using (var hdc = new HotelDataEntryDataContext())
     {
         user.UpdateDateTime = DateTime.Now;
         hdc.Users.InsertOnSubmit(user);
         try
         {
             hdc.SubmitChanges();
         }
         catch (SqlException ex)
         {
             if (ex.Number == 2601 || ex.Number == 2627)
             {
                 throw;
             }
         }
     }
 }
Beispiel #19
0
 public static void DeleteUserProfile(int userId)
 {
     using (var hdc = new HotelDataEntryDataContext())
     {
         var user = hdc.Users.Single(item => item.UserId == userId);
         hdc.Users.DeleteOnSubmit(user);
         try
         {
             hdc.SubmitChanges();
         }
         catch (SqlException ex)
         {
             if (ex.Number == 2601 || ex.Number == 2627)
             {
                 throw;
             }
         }
     }
 }
 public static void DeleteCurrency(int currencyId)
 {
     using (var hdc = new HotelDataEntryDataContext())
     {
         var currency = hdc.Currencies.Single(item => item.CurrencyId == currencyId);
         hdc.Currencies.DeleteOnSubmit(currency);
         try
         {
             hdc.SubmitChanges();
         }
         catch (SqlException ex)
         {
             if (ex.Number == 2601 || ex.Number == 2627)
             {
                 throw;
             }
         }
     }
 }
Beispiel #21
0
 public static void DeleteProperty(int propertyId)
 {
     using (var hdc = new HotelDataEntryDataContext())
     {
         var property = hdc.Properties.Single(item => item.PropertyId == propertyId);
         hdc.Properties.DeleteOnSubmit(property);
         try
         {
             hdc.SubmitChanges();
         }
         catch (SqlException ex)
         {
             if (ex.Number == 2601 || ex.Number == 2627)
             {
                 throw;
             }
         }
     }
 }
 public static void DeleteProperty(int propertyId)
 {
     using (var hdc = new HotelDataEntryDataContext())
     {
         var property = hdc.Properties.Single(item => item.PropertyId == propertyId);
         hdc.Properties.DeleteOnSubmit(property);
         try
         {
             hdc.SubmitChanges();
         }
         catch (SqlException ex)
         {
             if (ex.Number == 2601 || ex.Number == 2627)
             {
                 throw;
             }
         }
     }
 }
 public static void DeleteCurrency(int currencyId)
 {
     using (var hdc = new HotelDataEntryDataContext())
     {
         var currency = hdc.Currencies.Single(item => item.CurrencyId == currencyId);
         hdc.Currencies.DeleteOnSubmit(currency);
         try
         {
             hdc.SubmitChanges();
         }
         catch (SqlException ex)
         {
             if (ex.Number == 2601 || ex.Number == 2627)
             {
                 throw;
             }
         }
     }
 }
 public static void UpdateIsBaseCurrency()
 {
     using (var hdc = new HotelDataEntryDataContext())
     {
         var baseCurrency = hdc.Currencies.Single(item => item.IsBase == 1);
         if (baseCurrency != null)
         {
             baseCurrency.IsBase = 0;
             try
             {
                 hdc.SubmitChanges();
             }
             catch (SqlException ex)
             {
                 if (ex.Number == 2601 || ex.Number == 2627)
                 {
                     throw;
                 }
             }
         }
     }
 }
Beispiel #25
0
        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;
                        }
                    }
                }
            }
        }
Beispiel #26
0
        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;
                        }
                    }
                }
            }
        }
Beispiel #27
0
 public static void UpdateUserProfile(User user)
 {
     using (var hdc = new HotelDataEntryDataContext())
     {
         var getUser = (from dataItem in hdc.Users
                              where dataItem.UserId == user.UserId
                              select dataItem).First();
         getUser.FirstName = user.FirstName;
         getUser.LastName = user.LastName;
         getUser.Email = user.Email;
         getUser.PropertyId = user.PropertyId;
         getUser.UpdateDateTime = DateTime.Now;
         getUser.PermissionId = user.PermissionId;
         getUser.Status = user.Status;
         getUser.Position = user.Position;
         getUser.AccessProperties = user.AccessProperties;
         getUser.Username = user.Username;
         try
         {
             hdc.SubmitChanges();
         }
         catch (SqlException ex)
         {
             if (ex.Number == 2601 || ex.Number == 2627)
             {
                 throw;
             }
         }
     }
 }
        public static void UpdateCurrency(Currency currency)
        {
            if (currency.IsBase == 1)
            {
                UpdateIsBaseCurrency();
            }
            using (var hdc = new HotelDataEntryDataContext())
            {
                var cur = hdc.Currencies.Single(item => item.CurrencyId == currency.CurrencyId);
                cur.CurrencyName = currency.CurrencyName;
                cur.CurrencyCode = currency.CurrencyCode;
                cur.Status = currency.Status;
                cur.ConversionRate = currency.ConversionRate;
                cur.UpdateDateTime = DateTime.Now;
                cur.IsBase = currency.IsBase;

                try
                {
                    hdc.SubmitChanges();
                }
                catch (SqlException ex)
                {
                    if (ex.Number == 2601 || ex.Number == 2627)
                    {
                        throw;
                    }
                }
            }
        }
Beispiel #29
0
 public static void UpdateBudgetEntry(BudgetEntry budgetEntry)
 {
     using (var hdc = new HotelDataEntryDataContext())
      {
          try
          {
              var entry = hdc.BudgetEntries.Single(item => item.BudgetId == budgetEntry.BudgetId);
              entry.OccupancyRoom = budgetEntry.OccupancyRoom;
              entry.RoomBudget = budgetEntry.RoomBudget;
              entry.FBBudget = budgetEntry.FBBudget;
              entry.SpaBudget = budgetEntry.SpaBudget;
              entry.Others = budgetEntry.Others;
              entry.Total = budgetEntry.Total;
              entry.UpdateDateTime = DateTime.Now;
              entry.UpdateUser = budgetEntry.UpdateUser;
              hdc.SubmitChanges();
          }
          catch (SqlException ex)
          {
              if (ex.Number == 2601 || ex.Number == 2627)
              {
                  throw;
              }
          }
      }
 }
 public static void UpdateIsBaseCurrency()
 {
     using (var hdc = new HotelDataEntryDataContext())
     {
         var baseCurrency = hdc.Currencies.Single(item => item.IsBase == 1);
         if (baseCurrency != null)
         {
             baseCurrency.IsBase = 0;
             try
             {
                 hdc.SubmitChanges();
             }
             catch (SqlException ex)
             {
                 if (ex.Number == 2601 || ex.Number == 2627)
                 {
                     throw;
                 }
             }
         }
     }
 }
Beispiel #31
0
 public static void UpdateRevenueEntry(RevenueEntry revenueEntry)
 {
     using (var hdc = new HotelDataEntryDataContext())
     {
         try
         {
             var entry = hdc.RevenueEntries.Single(item => item.RevenueId == revenueEntry.RevenueId);
             entry.OccupancyRoom = revenueEntry.OccupancyRoom;
             entry.FBRevenue = revenueEntry.FBRevenue;
             entry.SpaRevenue = revenueEntry.SpaRevenue;
             entry.RoomRevenue = revenueEntry.RoomRevenue;
             entry.Others = revenueEntry.Others;
             entry.Total = revenueEntry.Total;
             entry.UpdateDateTime = DateTime.Now;
             entry.UpdateUser = revenueEntry.UpdateUser;
             hdc.SubmitChanges();
         }
         catch (SqlException ex)
         {
             if (ex.Number == 2601 || ex.Number == 2627)
             {
                 throw;
             }
         }
     }
 }
        public static void UpdateProperty(Property property)
        {
            using (var hdc = new HotelDataEntryDataContext())
            {
                var prop = hdc.Properties.Single(item => item.PropertyId == property.PropertyId);

                prop.PropertyName =property.PropertyName;
                prop.PropertyCode = property.PropertyCode;
                prop.CurrencyId = property.CurrencyId;
                prop.Status = property.Status;
                prop.UpdateDateTime = DateTime.Now;

                try
                {
                    hdc.SubmitChanges();
                }
                catch (SqlException ex)
                {
                    if (ex.Number == 2601 || ex.Number == 2627)
                    {
                        throw;
                    }
                }
            }
        }