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 SetData(RecordToDispensation clsRecordToDispensation) { using (new WaitCursor()) { clsRecordToDispensation.Record_Id = System.Convert.ToInt32(cbRecord_Id.SelectedValue); clsRecordToDispensation.Dispensation_Id = System.Convert.ToInt32(cbDispensation_Id.SelectedValue); } }
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 { } } } }