private void btnAddCompanyDetails_Click(object sender, RoutedEventArgs e) { Button btn = e.Source as Button; if (btn.Content.ToString() == "Add") { btn.Content = "OK"; setCompanyAddMode(); } else { if (txtCompanyName.Text == "" || txtCompanyName.Text.Length == 0) { MessageBox.Show("Company name cannot be empty"); setCompanyAddMode(); return; } DataLayer dl = new DataLayer(); Company company = new Company(); company.companyName = txtCompanyName.Text; Response res = dl.AddNewCompany(company); if (res.success) { Thread.Sleep(1000); populateCompaniesCmb(); setCompanyViewMode(); btn.Content = "Add"; lblCompanyStatus.Content = "Company Added Successfully"; } else if (res.isException) { MessageBox.Show(res.exception); } } }
private void Button_Click(object sender, RoutedEventArgs e) { DataLayer dl = new DataLayer(); Company company = new Company(); company.companyName = txtCompanyName.Text; Response response = dl.AddNewCompany(company); if (response.success) { MessageBox.Show("Company Added"); } else if (response.isException) { MessageBox.Show("Comapany Not added " + response.exception); } else { MessageBox.Show("Error"); } }