Esempio n. 1
0
        void ipc_OnScan(object sender, ProximityConnectorEventArgs e)
        {
            if (LblScanBadge.Visible == false)
            {
                return;
            }

            if (this.InvokeRequired)
            {
                this.Invoke((Action)(() => ipc_OnScan(sender, e)));
                return;
            }
            var t           = new RestClient();
            var badgeNumber = e.BadgeNumber.ToString();

            //tmp
            var badgeAndPicture = FindMatchingBadge(badgeNumber);
            var jsonStr         = t.Get(ConfigurationManager.AppSettings["CardUrl"] + badgeAndPicture.LongId);
            var user            = JsonConvert.DeserializeObject <CardUser>(jsonStr);

            if (user != null)
            {
                //Hide Scan Badge
                LblScanBadge.Visible = false;

                //Get Image
                string filename = @ConfigurationManager.AppSettings["PictureLocation"] + badgeAndPicture.PhotoPath;
                //string filename = @"\\ctac\service\Pictures\P1960-Darian Everett.jpg";
                pbPicture.Image   = Bitmap.FromFile(filename);
                pbPicture.Visible = true;

                //Show Name
                lblWelcome.Text    = "Welcome " + user.FirstName + " " + user.LastName;
                lblWelcome.Left    = (ClientSize.Width - lblWelcome.Width) / 2;
                lblWelcome.Visible = true;


                if (badgeAndPicture.Age < 21)
                {
                    rejectBtn.Text    = "Under 21!";
                    rejectBtn.Visible = true;
                    return;
                }

                badgeAndPicture.DrinkCount++;

                // db work

                var emp = SqliteDataAccess.GetEmployeeByBadgeNumber(badgeNumber);

                if (emp == null)
                {
                    emp = new EmployeeModel
                    {
                        EmployeeId   = e.BadgeNumber,
                        EmployeeName = user.FirstName + " " + user.LastName
                    };
                }

                if (emp.DrinksToday > 2)
                {
                    rejectBtn.Text    = "Over Drink Limit!";
                    rejectBtn.Visible = true;
                    return;
                }

                emp.DrinksToday++;
                emp.LastLogin     = DateTime.Today;
                acceptBtn.Visible = true;
                SqliteDataAccess.SaveEmployee(emp);
            }
        }
Esempio n. 2
0
 private void LoadEmployeeList()
 {
     _employees = SqliteDataAccess.LoadEmployees();
 }