コード例 #1
0
        private void AddClientToSelectedYearTableButton_Click(object sender, RoutedEventArgs e)
        {
            if (mMode == ClientMode.DatabaseClientsTableDuplicates || mMode == ClientMode.DatabaseClientsTableUpdateClient || mMode == ClientMode.DatabaseClientsTableAddClient)
            {
                int    rowToInsert      = -1;
                int    selectedRowCount = 0;
                string clientID         = "";
                string firstName        = "";
                string lastName         = "";

                //See see if only 1 row is selected and get that row number
                for (int i = 0; i < mDatabaseClientsTable.Rows.Count; i++)
                {
                    if (BottomTable.IsSelected(i))
                    {
                        rowToInsert = i;
                        selectedRowCount++;
                    }
                }

                //See see if only 1 row is selected
                if (selectedRowCount > 1)
                {
                    System.Windows.MessageBox.Show("Only Select 1 client");
                    return;
                }

                //See if we should insert the client into the mSelectedYear table
                if (rowToInsert != -1)
                {
                    //Get information to display to the user for confirmation
                    clientID  = mDatabaseClientsTable.Rows[rowToInsert]["Client_ID"].ToString();
                    lastName  = mDatabaseClientsTable.Rows[rowToInsert]["Last_Name"].ToString();
                    firstName = mDatabaseClientsTable.Rows[rowToInsert]["First_Name"].ToString();

                    //Update Access Database
                    string insertCommand = "INSERT INTO " + Main.mSelectedYear + " (Box_Number,Client_ID) VALUES (-1," + mDatabaseClientsTable.Rows[rowToInsert]["Client_ID"] + ")";
                    Main.mChristmasBasketsAccessDatabase.ExecuteNonQuery(insertCommand);
                }

                //Update data grid display
                TopTable.Refresh();
                BottomTable.Refresh();

                if (rowToInsert != -1)
                {
                    //Show status message box
                    System.Windows.MessageBox.Show("Client:  " + clientID + " - " + lastName + ", " + firstName + " ADDED in " + Main.mSelectedYear + " Table");

                    //Close the Import Helper
                    this.Close();
                }
            }
        }
コード例 #2
0
        private void DeleteSelectedClientButton_Click(object sender, RoutedEventArgs e)
        {
            if (mMode == ClientMode.DatabaseClientsTableDuplicates || mMode == ClientMode.DatabaseClientsTableUpdateClient || mMode == ClientMode.DatabaseClientsTableAddClient || mMode == ClientMode.DatabaseClientsTableAddClient)
            {
                int    rowToDelete      = -1;
                int    selectedRowCount = 0;
                string clientID         = "";
                string firstName        = "";
                string lastName         = "";

                //See see if only 1 row is selected and get that row number
                for (int i = 0; i < mDatabaseClientsTable.Rows.Count; i++)
                {
                    if (BottomTable.IsSelected(i))
                    {
                        rowToDelete = i;
                        selectedRowCount++;
                    }
                }

                //See see if only 1 row is selected
                if (selectedRowCount > 1)
                {
                    System.Windows.MessageBox.Show("Only Select 1 client");
                    return;
                }

                //See if we should delete the client into the Clients table
                if (rowToDelete != -1)
                {
                    //Get information to display to the user for confirmation
                    clientID  = mDatabaseClientsTable.Rows[rowToDelete]["Client_ID"].ToString();
                    lastName  = mDatabaseClientsTable.Rows[rowToDelete]["Last_Name"].ToString();
                    firstName = mDatabaseClientsTable.Rows[rowToDelete]["First_Name"].ToString();

                    //Update Access Database
                    string deleteCommand = "DELETE FROM Clients WHERE Client_ID = " + mDatabaseClientsTable.Rows[rowToDelete]["Client_ID"];
                    Main.mChristmasBasketsAccessDatabase.ExecuteNonQuery(deleteCommand);

                    //Update data grid source
                    mDatabaseClientsTable.Rows.RemoveAt(rowToDelete);
                }

                //Update data grid display
                TopTable.Refresh();
                BottomTable.Refresh();

                if (rowToDelete != -1)
                {
                    //Show status message box
                    System.Windows.MessageBox.Show("Client:  " + clientID + " - " + lastName + ", " + firstName + " DELETED from Clients Table");
                }
            }
        }
