public void TestEditCompraGado() { classNova.Id = 1; classNova.DataEntrega = Convert.ToDateTime("2018/01/01"); classNova.PecuaristaId = 1; bool resultado = wbClinet.UpdateCompraGado(classNova); Assert.AreEqual(true, resultado); }
private void btnNovo_Click(object sender, EventArgs e) { if (btnNovo.Text == "Novo") { btnNovoAnimal.Enabled = true; txtDataEntrega.Enabled = true; //txtDataEntrega.Checked = false; cmbPecuarista.Enabled = true; txtId.Text = "NOVO"; btnNovo.Enabled = false; } else { if (MetroFramework.MetroMessageBox.Show(this, "Tem certeza que deseja salvar as alterações", "Salvar ?", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) { return; } WebServiceMarfrigSoapClient wbClinet = null; CompraGado classCompragado = null; try { wbClinet = new WebServiceMarfrigSoapClient(); classCompragado = new WebServiceMarfrig.CompraGado(); if (txtDataEntrega.Checked) { classCompragado.DataEntrega = Convert.ToDateTime(txtDataEntrega.Text); } classCompragado.Id = Convert.ToInt32(txtId.Text); classCompragado.PecuaristaId = Convert.ToInt32(cmbPecuarista.SelectedValue); wbClinet.UpdateCompraGado(classCompragado); this.Close(); } catch (Exception ex) { MetroFramework.MetroMessageBox.Show(this, ex.Message, "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }
private void btnInserir_Click(object sender, EventArgs e) { WebServiceMarfrigSoapClient wbClient = null; CompraGado classCompragado = null; try { wbClient = new WebServiceMarfrigSoapClient(); classCompragado = new WebServiceMarfrig.CompraGado(); if (txtId.Text == "NOVO") { classCompragado.Id = 1; } else { classCompragado.Id = Convert.ToInt32(txtId.Text); } if (txtDataEntrega.Checked) { classCompragado.DataEntrega = Convert.ToDateTime(txtDataEntrega.Text); } else { MetroFramework.MetroMessageBox.Show(this, "Por favor, selecionar uma data de entrega.", "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (cmbPecuarista.SelectedValue == null) { MetroFramework.MetroMessageBox.Show(this, "Por favor, selecionar um pecuarista", "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } classCompragado.PecuaristaId = Convert.ToInt32(cmbPecuarista.SelectedValue); int Id; if (txtId.Text == "NOVO") { Id = wbClient.InserirCompraGado(classCompragado); txtId.Text = Id.ToString(); } else { wbClient.UpdateCompraGado(classCompragado); } } catch (Exception ex) { MetroFramework.MetroMessageBox.Show(this, ex.Message, "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } frmCompraGadoItem frmcompragadoitem = new frmCompraGadoItem(Convert.ToInt32(txtId.Text)); frmcompragadoitem.ShowDialog(); //Atualiza o grid getAllCompraGadoItem(Convert.ToInt32(txtId.Text)); btnExcluirAnimal.Enabled = true; }