private void cadastrarNovoToolStripMenuItem3_Click(object sender, EventArgs e) { ModelServicos modelServicos = new ModelServicos(); modelServicos.acao = "Cadastrar"; FrmCadastroServico frmCadastroServico = new FrmCadastroServico(modelServicos); frmCadastroServico.ShowDialog(); }
private void btnCadastrar_Click(object sender, EventArgs e) { try { modelServicos.acao = btnCadastrar.Text; FrmCadastroServico frmCadastroServico = new FrmCadastroServico(modelServicos); frmCadastroServico.ShowDialog(); } catch (Exception ex) { MessageBox.Show(ex.Message, "Erro!", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void btnEditar_Click(object sender, EventArgs e) { try { if (dgvServicos.Rows.Count > 0) { modelServicos.acao = btnEditar.Text; modelServicos.Codigo = Convert.ToInt32(dgvServicos.CurrentRow.Cells["Codigo"].Value.ToString()); modelServicos.Nome = dgvServicos.CurrentRow.Cells["Nome"].Value.ToString(); modelServicos.Tipo = dgvServicos.CurrentRow.Cells["Tipo"].Value.ToString(); modelServicos.Valor = Convert.ToDecimal(dgvServicos.CurrentRow.Cells["Valor"].Value.ToString()); modelServicos.Descricao = dgvServicos.CurrentRow.Cells["Descricao"].Value.ToString(); FrmCadastroServico frmCadastroServico = new FrmCadastroServico(modelServicos); frmCadastroServico.ShowDialog(); } } catch (Exception ex) { MessageBox.Show(ex.Message, "Erro!", MessageBoxButtons.OK, MessageBoxIcon.Error); } }