/// <summary>
        /// Gets the users for a specific role filtered using primeui autocomplete
        /// </summary>
        /// <param name="role">Role that you want users from</param>
        /// <param name="searchText">primeui search text</param>
        /// <param name="limit">number of users to return, -1 is default and returns all</param>
        /// <returns>IENumerable of ID Labels used with primeui autocomplete</returns>

        public IEnumerable <IDLabel> SearchUsers(string role, string searchText, int limit = -1)
        {
            RecordRestriction restriction = new RecordRestriction("ID IN (SELECT UserAccountID FROM ApplicationRoleUserAccount WHERE ApplicationRoleUserAccount.ApplicationRoleID IN (SELECT ID FROM ApplicationRole WHERE Name = {0}))", role);

            if (limit < 1)
            {
                return(DataContext
                       .Table <UserAccount>()
                       .QueryRecords(restriction: restriction)
                       .Select(record =>
                {
                    record.Name = UserInfo.SIDToAccountName(record.Name ?? "");
                    return record;
                })
                       .Where(record => record.Name?.ToLower().Contains(searchText.ToLower()) ?? false)
                       .Select(record => IDLabel.Create(record.ID.ToString(), record.Name)));
            }

            return(DataContext
                   .Table <UserAccount>()
                   .QueryRecords(restriction: restriction)
                   .Select(record =>
            {
                record.Name = UserInfo.SIDToAccountName(record.Name ?? "");
                return record;
            })
                   .Where(record => record.Name?.ToLower().Contains(searchText.ToLower()) ?? false)
                   .Take(limit)
                   .Select(record => IDLabel.Create(record.ID.ToString(), record.Name)));
        }
예제 #2
0
        /// <summary>
        /// Searches user accounts by resolved names limited to the specified number of records.
        /// </summary>
        /// <param name="searchText">Search text to lookup.</param>
        /// <param name="limit">Limit of number of record to return.</param>
        /// <returns>Search results as "IDLabel" instances - serialized as JSON [{ id : "value", label : "name" }, ...]; useful for dynamic lookup lists.</returns>
        public IEnumerable <IDLabel> SearchUserAccounts(string searchText, int limit)
        {
            if (limit < 1)
            {
                return(DataContext
                       .Table <UserAccount>()
                       .QueryRecords()
                       .Select(record =>
                {
                    record.Name = UserInfo.SIDToAccountName(record.Name ?? "");
                    return record;
                })
                       .Where(record => record.Name?.StartsWith(searchText, StringComparison.InvariantCultureIgnoreCase) ?? false)
                       .Select(record => IDLabel.Create(record.ID.ToString(), record.Name)));
            }

            return(DataContext
                   .Table <UserAccount>()
                   .QueryRecords()
                   .Select(record =>
            {
                record.Name = UserInfo.SIDToAccountName(record.Name ?? "");
                return record;
            })
                   .Where(record => record.Name?.StartsWith(searchText, StringComparison.InvariantCultureIgnoreCase) ?? false)
                   .Take(limit)
                   .Select(record => IDLabel.Create(record.ID.ToString(), record.Name)));
        }
예제 #3
0
 public AddAdminForm(string formname, int id_n)
 {
     InitializeComponent();
     this.Text = formname;
     if (formname == "Dodawanie Administratora")
     {
         IDLabel.Hide();
         choice = 1;
     }
     if (formname == "Edycja danych Administratora")
     {
         id     = id_n;
         choice = 2;
         UpdateData();
     }
     if (formname == "Wyświetlanie danych Administratora")
     {
         id     = id_n;
         choice = 3;
         UpdateData();
         LoginBox.Enabled    = false;
         PasswordBox.Enabled = false;
         TypeBox.Enabled     = false;
         OKButton.Hide();
         ApplyButton.Hide();
         CancelButton.Text = "OK";
     }
 }
예제 #4
0
파일: Form1.cs 프로젝트: cristi-iacob/uvvss
 private void MenuButton_Click(object sender, EventArgs e)
 {
     TimeLabel.Hide();
     NextButton.Hide();
     AddQuestionButton.Show();
     StartButton.Show();
     ResetButton.Hide();
     IDLabel.Show();
     IDTextField.Show();
     DeleteAnswersButton.Hide();
     Timp.Stop();
 }
예제 #5
0
 public AddPaymentForm(int id, string n, decimal m)
 {
     InitializeComponent();
     id_user              = id;
     name                 = n;
     old_money            = m;
     UserLogin.Text      += name;
     DateCheckBox.Checked = true;
     HourBox.Hide();
     MinuteBox.Hide();
     TimeLabel.Hide();
     IDLabel.Hide();
     IDComboBox.Hide();
     hLabel.Hide();
     mLabel.Hide();
 }
예제 #6
0
 public AddECostForm(int id, string n, string formname)
 {
     InitializeComponent();
     id_user   = id;
     login     = n;
     this.Text = formname;
     if (formname == "Dodawanie kosztu dodatkowego")
     {
         NoRButton.Checked = true;
         paid = false;
         IDComboBox.Hide();
         IDLabel.Hide();
         PayInfo(id);
         DateCheckBox.Checked = true;
         choice = 1;
     }
     else if (formname == "Wyświetlanie kosztów dodatkowych")
     {
         UpdateData(id);
         DescriptionBox.Enabled = false;
         MoneyBox.Enabled       = false;
         DateBox.Enabled        = false;
         YesRButton.Enabled     = false;
         NoRButton.Enabled      = false;
         ApplyButton.Hide();
         OKButton.Hide();
         CancelButton.Text = "OK";
         DateCheckBox.Hide();
         DateBox.Format       = DateTimePickerFormat.Custom;
         DateBox.CustomFormat = "dd.MM.yyyy HH:mm";
         choice = 2;
     }
     else if (formname == "Edycja kosztów dodatkowych")
     {
         UpdateData(id);
         ApplyButton.Text = "Zastosuj zmiany";
         now = false;
         DateCheckBox.Checked = false;
         choice = 3;
     }
 }
