private void button1_Click(object sender, EventArgs e) { if (currentID != -1) // Update { #if DEBUG if (tipoPastagemDao == null) { DebugDLL.Debug.info("TipoPastagem Null"); } if (currentTipoPastagem == null) { DebugDLL.Debug.info("currentTipoPastagem Null"); } #endif currentTipoPastagem.nome = textBox1.Text; tipoPastagemDao.update(currentTipoPastagem); } else { currentTipoPastagem = new TipoPastagem(textBox1.Text); tipoPastagemDao.insert(currentTipoPastagem); } MainWindow.updateTreeNodesAction(); MessageBox.Show(this, "Tipo de pastagem adicionado com sucesso."); Dispose(); }
public TipoPastageUserControl(string id = null) { InitializeComponent(); currentID = -1; tipoPastagemDao = new TipoPastagemDAO(MainWindow.currentPath); if (id != null) { currentID = int.Parse(id); currentTipoPastagem = tipoPastagemDao.selectById(int.Parse(id)); textBox1.Text = currentTipoPastagem.nome; } }