private void BtnSave_Click(object sender, RoutedEventArgs e) { try { if (txtIdClient.Text == "") { Client client = new Client(); client.Name = txtClientName.Text; client.Cnpj = txtClientCPF.Text; client.BirthDate = dtBirth.SelectedDate; client.Segment = txtSegment.Text; client.CreationDate = System.DateTime.Now; client.ProductList = productList; ClientBS clientBs = new ClientBS(); client.Id = clientBs.AddClient(client); txtIdClient.Text = client.Id.ToString(); MessageBox.Show("Cliente " + client.Name + " ID " + client.Id + " Salvo com sucesso"); } else { Client client = new Client(); client.Id = int.Parse(txtIdClient.Text); client.Name = txtClientName.Text; client.Cnpj = txtClientCPF.Text; client.Segment = txtSegment.Text; client.BirthDate = dtBirth.SelectedDate; client.CreationDate = System.DateTime.Now; client.ProductList = productList; ClientBS clientBs = new ClientBS(); client.Id = clientBs.EditClient(client); MessageBox.Show("Cliente " + client.Name + " ID " + client.Id + " Alterado com sucesso"); } } catch (Exception ex) { MessageBox.Show("ERRO: " + ex.Message); } }
private void BtnFilter_Click(object sender, RoutedEventArgs e) { { try { ClientBS productBs = new ClientBS(); ClientFilterModel model = new ClientFilterModel(); model.Name = txtName.Text; model.Segment = txtSegment.Text; model.CreationDateBegin = dtBegin.SelectedDate; model.CreationDateEnd = dtEnd.SelectedDate; clientList = productBs.getClientByFilter(model); } catch (Exception ex) { MessageBox.Show("ERRO: " + ex.Message); } grdClient.ItemsSource = clientList; } }