private void LogonGridUser() { try { //if nothing is selected display an error message if (grvUserData.SelectedRowsCount == 0) { PosApplication.Instance.Services.Dialog.ShowMessage(31, MessageBoxButtons.OK, MessageBoxIcon.Information); return; } //Get the selected user id DataRow row = grvUserData.GetDataRow(grvUserData.GetSelectedRows()[0]); operatorId = row["STAFFID"].ToString(); operatorName = row["NAME"].ToString(); LogonData logonData = new LogonData(ApplicationSettings.Database.LocalConnection, ApplicationSettings.Database.DATAAREAID); EF.PosPermission posPermission = logonData.GetUserPosPermission(ApplicationSettings.Terminal.StoreId, operatorId); if (!string.IsNullOrWhiteSpace(operatorId)) { //This is to assign the operator culture ONCE such that it is available throughout all translation attempts LSRetailPosis.DataAccess.Language lang = new Language(ApplicationSettings.Database.LocalConnection, ApplicationSettings.Database.DATAAREAID); // Set operator culture if found, otherwise default to terminal culture string opCultNam = lang.GetOperatorCultureName(ApplicationSettings.Terminal.StoreId, operatorId); if (!string.IsNullOrEmpty(opCultNam)) { ApplicationSettings.Terminal.OperatorCultureName = opCultNam; } } if (posPermission == null) { // No permisison or position using (frmMessage message = new frmMessage(1004)) { POSFormsManager.ShowPOSForm(message); } return; } //display the numpad to get the password using (LSRetailPosis.POSProcesses.frmInputNumpad frmNumPad = new LSRetailPosis.POSProcesses.frmInputNumpad()) { frmNumPad.EntryTypes = NumpadEntryTypes.Password; frmNumPad.PromptText = ApplicationLocalizer.Language.Translate(2379); //"Password"; bool logonWorked = false; while (logonWorked == false) { //if button OK / Enter was hit POSFormsManager.ShowPOSForm(frmNumPad); if (frmNumPad.DialogResult == DialogResult.OK) { password = frmNumPad.InputText; if (logonWorked = Login.LogOnUser(true, operatorId, operatorName, operatorName, password)) { //Set privilege ApplicationSettings.Terminal.TerminalOperator.MaxLineReturnAmount = PosApplication.Instance.BusinessLogic.Utility.ToDecimal(posPermission.MaxLineReturnAmount); ApplicationSettings.Terminal.TerminalOperator.MaxTotalReturnAmount = PosApplication.Instance.BusinessLogic.Utility.ToDecimal(posPermission.MaxTotalReturnAmount); ApplicationSettings.Terminal.TerminalOperator.UserIsManager = PosApplication.Instance.BusinessLogic.Utility.ToBool(posPermission.ManagerPrivileges); ApplicationSettings.Terminal.TerminalOperator.UserIsInventoryUser = PosApplication.Instance.BusinessLogic.Utility.ToBool(posPermission.UseHandheld); LogonSuccessful(); } } else { logonWorked = true; status = LogOnStatus.None; } frmNumPad.TryAgain(); } } if (status == LogOnStatus.LogOn) { dlgResult = DialogResult.OK; Close(); } } catch (Exception x) { // The user hasn't entered all the information needed. LSRetailPosis.ApplicationExceptionHandler.HandleException(this.ToString(), x); throw new PosisException(34, x); } }
/// <summary> /// This creates a loyalty line item based on the passed in card info, or prompts /// to initialize default loyalty card info if no card info is supplied. /// </summary> /// <param name="cardInfo">Card info of loyalty card. If null, it will be initialized through user prompt.</param> /// <returns>Loyalty line item and loyalty card info if un-initialized</returns> private LoyaltyItem GetLoyaltyItem(ref ICardInfo cardInfo) { if (cardInfo == null) { // The loyalty card was not swiped and therefore we need to prompt for the card number... using (LSRetailPosis.POSProcesses.frmInputNumpad inputDialog = new LSRetailPosis.POSProcesses.frmInputNumpad(true, true)) { inputDialog.EntryTypes = NumpadEntryTypes.CardValidation; inputDialog.PromptText = LSRetailPosis.ApplicationLocalizer.Language.Translate(50056); //Loyalty card number inputDialog.Text = ApplicationLocalizer.Language.Translate(50062); // Add loyalty card LP.POSFormsManager.ShowPOSForm(inputDialog); DialogResult result = inputDialog.DialogResult; // Quit if cancel is pressed... if (result != System.Windows.Forms.DialogResult.OK) { return(null); } else { cardInfo = Utility.CreateCardInfo(); cardInfo.CardEntryType = CardEntryTypes.MANUALLY_ENTERED; cardInfo.CardNumber = inputDialog.InputText; // Set card type to Loyalty card since this is a loyalty payment // Calling GetCardType sets the tender type properties on the cardInfo object or prompts user for more information. cardInfo.CardType = CardTypes.LoyaltyCard; this.Application.Services.Card.GetCardType(ref cardInfo); } } } // Create the loyalty item LoyaltyItem loyaltyItem = (LoyaltyItem)this.Application.BusinessLogic.Utility.CreateLoyaltyItem(); // Set its properties if (cardInfo.CardEntryType == CardEntryTypes.MAGNETIC_STRIPE_READ) { loyaltyItem.LoyaltyCardNumber = cardInfo.Track2Parts[0]; } else { loyaltyItem.LoyaltyCardNumber = cardInfo.CardNumber; } // Check whether the card is allowed to collect loyalty points bool cardIsValid = false; string comment = string.Empty; int loyaltyTenderTypeBase = 0; decimal pointsEarned = 0; GetPointStatus(ref pointsEarned, ref cardIsValid, ref comment, ref loyaltyTenderTypeBase, loyaltyItem.LoyaltyCardNumber); if (cardIsValid) { loyaltyItem.AccumulatedLoyaltyPoints = pointsEarned; GetLoyaltyInfoFromDB(loyaltyItem); if (string.IsNullOrEmpty(this.transaction.Customer.CustomerId) || string.IsNullOrEmpty(loyaltyItem.CustID) || string.Compare(this.transaction.Customer.CustomerId, loyaltyItem.CustID, StringComparison.OrdinalIgnoreCase) == 0) { return(loyaltyItem); } else { // loyalty payment could change customer, which is not desirable under various condition. // All logic is captured in CustomerClear action, so we ask cashier to do that first. LSRetailPosis.POSProcesses.POSFormsManager.ShowPOSMessageDialog(3222); // You must clear the customer before performing this operation. return(null); } } else { LSRetailPosis.POSProcesses.POSFormsManager.ShowPOSStatusBarText("Card ID: " + loyaltyItem.LoyaltyCardNumber); //License only allows limited number of item sales LSRetailPosis.POSProcesses.frmMessage dialog = null; try { if (string.IsNullOrEmpty(comment)) { dialog = new LSRetailPosis.POSProcesses.frmMessage(50058, System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error); } else { dialog = new LSRetailPosis.POSProcesses.frmMessage(comment, System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error); } LSRetailPosis.POSProcesses.POSFormsManager.ShowPOSForm(dialog); // Invalid loyaltycard return(null); } finally { if (dialog != null) { dialog.Dispose(); } } } }