private void Buscar() { TipoServicoBLL bll = new TipoServicoBLL(); List <TipoServico> list = bll.Search(txPesquisa.Text); dataGrid.ItemsSource = list; }
private void btSalvar_Click(object sender, RoutedEventArgs e) { if (string.IsNullOrEmpty(txCodigo.Text)) { MessageBox.Show("Informe um código para o tipo de serviço", "Atenção", MessageBoxButton.OK, MessageBoxImage.Exclamation); return; } TipoServicoBLL bll = new TipoServicoBLL(); TipoServico tipo = (IdAtual == 0 ? new TipoServico() : bll.Find(IdAtual)); tipo.Id = int.Parse(txCodigo.Text); tipo.Nome = txNome.Text; tipo.Preco = decimal.Parse(txPreco.Text); if (tipo.Id == 0) { MessageBox.Show("Informe um código para o tipo de serviço", "Atenção", MessageBoxButton.OK, MessageBoxImage.Exclamation); return; } bll.Save(tipo); Buscar(); LimparCampos(); }
private void btExcluir_Click(object sender, RoutedEventArgs e) { TipoServico tipo = (TipoServico)listBox.SelectedItem; if (tipo == null) { return; } MessageBoxResult res = MessageBox.Show($"Confirmar a exclusão do '{tipo.Nome}'? \nEsta ação não pode ser revertida!", "Confirmar Exclusão", MessageBoxButton.YesNo, MessageBoxImage.Question); if (res == MessageBoxResult.No) { return; } try { TipoServicoBLL bll = new TipoServicoBLL(); bll.Remove(tipo.Id); LimparCampos(); Buscar(); } catch (Exception ex) { MessageBox.Show(ex.Message, "Atenção", MessageBoxButton.OK, MessageBoxImage.Exclamation); } }
private void cbTipoServico_SelectionChanged(object sender, SelectionChangedEventArgs e) { int id = (int)cbTipoServico.SelectedValue; TipoServico tipo = new TipoServicoBLL().Find(id); txValorUnit.Text = tipo.Preco.ToString("N2"); txQuant.Text = "1"; }
private void Buscar() { TipoServicoBLL bll = new TipoServicoBLL(); List <TipoServico> list = bll.Search(txPesquisa.Text); listBox.DisplayMemberPath = "Nome"; listBox.ItemsSource = list; }
public IncluirItemServico() { InitializeComponent(); txValorUnit.ToMoney(); txQuant.ToNumeric(); txTotal.ToMoney(); List <TipoServico> tipos = new TipoServicoBLL().Search(""); cbTipoServico.DisplayMemberPath = "Nome"; cbTipoServico.SelectedValuePath = "Id"; cbTipoServico.ItemsSource = tipos; if (tipos.Count > 0) { cbTipoServico.SelectedIndex = 0; } }