private void DoLogin(string scanCode) { Employee employee = EmployeeManager.LookupByScanCode(scanCode); if (employee == null) { // The debug version will have an exception here if escape-exit is used try { PosDialogWindow.ShowDialog(Types.Strings.LoginLoginIncorrect, Types.Strings.Error); return; } catch { return; } } // Check if logged-in somewhere else if (PosHelper.IsLocked(TableName.Employee, employee.Id)) { #if !DEMO BroadcastClientSocket.SendRemoteLogout(employee.Id); #endif PosHelper.Unlock(TableName.Employee, employee.Id); } // Check if clock-in is required if (!employee.IsClockedIn()) { if (!DoClockIn(employee) && !employee.HasPermission(Permissions.SystemMaintenance)) { return; } } // Proceed with login IsLoggedIn = true; // Clear dead-locks Lock.DeleteAllEmployeeLocks(employee.Id); // Lock the employee to prevent simultaneous logins PosHelper.Lock(TableName.Employee, employee.Id, employee.Id); #if !DEMO // Tell other clients, that this employee just logged in BroadcastClientSocket.SendMessage("LOGIN " + employee.Id); #endif StartAutoLogoutTimer(); if (Login != null) { Login.Invoke(this, new UserLoginEventArgs(employee)); } }
private void EditPartyInfo() { if (PosHelper.IsLocked(TableName.Party, CurrentTicket.PartyId)) { PosDialogWindow.ShowDialog( Types.Strings.ThePartyInformationForThisTicketIsCurrentlyBeingModifiedSomewhereElse, Types.Strings.PartyInformationLocked); return; } PosHelper.Lock(TableName.Party, CurrentTicket.PartyId, SessionManager.ActiveEmployee.Id); PosDialogWindow window = PartyEditControl.CreateInDefaultWindow(); PartyEditControl control = window.DockedControl as PartyEditControl; control.Initialize(ParentTicket.PartyId); window.ShowDialog(ParentWindow); control.ActiveParty.Update(); PosHelper.Unlock(TableName.Party, CurrentTicket.PartyId); }
private void RestoreToSingleTicket() { // Need to check for locks on any of the settings in the source list if (listboxSourceTicket.Items.Cast <FormattedListBoxItem>() .Where(item => item.Id != OriginalTicket.PrimaryKey.Id) .Any(item => PosHelper.IsLocked(TableName.Ticket, item.Id))) { PosDialogWindow.ShowDialog( Types.Strings.OneOrMoreOfTheTicketsInThisPartyIsCurrentlyBeingModifiedSomewhereElseCanNotChangeToSingleTicket, Types.Strings.TicketLocked); return; } // Move TicketItems IEnumerable <Ticket> tickets = TicketManager.GetPartyTickets(ParentTicket.PartyId); foreach (Ticket ticket in tickets) { if (ticket.PrimaryKey.Equals(ParentTicket.PrimaryKey) || ticket.IsClosed || ticket.IsCanceled) { continue; } // Move all ticket items that are not on the ParentTicket, back to // the ParentTicket #if DEMO int ticketItemCount = ParentTicket.GetNumberOfTicketItems() + ticket.GetNumberOfTicketItems(); if (ticketItemCount > 3) { PosDialogWindow.ShowDialog(Window.GetWindow(this), Types.Strings.YouCanNotAddMoreThan3TicketItemsToASingleTicketInTheDemoVersionAdditionalTicketItemsWillBeRemoved, Types.Strings.DemoRestriction); } #endif IEnumerable <TicketItem> ticketItems = TicketItem.GetAll(ticket.PrimaryKey); foreach (TicketItem ticketItem in ticketItems) { #if DEMO if (ParentTicket.GetNumberOfTicketItems() >= 3) { ticketItem.Delete(); continue; } #endif ticketItem.SetTicketId(ParentTicket.PrimaryKey.Id); ticketItem.UpdateTicketId(); } // Delete the child ticket TicketManager.Delete(ticket.PrimaryKey); } // Delete Party Invites IEnumerable <PartyInvite> invites = PartyInvite.GetAll(ParentTicket.PartyId); foreach (PartyInvite invite in invites) { PartyInvite.Delete(invite.Id); } // Delete the party Party.Delete(ParentTicket.PartyId); ParentTicket.SetPartyId(0); ParentTicket.Update(); CurrentTicket = OriginalTicket = ParentTicket; // Done, Close the parent window Window.GetWindow(this).Close(); }