Esempio n. 1
0
 private void BtnSave_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         if (error != 0 || (string.IsNullOrWhiteSpace(txtId.Text)) || (string.IsNullOrWhiteSpace(txtName.Text)) || (string.IsNullOrWhiteSpace(txtPercentage.Text)) || (string.IsNullOrWhiteSpace(txtstatus.Text)))
         {
             MessageBox.Show("Please fill all fields");
         }
         else
         {
             offers.OFF_ID            = Convert.ToInt32(txtId.Text);
             offers.OFF_Name          = txtName.Text;
             offers.OFF_Percentage    = txtPercentage.Text;
             offers.OFF_MaxAmount     = txtAmount.Text;
             offers.OFF_ReportingName = txtrpt.Text;
             offers.OFF_Status        = txtstatus.Text;
             string a = "Save"; b = Convert.ToString(btnSave.Content);
             if (a == b)
             {
                 offers.Insert();
             }
             else
             {
                 offers.UPDATE();
             }
             DataTable dtt = offers.GetOffers();
             dgoff.ItemsSource = dtt.DefaultView;
             Clear();
             this.NavigationService.Refresh();
             MessageBox.Show("Saved successfully");
             btnSave.Content = "Save";
         }
     }
     catch (SystemException)
     { }
 }