コード例 #3
0
        private void UpdateClientInformationButton_Click(object sender, RoutedEventArgs e)
        {
            if (mMode == ClientMode.DatabaseClientsTableDuplicates || mMode == ClientMode.DatabaseClientsTableUpdateClient || mMode == ClientMode.DatabaseClientsTableAddClient)
            {
                int    rowToUpdate      = -1;
                int    selectedRowCount = 0;
                string clientID         = "";
                string firstName        = "";
                string lastName         = "";

                //See see if only 1 row is selected and get that row number
                for (int i = 0; i < mDatabaseClientsTable.Rows.Count; i++)
                {
                    if (BottomTable.IsSelected(i))
                    {
                        rowToUpdate = i;
                        selectedRowCount++;
                    }
                }

                //See see if only 1 row is selected
                if (selectedRowCount > 1)
                {
                    System.Windows.MessageBox.Show("Only Select 1 client");
                    return;
                }

                //See if we should update the client in the Clients table
                if (rowToUpdate != -1)
                {
                    //Get information to display to the user for confirmation
                    clientID  = mDatabaseClientsTable.Rows[rowToUpdate]["Client_ID"].ToString();
                    lastName  = mDatabaseClientsTable.Rows[rowToUpdate]["Last_Name"].ToString();
                    firstName = mDatabaseClientsTable.Rows[rowToUpdate]["First_Name"].ToString();

                    //Check for null values
                    foreach (DataColumn column in mDatabaseClientsTable.Columns)
                    {
                        if (mDatabaseClientsTable.Rows[rowToUpdate][column.ColumnName].ToString() == "")
                        {
                            mDatabaseClientsTable.Rows[rowToUpdate][column.ColumnName] = "null";
                        }
                    }

                    string updateCommand = "UPDATE Clients SET Last_Name = '" + mDatabaseClientsTable.Rows[rowToUpdate]["Last_Name"].ToString() + "', " +
                                           "First_Name = '" + mDatabaseClientsTable.Rows[rowToUpdate]["First_Name"].ToString() + "', " +
                                           "Middle_Name = '" + mDatabaseClientsTable.Rows[rowToUpdate]["Middle_Name"].ToString() + "', " +
                                           "Title = '" + mDatabaseClientsTable.Rows[rowToUpdate]["Title"].ToString() + "', " +
                                           "Address_Number = '" + mDatabaseClientsTable.Rows[rowToUpdate]["Address_Number"].ToString() + "', " +
                                           "Street_Address = '" + mDatabaseClientsTable.Rows[rowToUpdate]["Street_Address"].ToString() + "', " +
                                           "City = '" + mDatabaseClientsTable.Rows[rowToUpdate]["City"].ToString() + "', " +
                                           "Zipcode = '" + mDatabaseClientsTable.Rows[rowToUpdate]["Zipcode"].ToString() + "', " +
                                           "Phone = '" + mDatabaseClientsTable.Rows[rowToUpdate]["Phone"].ToString() + "', " +
                                           "Organization = '" + mDatabaseClientsTable.Rows[rowToUpdate]["Organization"].ToString() + "', " +
                                           "Directions = '" + mDatabaseClientsTable.Rows[rowToUpdate]["Directions"].ToString() + "', " +
                                           "Instructions = '" + mDatabaseClientsTable.Rows[rowToUpdate]["Instructions"].ToString() + "', " +
                                           "Year_Last_Delivered_To = '" + mDatabaseClientsTable.Rows[rowToUpdate]["Year_Last_Delivered_To"].ToString() + "'" +
                                           " WHERE Client_ID = " + mDatabaseClientsTable.Rows[rowToUpdate]["Client_ID"].ToString();

                    Main.mChristmasBasketsAccessDatabase.ExecuteNonQuery(updateCommand);
                }

                //Update data grid display
                TopTable.Refresh();
                BottomTable.Refresh();

                if (rowToUpdate != -1)
                {
                    //Show Status message box
                    System.Windows.MessageBox.Show("Client:  " + clientID + " - " + lastName + ", " + firstName + " UPDATED in Clients Table");
                }
            }
        }