コード例 #1
0
 private void LoadGrid(bool SelectRow)
 {
     using (new WaitCursor())
     {
         try
         {
             DataTable dt = DispensationData.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
         {
         }
     }
 }
コード例 #2
0
 private void butSearch_Click(object sender, RoutedEventArgs e)
 {
     using (new WaitCursor())
     {
         try
         {
             DataTable dt = DispensationData.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
         {
         }
     }
 }
コード例 #3
0
        private void UpdateRecord()
        {
            using (new WaitCursor())
            {
                Dispensation oclsDispensation = new Dispensation();
                Dispensation clsDispensation  = new Dispensation();

                oclsDispensation.Dispensation_ID = System.Convert.ToInt32((Grid.SelectedCells[0].Column.GetCellContent(Grid.SelectedItem) as TextBlock).Text);
                oclsDispensation = DispensationData.Select_Record(oclsDispensation);

                if (VerifyData() == true)
                {
                    SetData(clsDispensation);
                    Boolean bSucess = new Boolean();
                    bSucess = DispensationData.Update(oclsDispensation, clsDispensation);
                    if (bSucess == true)
                    {
                        GoBack_To_Grid();
                    }
                    else
                    {
                        MessageBox.Show("Update failed.", "Error");
                    }
                }
            }
        }
コード例 #4
0
 private void InsertRecord()
 {
     using (new WaitCursor())
     {
         Dispensation clsDispensation = new Dispensation();
         if (VerifyData() == true)
         {
             SetData(clsDispensation);
             Boolean bSucess = new Boolean();
             bSucess = DispensationData.Add(clsDispensation);
             if (bSucess == true)
             {
                 GoBack_To_Grid();
             }
             else
             {
                 MessageBox.Show("Insert failed.", "Error");
             }
         }
     }
 }
コード例 #5
0
 private void DeleteRecord()
 {
     using (new WaitCursor())
     {
         Dispensation clsDispensation = new Dispensation();
         clsDispensation.Dispensation_ID = System.Convert.ToInt32((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(clsDispensation);
             Boolean bSucess = new Boolean();
             bSucess = DispensationData.Delete(clsDispensation);
             if (bSucess == true)
             {
                 GoBack_To_Grid();
             }
             else
             {
                 MessageBox.Show("Delete failed.", "Error");
             }
         }
     }
 }
コード例 #6
0
        private void GetData()
        {
            using (new WaitCursor())
            {
                ClearRecord();

                Dispensation clsDispensation = new Dispensation();
                clsDispensation.Dispensation_ID = System.Convert.ToInt32((Grid.SelectedCells[0].Column.GetCellContent(Grid.SelectedItem) as TextBlock).Text);
                clsDispensation = DispensationData.Select_Record(clsDispensation);

                if ((clsDispensation != null))
                {
                    try
                    {
                        nudDispensation_ID.Text      = System.Convert.ToInt32(clsDispensation.Dispensation_ID).ToString();
                        tbDispensation_Category.Text = Convert.ToString(clsDispensation.Dispensation_Category);
                    }
                    catch
                    {
                    }
                }
            }
        }