예제 #1
0
        /*************************************************************************************************************
         **************************************************************************************************************
         **************************************************************************************************************/



        /*************************************************************************************************************
         * ------------------------------------Lädt-alle-Benutzer-aus-der-Datenbank--------------------------------------
         **************************************************************************************************************/
        private void LoadUserFromDb()
        {
            SqlConnection con = new SqlConnection();

            con.ConnectionString = (SqlHelper.GetSqlConnectionString());

            string strSQL = "select idBenutzer, Benutzername From Benutzer order by idBenutzer";

            SqlCommand cmd = new SqlCommand(strSQL, con);


            con.Open();

            string        strUsername = "";
            SqlDataReader reader      = cmd.ExecuteReader();

            while (reader.Read())
            {
                strUsername = reader["Benutzername"].ToString();

                if (strUsername != "")
                {
                    ListboxItem item = new ListboxItem();
                    item.Username = strUsername;
                    item.UserID   = (int)reader["idBenutzer"];
                    this.lstbAllUsers.Items.Add(item);
                }
            }

            reader.Close();
            con.Close();
        }
예제 #2
0
        // ------------------------------------------------------
        //
        // ISelectionProvider interface implementation
        //
        // ------------------------------------------------------

        // Returns an enumerator over the current selection.
        IRawElementProviderSimple[] ISelectionProvider.GetSelection()
        {
            int count          = Length;
            int countSelection = IsMultipleSelection() ? GetSelectionCount() : 1;

            if (count <= 0 || countSelection <= 0)
            {
                return(null);
            }

            IRawElementProviderSimple[] selection = new IRawElementProviderSimple[countSelection];

            int index = 0;

            for (int itemPos = 0; itemPos < count; itemPos++)
            {
                if (ListboxItem.IsSelected(_hwnd, itemPos))
                {
                    selection[index] = CreateListboxItem(itemPos);
                    index++;
                }
            }

            if (index == 0)
            {
                return(null);
            }

            return(selection);
        }
예제 #3
0
        /*************************************************************************************************************
         **************************************************************************************************************
         **************************************************************************************************************/



        /*************************************************************************************************************
         * ----------------------------Speichert-die-Weitergabe-Tabelle-in-der-Datenbank---------------------------------
         **************************************************************************************************************/
        private void btnSave_Click_1(object sender, EventArgs e)
        {
            int i      = 0;
            int nMaxID = SqlHelper.GetMaxID("idBenutzerordner", "Benutzerordner");

            SqlConnection con = new SqlConnection();

            con.ConnectionString = (SqlHelper.GetSqlConnectionString());
            string strSQL = "Delete from Benutzerordner where ID_Ordner = @m_nFolderID";

            SqlCommand cmd = new SqlCommand();

            cmd.CommandText = strSQL;
            cmd.Parameters.AddWithValue("@m_nFolderID", m_nFolderID);

            cmd.Connection = con;

            con.Open();
            cmd.ExecuteNonQuery();
            con.Close();

            for (i = 0; i < lstbChosenUsers.Items.Count; i++)
            {
                ListboxItem item = (ListboxItem)lstbChosenUsers.Items[i];
                nMaxID = nMaxID + 1;

                if (item != null)
                {
                    SqlHelper.SendQueryToDb("Insert into Benutzerordner values (" + nMaxID + ", " + item.UserID + ", " + m_nFolderID + ", " + i + ", 0)");
                }
            }

            MessageBox.Show("Einträge wurden gespeichert.", "Gespeichert");
        }
예제 #4
0
        /*************************************************************************************************************
         * --------------------Lädt-alle-Benutzer-aus-der-Datenbank,-die-in-der-Weitergabeliste-stehen-------------------
         **************************************************************************************************************/
        private void LoadChosenUserFromDb()
        {
            SqlConnection con = new SqlConnection();

            con.ConnectionString = (SqlHelper.GetSqlConnectionString());

            string strSQL = "select idbenutzer, Benutzername From Benutzer join Benutzerordner on idBenutzer = ID_Benutzer where ID_Ordner = @m_nFolderID order by Position ";

            SqlCommand cmd = new SqlCommand(strSQL, con);

            cmd.Parameters.AddWithValue("@m_nFolderID", m_nFolderID);

            con.Open();

            string        strUsername = "";
            SqlDataReader reader      = cmd.ExecuteReader();

            while (reader.Read())
            {
                strUsername = reader["Benutzername"].ToString();

                if (strUsername != "")
                {
                    ListboxItem item = new ListboxItem();
                    item.Username = strUsername;
                    item.UserID   = (int)reader["idBenutzer"];
                    this.lstbChosenUsers.Items.Add(item);
                }
            }

            reader.Close();
            con.Close();
        }
