示例#1
0
        // Retreieving id information from user.
        private string UI_RequestId(string message)
        {
            DialogBoxFactory dialogFactory = new DialogBoxFactory();
            RequestDialogBox dialogBox;
            string           id;

            // dialog box building part:
            dialogFactory.HeaderMessage       = message;
            dialogFactory.RequestedParameters = new List <string>()
            {
                "Numer Identyfikacyjny"
            };
            dialogFactory.DefaultValuesForRequestedParameters = new List <string>();
            dialogFactory.CorrespondingRules = new List <ValidationRules> {
                ValidationRules.StringTyped4DigitCode
            };

            dialogBox = dialogFactory.GetRequestDialogBox();
            // dialog handling:
            if ((bool)dialogBox.ShowDialog())
            {
                id = dialogBox[0];
            }
            else
            {
                return(null);
            }

            return(id);
        }
示例#2
0
        // Method finding particular key specified by user:
        protected virtual void ShowSpecifiedKey()
        {
            DialogBoxFactory dialogFactory = new DialogBoxFactory();
            RequestDialogBox dialogBox;
            RoomKey          key;
            string           id;

            // dialog box building part:
            dialogFactory.HeaderMessage       = "Proszę podać numer szukanego klucza.";
            dialogFactory.RequestedParameters = new List <string>()
            {
                "Numer Identyfikacyjny"
            };
            dialogFactory.DefaultValuesForRequestedParameters = new List <string>();
            dialogFactory.CorrespondingRules = new List <ValidationRules> {
                ValidationRules.StringTyped4DigitCode
            };

            dialogBox = dialogFactory.GetRequestDialogBox();
            // dialog box handling part:
            if ((bool)dialogBox.ShowDialog())
            {
                id = dialogBox[0];
            }
            else
            {
                return;
            }
            // data access part
            try
            {
                key = _queryProvider.GetRoomKeyByIdAsync(id).Result;
            }
            catch (Exception e)
            {
                SendTabNotification(new TabNotificationSentEventArgs()
                {
                    Message = e.Message
                });
                return;
            }
            // data validation part:
            if (key == null)
            {
                DialogBoxFactory.GetInfoBox($"Brak wyników. Klucz o numerze: {id} nie istnieje w Bazie.").Show();
                ResetKeysCollection();
            }
            else
            {
                ResetKeysCollection(new List <RoomKey>()
                {
                    key
                });
            }
            ResetPresentedDetail();
        }
示例#3
0
        protected virtual void ConfigureConnection() // Method building a request dialog box, with presented actual connection string parameters, and allows for their independent change.
        {
            string currentConnectionString = ConnectionSetting.GetCurrentConnectionString();

            string[]      connectionStringRawParams = currentConnectionString.Split(';');
            List <string> connectionStringParams    = new List <string>();

            foreach (string rawParam in connectionStringRawParams)
            {
                string param = rawParam.Substring(rawParam.IndexOf('=') + 1);
                connectionStringParams.Add(param);
            }

            DialogBoxFactory dialogBoxFactory = new DialogBoxFactory();

            dialogBoxFactory.HeaderMessage       = "Ustawienia połączenia z bazą danych:";
            dialogBoxFactory.RequestedParameters = new List <string>()
            {
                "Nazwa/Adres Serwera", "Nazwa Bazy Danych", "Login", "Hasło"
            };
            dialogBoxFactory.DefaultValuesForRequestedParameters = connectionStringParams;
            dialogBoxFactory.CorrespondingRules = new List <ValidationRules>();

            RequestDialogBox dialogBox = dialogBoxFactory.GetRequestDialogBox();

            if ((bool)dialogBox.ShowDialog())
            {
                ConnectionSetting.SetNewConnectionString(dialogBox[0], dialogBox[1], dialogBox[2], dialogBox[3]);
                if (ConnectionSetting.TestDatabaseExistance())
                {
                    ReportStatus("Konfiguracja połączenia zakończona sukcesem.");
                }
                else
                {
                    ReportStatus("Błąd konfiguracji. Nie odnaleziono bazy danych.");
                }
            }
            else
            {
                ReportStatus("Konfiguracja połączenia anulowana.");
            }
        }
示例#4
0
        // Retrieving initial informations from user.
        private IEnumerable <Employee> UI_RequestEmployeeNames()
        {
            DialogBoxFactory dialogFactory = new DialogBoxFactory();
            RequestDialogBox dialogBox;
            string           name, surname;

            IEnumerable <Employee> employees;

            // dialog box building part:
            dialogFactory.HeaderMessage       = "Proszę podać Imię i Nazwisko:";
            dialogFactory.RequestedParameters = new List <string>()
            {
                "Imię", "Nazwisko"
            };
            dialogFactory.DefaultValuesForRequestedParameters = new List <string>();
            dialogFactory.CorrespondingRules = new List <ValidationRules>();

            dialogBox = dialogFactory.GetRequestDialogBox();
            // dialog handling:
            if ((bool)dialogBox.ShowDialog())
            {
                name    = dialogBox[0];
                surname = dialogBox[1];
            }
            else
            {
                return(null);
            }
            // data access part:
            try
            {
                return(employees = _dataQueryProvider.GetEmployeesByNamesAsync(name, surname).Result);
            }
            catch (Exception e)
            {
                SendTabNotification(new TabNotificationSentEventArgs()
                {
                    Message = e.Message
                });
                return(new List <Employee>());
            }
        }