Beispiel #1
0
 /// <summary>
 /// Save updated person into DB
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private async void MainGridView_RowUpdated(object sender, DevExpress.XtraGrid.Views.Base.RowObjectEventArgs e)
 {
     try
     {
         using (PersonsReference.PersonsServiceClient client = new PersonsReference.PersonsServiceClient())
         {
             ShowErrorMessage((await client.UpdatePersonAsync((PersonsReference.Person)e.Row)).Result);
             #warning ToDo: Add here code for reutrn original values to modified person object
         }
     }
     catch
     {
         this.ShowErrorMessage(Properties.Resources.OtherErrorMessage);
     }
 }
Beispiel #2
0
 /// <summary>
 /// DX doesn't support onRowDeleted event, so I have to reduce code redundancy by this way.
 /// </summary>
 /// <returns></returns>
 private async void DeleteSelectedPersonsFromDataGrid()
 {
     try
     {
         using (PersonsReference.PersonsServiceClient client = new PersonsReference.PersonsServiceClient())
         {
             foreach (int rowNr in MainGridView.GetSelectedRows())
             {
                 PersonsReference.Person person = MainGridView.GetRow(rowNr) as PersonsReference.Person;
                 ShowErrorMessage((await client.DeletePersonAsync(person)).Result);
             }
         }
         MainGridView.DeleteSelectedRows();
     }
     catch
     {
         this.ShowErrorMessage(Properties.Resources.OtherErrorMessage);
     }
 }
Beispiel #3
0
 /// <summary>
 /// Load data from DB
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private async void MainForm_Load(object sender, EventArgs e)
 {
     try
     {
         MainRibbonControl.Enabled        = false;
         DataLoadingProgressPanel.Visible = true;
         using (PersonsReference.PersonsServiceClient client = new PersonsReference.PersonsServiceClient())
         {
             personBindingSource.DataSource = (await client.GetPersonsDSAsync()).ToList();
             MainGridControl.RefreshDataSource();
         }
         MainRibbonControl.Enabled        = true;
         DataLoadingProgressPanel.Visible = false;
         RefreshDataButtonItem.Visibility = DevExpress.XtraBars.BarItemVisibility.Never;
     }
     catch
     {
         ShowErrorMessage(Properties.Resources.DataLoadingError);
         RefreshDataButtonItem.Visibility = DevExpress.XtraBars.BarItemVisibility.Always;
         MainRibbonControl.Enabled        = true;
     }
 }
Beispiel #4
0
 private async void FillDatabaseButtonItem_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
 {
     try
     {
         DataLoadingProgressPanel.Description = "Inserting data into DB ...";
         DataLoadingProgressPanel.Visible     = true;
         using (PersonsReference.PersonsServiceClient client = new PersonsReference.PersonsServiceClient())
         {
             await client.BulkInsert10000RecordsAsync();
         }
     }
     catch
     {
         this.ShowErrorMessage(Properties.Resources.OtherErrorMessage);
     }
     finally
     {
         DataLoadingProgressPanel.Visible     = false;
         DataLoadingProgressPanel.Description = "Loading data from DB ...";
         MainForm_Load(null, null);
     }
 }