Exemplo n.º 1
0
        /// <summary>
        /// Handles the Load event of the Page control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
        /// <exception cref="System.ApplicationException">Permission denied for this Booking.</exception>
        protected void Page_Load(object sender, EventArgs e)
        {
            //IsLargeContentArea = true;
            if (!IsPostBack)
            {
                Data.Booking booking = GetBL <InventoryBL>().GetBooking(BookingId);
                if (booking != null)
                {
                    bool hasAdimnRights = Support.IsCompanyAdministrator(this.CompanyId) || Support.IsCompanyInventoryStaffMember(this.CompanyId);
                    if (hasAdimnRights)
                    {
                        hyperLinkInventorySharing.NavigateUrl = ResolveUrl(string.Format("~/Inventory/InventorySharing.aspx?CompanyId={0}", this.CompanyId));

                        editBookingDetails.IsToDateChange     = IsToDateChange;
                        editBookingDetails.CompanyId          = CompanyId;
                        editBookingDetails.IsInventoryManager = true;
                        editBookingDetails.ViewingCompanyId   = CompanyId;
                        editBookingDetails.ItemTypeId         = ItemTypeId;
                        editBookingDetails.BookingId          = BookingId;
                        editBookingDetails.CallBackURL        = string.Format("~/Inventory/BookingDetails.aspx?BookingId={0}&CompanyId={1}", BookingId, CompanyId);

                        StageBitz.Data.Company company = DataContext.Companies.Where(c => c.CompanyId == this.CompanyId).FirstOrDefault();
                        DisplayTitle                   = string.Concat(Support.TruncateString(company.CompanyName, 30), "'s Inventory");
                        lnkCompanyInventory.HRef       = ResolveUrl(string.Format("~/Inventory/CompanyInventory.aspx?CompanyId={0}", this.CompanyId));
                        hyperLinkMyBooking.NavigateUrl = string.Format("~/Inventory/MyBookings.aspx?CompanyId={0}", this.CompanyId);
                        LoadBreadCrumbs(company);
                    }
                    else
                    {
                        throw new ApplicationException("Permission denied for this Booking.");
                    }
                }
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Handles the Click event of the btnSendEmailToIM control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
        protected void btnSendEmailToBookingManager_Click(object sender, EventArgs e)
        {
            if (!PageBase.StopProcessing)
            {
                Data.Item item = GetBL <InventoryBL>().GetItem(this.ciItemCompleteTab.ItemId);
                if (item != null)
                {
                    Data.User    user           = GetBL <PersonalBL>().GetUser(this.UserID);
                    Data.Booking booking        = GetBL <InventoryBL>().GetBooking(this.ProjectId, GlobalConstants.RelatedTables.Bookings.Project);
                    Data.User    bookingManager = GetBL <InventoryBL>().GetContactBookingManager(item.CompanyId.Value, item.LocationId);

                    if (user != null && booking != null && bookingManager != null)
                    {
                        string userWebUrl   = Utils.GetSystemValue("SBUserWebURL");
                        string userInput    = HttpUtility.HtmlDecode(txtContactIMEmailBody.Text.Trim());
                        string emailContent = Utils.GetSafeHtmlFragments(userInput);
                        string itemUrl      = string.Format("{0}/Inventory/ItemDetails.aspx?ItemId={1}&CompanyId={2}", userWebUrl, item.ItemId, item.CompanyId.Value);
                        string bookingUrl   = string.Format("{0}/Inventory/BookingDetails.aspx?BookingId={1}&CompanyId={2}", userWebUrl, booking.BookingId, item.CompanyId.Value);

                        EmailSender.SendContactInventoryManagerForItemChangesDuetoBookingOverlapEmail(bookingManager.Email1,
                                                                                                      bookingManager.FirstName, user.FirstName, item.Name, itemUrl,
                                                                                                      GetBL <InventoryBL>().GetCompanyBookingNumber(booking.BookingId, item.CompanyId.Value).BookingNumber.ToString(CultureInfo.InvariantCulture),
                                                                                                      bookingUrl, emailContent);
                        popupBookingOverlapContactBookingManager.HidePopup();
                    }
                }
            }
        }
        /// <summary>
        /// Handles the Load event of the Page control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
        /// <exception cref="System.ApplicationException">Permission denied for this Booking.</exception>
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                Data.Booking booking = GetBL <InventoryBL>().GetBooking(BookingId);
                if (booking != null)
                {
                    if (booking.RelatedTable == "NonProject" && GetBL <InventoryBL>().GetNonProjectBooking(BookingId).CreatedBy == UserID)
                    {
                        hyperLinkInventorySharing.NavigateUrl = ResolveUrl(string.Format("~/Inventory/InventorySharing.aspx?CompanyId={0}", this.CompanyId));

                        editBookingDetails.IsToDateChange     = IsToDateChange;
                        editBookingDetails.CompanyId          = CompanyId;
                        editBookingDetails.ViewingCompanyId   = ViewingCompanyId;
                        editBookingDetails.ItemTypeId         = ItemTypeId;
                        editBookingDetails.BookingId          = BookingId;
                        editBookingDetails.IsInventoryManager = false;
                        editBookingDetails.CallBackURL        = string.Format("~/Inventory/MyBookingDetails.aspx?BookingId={0}&CompanyId={1}", BookingId, CompanyId);

                        StageBitz.Data.Company company = DataContext.Companies.Where(c => c.CompanyId == this.CompanyId).FirstOrDefault();
                        DisplayTitle                   = "Change Booking Dates";
                        lnkCompanyInventory.HRef       = ResolveUrl(string.Format("~/Inventory/CompanyInventory.aspx?CompanyId={0}", this.CompanyId));
                        hyperLinkMyBooking.NavigateUrl = string.Format("~/Inventory/MyBookings.aspx?CompanyId={0}", this.CompanyId);
                        LoadBreadCrumbs(company);
                    }
                    else
                    {
                        throw new ApplicationException("Permission denied for this Booking.");
                    }
                }
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// Handles the Load event of the Page control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
        /// <exception cref="System.Exception">project not found</exception>
        /// <exception cref="System.ApplicationException">
        /// Permission denied for this project
        /// or
        /// Permission denied to this page
        /// </exception>
        protected void Page_Load(object sender, EventArgs e)
        {
            //IsLargeContentArea = true;
            if (!IsPostBack)
            {
                StageBitz.Data.Project project = (from p in DataContext.Projects
                                                  where p.ProjectId == ProjectId && p.IsActive == true
                                                  select p).FirstOrDefault();
                if (project == null)
                {
                    throw new Exception("project not found");
                }

                if (!Support.CanAccessProject(project))
                {
                    if (GetBL <ProjectBL>().IsProjectClosed(ProjectId))
                    {
                        StageBitzException.ThrowException(new StageBitzException(ExceptionOrigin.ProjectClose, project.ProjectId, "Permission denied for this project."));
                    }

                    throw new ApplicationException("Permission denied for this project ");
                }

                if (Support.IsReadOnlyRightsForProject(ProjectId, UserID, false))
                {
                    if (GetBL <ProjectBL>().IsProjectClosed(project.ProjectId))
                    {
                        StageBitzException.ThrowException(new StageBitzException(ExceptionOrigin.ProjectClose, project.ProjectId, "Permission denied for this page."));
                    }

                    throw new ApplicationException("Permission denied to this page ");
                }

                Data.Booking booking = this.GetBL <InventoryBL>().GetBooking(ProjectId, GlobalConstants.RelatedTables.Bookings.Project);
                editBookingDetails.ItemTypeId         = ItemTypeId;
                editBookingDetails.IsToDateChange     = IsToDateChange;
                editBookingDetails.BookingId          = booking.BookingId;
                editBookingDetails.IsInventoryManager = false;
                editBookingDetails.CallBackURL        = string.Format("~/Project/ProjectBookingDetails.aspx?projectid={0}", ProjectId);

                DisplayTitle = "Bookings";
                LoadBreadCrumbs(project);
                lnkCompanyInventory.HRef = string.Format("~/Inventory/CompanyInventory.aspx?companyid={0}&relatedtable={1}&relatedid={2}", project.CompanyId, (int)BookingTypes.Project, ProjectId);
                lnkBookings.HRef         = string.Format("~/Project/ProjectBookingDetails.aspx?projectid={0}", ProjectId);
                linkTaskManager.HRef     = string.Format("~/ItemBrief/TaskManager.aspx?projectid={0}", ProjectId);
                reportList.ShowReportLinks(string.Format("~/ItemBrief/ItemisedPurchaseReport.aspx?projectid={0}", ProjectId), string.Format("~/ItemBrief/BudgetSummaryReport.aspx?projectid={0}", ProjectId), ProjectId);
                projectUpdatesLink.ProjectID = ProjectId;
                projectUpdatesLink.LoadData();
            }
        }
        public async Task SendBookingInfo(Data.Booking booking)
        {
            using (var client = new HttpClient())
            {
                client.BaseAddress = new Uri($"http://{_hostIp}:19081/");
                client.DefaultRequestHeaders.Accept.Clear();
                client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));

                var partitionKey = Char.ToUpper(booking.Passport.First());
                var postContent  = new StringContent(JsonConvert.SerializeObject(booking), Encoding.UTF8, "application/json");
                postContent.Headers.ContentType = new MediaTypeHeaderValue("application/json");
                var response = await client.PostAsync($"{_appName}/SmartHotel.Registration.StoreKPIs/api/values?key={booking.Passport}&PartitionKey={partitionKey}&PartitionKind=Int64Range", postContent);

                response.EnsureSuccessStatusCode();
            }
        }
