public bool EditAddress(int ID)
        {
            string strStreet   = "";
            string strCity     = "";
            string strProvince = "";
            string strCountry  = "";

            //Validate inputs
            if (!txtStreet.Text.Equals(""))
            {
                strStreet = txtStreet.Text;
            }
            if (!txtCity.Text.Equals(""))
            {
                strCity = txtCity.Text;
            }
            if (!txtProvince.Text.Equals(""))
            {
                strProvince = txtProvince.Text;
            }
            if (!txtCountry.Text.Equals(""))
            {
                strCountry = txtCountry.Text;
            }
            EventAddress add = new EventAddress();

            add.STREET   = strStreet;
            add.CITY     = strCity;
            add.PROVINCE = strProvince;
            add.COUNTRY  = strCountry;
            MappingClient mapp  = new MappingClient();
            EventAddress  addID = mapp.EditAddress(add, Convert.ToString(ID));

            return(true);
        }
        public int getAddressID()
        {
            string strStreet   = "";
            string strCity     = "";
            string strProvince = "";
            string strCountry  = "";

            //Validate inputs
            if (!txtStreet.Text.Equals(""))
            {
                strStreet = txtStreet.Text;
            }
            if (!txtCity.Text.Equals(""))
            {
                strCity = txtCity.Text;
            }
            if (!txtProvince.Text.Equals(""))
            {
                strProvince = txtProvince.Text;
            }
            if (!txtCountry.Text.Equals(""))
            {
                strCountry = txtCountry.Text;
            }
            EventAddress add = new EventAddress();

            add.STREET   = strStreet;
            add.CITY     = strCity;
            add.PROVINCE = strProvince;
            add.COUNTRY  = strCountry;
            MappingClient mapp  = new MappingClient();
            int           addID = mapp.createAddress(add);

            return(addID);
        }
