private void LoadGrid(bool SelectRow) { using (new WaitCursor()) { try { DataTable dt = RecordToDispensationData.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 = RecordToDispensationData.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()) { RecordToDispensation oclsRecordToDispensation = new RecordToDispensation(); RecordToDispensation clsRecordToDispensation = new RecordToDispensation(); oclsRecordToDispensation.id = System.Convert.ToInt32((Grid.SelectedCells[0].Column.GetCellContent(Grid.SelectedItem) as TextBlock).Text); oclsRecordToDispensation = RecordToDispensationData.Select_Record(oclsRecordToDispensation); if (VerifyData() == true) { SetData(clsRecordToDispensation); Boolean bSucess = new Boolean(); bSucess = RecordToDispensationData.Update(oclsRecordToDispensation, clsRecordToDispensation); if (bSucess == true) { GoBack_To_Grid(); } else { MessageBox.Show("Update failed.", "Error"); } } } }
private void InsertRecord() { using (new WaitCursor()) { RecordToDispensation clsRecordToDispensation = new RecordToDispensation(); if (VerifyData() == true) { SetData(clsRecordToDispensation); Boolean bSucess = new Boolean(); bSucess = RecordToDispensationData.Add(clsRecordToDispensation); if (bSucess == true) { GoBack_To_Grid(); } else { MessageBox.Show("Insert failed.", "Error"); } } } }
private void DeleteRecord() { using (new WaitCursor()) { RecordToDispensation clsRecordToDispensation = new RecordToDispensation(); clsRecordToDispensation.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(clsRecordToDispensation); Boolean bSucess = new Boolean(); bSucess = RecordToDispensationData.Delete(clsRecordToDispensation); if (bSucess == true) { GoBack_To_Grid(); } else { MessageBox.Show("Delete failed.", "Error"); } } } }
private void GetData() { using (new WaitCursor()) { ClearRecord(); RecordToDispensation clsRecordToDispensation = new RecordToDispensation(); clsRecordToDispensation.id = System.Convert.ToInt32((Grid.SelectedCells[0].Column.GetCellContent(Grid.SelectedItem) as TextBlock).Text); clsRecordToDispensation = RecordToDispensationData.Select_Record(clsRecordToDispensation); if ((clsRecordToDispensation != null)) { try { nudid.Text = System.Convert.ToInt32(clsRecordToDispensation.id).ToString(); cbRecord_Id.SelectedValue = System.Convert.ToInt32(clsRecordToDispensation.Record_Id); cbDispensation_Id.SelectedValue = System.Convert.ToInt32(clsRecordToDispensation.Dispensation_Id); } catch { } } } }