//Métodos private void carregaComboBox() { ServiceCor serviceCor = new ServiceCor(); this.cboCor.DataSource = serviceCor.ListCor(); this.cboCor.SelectedIndex += -1; ServiceCategoria serviceCategoria = new ServiceCategoria(); this.cboCategoria.DataSource = serviceCategoria.ListCategoria(); this.cboCategoria.SelectedIndex += -1; this.cboAcessorio.DataSource = Enum.GetValues(typeof(EnumAcessorio)); this.cboAcessorio.SelectedIndex += -1; }
private void btnExcluir_Click(object sender, EventArgs e) { try { if (_cor != null) { ServiceCor serviceCor = new ServiceCor(); serviceCor.Delete(_cor); this.Close(); } } catch (Exception) { throw; } }
private void btnSalvar_Click(object sender, EventArgs e) { try { if (valida()) { if (_cor == null) { Cor cor = new Cor //outro exemplo { Nome = this.txtNome.Text, Descricao = this.txtDescricao.Text }; ServiceCor serviceCor = new ServiceCor(); serviceCor.Create(cor); } else { ServiceCor serviceCor = new ServiceCor(); Cor cor = serviceCor.FindCor(_cor); cor.Nome = this.txtNome.Text; cor.Descricao = this.txtDescricao.Text; serviceCor.Update(); _cor = null; } this.Close(); } } catch (Exception) { throw; } }