예제 #1
0
        public ActionResult Save(Staff staff)
        {
            UserLogin profile = (UserLogin)Session["UserProfile"];

            ViewBag.Country = new SelectList(db.MCountries, "iCountry", "strCountryName", staff.iCountryID);
            var countryList = db.MCities.Where(x => x.iCountry == staff.iCountryID).ToList();

            ViewBag.City = new SelectList(countryList, "iCity", "strCityName", staff.iCityID);
            bool status = false;

            try
            {
                if (ModelState.IsValid)
                {
                    StaffServiceClient staffServiceClient = new StaffServiceClient();

                    status = staffServiceClient.SaveData(staff);
                    return(RedirectToAction("Index"));
                }
            }
            catch (Exception e)
            {
                ModelState.AddModelError("error", "Something Went Wrong");
                status = false;
                throw e;
            }
            return(View(staff));
            //   return new JsonResult { Data = new { status = status } };
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            String id = Request.Params["Id"];
            if (id != null)
            {
                StaffServiceClient staffServiceClient = new StaffServiceClient();
                Staff staff = staffServiceClient.QueryStaff(Int32.Parse(id));

                RoomServiceClient roomServiceClient = new RoomServiceClient();
                Room room = roomServiceClient.QueryRoom(staff.Room);

                ZipcodeServiceClient zipcodeServiceClient = new ZipcodeServiceClient();
                Zipcode zipcode = zipcodeServiceClient.QueryZipcode(room.Zipcode);

                GeolocationServiceClient geolocationServiceClient = new GeolocationServiceClient();
                String location = geolocationServiceClient.GetCountry(staff.IpAddress);

                td_Id.InnerText = staff.Id.ToString();
                td_Name.InnerText = staff.Name;
                td_LastName.InnerText = staff.LastName;
                td_Room.InnerText = staff.Room;
                td_Zipcode.InnerText = room.Zipcode;
                td_Street.InnerText = zipcode.Street;
                td_City.InnerText = zipcode.City;
                td_ipAddress.InnerText = staff.IpAddress;
                td_location.InnerText = location;

                geolocationServiceClient.Close();
                zipcodeServiceClient.Close();
                roomServiceClient.Close();
                staffServiceClient.Close();
            }
        }
예제 #3
0
        public ActionResult Save(string ID)
        {
            int id = 0;

            if (ID != "0")
            {
                id = Convert.ToInt32(Helpers.CommonMethods.Decrypt(HttpUtility.UrlDecode(ID)));
            }
            Staff staff = new Staff();

            try
            {
                if (ModelState.IsValid)
                {
                    StaffServiceClient staffServiceClient = new StaffServiceClient();

                    staff = staffServiceClient.GetStaff(id);

                    ViewBag.Country = new SelectList(db.MCountries, "iCountry", "strCountryName", staff.iCountryID);
                    var countryList = db.MCities.Where(x => x.iCountry == staff.iCountryID).ToList();

                    ViewBag.City     = new SelectList(countryList, "iCity", "strCityName", staff.iCityID);
                    ViewBag.PageName = "Create Staff";
                }
            }
            catch (Exception e)
            {
                ModelState.AddModelError("error", "something went wrong");
                staff = null;
                throw e;
            }
            return(View(staff));
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            RoomServiceClient roomServiceClient = new RoomServiceClient();
            string[] roomIdentifiers = roomServiceClient.QueryAllRoomIdentifiers();

            td_Room.DataSource = roomIdentifiers;
            td_Room.DataBind();

            String id = Request.Params["id"];

            if (id == null)
            {
                action.Value = "insert";
            }
            else
            {
                StaffServiceClient staffServiceClient = new StaffServiceClient();
                Staff staff = staffServiceClient.QueryStaff(Int32.Parse(id));

                action.Value = "update";
                old_Id.Value = id;

                td_Id.Text = staff.Id.ToString();
                td_Name.Text = staff.Name;
                td_LastName.Text = staff.LastName;
                td_Room.SelectedValue = staff.Room;
                td_ipAddress.Text = staff.IpAddress;

                staffServiceClient.Close();
            }

            roomServiceClient.Close();
        }
예제 #5
0
        private void valider_Click(object sender, RoutedEventArgs e)
        {
            ServiceReference13.Staff s      = new ServiceReference13.Staff();
            StaffServiceClient       client = new StaffServiceClient();

            s.StaffUsername   = usernamem.Text;
            s.StaffFirstName  = prenomm.Text;
            s.StaffLastName   = nomm.Text;
            s.StaffLastUpdate = DateTime.Now;
            s.StaffEmail      = emailm.Text;
            s.StaffPassword   = passwordBox.Text;
            s.StaffPicture    = b;
            s.AddressId       = ((ServiceReference14.Address)addressem.SelectedItem).AddressId;
            s.StoreId         = ((ServiceReference13.Store)Storem.SelectedItem).StoreId;
            client.Add(s);
        }