Beispiel #3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            //delete event trigger===========================================
            string Status        = "";
            String deleterequest = (Request.QueryString["dl"]);

            if (deleterequest != null)
            {
                //delete QR Code;
                TicketServiceClient ticketToDelete = new TicketServiceClient();
                string dl_GT_BridgingTable         = "";
                string dl_ticket_template          = "";
                string dl_QRCode = ticketToDelete.dl_QRCodeByEventID(deleterequest);
                if (dl_QRCode.ToLower().Contains("success"))
                {
                    dl_GT_BridgingTable = ticketToDelete.dl_GuestTicket_BT_ByEventID(deleterequest);
                    if (dl_GT_BridgingTable.ToLower().Contains("success"))
                    {
                        dl_ticket_template = ticketToDelete.dl_TicketTemplate_byEventID(deleterequest);
                        if (dl_ticket_template.ToLower().Contains("success"))
                        {
                            Status = "\n All tickets Deleted";
                        }
                    }
                }
                FileUploadClient img         = new FileUploadClient();
                string           deleteImage = img.deleteImagebyEventID(deleterequest);
                if (deleteImage.ToLower().Contains("Failed"))
                {
                    Status += "\n Image not Delete";
                }
                else
                {
                    Status += "\n Image Delete";
                }
                StaffServiceClient ssc         = new StaffServiceClient();
                string             deletestaff = ssc.deleteStaffByEventID(deleterequest);
                if (deletestaff.ToLower().Contains("Failed"))
                {
                    Status += "\n Staff not Deleted";
                }
                else
                {
                    Status += "\n Staff Deleted";
                }
                ProductServiceClient psc = new ProductServiceClient();
                string deleteProduct     = psc.DeleteProductByEventID(deleterequest);
                if (deleteProduct.ToLower().Contains("Failed"))
                {
                    Status += "\n Product not Deleted";
                }
                else
                {
                    Status += "\n Product Deleted";
                }
                EventServiceClient esc = new EventServiceClient();
                EventModel         ev  = new EventModel();
                ev = esc.findByEventID(deleterequest);
                string deleteEvent = esc.deleteEventByID(deleterequest);
                if (deleteEvent.ToLower().Contains("Failed"))
                {
                    Status += "\n Event not Deleted";
                }
                else
                {
                    Status += "\n Event Deleted";
                    //delete event's address
                    try
                    {
                        int           Address_ID = ev.EventAddress;
                        MappingClient mapping    = new MappingClient();
                        mapping.deleteAddressByID(Convert.ToString(Address_ID));
                    }
                    catch (Exception)
                    {
                        Status += "Event Already Deleted";
                    }
                    int LoggedID = Convert.ToInt32(Session["ID"]);
                    Response.Redirect("EventManagement.aspx?HostID=" + LoggedID);
                }
            }   //done deleting an event============================================

            //display event list
            List <EventModel> display = new List <EventModel>();
            int intUserID;

            intUserID = Convert.ToInt32(Session["ID"]);
            String request = (Request.QueryString["ME"]);

            if (request != null) //If request is made
            {
                //guest's events
                //    int reqID = Convert.ToInt32(request);
                string sessionlevel = Convert.ToString(Session["Level"]);
                if (sessionlevel.ToLower().Equals("guest") && request.ToLower().Equals("1"))
                {
                    string GuestID = Convert.ToString(Session["ID"]);
                    Response.Redirect("GuestEventList.aspx?GuestID=" + GuestID);
                }

                if (request.Equals("Edit")) //Edit Event
                {
                    ImageFile        img = new ImageFile();
                    FileUploadClient fuc = new FileUploadClient();
                    display = GetEvent(intUserID);
                    string htmltag = "";
                    foreach (EventModel em in display)
                    {
                        strEventID = em.EventID;
                        string EventID     = Convert.ToString(em.EventID);
                        string imgLocation = "";
                        string output      = ""; //trim string path from Event
                                                 //   string strout = output;
                        img = fuc.getImageById(EventID);
                        if (img == null)
                        {
                            output = "Events/Eventrix_Default_Image.png";
                        }
                        else
                        {
                            imgLocation = img.Location;
                            output      = imgLocation.Substring(imgLocation.IndexOf('E')); //trim string path from Event
                        }
                        htmltag += "<div class='portfolio-item col-sm-6 col-md-4' data-groups='['all', 'numbers', 'blue', 'square']'>";
                        htmltag += "<div class='single-portfolio'>";
                        htmltag += "<img src='" + output + "' alt='' style='width: 317px; height: 190px'>";
                        //   htmltag += "<asp:Button style='padding:10px 130px;' class='btn btn-primary animated lightSpeedIn' OnClick='btnDelete_Click'><a style='color:white;' href='EditEvent.aspx?EventID=" + em.EventID + "'>Edit Event</a></asp:Button>";
                        htmltag += "<a style='padding:10px 130px;' class='btn btn-primary animated bounceIn' href='EditEvent.aspx?ed=" + em.EventID + "'>Edit Event</a>";
                        htmltag += "<div class='portfolio-links' style='width: 200px; margin-left: -120px;'>";
                        htmltag += "<li class='fa fa-link'>";
                        htmltag += "<a href='#' style='font-size:18px;";
                        htmltag += "font-family:'Roboto',sans-serif;";
                        htmltag += "color:white;'>";
                        htmltag += "<p>" + em.Name + "</p>";
                        htmltag += "<p> " + em.sDate + " </p></a>";
                        htmltag += "</li>";
                        htmltag += "<a class='image-link' href='" + output + "'><i class='fa fa-search-plus'></i></a>";
                        htmltag += "<a href='EventDetails.aspx?EventID=" + em.EventID + "'><i class='fa fa-link'></i></a>";
                        htmltag += "</div><!-- /.links -->";
                        htmltag += "</div><!-- /.single-portfolio -->";
                        htmltag += "</div><!-- /.portfolio-item -->";
                    }
                    grid.InnerHtml = htmltag;
                }
                else if (request.Equals("Delete")) //Delete Event
                {
                    ImageFile        img = new ImageFile();
                    FileUploadClient fuc = new FileUploadClient();
                    display = GetEvent(intUserID);
                    string htmltag     = "";
                    string imgLocation = "";
                    foreach (EventModel em in display)
                    {
                        string output  = "";
                        string EventID = Convert.ToString(em.EventID);
                        img = fuc.getImageById(EventID);
                        if (img == null)
                        {
                            output = "Events/Eventrix_Default_Image.png";
                        }
                        else
                        {
                            imgLocation = img.Location;
                            output      = imgLocation.Substring(imgLocation.IndexOf('E')); //trim string path from Event
                        }                                                                  //                                                                 //   string strout = output;
                                                                                           //    htmltag += "<a href='EventDetails.aspx'><i class='fa fa-link'></i></a>";
                        htmltag += "<div class='portfolio-item col-sm-6 col-md-4' data-groups='['all', 'numbers', 'blue', 'square']'>";
                        htmltag += "<div class='single-portfolio'>";
                        htmltag += "<img src='" + output + "' alt='' style='width: 317px; height: 190px'>";
                        htmltag += "<a style='padding:10px 130px;' class='btn btn-primary animated bounceIn' href='EventList.aspx?dl=" + em.EventID + "'>Delete Event</a>";
                        htmltag += "<div class='portfolio-links' style='width: 200px; margin-left: -120px;'>";
                        htmltag += "<li class='fa fa-link'>";
                        htmltag += "<a href='#' style='font-size:18px;";
                        htmltag += "font-family:'Roboto',sans-serif;";
                        htmltag += "color:white;'>";
                        htmltag += "<p>" + em.Name + "</p>";
                        htmltag += "<p>" + em.sDate + " </p></a>";
                        htmltag += "</li>";
                        htmltag += "<a class='image-link' href='" + output + "'><i class='fa fa-search-plus'></i></a>";
                        htmltag += "<a href='EventDetails.aspx?EventID=" + em.EventID + "'><i class='fa fa-link'></i></a>";
                        htmltag += "</div><!-- /.links -->";
                        htmltag += "</div><!-- /.single-portfolio -->";
                        htmltag += "</div><!-- /.portfolio-item -->";
                    }
                    grid.InnerHtml = htmltag;
                }
                else if (request.Equals("EventReport"))  //Event Report
                {
                    ImageFile        img = new ImageFile();
                    FileUploadClient fuc = new FileUploadClient();
                    display = GetEvent(intUserID);
                    string htmltag     = "";
                    string imgLocation = "";
                    foreach (EventModel em in display)
                    {
                        string output  = "";
                        string EventID = Convert.ToString(em.EventID);
                        img = fuc.getImageById(EventID);
                        if (img == null)
                        {
                            output = "Events/Eventrix_Default_Image.png";
                        }
                        else
                        {
                            imgLocation = img.Location;
                            output      = imgLocation.Substring(imgLocation.IndexOf('E')); //trim string path from Event
                        }                                                                  //                                                                 //   string strout = output;
                                                                                           //    htmltag += "<a href='EventDetails.aspx'><i class='fa fa-link'></i></a>";
                        htmltag += "<div class='portfolio-item col-sm-6 col-md-4' data-groups='['all', 'numbers', 'blue', 'square']'>";
                        htmltag += "<div class='single-portfolio'>";
                        htmltag += "<img src='" + output + "' alt='' style='width: 317px; height: 190px'>";
                        //AAFReport.aspx?eventID=" + strEventID
                        htmltag += "<a style='padding:10px 130px;' class='btn btn-primary animated bounceIn' href='AAFReport.aspx?eventID=" + em.EventID + "'>Event Report</a>";
                        htmltag += "<div class='portfolio-links' style='width: 200px; margin-left: -120px;'>";
                        htmltag += "<li class='fa fa-link'>";
                        htmltag += "<a href='#' style='font-size:18px;";
                        htmltag += "font-family:'Roboto',sans-serif;";
                        htmltag += "color:white;'>";
                        htmltag += "<p>" + em.Name + "</p>";
                        htmltag += "<p>" + em.sDate + " </p></a>";
                        htmltag += "</li>";
                        htmltag += "<a class='image-link' href='" + output + "'><i class='fa fa-search-plus'></i></a>";
                        htmltag += "<a href='EventDetails.aspx?EventID=" + em.EventID + "'><i class='fa fa-link'></i></a>";
                        htmltag += "</div><!-- /.links -->";
                        htmltag += "</div><!-- /.single-portfolio -->";
                        htmltag += "</div><!-- /.portfolio-item -->";
                    }
                    grid.InnerHtml = htmltag;
                }
                else //View "My Event"
                {
                    Response.Redirect("HostEventList.aspx?HostID=" + intUserID);
                }
            }
        }