예제 #5
0
        /*************************************************************************************************************
         **************************************************************************************************************
         **************************************************************************************************************/



        /*************************************************************************************************************
         * ------------------------------Löscht-das-markierte-Objekt-aus-der-Weitergabe-Tabelle--------------------------
         **************************************************************************************************************/
        private void btnDeleteChosesUser_Click(object sender, EventArgs e)
        {
            ListboxItem item = (ListboxItem)this.lstbChosenUsers.SelectedItem;

            if (item != null)
            {
                this.lstbChosenUsers.Items.Remove(item);
            }
        }
예제 #6
0
        /*************************************************************************************************************
         **************************************************************************************************************
         **************************************************************************************************************/



        /*************************************************************************************************************
         **************************************************************************************************************
         **************************************************************************************************************/
        private void btnInsertItem_Click(object sender, EventArgs e)
        {
            ListboxItem item = (ListboxItem)this.lstbAllUsers.SelectedItem;

            if (item != null)
            {
                this.lstbChosenUsers.Items.Insert(this.lstbChosenUsers.SelectedIndex + 1, item);
            }
        }
예제 #7
0
        /*************************************************************************************************************
         **************************************************************************************************************
         **************************************************************************************************************/



        /*************************************************************************************************************
         * ------------------Kopiert-den-Benutzer-aus-der-allgemeinen-Tebelle-in-die-Weitergabe-Tabelle------------------
         **************************************************************************************************************/
        private void btnAddUser_Click(object sender, EventArgs e)
        {
            ListboxItem item = (ListboxItem)this.lstbAllUsers.SelectedItem;

            if (item != null)
            {
                this.lstbChosenUsers.Items.Add(item);
            }
        }
예제 #8
0
        // Detect if there any selections in
        // This is used by the WindowsListBoxItem class
        // returns true if any items are selected
        private bool HasSelection()
        {
            int i, count;

            for (i = 0, count = Length; i < count && !ListboxItem.IsSelected(_hwnd, i); i++)
            {
                ;
            }

            return(i < count);
        }
예제 #9
0
        // Detect if listbox has any element except skipItem selected
        // This is used by the WindowsListBoxItem class
        // returns true if any items
        private bool HasOtherSelections(int skipItem)
        {
            for (int i = 0, count = Length; i < count; i++)
            {
                if (i != skipItem && ListboxItem.IsSelected(_hwnd, i))
                {
                    return(true);
                }
            }

            return(false);
        }
예제 #10
0
        private int GetOtherSelection(int skipItem)
        {
            for (int i = 0, count = Length; i < count; i++)
            {
                if (i != skipItem && ListboxItem.IsSelected(_hwnd, i))
                {
                    // Win32 listbox items are 0 based, UIAutomation listbox items are 1 based.
                    return(i + 1);
                }
            }

            return(NativeMethods.LB_ERR);
        }
예제 #11
0
 public ListBoxItem(ListboxItem edititem, int count)
 {
     InitializeComponent();
     this.DataContext     = this;
     editcount            = count;
     item                 = new ListboxItem();
     item                 = edititem;
     GameNameTxtbox.Text  = item.ItemName;
     PriceTxtBox.Text     = item.ItemPrice.ToString();
     ImagePathTxtbox.Text = item.ItemImagePath;
     Operatingtxtbox.Text = item.ItemOperatingSystem;
     Yeartxtbox.Text      = item.ItemYear.ToString();
 }
예제 #12
0
            // Adds this element to the selection
            void ISelectionItemProvider.AddToSelection()
            {
                // Check that control can be interacted with.
                // This state could change anytime
                if (!SafeNativeMethods.IsWindowEnabled(_hwnd))
                {
                    throw new ElementNotEnabledException();
                }

                // check if item already selected
                if (ListboxItem.IsSelected(_hwnd, _item) && !_listBox.IsParentedByCombo())
                {
                    // if it is a combo, then always perform the selection otherwise the listbox won't disappear
                    return;
                }

                bool multipleSelection = _listBox.IsMultipleSelection();

                // object does not support multi-selection
                if (!multipleSelection)
                {
                    IRawElementProviderSimple container = ((ISelectionItemProvider)this).SelectionContainer;
                    bool selectionRequired = container != null ? ((ISelectionProvider)container).IsSelectionRequired : true;

                    // For single selection containers that IsSelectionRequired == false and nothing is selected
                    // an AddToSelection is valid.
                    if (selectionRequired || _listBox.HasSelection())
                    {
                        throw new InvalidOperationException(SR.Get(SRID.DoesNotSupportMultipleSelection));
                    }
                }

                if (_listBox.IsParentedByCombo())
                {
                    // if this is a combo and the listbox is not displayed the selection will not stick, so
                    // display the listbox before doing the select.
                    if (((IExpandCollapseProvider)_listBox._parent).ExpandCollapseState == ExpandCollapseState.Collapsed)
                    {
                        ((IExpandCollapseProvider)_listBox._parent).Expand();
                    }
                }

                // At this point we know: Item either supports multiple selection or nothing
                // is selected in the list
                // Try to select an item
                if (!Select(multipleSelection))
                {
                    throw new InvalidOperationException(SR.Get(SRID.OperationCannotBePerformed));
                }
            }