예제 #6
0
        public ActionResult GetAllStaff()
        {
            dynamic staff = 0;

            try
            {
                if (ModelState.IsValid)
                {
                    StaffServiceClient staffServiceClient = new StaffServiceClient();
                    staff = staffServiceClient.GetAllStaff();
                }
            }
            catch (Exception e)
            {
                ModelState.AddModelError("error", "Something Wrong");
                staff = null;
                throw e;
            }
            return(Json(staff, JsonRequestBehavior.AllowGet));
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            String action = Request.Params["action"];

            if (action != null)
            {
                StaffServiceClient staffServiceClient = new StaffServiceClient();

                if (action.Equals("insert"))
                {
                    Staff staff = new Staff();
                    staff.Id = Int32.Parse(Request.Params["td_Id"]);
                    staff.Name = Request.Params["td_Name"];
                    staff.LastName = Request.Params["td_LastName"];
                    staff.Room = Request.Params["td_Room"];
                    staff.IpAddress = Request.Params["td_ipAddress"];

                    staffServiceClient.InsertStaff(staff);
                }
                else if (action.Equals("update"))
                {
                    Staff staff = new Staff();
                    staff.Id = Int32.Parse(Request.Params["td_Id"]);
                    staff.Name = Request.Params["td_Name"];
                    staff.LastName = Request.Params["td_LastName"];
                    staff.Room = Request.Params["td_Room"];
                    staff.IpAddress = Request.Params["td_ipAddress"];

                    staffServiceClient.UpdateStaff(Int32.Parse(Request.Params["old_Id"]), staff);
                }
                else if (action.Equals("delete"))
                {
                    staffServiceClient.DeleteStaff(Int32.Parse(Request.Params["Id"]));
                }

                staffServiceClient.Close();

                Response.Status = "301 Moved Permanently";
                Response.AddHeader("Location", Request.ApplicationPath.TrimEnd('/') + "/stafftable.aspx");
            }
        }
예제 #8
0
        public ActionResult DeleteStaff(String ID)
        {
            int  id     = Convert.ToInt32(Helpers.CommonMethods.Decrypt(HttpUtility.UrlDecode(ID)));//Decrypt ID
            bool status = false;

            try
            {
                if (ModelState.IsValid)
                {
                    StaffServiceClient staffServiceClient = new StaffServiceClient();

                    status = staffServiceClient.Delete(id);
                    return(RedirectToAction("Index"));
                }
            }
            catch (Exception e)
            {
                ModelState.AddModelError("error", "Something Went Wrong!");
                status = false;
                throw e;
            }
            return(View());
            //return new JsonResult { Data = new { status = status } };
        }
예제 #9
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);
                }
            }
        }
예제 #10
0
 public StaffServiceClient(EndpointConfiguration endpointConfiguration, System.ServiceModel.EndpointAddress remoteAddress) :
     base(StaffServiceClient.GetBindingForEndpoint(endpointConfiguration), remoteAddress)
 {
     this.Endpoint.Name = endpointConfiguration.ToString();
     ConfigureEndpoint(this.Endpoint, this.ClientCredentials);
 }
예제 #11
0
 public StaffServiceClient(EndpointConfiguration endpointConfiguration) :
     base(StaffServiceClient.GetBindingForEndpoint(endpointConfiguration), StaffServiceClient.GetEndpointAddress(endpointConfiguration))
 {
     this.Endpoint.Name = endpointConfiguration.ToString();
     ConfigureEndpoint(this.Endpoint, this.ClientCredentials);
 }
예제 #12
0
 public StaffServiceClient() :
     base(StaffServiceClient.GetDefaultBinding(), StaffServiceClient.GetDefaultEndpointAddress())
 {
     this.Endpoint.Name = EndpointConfiguration.BasicHttpBinding_IStaffService.ToString();
     ConfigureEndpoint(this.Endpoint, this.ClientCredentials);
 }
예제 #13
0
 private static System.ServiceModel.EndpointAddress GetDefaultEndpointAddress()
 {
     return(StaffServiceClient.GetEndpointAddress(EndpointConfiguration.BasicHttpBinding_IStaffService));
 }
예제 #14
0
 private static System.ServiceModel.Channels.Binding GetDefaultBinding()
 {
     return(StaffServiceClient.GetBindingForEndpoint(EndpointConfiguration.BasicHttpBinding_IStaffService));
 }
예제 #15
0
        string ImportData(FileUpload flInfo, int EventID)
        {
            string         path                 = "";
            string         response             = "";
            bool           isValidGuestColumn   = false;
            bool           isValidStaffColumn   = false;
            bool           isValidProductColumn = false;
            int            startColumn;
            int            startRow;
            ExcelWorksheet GuestworkSheet;
            ExcelWorksheet StaffworkSheet;
            ExcelWorksheet ProductworkSheet;
            int            count = 0;

            if (flInfo.HasFile)
            {
                try
                {
                    string filename       = Path.GetFileName(flInfo.FileName);
                    string serverLocation = "~/Temp/" + "/" + filename;
                    string SaveLoc        = Server.MapPath(serverLocation);
                    flInfo.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";
                    return(response);
                }
                //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    = 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);
                        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   = 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";
            }

            //Directory.Delete(path, true);
            return(response);
        }
예제 #16
0
        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>");
        }