コード例 #1
0
        public void LoadById(int eventid)
        {
            LFGuestSystemEntities db = new LFGuestSystemEntities();

            var d = (from p in db.tblEvents
                     join s in db.tblSites on p.SiteID equals s.SiteID
                     where p.EventID == eventid
                     orderby p.EventID
                     select new
            {
                p.EventID,
                p.Date,
                p.MealCount,
                p.VolunteerCount,
                s.SiteName,
                p.SiteID,
                p.WeatherDesc,
                p.Temp,
                p.ChildTray,
                p.AdultTray,
                p.Comments
            }).FirstOrDefault();

            this.EventID        = d.EventID;
            this.Date           = d.Date;
            this.MealCount      = d.MealCount ?? 0;
            this.VolunteerCount = d.VolunteerCount ?? 0;
            this.SiteName       = d.SiteName;
            this.SiteID         = d.SiteID;
            this.WeatherDesc    = d.WeatherDesc;
            this.Temp           = d.Temp ?? 54.0m;
            this.ChildTray      = d.ChildTray ?? 0;
            this.AdultTray      = d.AdultTray ?? 0;
            this.Comments       = d.Comments;
        }
コード例 #2
0
        //methods
        public void Insert()
        {
            try
            {
                LFGuestSystemEntities oDc = new LFGuestSystemEntities();
                tblEvent t_event          = new tblEvent();
                t_event.EventID = 1;
                // automatically calculate the new tblEventID
                if (oDc.tblEvents.Count() > 0)
                {
                    t_event.EventID = oDc.tblEvents.Max(p => p.EventID) + 1;
                }

                // fill in the data
                this.EventID           = t_event.EventID;
                t_event.Date           = this.Date;
                t_event.MealCount      = 0;
                t_event.VolunteerCount = 0;
                t_event.SiteID         = this.SiteID;
                t_event.WeatherDesc    = "Clear";
                t_event.Temp           = 50.0m;
                t_event.ChildTray      = 0;
                t_event.AdultTray      = 0;
                t_event.IsActive       = true;
                t_event.Comments       = this.Comments;
                oDc.tblEvents.Add(t_event);
                oDc.SaveChanges();
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
コード例 #3
0
        public void Update()
        {
            try
            {
                LFGuestSystemEntities oDc = new LFGuestSystemEntities();

                var item = (from p in oDc.tblGuests
                            where p.EventID == this.EventID
                            select p).FirstOrDefault();

                if (item != null)
                {
                    item.GuestID       = this.GuestID;
                    item.Gender        = this.Gender;
                    item.AgeGroup      = this.AgeGroup;
                    item.City          = this.City;
                    item.Ethnicity     = this.Ethnicity;
                    item.RepeatVisitor = this.RepeatVisitor;
                    item.EventID       = this.EventID;
                    oDc.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
コード例 #4
0
        public void Load()
        {
            LFGuestSystemEntities oDc = new LFGuestSystemEntities();

            var guests = (from g in oDc.tblGuests
                          select new
            {
                g.GuestID,
                g.Gender,
                g.AgeGroup,
                g.Ethnicity,
                g.City,
                g.RepeatVisitor,
                g.EventID
            }).ToList();

            foreach (var guest in guests)
            {
                CGuest oGuest = new CGuest();

                oGuest.GuestID       = guest.GuestID;
                oGuest.Gender        = guest.Gender;
                oGuest.AgeGroup      = guest.AgeGroup;
                oGuest.Ethnicity     = guest.Ethnicity;
                oGuest.City          = guest.City;
                oGuest.RepeatVisitor = (byte)guest.RepeatVisitor;
                oGuest.GuestID       = guest.GuestID;
            }
        }
コード例 #5
0
        public void Update(int id)
        {
            try
            {
                LFGuestSystemEntities oDc = new LFGuestSystemEntities();

                var item = (from p in oDc.tblEvents
                            where p.EventID == id
                            select p).FirstOrDefault();

                if (item != null)
                {
                    this.EventID        = this.EventID;
                    item.Date           = this.Date;
                    item.MealCount      = this.ChildTray + this.AdultTray;
                    item.VolunteerCount = this.VolunteerCount;
                    item.SiteID         = this.SiteID;
                    item.WeatherDesc    = this.WeatherDesc;
                    item.Temp           = this.Temp;
                    item.ChildTray      = this.ChildTray;
                    item.AdultTray      = this.AdultTray;
                    item.Comments       = this.Comments;
                    oDc.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
コード例 #6
0
        public void LoadByID()
        {
            try
            {
                LFGuestSystemEntities oDc = new LFGuestSystemEntities();

                var otblGuest = oDc.tblGuests.Where(g => g.GuestID == this.GuestID).FirstOrDefault();

                if (otblGuest != null)
                {
                    this.Gender        = otblGuest.Gender;
                    this.AgeGroup      = otblGuest.AgeGroup;
                    this.Ethnicity     = otblGuest.Ethnicity;
                    this.City          = otblGuest.City;
                    this.RepeatVisitor = (byte)otblGuest.RepeatVisitor;
                }
                else
                {
                    throw new Exception("Customer was not found.");
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
コード例 #7
0
ファイル: CSite.cs プロジェクト: OneBadApple/Check-In-Manager
        public void Update(int id)
        {
            try
            {
                LFGuestSystemEntities oDc = new LFGuestSystemEntities();

                var site = (from p in oDc.tblSites
                            where p.SiteID == id
                            select p).FirstOrDefault();

                if (site != null)
                {
                    site.SiteID   = this.SiteID;
                    site.SiteName = this.SiteName;
                    site.Street   = this.Street;
                    site.City     = this.City;
                    site.State    = this.State;
                    site.ZipCode  = this.ZipCode;
                    oDc.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
コード例 #8
0
ファイル: CSite.cs プロジェクト: OneBadApple/Check-In-Manager
        //methods
        public void Insert()
        {
            try
            {
                LFGuestSystemEntities oDc = new LFGuestSystemEntities();
                tblSite t_site            = new tblSite();
                t_site.SiteID = 1;
                // automatically calculate the new siteID
                if (oDc.tblSites.Count() > 0)
                {
                    t_site.SiteID = oDc.tblSites.Max(p => p.SiteID) + 1;
                }

                // fill in the data
                this.SiteID     = t_site.SiteID;
                t_site.SiteName = this.SiteName;
                t_site.Street   = this.Street;
                t_site.City     = this.City;
                t_site.State    = this.State;
                t_site.ZipCode  = this.ZipCode;
                oDc.tblSites.Add(t_site);
                oDc.SaveChanges();
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
コード例 #9
0
ファイル: CSite.cs プロジェクト: OneBadApple/Check-In-Manager
        public void Load()
        {
            LFGuestSystemEntities oDc = new LFGuestSystemEntities();

            foreach (tblSite tsite in oDc.tblSites)
            {
                CSite osite = new CSite();
                osite.SiteID   = tsite.SiteID;
                osite.SiteName = tsite.SiteName;
                osite.Street   = tsite.Street;
                osite.City     = tsite.City;
                osite.State    = tsite.State;
                osite.ZipCode  = tsite.ZipCode;
                Add(osite);
            }
            //var sites = (from s in oDc.tblSites
            //             select new
            //             {
            //                 s.SiteID,
            //                 s.SiteName,
            //                 s.Street,
            //                 s.City,
            //                 s.State,
            //                 s.ZipCode
            //             }).ToList();
            //foreach(var si in sites)
            //{
            //    CSite oSite = new CSite(si.SiteID, si.SiteName, si.Street, si.City, si.State, si.ZipCode);
            //    Add(oSite);

            //}
        }
コード例 #10
0
        public void Load()
        {
            LFGuestSystemEntities oDc = new LFGuestSystemEntities();

            var Employees = from p in oDc.tblEmployees
                            where p.IsActive == true
                            orderby p.LastName
                            select p;

            foreach (var s in Employees)
            {
                CEmployees e = new CEmployees();
                e.City       = s.City;
                e.DOB        = (DateTime)s.DOB;
                e.Email      = s.Email;
                e.EmployeeID = s.EmployeeID;
                e.FirstName  = s.FirstName;
                e.Key        = s.Key;
                e.LastName   = s.LastName;
                e.Password   = s.Password;
                e.Phone      = s.Phone;
                e.RoleID     = (int)s.RoleID;
                e.State      = s.State;
                e.Street     = s.Street;
                e.UserName   = s.UserName;
                e.ZipCode    = s.ZipCode;

                this.Add(e);
            }
        }
コード例 #11
0
        public void LoadbyDate(DateTime date)
        {
            LFGuestSystemEntities db = new LFGuestSystemEntities();


            var ebd = (from e in db.tblEvents
                       join s in db.tblSites on e.SiteID equals s.SiteID
                       where e.Date == date && e.IsActive == true
                       orderby e.Date
                       select new
            {
                e.EventID,
                e.Date,
                s.SiteName,
                e.MealCount,
                e.VolunteerCount,
                e.SiteID,
                e.WeatherDesc,
                e.Temp,
                e.ChildTray,
                e.AdultTray,
                e.IsActive,
                e.Comments
            }
                       ).ToList();

            foreach (var ev in ebd)
            {
                CEvents t_event = new CEvents(ev.EventID, ev.Date, ev.SiteName, (int)ev.MealCount, (int)ev.VolunteerCount, ev.SiteID, ev.WeatherDesc, (decimal)ev.Temp, (int)ev.ChildTray, (int)ev.AdultTray, ev.Comments);
                Add(t_event);
            }
        }
コード例 #12
0
        public void Insert(int eventid)
        {
            try
            {
                var eventguests = new CGuestList();
                var eventinfo   = new CEvents();

                eventguests.LoadbyEventID(eventid);
                eventinfo.LoadById(eventid);

                LFGuestSystemEntities oDc = new LFGuestSystemEntities();

                HistoricalData hdEvent = new HistoricalData();
                hdEvent.Id = 1;
                if (oDc.HistoricalDatas.Count() > 0)
                {
                    hdEvent.Id = oDc.HistoricalDatas.Max(p => p.Id) + 1;
                }

                // fill in the data
                this.Id             = hdEvent.Id;
                hdEvent.Date        = eventinfo.Date;
                hdEvent.Meals       = eventinfo.MealCount;
                hdEvent.Guests      = eventguests.Count();
                hdEvent.Male        = eventguests.Where(g => g.Gender == "Male").Count();
                hdEvent.Female      = eventguests.Where(g => g.Gender == "Female").Count();
                hdEvent.Adult       = eventguests.Where(a => a.AgeGroup == "Adult").Count();;
                hdEvent.Children    = eventguests.Where(a => a.AgeGroup == "Child").Count();
                hdEvent.Seniors     = eventguests.Where(a => a.AgeGroup == "Senior").Count();
                hdEvent.NativeAm    = eventguests.Where(e => e.Ethnicity == "NativeAm").Count();
                hdEvent.AfricanAm   = eventguests.Where(e => e.Ethnicity == "AfricanAm").Count();
                hdEvent.White       = eventguests.Where(e => e.Ethnicity == "White").Count();
                hdEvent.Hispanic    = eventguests.Where(e => e.Ethnicity == "Hispanic").Count();
                hdEvent.AsianAm     = eventguests.Where(e => e.Ethnicity == "AsianAm").Count();
                hdEvent.Unspecified = eventguests.Where(e => e.Ethnicity == "Unspecified").Count();
                hdEvent.Appleton    = eventguests.Where(c => c.City == "Appleton").Count();
                hdEvent.Menasha     = eventguests.Where(c => c.City == "Menasha").Count();
                hdEvent.Kimberly    = eventguests.Where(c => c.City == "Kimberly").Count();
                hdEvent.Kaukauna    = eventguests.Where(c => c.City == "Kaukauna").Count();
                hdEvent.LtChute     = eventguests.Where(c => c.City == "LtChute").Count();
                hdEvent.Neenah      = eventguests.Where(c => c.City == "Neenah").Count();
                hdEvent.Other       = eventguests.Where(c => c.City == "Other").Count();
                hdEvent.Weather     = eventinfo.WeatherDesc;

                hdEvent.Temp_F         = eventinfo.Temp;
                hdEvent.EventID        = eventid;
                hdEvent.SiteID         = eventinfo.SiteID;
                hdEvent.Comments       = eventinfo.Comments;
                hdEvent.RepeatVisitors = eventguests.Where(r => r.RepeatVisitor == 1).Count();
                oDc.HistoricalDatas.Add(hdEvent);
                oDc.SaveChanges();
            }

            catch (Exception ex)
            {
                throw ex;
            }
        }
コード例 #13
0
        public void LoadJustTallies()
        {
            LFGuestSystemEntities oDc = new LFGuestSystemEntities();

            try
            {
                var ohd = (from hds in oDc.HistoricalDatas
                           where hds.Comments == "Tallied Meal"
                           orderby hds.Date
                           select new
                {
                    hds.Id,
                    hds.Date,
                    hds.Meals,
                    hds.Guests,
                    hds.Male,
                    hds.Female,
                    hds.Children,
                    hds.Seniors,
                    hds.NativeAm,
                    hds.Hispanic,
                    hds.AfricanAm,
                    hds.White,
                    hds.AsianAm,
                    hds.Unspecified,
                    hds.Appleton,
                    hds.Menasha,
                    hds.Kimberly,
                    hds.Kaukauna,
                    hds.LtChute,
                    hds.Neenah,
                    hds.Other,
                    hds.Weather,
                    hds.Temp_F,
                    hds.Adult,
                    hds.EventID,
                    hds.SiteID,
                    hds.Comments,
                    hds.RepeatVisitors
                }
                           ).ToList();
                foreach (var hd in ohd)
                {
                    CHistory t_history = new CHistory(hd.Id, hd.Date, hd.Meals, hd.Guests, hd.Male, hd.Female, hd.Children, hd.Seniors, hd.NativeAm, hd.Hispanic, hd.AfricanAm, hd.White, hd.AsianAm, hd.Unspecified, hd.Appleton, hd.Menasha, hd.Kimberly, hd.Kaukauna, hd.LtChute,
                                                      hd.Neenah, hd.Other, hd.Weather, hd.Temp_F, hd.Adult, hd.EventID, hd.SiteID, hd.Comments, hd.RepeatVisitors);
                    Add(t_history);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
コード例 #14
0
        public void InsertTally()
        {
            try
            {
                LFGuestSystemEntities db   = new LFGuestSystemEntities();
                HistoricalData        tDat = new HistoricalData();

                tDat.Id = 1;
                if (db.HistoricalDatas.Count() > 0)
                {
                    tDat.Id = db.HistoricalDatas.Max(h => h.Id) + 1;
                }

                this.Id             = tDat.Id;
                tDat.Date           = this.Date;
                tDat.Meals          = this.Meals;
                tDat.Guests         = this.Guests;
                tDat.Male           = this.Male;
                tDat.Female         = this.Female;
                tDat.Children       = this.Children;
                tDat.Seniors        = this.Seniors;
                tDat.NativeAm       = this.NativeAm;
                tDat.Hispanic       = this.Hispanic;
                tDat.AfricanAm      = this.AfricanAm;
                tDat.White          = this.White;
                tDat.AsianAm        = this.AsianAm;
                tDat.Unspecified    = this.Unspecified;
                tDat.Appleton       = this.Appleton;
                tDat.Menasha        = this.Menasha;
                tDat.Kimberly       = this.Kimberly;
                tDat.Kaukauna       = this.Kaukauna;
                tDat.LtChute        = this.LtChute;
                tDat.Neenah         = this.Neenah;
                tDat.Other          = this.Other;
                tDat.Weather        = this.Weather ?? "Clear";
                tDat.Adult          = this.Adult;
                tDat.Temp_F         = this.Temp_F;
                tDat.EventID        = this.EventID;
                tDat.SiteID         = this.SiteID;
                tDat.Comments       = this.Comments;
                tDat.RepeatVisitors = this.RepeatVisitors;
                db.SaveChanges();
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
コード例 #15
0
ファイル: CRole.cs プロジェクト: OneBadApple/Check-In-Manager
        public void Load()
        {
            LFGuestSystemEntities oDc = new LFGuestSystemEntities();

            var role = from p in oDc.tblRoles
                       orderby p.RoleID
                       select p;

            foreach (var s in role)
            {
                CRole e = new CRole();
                e.ID   = s.RoleID;
                e.Desc = s.Description;


                this.Add(e);
            }
        }
コード例 #16
0
        public void LoadbyEventID(int eventid)
        {
            LFGuestSystemEntities oDc = new LFGuestSystemEntities();
            var hdEvent = (from hd in oDc.HistoricalDatas
                           where hd.EventID == eventid
                           select new
            {
                hd.Id,
                hd.Date,
                hd.Meals,
                hd.Guests,
            }).FirstOrDefault();

            Id     = hdEvent.Id;
            Date   = (DateTime)hdEvent.Date;
            Meals  = (int)hdEvent.Meals;
            Guests = (int)hdEvent.Guests;
        }
コード例 #17
0
        public ActionResult Dashboard()
        {
            LFGuestSystemEntities  _db          = new LFGuestSystemEntities();
            JsonSerializerSettings _jsonSetting = new JsonSerializerSettings()
            {
                NullValueHandling = NullValueHandling.Ignore
            };

            if (Session["employee"] == null)
            {
                return(RedirectToAction("Login", "Login", new { returnurl = HttpContext.Request.Url }));
            }
            else
            {
                try
                {
                    DateTime today        = DateTime.Now;
                    DateTime sixMonthsAgo = today.AddMonths(-6);
                    // or
                    //var lastYear = today.AddYears(-1).Year;

                    var Coord = (from x in _db.HistoricalDatas
                                 where x.Date >= sixMonthsAgo
                                 //where x.Date.Value.Year == lastYear
                                 orderby x.Date
                                 select new
                    {
                        x.Date,
                        x.Guests
                    }).ToList();
                    ViewBag.DataPoints = JsonConvert.SerializeObject(Coord, _jsonSetting);
                    //ViewBag.DataPoints = JsonConvert.SerializeObject(_db.tblEvents.ToList(), _jsonSetting);
                    return(View());
                }
                catch (System.Data.Entity.Core.EntityException)
                {
                    return(View("Error"));
                }
                catch (System.Data.SqlClient.SqlException)
                {
                    return(View("Error"));
                }
            }
        }
コード例 #18
0
        public void Load()
        {
            LFGuestSystemEntities db = new LFGuestSystemEntities();

            var ebd = (from e in db.tblEvents
                       join s in db.tblSites on e.SiteID equals s.SiteID
                       where e.IsActive == true
                       orderby e.Date
                       select new
            {
                e.EventID,
                e.Date,
                s.SiteName,
                e.MealCount,
                e.VolunteerCount,
                e.SiteID,
                e.WeatherDesc,
                e.Temp,
                e.ChildTray,
                e.AdultTray,
                e.IsActive,
                e.Comments
            }
                       ).ToList();

            foreach (var ev in ebd)
            {
                CEvents es = new CEvents();
                es.EventID        = ev.EventID;
                es.Date           = ev.Date;
                es.SiteName       = ev.SiteName;
                es.MealCount      = ev.MealCount ?? 0;
                es.VolunteerCount = ev.VolunteerCount ?? 0;
                es.SiteID         = ev.SiteID;
                es.WeatherDesc    = ev.WeatherDesc;
                es.Temp           = ev.Temp ?? 54.0m;
                es.ChildTray      = ev.ChildTray ?? 0;
                es.AdultTray      = ev.AdultTray ?? 0;
                es.isActive       = ev.IsActive ?? true;
                es.Comments       = ev.Comments;

                Add(es);
            }
        }
コード例 #19
0
        public void CloseEvent()
        {
            CWeather CurrentWeather = new CWeather();

            // dynamic CurrentWeather;
            try
            {
                using (var wc = new WebClient())
                {
                    var jsonString = "http://api.wunderground.com/api/37f4201157f6db0a/conditions/q/WI/Appleton.json";

                    string rawJSON = wc.DownloadString(jsonString);
                    CurrentWeather = JsonConvert.DeserializeObject <CWeather>(rawJSON);
                }
                LFGuestSystemEntities oDc = new LFGuestSystemEntities();

                var item = (from p in oDc.tblEvents
                            where p.EventID == this.EventID
                            select p).FirstOrDefault();

                if (item != null)
                {
                    //item.EventID = this.EventID;
                    //item.Date = this.Date;
                    item.MealCount      = this.ChildTray + this.AdultTray;
                    item.VolunteerCount = this.VolunteerCount;
                    //item.SiteID = this.SiteID;
                    item.Temp        = Convert.ToDecimal(CurrentWeather.CurrentObservation.TempF);
                    item.WeatherDesc = CurrentWeather.CurrentObservation.Weather;
                    item.ChildTray   = this.ChildTray;
                    item.AdultTray   = this.AdultTray;
                    item.IsActive    = false;
                    item.Comments    = this.Comments;
                    oDc.SaveChanges();
                }

                CHistory archive = new CHistory();
                archive.Insert(EventID);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
コード例 #20
0
        //methods
        public void Insert()
        {
            try
            {
                LFGuestSystemEntities oDc         = new LFGuestSystemEntities();
                tblEmployee           tblEmployee = new tblEmployee();
                tblEmployee.EmployeeID = 1;
                // automatically calculate the new EmployeeID
                if (oDc.tblEmployees.Any())
                {
                    tblEmployee.EmployeeID = oDc.tblEmployees.Max(p => p.EmployeeID) + 1;
                }

                // fill in the data
                this.EmployeeID       = tblEmployee.EmployeeID;
                tblEmployee.FirstName = this.FirstName;
                tblEmployee.LastName  = this.LastName;
                tblEmployee.DOB       = this.DOB;
                tblEmployee.Street    = this.Street;
                tblEmployee.City      = this.City;
                tblEmployee.State     = this.State;
                tblEmployee.ZipCode   = this.ZipCode;
                tblEmployee.Phone     = this.Phone;
                tblEmployee.Email     = this.Email;
                tblEmployee.UserName  = this.UserName;
                tblEmployee.Password  = this.Password;
                tblEmployee.Password  = this.GetHash();
                tblEmployee.Key       = this.Key;
                tblEmployee.RoleID    = this.RoleID;
                tblEmployee.IsActive  = true;


                oDc.tblEmployees.Add(tblEmployee);
                oDc.SaveChanges();
                oDc = null;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
コード例 #21
0
        public void UpdateTally(int id)
        {
            LFGuestSystemEntities db = new LFGuestSystemEntities();

            var hist = (from h in db.HistoricalDatas
                        where h.Id == id
                        select h).FirstOrDefault();

            if (hist != null)
            {
                this.Id             = this.Id;
                hist.Date           = this.Date;
                hist.Meals          = this.Meals;
                hist.Guests         = this.Guests;
                hist.Male           = this.Male;
                hist.Female         = this.Female;
                hist.Children       = this.Children;
                hist.Seniors        = this.Seniors;
                hist.NativeAm       = this.NativeAm;
                hist.Hispanic       = this.Hispanic;
                hist.AfricanAm      = this.AfricanAm;
                hist.White          = this.White;
                hist.AsianAm        = this.AsianAm;
                hist.Unspecified    = this.Unspecified;
                hist.Appleton       = this.Appleton;
                hist.Menasha        = this.Menasha;
                hist.Kimberly       = this.Kimberly;
                hist.Kaukauna       = this.Kaukauna;
                hist.LtChute        = this.LtChute;
                hist.Neenah         = this.Neenah;
                hist.Other          = this.Other;
                hist.Weather        = this.Weather;
                hist.Adult          = this.Adult;
                hist.Temp_F         = this.Temp_F;
                hist.EventID        = this.EventID;
                hist.SiteID         = this.SiteID;
                hist.Comments       = this.Comments;
                hist.RepeatVisitors = this.RepeatVisitors;
                db.SaveChanges();
            }
        }
コード例 #22
0
        public void Delete(int id)
        {
            try
            {
                LFGuestSystemEntities oDc = new LFGuestSystemEntities();

                var item = (from p in oDc.tblEmployees
                            where p.EmployeeID == id
                            select p).FirstOrDefault();

                if (item != null)
                {
                    item.IsActive = false;
                    oDc.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
コード例 #23
0
        public int GetEventID(DateTime date, int site)
        {
            this.Date   = date;
            this.SiteID = site;
            try
            {
                LFGuestSystemEntities oDc = new LFGuestSystemEntities();
                tblEvent t_event          = oDc.tblEvents.Where(p => (p.Date == this.Date && p.SiteID == this.SiteID)).FirstOrDefault();

                if (t_event == null)
                {
                    Insert();
                }

                return(this.EventID);
            }

            catch (Exception ex)
            {
                throw ex;
            }
        }
コード例 #24
0
ファイル: CSite.cs プロジェクト: OneBadApple/Check-In-Manager
        public void LoadById(int id)
        {
            LFGuestSystemEntities db = new LFGuestSystemEntities();
            var s = (from p in db.tblSites
                     where p.SiteID == id
                     select new
            {
                p.SiteID,
                p.SiteName,
                p.Street,
                p.City,
                p.State,
                p.ZipCode
            }).FirstOrDefault();

            this.SiteID   = s.SiteID;
            this.SiteName = s.SiteName;
            this.Street   = s.Street;
            this.City     = s.City;
            this.State    = s.State;
            this.ZipCode  = s.ZipCode;
        }
コード例 #25
0
ファイル: CRole.cs プロジェクト: OneBadApple/Check-In-Manager
        public void Update()
        {
            try
            {
                LFGuestSystemEntities oDc = new LFGuestSystemEntities();

                var item = (from p in oDc.tblRoles
                            where p.RoleID == this.ID
                            select p).FirstOrDefault();

                if (item != null)
                {
                    item.RoleID      = this.ID;
                    item.Description = this.Desc;
                    oDc.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
コード例 #26
0
        public bool Login()
        {
            try
            {
                if (UserName != string.Empty && Password != string.Empty)
                {
                    LFGuestSystemEntities oDc = new LFGuestSystemEntities();

                    tblEmployee user = oDc.tblEmployees.FirstOrDefault(p => p.UserName == this.UserName);

                    if (user != null)
                    {
                        if (user.Password == GetHash())
                        {
                            oDc = null;
                            return(true);
                        }
                        else
                        {
                            oDc = null;
                            return(false);
                        }
                    }
                    else
                    {
                        oDc = null;
                        return(false);
                    }
                }
                else
                {
                    return(true);
                }
            }
            catch
            {
                return(false);
            }
        }
コード例 #27
0
        public void Update(int id)
        {
            try
            {
                LFGuestSystemEntities oDc = new LFGuestSystemEntities();

                var item = (from p in oDc.tblEmployees
                            where p.EmployeeID == id
                            select p).FirstOrDefault();

                if (item != null)
                {
                    if (this.Password != item.Password)
                    {
                        this.Password = this.GetHash();
                    }

                    this.EmployeeID = this.EmployeeID;
                    item.FirstName  = this.FirstName;
                    item.LastName   = this.LastName;
                    item.Street     = this.Street;
                    item.City       = this.City;
                    item.State      = this.State;
                    item.ZipCode    = this.ZipCode;
                    item.Phone      = this.Phone;
                    item.Email      = this.Email;
                    item.UserName   = this.UserName;
                    item.Password   = this.Password;
                    item.Key        = this.Key;
                    item.RoleID     = this.RoleID;
                    item.IsActive   = this.isActive;
                    oDc.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
コード例 #28
0
        //Add an update to "delete" make employee's not active


        public void LoadById(int id)
        {
            LFGuestSystemEntities db = new LFGuestSystemEntities();

            var d = (from p in db.tblEmployees
                     where p.EmployeeID == id && p.IsActive == true
                     orderby p.EmployeeID
                     select new
            {
                p.EmployeeID,
                p.FirstName,
                p.LastName,
                p.Phone,
                p.Street,
                p.City,
                p.State,
                p.DOB,
                p.ZipCode,
                p.Email,
                p.UserName,
                p.Password,
                p.Key,
                p.RoleID
            }).FirstOrDefault();

            this.EmployeeID = d.EmployeeID;
            this.FirstName  = d.FirstName;
            this.LastName   = d.LastName;
            this.DOB        = (DateTime)d.DOB;
            this.Phone      = d.Phone;
            this.Street     = d.Street;
            this.City       = d.City;
            this.State      = d.State;
            this.ZipCode    = d.ZipCode;
            this.Email      = d.Email;
            this.UserName   = d.UserName;
            this.Password   = d.Password;
            this.Key        = d.Key;
        }
コード例 #29
0
        //public CGuest(int guestID, string gender, string ageGroup, string city, string ethnicity, int eventID)
        //{
        //    GuestID = guestID;
        //    Gender = gender;
        //    AgeGroup = ageGroup;
        //    City = city;
        //    Ethnicity = ethnicity;
        //    EventID = eventID;
        //}

        //methods
        public bool Insert()
        {
            try
            {
                LFGuestSystemEntities oDc = new LFGuestSystemEntities();

                tblGuest t_guest = new tblGuest();

                t_guest.GuestID = 1;

                // automatically calculate the new GuestID
                if (oDc.tblGuests.Count() > 0)
                {
                    t_guest.GuestID = oDc.tblGuests.Max(p => p.GuestID) + 1;
                }

                // fill in the data
                this.GuestID = t_guest.GuestID;

                t_guest.Gender        = this.Gender;
                t_guest.AgeGroup      = this.AgeGroup;
                t_guest.City          = this.City;
                t_guest.Ethnicity     = this.Ethnicity;
                t_guest.RepeatVisitor = this.RepeatVisitor;
                t_guest.EventID       = this.EventID;

                oDc.tblGuests.Add(t_guest);

                oDc.SaveChanges();

                return(true);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
コード例 #30
0
        public void LoadbyEventID(int eventid)
        {
            LFGuestSystemEntities db = new LFGuestSystemEntities();

            var lbd = (from g in db.tblGuests
                       where g.EventID == eventid
                       select new
            {
                GuestID = g.GuestID,
                Gender = g.Gender,
                AgeGroup = g.AgeGroup,
                City = g.City,
                Ethnicity = g.Ethnicity,
                RepeatVisitor = g.RepeatVisitor,
                EventID = g.EventID
            }
                       ).ToList();

            foreach (var g in lbd)
            {
                CGuest guest = new CGuest(g.GuestID, g.Gender, g.AgeGroup, g.City, g.Ethnicity, (byte)g.RepeatVisitor, g.EventID);
                Add(guest);
            }
        }