Beispiel #4
0
        //Sending Invitation
        public void sendMsgInvite(GuestModel _guest, EventModel _event, string pass, int EventID)
        {
            EventAddress  addres     = new EventAddress();
            MappingClient add_client = new MappingClient();

            addres = add_client.getAddressById(Convert.ToString(_event.EventAddress));

            EventHostModel    host    = new EventHostModel();
            HostServiceClient ev_host = new HostServiceClient();

            host = ev_host.findhsotbyID(Convert.ToString(_event.HostID));
            SmtpClient smtp = new SmtpClient();

            smtp.Host        = "smtp.gmail.com";
            smtp.Port        = 587;
            smtp.Credentials = new System.Net.NetworkCredential("*****@*****.**", "*****@*****.**");
            smtp.EnableSsl   = true;

            MailMessage msg = new MailMessage();

            msg.Subject = "Invitation to the " + _event.Name;
            msg.Body    = "Hi " + _guest.NAME + ",";
            msg.Body   += "<tr><td>EventriX would like to invite you to attend the " + _event.Desc + "</td></tr>";
            msg.Body   += "<tr>";
            msg.Body   += "<td><img src='" + _event.ImageLocation + "' alt=''/></td>";
            msg.Body   += "</tr>";
            msg.Body   += "<tr>";
            msg.Body   += "<td>" + _event.eDate + "</td>";
            msg.Body   += "</tr>";
            msg.Body   += "<tr>";
            msg.Body   += "<td> Location: " + addres.STREET + ", " + addres.CITY + ", " + addres.PROVINCE + "</td>";
            msg.Body   += "</tr>";
            msg.Body   += "<tr>";
            //http://localhost:60469/Login.aspx?e_ID=
            //
            msg.Body += "<td>To RSVP please <a href='http://*****:*****@gmail.com";

            msg.From       = new MailAddress(FromAddress);
            msg.IsBodyHtml = true;

            try
            {
                smtp.Send(msg);
            }
            catch (Exception ex)
            {
                ex.Message.ToString();
            }
        }
