private void frmTimer_Load(object sender, EventArgs e) { TecnicaRegrasDeNegocio tecnicaRegras = new TecnicaRegrasDeNegocio(); lista = tecnicaRegras.BuscarTecnica(null); cmbTecnica.DataSource = lista; cmbTecnica.DisplayMember = "Nome"; cmbTecnica.ValueMember = "Id"; cmbTecnica.SelectedIndex = -1; }
private void btnLocalizaTec_Click(object sender, EventArgs e) { Tecnica tecnica = new Tecnica(); tecnica.Nome = txtLocalizaTec.Text; int id; int.TryParse(txtLocalizarTecId.Text, out id); //tentando converter, se não converter mantém o valor atual tecnica.Id = id; TecnicaRegrasDeNegocio tecnicaRegras = new TecnicaRegrasDeNegocio(); List <Tecnica> lista = new List <Tecnica>(); lista = tecnicaRegras.BuscarTecnica(tecnica); dgvLocalizaTec.DataSource = lista; txtLocalizarTecId.Clear(); txtLocalizaTec.Clear(); }
private void btnExcluir_Click(object sender, EventArgs e) { try { DialogResult d = MessageBox.Show("Deseja excluir o registro?", "Aviso", MessageBoxButtons.YesNo); if (d.ToString() == "Yes") { TecnicaRegrasDeNegocio tecnicaRegrasDeNegocio = new TecnicaRegrasDeNegocio(); tecnicaRegrasDeNegocio.Excluir(Convert.ToInt32(txtIdTec.Text)); this.LimpaTela(); this.AlteraBotoes(1); MessageBox.Show("Registro excluído com sucesso!"); } } catch { MessageBox.Show("Impossível excluir esse registro. \nO registro está sendo utilizado em outro local."); this.AlteraBotoes(3); } }
private void btnSalvar_Click(object sender, EventArgs e) { try { TecnicaRegrasDeNegocio tecnicaRegras = new TecnicaRegrasDeNegocio(); if (this.operacao == "Inserir") { Tecnica tecnica = new Tecnica(); tecnica.Nome = txtNomeTec.Text; tecnica.IdUsuarioCadastro = Convert.ToInt32(txtIdUsuCadastro.Text); tecnica.TempoCiclo = Convert.ToInt32(txtTempoCiclo.Text); tecnica.DescCurto = Convert.ToInt32(txtDescCurto.Text); tecnica.DescLongo = Convert.ToInt32(txtDescLongo.Text); tecnica.Padrao = chkPadrao.Checked == true ? "S" : "N"; tecnicaRegras.Incluir(tecnica); txtIdTec.Text = tecnica.Id.ToString(); MessageBox.Show("Cadastro efetuado com sucesso! " + tecnica.Id.ToString()); } if (this.operacao == "Alterar" && txtIdTec.Text != null) { txtIdUsuAlteracao.ReadOnly = false; Tecnica tecnica = new Tecnica(); tecnica.Nome = txtNomeTec.Text; tecnica.IdUsuarioCadastro = Convert.ToInt32(txtIdUsuCadastro.Text); tecnica.TempoCiclo = Convert.ToInt32(txtTempoCiclo.Text); tecnica.DescCurto = Convert.ToInt32(txtDescCurto.Text); tecnica.DescLongo = Convert.ToInt32(txtDescLongo.Text); tecnica.Id = Convert.ToInt32(txtIdTec.Text); tecnica.DataAlteracao = Convert.ToDateTime(mskDataAlteracao.Text); tecnica.Padrao = chkPadrao.Checked == true ? "S" : "N"; if (txtIdUsuAlteracao.Text != String.Empty) { IdLogin.IdLogado(Convert.ToInt32(txtIdUsuAlteracao.Text)); tecnica.IdUsuarioAlteracao = Convert.ToInt32(txtIdUsuAlteracao.Text); } else { tecnica.IdUsuarioAlteracao = IdLogin.IdLogado(Convert.ToInt32(txtIdUsuCadastro.Text)); } tecnicaRegras.Alterar(tecnica); MessageBox.Show("Alteração efetuada com sucesso! " + tecnica.Id.ToString()); } } catch (Exception) { throw; } txtNomeTec.UseWaitCursor = false; this.LimpaTela(); this.AlteraBotoes(1); }