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); }