예제 #7
0
파일: Form1.cs 프로젝트: cristi-iacob/uvvss
        private void Start()
        {
            AddQuestionButton.Hide();
            DeleteAnswersButton.Show();
            ResetButton.Show();
            NextButton.Show();
            InitializeVisited();
            ResetCorecteGresite();
            StartButton.Hide();
            IDLabel.Hide();
            IDTextField.Hide();

            TimeLeft = 1800;
            Timp.Start();
            TimeLabel.Show();

            List <model.Question> questions = QuestionRepository.ReadAllQuestions();

            quizController = new controller.QuizController();
            QuestionNumber = 0;

            DisplayQuestion(0);
        }
예제 #8
0
파일: Form1.cs 프로젝트: cristi-iacob/uvvss
        private void NextButton_Click(object sender, EventArgs e)
        {
            List <string> variante = new List <string>();

            if (VariantaACheckBox.Checked)
            {
                variante.Add("a");
            }

            if (VariantaBCheckBox.Checked)
            {
                variante.Add("b");
            }

            if (VariantaCCheckBox.Checked)
            {
                variante.Add("c");
            }

            if (VariantaDCheckBox.Checked)
            {
                variante.Add("d");
            }

            if (variante.Count() == 0)
            {
                while (Visited[(QuestionNumber + 1) % 26])
                {
                    QuestionNumber++;

                    if (QuestionNumber == 26)
                    {
                        QuestionNumber = 0;
                    }
                }

                QuestionNumber++;
                DisplayQuestion(QuestionNumber);
                return;
            }

            Visited[QuestionNumber] = true;

            if (quizController.CheckAnswer(QuestionNumber, variante) == false)
            {
                quizController.Quiz.Gresite++;
                UpdateGresite();
            }
            else
            {
                quizController.Quiz.Corecte++;
                UpdateCorecte();
            }

            if (CheckIfLost())
            {
                IntrebareTextBox.Text = "AI PICAT!";
                NextButton.Hide();
                DeleteAnswersButton.Hide();
                AddQuestionButton.Show();
                IDLabel.Show();
                IDTextField.Show();
                ResetCheckBoxes();
                TimeLabel.Hide();
                return;
            }

            if (quizController.Quiz.Corecte + quizController.Quiz.Gresite == 26)
            {
                if (CheckIfPassed())
                {
                    IntrebareTextBox.Text = "AI TRECUT!";
                    NextButton.Hide();
                    DeleteAnswersButton.Hide();
                    AddQuestionButton.Show();
                    IDLabel.Show();
                    IDTextField.Show();
                    ResetCheckBoxes();
                    TimeLabel.Hide();
                    return;
                }

                if (CheckIfLost())
                {
                    IntrebareTextBox.Text = "AI PICAT!";
                    NextButton.Hide();
                    DeleteAnswersButton.Hide();
                    AddQuestionButton.Show();
                    IDLabel.Show();
                    IDTextField.Show();
                    ResetCheckBoxes();
                    TimeLabel.Hide();
                    return;
                }
            }

            ResetCheckBoxes();

            while (Visited[QuestionNumber])
            {
                QuestionNumber++;

                if (QuestionNumber == 26)
                {
                    QuestionNumber = 0;
                }
            }

            DisplayQuestion(QuestionNumber);
        }
예제 #9
0
 public EditBikeForm(MySqlDataReader rdr, string formname)
 {
     InitializeComponent();
     this.Text = formname;
     EdBikeNumTBox.Hide();
     BikeNumLabel.Hide();
     if (formname == "Wyświetl dane roweru")
     {
         EdBikeNumTBox.Enabled     = false;
         EdBikePlaceCBox.Enabled   = false;
         RentYesRButton.Enabled    = false;
         RentNoRButton.Enabled     = false;
         EdBikeUsLoginCBox.Enabled = false;
         BikeStatusBox.Enabled     = false;
         OKButton.Hide();
         EditBikeButton.Hide();
         CancelButton.Text = "OK";
         edit_mode         = false;
         choice            = 1;
     }
     if (formname == "Edytuj dane roweru")
     {
         choice = 2;
     }
     if (formname != "Dodaj rower")
     {
         ImportData(rdr);
         rdr.Close();
         AddAllPlaces();
         IDLabel.Text      += "  " + id;
         EdBikeNumTBox.Text = number.ToString();
         if (rent)
         {
             RentYesRButton.Checked = true;
             RentNoRButton.Checked  = false;
             //EdBikeUsLoginCBox.Enabled = true;
             AddAllUsers();
             SelectUser(id_user);
             EdBikeUsLoginCBox.SelectedIndex = EdBikeUsLoginCBox.FindStringExact(user_login);
         }
         else
         {
             RentNoRButton.Checked     = true;
             RentYesRButton.Checked    = false;
             EdBikeUsLoginCBox.Enabled = false;
         }
         //tutaj jeszcze powinno wybrać miejsce?
         SelectPlace(id_place);
         EdBikePlaceCBox.SelectedIndex = EdBikePlaceCBox.FindStringExact(place);
         BikeStatusBox.SelectedIndex   = BikeStatusBox.FindStringExact(status);
     }
     else
     {
         AddAllPlaces();
         AddAllUsers();
         IDLabel.Hide();
         RentBikeLabel.Hide();
         LoginUserLabel.Hide();
         EdBikeUsLoginCBox.Hide();
         RentYesRButton.Hide();
         RentNoRButton.Hide();
         EditBikeButton.Text = "Zastosuj";
         choice = 3;
     }
 }