Exemplo n.º 6
0
        /// <summary>
        /// Gets the name of the booking.
        /// </summary>
        /// <returns></returns>
        private string GetBookingName()
        {
            Data.Booking booking = GetBL <InventoryBL>().GetBooking(BookingId);
            RelatedTableName = booking.RelatedTable;
            RelatedId        = booking.RelatedId;

            if (RelatedTableName == GlobalConstants.RelatedTables.Bookings.Project)
            {
                Data.Project project = GetBL <ProjectBL>().GetProject(RelatedId);
                return(project.ProjectName);
            }
            else
            {
                Data.NonProjectBooking nonProjectBooking = GetBL <InventoryBL>().GetNonProjectBooking(BookingId);
                return(nonProjectBooking.Name);
            }
        }
Exemplo n.º 7
0
        /// <summary>
        /// Handles the Load event of the Page control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
        /// <exception cref="System.ApplicationException">
        /// Permission denied for this Booking.
        /// or
        /// Booking does not exist.
        /// </exception>
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                Data.Booking booking = GetBL <InventoryBL>().GetBooking(BookingId);
                if (booking != null && (GetBL <InventoryBL>().GetNonProjectBooking(BookingId).CreatedBy != UserID || booking.RelatedTable == "Project"))
                {
                    throw new ApplicationException("Permission denied for this Booking.");
                }

                if (booking == null)
                {
                    throw new ApplicationException("Booking does not exist.");
                }

                bookingDetails.BookingId   = BookingId;
                bookingDetails.CompanyId   = CompanyId;
                bookingDetails.DisplayMode = UserWeb.Controls.Inventory.BookingDetails.ViewMode.NonProject;

                StageBitz.Data.Company company = this.GetBL <CompanyBL>().GetCompany(CompanyId);
                //Get NonProject BookingName
                if (booking.RelatedTable == "NonProject")
                {
                    DisplayTitle = "Bookings";
                }

                lnkCompanyInventory.HRef       = ResolveUrl(string.Format("~/Inventory/CompanyInventory.aspx?CompanyId={0}", this.CompanyId));
                hyperLinkMyBooking.NavigateUrl = string.Format("~/Inventory/MyBookings.aspx?CompanyId={0}", this.CompanyId);

                if (Support.IsCompanyAdministrator(this.CompanyId) || Support.IsCompanyInventoryStaffMember(this.CompanyId))
                {
                    spnInventorySharing.Visible           = true;
                    hyperLinkInventorySharing.NavigateUrl = ResolveUrl(string.Format("~/Inventory/InventorySharing.aspx?CompanyId={0}", this.CompanyId));
                }
                else
                {
                    spnInventorySharing.Visible = false;
                }

                LoadBreadCrumbs(company);
            }
        }
Exemplo n.º 8
0
        /// <summary>
        /// Here the rent of the boat is registred in the database
        /// </summary>
        /// <param name="personnumber"></param>
        /// <param name="boatid"></param>
        /// <returns></returns>
        public bool RentABoatRegistry(string personnumber, int boatid)
        {
            var rentopportunity = new Data.Booking();

            try
            {
                using (var DB = new Data.BoatBookingSystemEntities1())
                {
                    rentopportunity.PersonNumber    = personnumber;
                    rentopportunity.BoatID          = boatid;
                    rentopportunity.DeliveyDateTime = DateTime.Now;

                    DB.Bookings.Add(rentopportunity);
                    DB.SaveChanges();
                }
                return(true);
            }
            catch (Exception ex)
            {
                string.Format("The rent registry could't be saved because of \"{0}\" .", ex.Message);
                return(false);
            }
        }