Exemplo n.º 1
0
        public void TestCreateCompraGado()
        {
            classNova.Id           = 1;
            classNova.DataEntrega  = Convert.ToDateTime("2018/01/01");
            classNova.PecuaristaId = 1;

            int resultado = wbClinet.InserirCompraGado(classNova);

            Assert.AreEqual(resultado != 0, resultado);
        }
Exemplo n.º 2
0
        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;
        }