Beispiel #5
0
        //Sending survey emails to guest
        public void sendSurvey(string Name, string Email, EventModel _event)
        {
            EventAddress  addres     = new EventAddress();
            MappingClient add_client = new MappingClient();

            addres = add_client.getAddressById(Convert.ToString(_event.EventAddress));

            EventHostModel    host    = new EventHostModel();
            HostServiceClient ev_host = new HostServiceClient();

            host = ev_host.findhsotbyID(Convert.ToString(_event.HostID));
            SmtpClient smtp = new SmtpClient();

            smtp.Host        = "smtp.gmail.com";
            smtp.Port        = 587;
            smtp.Credentials = new System.Net.NetworkCredential("*****@*****.**", "*****@*****.**");
            smtp.EnableSsl   = true;

            MailMessage msg = new MailMessage();

            msg.Subject = "Post Event Survey for " + _event.Name;
            msg.Body    = "Hi " + Name + ",";
            msg.Body   += "<tr><td>On behalf of TNT Eventrix and " + _event.Name + ", we would like to thank you for taking part.</td></tr>";
            msg.Body   += "<tr>";
            msg.Body   += "<td>Would you take 3 minutes of your time and complete the very breif survey and help us help you in improving your satisfaction for our next event?</td>";
            msg.Body   += "</tr>";
            msg.Body   += "<tr>";
            msg.Body   += "<td>Kindly <a href='http://*****:*****@gmail.com";

            msg.From       = new MailAddress(FromAddress);
            msg.IsBodyHtml = true;

            try
            {
                smtp.Send(msg);
            }
            catch (Exception ex)
            {
                ex.Message.ToString();
            }
        }
        // string reqEventID = "";
        protected void Page_Load(object sender, EventArgs e)
        {
            String request = (Request.QueryString["EventID"]);

            // reqEventID = request;
            if (!IsPostBack)
            {
                if (request == null)
                {
                    request = (Request.QueryString["ed"]);
                }
                int EventID = Convert.ToInt32(request);
                strEventID = EventID;
                EventModel          em           = new EventModel();
                ImageFile           img          = new ImageFile();
                List <EventProduct> products     = new List <EventProduct>();
                EventTicket         EB_tickets   = new EventTicket();
                EventTicket         REG_tickets  = new EventTicket();
                EventTicket         VIP_tickets  = new EventTicket();
                EventTicket         VVIP_tickets = new EventTicket();
                EventAddress        _address     = new EventAddress();
                //Service Clients
                EventServiceClient   eventClient = new EventServiceClient();
                FileUploadClient     fuc         = new FileUploadClient();
                TicketServiceClient  tsc         = new TicketServiceClient();
                ProductServiceClient psc         = new ProductServiceClient();
                MappingClient        mc          = new MappingClient();

                //Gett Functions
                em = eventClient.findByEventID(request);
                string addID = Convert.ToString(em.EventAddress);
                AddressID    = Convert.ToInt32(addID);
                img          = fuc.getImageById(request);
                EB_tickets   = tsc.getEBTicket(request);
                REG_tickets  = tsc.getRegularTicket(request);
                VIP_tickets  = tsc.getVIPTicket(request);
                VVIP_tickets = tsc.getVVIPTicket(request);
                products     = psc.getProductByEventID(request);
                _address     = mc.getAddressById(addID);
                //First Tab
                divHearderName.InnerHtml = "Edit " + em.Name;
                txtEventName.Text        = em.Name;
                txtDesc.Text             = em.Desc;
                txtStart.Text            = Convert.ToString(em.sDate);
                txtEnd.Text = Convert.ToString(em.eDate);

                //Ticket Section
                if (EB_tickets == null)
                {
                    txtE_Price.Text       = "";
                    txtE_Quantity.Text    = "";
                    txtE_Token.Text       = "";
                    txtE_OpenDate.Text    = "";
                    txtE_ClosingDate.Text = "";
                }
                else
                {
                    txtE_Price.Text       = Convert.ToString(EB_tickets._Price);
                    txtE_Quantity.Text    = Convert.ToString(em.EB_Quantity);
                    txtE_Token.Text       = Convert.ToString(EB_tickets._Credit);
                    txtE_OpenDate.Text    = Convert.ToString(EB_tickets._StartDate);
                    txtE_ClosingDate.Text = Convert.ToString(EB_tickets._EndDate);
                }

                if (REG_tickets == null)
                {
                    txtR_Price.Text       = "";
                    txtR_Quantity.Text    = "";
                    txtR_Token.Text       = "";
                    txtR_OpenDate.Text    = "";
                    txtR_ClosingDate.Text = "";
                }
                else
                {
                    txtR_Price.Text       = Convert.ToString(REG_tickets._Price);
                    txtR_Quantity.Text    = Convert.ToString(em.Reg_Quantity);
                    txtR_Token.Text       = Convert.ToString(REG_tickets._Credit);
                    txtR_OpenDate.Text    = Convert.ToString(REG_tickets._StartDate);
                    txtR_ClosingDate.Text = Convert.ToString(REG_tickets._EndDate);
                }
                if (VIP_tickets == null)
                {
                    txtV_Price.Text       = "";
                    txtV_Quantity.Text    = "";
                    txtV_Token.Text       = "";
                    txtV_OpenDate.Text    = "";
                    txtV_ClosingDate.Text = "";
                }
                else
                {
                    txtV_Price.Text       = Convert.ToString(VIP_tickets._Price);
                    txtV_Quantity.Text    = Convert.ToString(em.VIP_Quantity);
                    txtV_Token.Text       = Convert.ToString(VIP_tickets._Credit);
                    txtV_OpenDate.Text    = Convert.ToString(VIP_tickets._StartDate);
                    txtV_ClosingDate.Text = Convert.ToString(VIP_tickets._EndDate);
                }

                if (VVIP_tickets == null)
                {
                    txtVV_Price.Text       = "";
                    txtVV_Quantity.Text    = "";
                    txtVV_Token.Text       = "";
                    txtVV_OpenDate.Text    = "";
                    txtVV_ClosingDate.Text = "";
                }
                else
                {
                    txtVV_Price.Text       = Convert.ToString(VVIP_tickets._Price);
                    txtVV_Quantity.Text    = Convert.ToString(em.VVIP_Quantity);
                    txtVV_Token.Text       = Convert.ToString(VVIP_tickets._Credit);
                    txtVV_OpenDate.Text    = Convert.ToString(VVIP_tickets._StartDate);
                    txtVV_ClosingDate.Text = Convert.ToString(VVIP_tickets._EndDate);
                }

                //Address
                txtStreet.Text   = _address.STREET;
                txtCity.Text     = _address.CITY;
                txtProvince.Text = _address.PROVINCE;
                txtCountry.Text  = _address.COUNTRY;
            }
        }
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            string EVENT_TRACKER;
            string SUBFOLDER = "Main_Image";
            int    hostID    = Convert.ToInt32(Session["ID"].ToString());
            String request   = (Request.QueryString["EventID"]);

            if (request == null)
            {
                request = (Request.QueryString["ed"]);
            }
            EventServiceClient _eventClient = new EventServiceClient();
            EventModel         oldEvent     = new EventModel();

            oldEvent = _eventClient.findByEventID(request);

            //Editing  Address
            EventAddress  currentAdd = new EventAddress();
            EventAddress  Oldadd     = new EventAddress();
            MappingClient mc         = new MappingClient();

            currentAdd = mc.getAddressById(Convert.ToString(oldEvent.EventAddress));
            if (txtCountry.Text.Equals(""))
            {
                Oldadd.COUNTRY = currentAdd.COUNTRY;
            }
            else
            {
                Oldadd.COUNTRY = txtCountry.Text;
            }
            if (txtCity.Text.Equals(""))
            {
                Oldadd.CITY = currentAdd.CITY;
            }
            else
            {
                Oldadd.CITY = txtCity.Text;
            }
            if (txtStreet.Text.Equals(""))
            {
                Oldadd.STREET = currentAdd.STREET;
            }
            else
            {
                Oldadd.STREET = txtStreet.Text;
            }
            if (txtProvince.Text.Equals(""))
            {
                Oldadd.PROVINCE = currentAdd.PROVINCE;
            }
            else
            {
                Oldadd.PROVINCE = txtProvince.Text;
            }
            EventAddress newAddress = new EventAddress();

            newAddress = mc.EditAddress(Oldadd, Convert.ToString(oldEvent.EventAddress));

            EventModel _event = new EventModel();

            _event.HostID = oldEvent.HostID;
            _event.Name   = txtEventName.Text;  //Event Name
            if (chkBoxPrivate.Checked == true)  //Public or Private Event
            {
                _event.Type = "Private";
            }
            else
            {
                _event.Type = "Public";
            }
            _event.Desc = txtDesc.Text; //Event Description
            string startdate = "";
            string enddate   = "";

            //DateTime sDate = DateTime.ParseExact(startdate, "yyyy-MM-ddTHH:mm", CultureInfo.InvariantCulture);
            //DateTime eDate = DateTime.ParseExact(enddate, "yyyy-MM-ddTHH:mm", CultureInfo.InvariantCulture);
            //_event.sDate = sDate; //Event Start Date
            //_event.eDate = eDate; //Event End Date

            if (txtStart.Text.Equals(""))
            {
                _event.sDate = oldEvent.sDate;
            }
            else
            {
                // _event.sDate = DateTime.ParseExact(txtStart.Text, "yyyy/MM/dd HH:mm:ss", CultureInfo.InvariantCulture);
                //var date = DateTime.Parse(strDate,new CultureInfo("en-US", true))
                _event.sDate = Convert.ToString(DateTime.Parse(txtStart.Text, new CultureInfo("en-US", true)));
            }
            if (txtEnd.Text.Equals(""))
            {
                _event.eDate = oldEvent.eDate;
            }
            else
            {
                //  _event.eDate = DateTime.ParseExact(txtEnd.Text, "yyyy-MM-ddTHH:mm", CultureInfo.InvariantCulture);
                _event.eDate = Convert.ToString(DateTime.Parse(txtEnd.Text, new CultureInfo("en-US", true)));
            }
            _event.EventAddress = newAddress.ID;   //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;
            }
            //Edit Event Event
            EventServiceClient _editEvent = new EventServiceClient();
            EventModel         newEvent   = new EventModel();

            newEvent = _editEvent.updateEvent(_event, request);
            bool isCreatedTicket = false;   //Ticket Controller

            EVENT_TRACKER = "Event Edited successfully";
            //Import users
            //string ImportSpreadsheet = "";
            //ImportSpreadsheet = ImportData(flGuest, newEvent.EventID);

            //===================Import guest,staff and products============================//

            string         path                 = "";
            string         response             = "";
            bool           isValidGuestColumn   = false;
            bool           isValidStaffColumn   = false;
            bool           isValidProductColumn = false;
            int            startColumn          = 0;
            int            startRow             = 0;
            ExcelWorksheet GuestworkSheet       = null;
            ExcelWorksheet StaffworkSheet       = null;
            ExcelWorksheet ProductworkSheet     = null;
            int            count                = 0;

            if (flGuest.HasFile)
            {
                try
                {
                    string filename       = Path.GetFileName(flGuest.FileName);
                    string serverLocation = "~/Temp/" + "/" + filename;
                    string SaveLoc        = Server.MapPath(serverLocation);
                    flGuest.SaveAs(SaveLoc);
                    path = Server.MapPath("/") + "\\Temp\\" + filename;

                    var package = new ExcelPackage(new System.IO.FileInfo(path));
                    ////  package.Workbook.Worksheets["TABNAME"].View.TabSelected = true;
                    startColumn      = 1;                              //where the file in the class excel start
                    startRow         = 2;
                    GuestworkSheet   = package.Workbook.Worksheets[1]; //read sheet one
                    StaffworkSheet   = package.Workbook.Worksheets[2]; //read sheet two
                    ProductworkSheet = package.Workbook.Worksheets[3];

                    isValidGuestColumn   = ValidateGuestColumns(GuestworkSheet);
                    isValidStaffColumn   = ValidateStaffColumns(StaffworkSheet);
                    isValidProductColumn = ValidateProductColumns(ProductworkSheet);
                    // isValidColumn = true;
                }
                catch
                {
                    response += "Failed";
                }
                //check staff sheet
                object data = null;
                if (isValidStaffColumn == true && isValidGuestColumn == true && isValidProductColumn == true)
                {
                    do
                    {
                        data = StaffworkSheet.Cells[startRow, startColumn].Value; //column Number
                        if (data == null)
                        {
                            continue;
                        }
                        //read column class name
                        object     Name       = StaffworkSheet.Cells[startRow, startColumn].Value;
                        object     Email      = StaffworkSheet.Cells[startRow, startColumn + 1].Value;
                        object     Occupation = StaffworkSheet.Cells[startRow, startColumn + 2].Value;
                        StaffModel _staff     = new StaffModel();
                        _staff.NAME       = Name.ToString();
                        _staff.EMAIL      = Email.ToString();
                        _staff.Occupation = Occupation.ToString();
                        _staff.PASS       = "******";
                        _staff.EventID    = newEvent.EventID;
                        //edit to db
                        StaffServiceClient ssv = new StaffServiceClient();
                        bool isCreated         = ssv.createStaff(_staff);
                        if (isCreated == true)
                        {
                            count++;
                        }
                        startRow++;
                    } while (data != null);

                    data        = null;
                    startColumn = 1;  //where the file in the class excel start
                    startRow    = 2;
                    do
                    {
                        data = GuestworkSheet.Cells[startRow, startColumn].Value; //column Number
                        if (data == null)
                        {
                            continue;
                        }
                        object     Name    = GuestworkSheet.Cells[startRow, startColumn].Value;
                        object     Surname = GuestworkSheet.Cells[startRow, startColumn + 1].Value;
                        object     Email   = GuestworkSheet.Cells[startRow, startColumn + 2].Value;
                        GuestModel _guest  = new GuestModel();
                        _guest.NAME    = Name.ToString();
                        _guest.SURNAME = Surname.ToString();
                        _guest.EMAIL   = Email.ToString();
                        _guest.PASS    = "******";
                        _guest.TYPE    = "Private";
                        Eventrix_Client.Registration reg = new Eventrix_Client.Registration();
                        //   response = reg.RegisterGuest(_guest);
                        sendMsg(_guest, _event);
                        if (response.Contains("successfully"))
                        {
                            count++;
                        }
                        startRow++;
                    } while (data != null);

                    //upload product details
                    data        = null;
                    startColumn = 1;  //where the file in the class excel start
                    startRow    = 2;
                    do
                    {
                        data = ProductworkSheet.Cells[startRow, startColumn].Value; //column Number
                        if (data == null)
                        {
                            continue;
                        }
                        object       Name        = ProductworkSheet.Cells[startRow, startColumn].Value;
                        object       Description = ProductworkSheet.Cells[startRow, startColumn + 1].Value;
                        object       Quantity    = ProductworkSheet.Cells[startRow, startColumn + 2].Value;
                        object       Price       = ProductworkSheet.Cells[startRow, startColumn + 3].Value;
                        EventProduct _product    = new EventProduct();
                        _product._Name = Name.ToString();
                        //     _product._Desc = Description.ToString();
                        _product._Quantity = Convert.ToInt32(Quantity.ToString());
                        _product._Price    = Convert.ToInt32(Price.ToString());
                        _product.EventID   = newEvent.EventID;
                        ProductServiceClient psv = new ProductServiceClient();
                        //  string isProductUpdated = psv.createProduct(_product);
                        string isProductUpdated = psv.createProduct(_product);
                        if (isProductUpdated.Contains("success"))
                        {
                            count++;
                        }
                        startRow++;
                    } while (data != null);
                    //check record
                    if (count == (GuestworkSheet.Dimension.Rows - 1) + (StaffworkSheet.Dimension.Rows - 1) + (ProductworkSheet.Dimension.Rows - 1))
                    {
                        response = "success: All Records uploaded";
                    }
                    else
                    {
                        response = "success: Not All Records uploaded";
                    }
                }
                else
                {
                    response += " Failed to upload Exceel: Check columns";
                }
            }
            else
            {
                response = "Failed: File not found";
            }


            //==============================================================================//
            if (response.Contains("success"))
            {
                EVENT_TRACKER += "\n Spreadsheet Uploaded";
                //Create Tickets
                isCreatedTicket = isLoadedTicket(newEvent, newEvent.EventID);
                if (isCreatedTicket == true)
                {
                    EVENT_TRACKER += "\n Ticket Created";
                }
                else
                {
                    EVENT_TRACKER += "\n Failed to upload ticket";
                }
            }
            else
            {
                EVENT_TRACKER += "\n Spreadsheet Uploaded";
                //Create Tickets
                isCreatedTicket = isLoadedTicket(newEvent, newEvent.EventID);
                if (isCreatedTicket == true)
                {
                    EVENT_TRACKER += "\n Ticket Created";
                }
                else
                {
                    EVENT_TRACKER += "\n Failed to upload ticket";
                }
                //Unable to upload guest
                EVENT_TRACKER += "\n failed to upload spreadsheet";
            }

            ////Upload images
            ImageFile mainPic = new ImageFile();

            mainPic = UploadFile(flEventImages, Convert.ToString(newEvent.EventID), SUBFOLDER); //Upload Event Main's Image to client directory
            if (mainPic != null)
            {
                FileUploadClient fuc    = new FileUploadClient();
                string           res1   = fuc.saveImage(mainPic); //Upload Event Main's Image to Database
                string           number = res1;
            }
            Response.Redirect("EventDetails.aspx?EventID=" + newEvent.EventID);

            //  Response.Write("<script> Alert("+ EVENT_TRACKER + ");</script>");
        }
Beispiel #8
0
 public DataService()
 {
     this._songkickClient = SongkickClientFactory.CreateSongkickClient(Keys.Songkick);
     this._mappingClient = new MappingClient();
 }