private void LoadGrid(bool SelectRow)
 {
     using (new WaitCursor())
     {
         try
         {
             DataTable dt = Catholic_PartyData.SelectAll();
             Grid.ItemsSource       = dt.DefaultView;
             Grid.CanUserAddRows    = false;
             Grid.CanUserDeleteRows = false;
             Grid.IsReadOnly        = true;
             if (Grid.Items.Count > 0 & SelectRow == true)
             {
                 Grid.SelectedItem = Grid.Items[0];
                 Grid.ScrollIntoView(Grid.SelectedItem);
             }
         }
         catch (System.Exception ex)
         {
             MessageBox.Show(ex.Message, ex.GetType().ToString());
         }
         finally
         {
         }
     }
 }
 private void butSearch_Click(object sender, RoutedEventArgs e)
 {
     using (new WaitCursor())
     {
         try
         {
             DataTable dt = Catholic_PartyData.Search(cmbFields.Text, cmbCondition.Text, txtSearch.Text);
             Grid.ItemsSource       = dt.DefaultView;
             Grid.CanUserAddRows    = false;
             Grid.CanUserDeleteRows = false;
             Grid.IsReadOnly        = true;
             if (Grid.Items.Count > 0)
             {
                 Grid.SelectedItem = Grid.Items[0];
                 Grid.ScrollIntoView(Grid.SelectedItem);
             }
         }
         catch
         {
             MessageBox.Show("An error occurred in butSearch_Click...", "Error");
         }
         finally
         {
         }
     }
 }
        private void UpdateRecord()
        {
            using (new WaitCursor())
            {
                Catholic_Party oclsCatholic_Party = new Catholic_Party();
                Catholic_Party clsCatholic_Party  = new Catholic_Party();

                oclsCatholic_Party.Catholic_Party_ID = System.Convert.ToInt16((Grid.SelectedCells[0].Column.GetCellContent(Grid.SelectedItem) as TextBlock).Text);
                oclsCatholic_Party = Catholic_PartyData.Select_Record(oclsCatholic_Party);

                if (VerifyData() == true)
                {
                    SetData(clsCatholic_Party);
                    Boolean bSucess = new Boolean();
                    bSucess = Catholic_PartyData.Update(oclsCatholic_Party, clsCatholic_Party);
                    if (bSucess == true)
                    {
                        GoBack_To_Grid();
                    }
                    else
                    {
                        MessageBox.Show("Update failed.", "Error");
                    }
                }
            }
        }
 private void InsertRecord()
 {
     using (new WaitCursor())
     {
         Catholic_Party clsCatholic_Party = new Catholic_Party();
         if (VerifyData() == true)
         {
             SetData(clsCatholic_Party);
             Boolean bSucess = new Boolean();
             bSucess = Catholic_PartyData.Add(clsCatholic_Party);
             if (bSucess == true)
             {
                 GoBack_To_Grid();
             }
             else
             {
                 MessageBox.Show("Insert failed.", "Error");
             }
         }
     }
 }
 private void DeleteRecord()
 {
     using (new WaitCursor())
     {
         Catholic_Party clsCatholic_Party = new Catholic_Party();
         clsCatholic_Party.Catholic_Party_ID = System.Convert.ToInt16((Grid.SelectedCells[0].Column.GetCellContent(Grid.SelectedItem) as TextBlock).Text);
         if (MessageBox.Show("Are you sure? Delete this record?", "Delete", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes)
         {
             SetData(clsCatholic_Party);
             Boolean bSucess = new Boolean();
             bSucess = Catholic_PartyData.Delete(clsCatholic_Party);
             if (bSucess == true)
             {
                 GoBack_To_Grid();
             }
             else
             {
                 MessageBox.Show("Delete failed.", "Error");
             }
         }
     }
 }
        private void GetData()
        {
            using (new WaitCursor())
            {
                ClearRecord();

                Catholic_Party clsCatholic_Party = new Catholic_Party();
                clsCatholic_Party.Catholic_Party_ID = System.Convert.ToInt16((Grid.SelectedCells[0].Column.GetCellContent(Grid.SelectedItem) as TextBlock).Text);
                clsCatholic_Party = Catholic_PartyData.Select_Record(clsCatholic_Party);

                if ((clsCatholic_Party != null))
                {
                    try
                    {
                        nudCatholic_Party_ID.Text      = System.Convert.ToInt16(clsCatholic_Party.Catholic_Party_ID).ToString();
                        tbCatholic_Party_Category.Text = Convert.ToString(clsCatholic_Party.Catholic_Party_Category);
                    }
                    catch
                    {
                    }
                }
            }
        }