private void backgroundSearcher_DoWork(object sender, DoWorkEventArgs e) { IClientService c = new ClientService(); try { var clients = c.Search(firstnameTxt.Text, lastnameTxt.Text, emailTxt.Text, phoneTxt.Text); e.Result = clients; } catch (Exception ex) { if (this.InvokeRequired) { this.Invoke(new Action(() => { MetroMessageBox.Show(this, ex.Message, "Gabim", MessageBoxButtons.OK, MessageBoxIcon.Error); })); } else { MetroMessageBox.Show(this, ex.Message, "Gabim", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }
private bool UpdateClient() { IClientService service = new ClientService(); try { service.UpdateClient(new Mana.Cards.API.Domain.Client() { Id = CurrentClient.Id }, card.Text); MetroMessageBox.Show(this.ParentForm, "Të dhënat u regjistruan me sukses", "Sukses", MessageBoxButtons.OK, MessageBoxIcon.Information); return true; } catch (Exception e) { MetroMessageBox.Show(this.ParentForm, e.Message, "Gabim", MessageBoxButtons.OK, MessageBoxIcon.Error); return false; } }
private bool CreateClient() { IClientService service = new ClientService(); int cityId = 0; Int32.TryParse(city.GetTag() != null ? city.GetTag().ToString() : string.Empty, out cityId); try { service.CreateClient(new Mana.Cards.API.Domain.Client() { Firstname = firstName.Text, Lastname = lastName.Text, Email = email.Text, Address = address.Text, Phone = phone.Text, City = cityId, Gender = gender.SelectedValue as string, Birthdate = birth_date.Value }, card.Text); MetroMessageBox.Show(this.ParentForm, "Të dhënat u regjistruan me sukses", "Sukses", MessageBoxButtons.OK, MessageBoxIcon.Information); return true; } catch (Exception e) { MetroMessageBox.Show(this.ParentForm, e.Message, "Gabim", MessageBoxButtons.OK, MessageBoxIcon.Error); return false; } }