Ejemplo n.º 1
0
        protected void btnSubmitEvent_Click1(object sender, EventArgs e)
        {
            int hostID = Convert.ToInt32(Session["ID"].ToString());
            //Creating Address
            int AddressID  = getAddressID();
            int intEventID = 0;
            EventServiceClient _eventClient = new EventServiceClient();
            EventModel         _event       = new EventModel();

            _event.HostID   = hostID;
            _event.Name     = txtEventName.Text; //Event Name
            _event.Category = txtCategory.Text;
            if (chkBoxPrivate.Checked == true)   //Public or Private Event
            {
                _event.Type = "Private";
            }
            else
            {
                _event.Type = "Public";
            }

            //Allowed to share?
            //chkShare
            if (chkShare.Checked == true)
            {
                //Share on Eventrix FB adn Twitter Page
            }
            _event.Desc = txtDesc.Value; //Event Description
            string startdate = txtStart.Text;
            string enddate   = txtEnd.Text;
            //Convert user input to DateTime format
            DateTime sDate       = DateTime.ParseExact(txtStart.Text, "yyyy-MM-ddTHH:mm", CultureInfo.InvariantCulture);
            DateTime eDate       = DateTime.ParseExact(txtEnd.Text, "yyyy-MM-ddTHH:mm", CultureInfo.InvariantCulture);
            int      result      = DateTime.Compare(sDate, eDate);
            int      currentDate = DateTime.Compare(sDate, DateTime.Now);
            string   htmltag     = "";

            if (result > 0 || currentDate < 0)
            {
                htmltag          = "<div class='alert alert-danger text-center' role='alert'>";
                htmltag         += "<button type = 'button' class='close' data-dismiss='alert' aria-label='Close'><span aria-hidden='true'>&times;</span></button>";
                htmltag         += " <strong> Danger!</strong> Please Check Date!";
                htmltag         += "</div>";
                status.InnerHtml = htmltag;
                Response.Redirect("CreateEvent.aspx");
            }


            _event.Start_Date   = sDate;
            _event.sDate        = Convert.ToString(sDate); //Event Start Date
            _event.eDate        = Convert.ToString(eDate); //Event End Date
            _event.EventAddress = AddressID;               //Event's address ID
                                                           //check ticket field
            if (!txtE_Quantity.Text.Equals(""))
            {
                _event.EB_Quantity = Convert.ToInt32(txtE_Quantity.Text);
            }
            else
            {
                _event.EB_Quantity = 0;
            }

            if (!txtR_Quantity.Text.Equals(""))
            {
                _event.Reg_Quantity = Convert.ToInt32(txtR_Quantity.Text);
            }
            else
            {
                _event.Reg_Quantity = 0;
            }

            if (!txtV_Quantity.Text.Equals(""))
            {
                _event.VIP_Quantity = Convert.ToInt32(txtV_Quantity.Text);
            }
            else
            {
                _event.VIP_Quantity = 0;
            }
            if (!txtVV_Quantity.Text.Equals(""))
            {
                _event.VVIP_Quantity = Convert.ToInt32(txtVV_Quantity.Text);
            }
            else
            {
                _event.VVIP_Quantity = 0;
            }
            //Create Event
            EventServiceClient _createEvent = new EventServiceClient();
            string             res          = _createEvent.createEvent(_event);
            bool isCreatedTicket            = false; //Ticket Controller

            if (res.ToLower().Contains("success"))   //Event Created
            {
                EVENT_TRACKER = "Event Created successfully";
                intEventID    = _createEvent.findEventID(_event); //Get Event ID
                string _strEventID = Convert.ToString(intEventID);
                makeDirectory(_strEventID);                       //Create Event Directory
                EVENT_TRACKER += "\n ID Exist";

                //------------------------------Upload Guest, Staff and Product-----------------------//
                string ImportSpreadsheet = "";
                ImportSpreadsheet = ImportData(flGuest, intEventID, _event);
                ///-------------------------------------------------------------------------------------//
                ///
                if (ImportSpreadsheet.Contains("success"))
                {
                    EVENT_TRACKER += "\n Spreadsheet Uploaded";
                    //Create Tickets
                    isCreatedTicket = isLoadedTicket(_event, intEventID);
                    if (isCreatedTicket == true)
                    {
                        EVENT_TRACKER += "\n Ticket Created";
                    }
                    else
                    {
                        EVENT_TRACKER += "\n Failed to upload ticket";
                    }
                }
                else
                {
                    //Unable to upload guest
                    EVENT_TRACKER += "\n failed to upload spreadsheet";
                    EVENT_TRACKER += "\n Spreadsheet Uploaded";
                    //Create Tickets
                    isCreatedTicket = isLoadedTicket(_event, intEventID);
                    if (isCreatedTicket == true)
                    {
                        EVENT_TRACKER += "\n Ticket Created";
                    }
                    else
                    {
                        EVENT_TRACKER += "\n Failed to upload ticket";
                    }
                }

                ////Upload images
                if (flEventImages.HasFile)
                {
                    ImageFile mainPic = new ImageFile();
                    mainPic = UploadFile(flEventImages, _strEventID, SUBFOLDER); //Upload Event Main's Image to client directory
                    FileUploadClient fuc    = new FileUploadClient();
                    string           res1   = fuc.saveImage(mainPic);            //Upload Event Main's Image to Database
                    string           number = res1;
                }

                //Populate the modal popup-------------------------------

                //EventModel _createdEvent = getDetails(_strEventID);
                //MappingClient mc = new MappingClient();
                //EventAddress _eventAddress = new EventAddress();
                //_eventAddress = mc.getAddressById(Convert.ToString(AddressID));
                //myModalLabel.InnerHtml = _createdEvent.Name;
                //mdl_Image.InnerHtml = "<img class='img-responsive' src='" + _createdEvent.ImageLocation + "'/>";
                //string htmltag = "";
                //htmltag += "<p>" + _createdEvent.Desc + "</p>";
                //htmltag += "<strong>Date: </strong> " + _createdEvent.sDate + " -" + _createdEvent.eDate;
                //htmltag += "<br/>";
                //htmltag += "<strong> Address: </strong><br/>";
                //htmltag += _eventAddress.STREET + "<br/>";
                //htmltag += _eventAddress.CITY + "<br/>";
                //htmltag += _eventAddress.PROVINCE + "<br/>";
                //htmltag += _eventAddress.COUNTRY + "<br/>";

                //mld_Details.InnerHtml = htmltag;


                //Session.Add("CurrentEventID", _strEventID);
                //string strModalButton = "";
                //       strModalButton += "<a href='EventList.aspx?dl="+ _strEventID + "' runat='server' class='btn btn-default'>Cancel</a>";
                //       strModalButton += "<a href='EventDetails.aspx?EventID="+ _strEventID + "' runat='server' class='btn btn-default'>Conitnue</a>";
                //btn_MDL.InnerHtml = strModalButton;
                //cssMapModal.Visible = true;

                Response.Redirect("EventDetails.aspx?ev=" + intEventID);
            }
            else
            {
                EVENT_TRACKER += "\n Event already exist";
                Response.Redirect("CreateEvent.aspx");
            }
            //  Response.Write("<script> Alert("+ EVENT_TRACKER + ");</script>");
        }