예제 #13
0
        protected bool combobox_SelectionChanged(WindowEventArgs e)
        {
            ListboxItem li = mCombobox.getSelectedItem();

            if (li == null)
            {
                mLog.LogMessage(string.Format("ComboBox Selection Changed  unable to getSelectedItem "));
            }
            else
            {
                mLog.LogMessage(string.Format("ComboBox Selection Changed  item {0}, {1}", li.getID(), li.getText()));
            }
            return(true);
        }
예제 #14
0
        public static int Show(ListboxItem[] values, Font font, int defaultSelection = 0, bool zebraStripe = false)
        {
            if (values == null)
            {
                return(-1);
            }
            var li = new ListboxItem[values.Length];

            for (int i = 0; i < li.Length; i++)
            {
                li[i] = new ListboxItem(values[i].Text);
            }
            return(InternalShow(li, font, defaultSelection, zebraStripe));
        }
예제 #15
0
        private void EditButton_Click(object sender, RoutedEventArgs e)
        {
            GameNameTxtbox.Text  = GameNameTxtbox.Text.Trim();
            PriceTxtBox.Text     = PriceTxtBox.Text.Trim();
            ImagePathTxtbox.Text = ImagePathTxtbox.Text.Trim();
            Operatingtxtbox.Text = Operatingtxtbox.Text.Trim();
            Yeartxtbox.Text      = Yeartxtbox.Text.Trim();

            if (GameNameTxtbox.Text.Length > 0)
            {
                if (PriceTxtBox.Text.Length > 0)
                {
                    double price = 0;
                    try
                    {
                        price = Convert.ToDouble(PriceTxtBox.Text);
                    }
                    catch (Exception)
                    {
                        MessageBox.Show("Price is not correct.Please Again", "Warning", MessageBoxButton.OK, MessageBoxImage.Warning);
                        return;
                    }
                    if (ImagePathTxtbox.Text.Length > 0)
                    {
                        if (File.Exists(ImagePathTxtbox.Text) == true)
                        {
                            if (Operatingtxtbox.Text.Length > 0)
                            {
                                if (Yeartxtbox.Text.Length > 0)
                                {
                                    int year = 0;
                                    try
                                    {
                                        year = Convert.ToInt32(Yeartxtbox.Text);
                                    }
                                    catch (Exception)
                                    {
                                        MessageBox.Show("Year is not correct.Please Again", "Warning", MessageBoxButton.OK, MessageBoxImage.Warning);
                                        return;
                                    }
                                    item                     = new ListboxItemnmsp.ListboxItem();
                                    item.ItemName            = GameNameTxtbox.Text;
                                    item.ItemPrice           = price;
                                    item.ItemImagePath       = ImagePathTxtbox.Text;
                                    item.ItemOperatingSystem = Operatingtxtbox.Text;
                                    item.ItemYear            = year;
                                    this.DialogResult        = true;
                                    this.Close();
                                }
                            }
                            else
                            {
                                MessageBox.Show("Operating must not be empty", "Warning", MessageBoxButton.OK, MessageBoxImage.Warning);
                            }
                        }
                        else
                        {
                            MessageBox.Show("There is no file in ImagePath.Path is not correct", "Warning", MessageBoxButton.OK, MessageBoxImage.Warning);
                        }
                    }
                    else
                    {
                        MessageBox.Show("ImagePath must not be empty", "Warning", MessageBoxButton.OK, MessageBoxImage.Warning);
                    }
                }
                else
                {
                    MessageBox.Show("Price must not be empty", "Warning", MessageBoxButton.OK, MessageBoxImage.Warning);
                }
            }
            else
            {
                MessageBox.Show("GameName must not be empty", "Warning", MessageBoxButton.OK, MessageBoxImage.Warning);
            }
        }