Ejemplo n.º 1
0
        private void btnExcluirAnimal_Click(object sender, EventArgs e)
        {
            if (metroGrid1.RowCount >= 1)
            {
                if (txtId.Text == "NOVO")
                {
                    return;
                }

                if (metroGrid1.CurrentRow.Cells[4].Value.ToString() == "")
                {
                    return;
                }

                if (MetroFramework.MetroMessageBox.Show(this, "Tem certeza que deseja excluir o item: " + metroGrid1.CurrentRow.Cells[0].Value.ToString(), "Excluir ?", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
                {
                    return;
                }

                WebServiceMarfrigSoapClient wbClinet = null;

                try
                {
                    wbClinet = new WebServiceMarfrigSoapClient();
                    wbClinet.DeleteCompraGadoItem(Convert.ToInt32(metroGrid1.CurrentRow.Cells[4].Value.ToString()));

                    getAllCompraGadoItem(Convert.ToInt32(txtId.Text));
                }
                catch (Exception ex)
                {
                    MetroFramework.MetroMessageBox.Show(this, ex.Message, "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
Ejemplo n.º 2
0
        private void metroButton2_Click(object sender, EventArgs e)
        {
            if (txtId.Text == "NOVO" || txtId.Text == "")
            {
                MetroFramework.MetroMessageBox.Show(this, "Por favor, selecione um animal.", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            if (MetroFramework.MetroMessageBox.Show(this, "Tem certeza que deseja excluir o registro", "Excluir ?", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
            {
                return;
            }

            WebServiceMarfrigSoapClient wbClinet = null;

            try
            {
                wbClinet = new WebServiceMarfrigSoapClient();
                wbClinet.DeleteAnimal(Convert.ToInt32(txtId.Text));

                txtId.Text        = "";
                txtDescricao.Text = "";
                txtPreco.Text     = "0";

                GetAllAnimal();
            }
            catch (Exception ex)
            {
                MetroFramework.MetroMessageBox.Show(this, ex.Message, "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Ejemplo n.º 3
0
        private void btnAlterar_Click(object sender, EventArgs e)
        {
            if (txtNome.Text.Trim() == "")
            {
                MetroFramework.MetroMessageBox.Show(this, "O nome do pecuarista não pode ficar em branco.", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Information);
                txtNome.Focus();
                return;
            }
            else
            {
                if (MetroFramework.MetroMessageBox.Show(this, "Deseja salvar as informações ?", "Aviso", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
                {
                    return;
                }

                WebServiceMarfrigSoapClient wbClinet = null;
                Pecuarista classPecuarista           = null;

                try
                {
                    wbClinet        = new WebServiceMarfrigSoapClient();
                    classPecuarista = new WebServiceMarfrig.Pecuarista();

                    if (txtId.Text != "NOVO" && txtId.Text != "")
                    {
                        classPecuarista.Id = Convert.ToInt32(txtId.Text);
                    }
                    else
                    {
                        classPecuarista.Id = 1;
                    }

                    classPecuarista.Nome = txtNome.Text;

                    if (txtId.Text != "NOVO" && txtId.Text != "")
                    {
                        wbClinet.UpdatePecuarista(classPecuarista);
                    }
                    else
                    {
                        wbClinet.InserirPecuarista(classPecuarista);

                        txtId.Text   = "";
                        txtNome.Text = "";
                    }

                    GetAllPecuarista();
                }
                catch (Exception ex)
                {
                    MetroFramework.MetroMessageBox.Show(this, ex.Message, "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
Ejemplo n.º 4
0
        private void GetAllAnimal()
        {
            try
            {
                WebServiceMarfrigSoapClient webpec = new WebServiceMarfrigSoapClient();
                animalBindingSource.DataSource = webpec.GetAllAnimalCompraGadoItem(compraGadoId);

                Animal oanimal = animalBindingSource.Current as Animal;
            }
            catch (Exception ex)
            {
                MetroFramework.MetroMessageBox.Show(this, ex.Message, "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Ejemplo n.º 5
0
        private void GetAllPecuarista()
        {
            try
            {
                WebServiceMarfrigSoapClient webpec = new WebServiceMarfrigSoapClient();
                pecuaristaBindingSource.DataSource = webpec.GetAllPecuarista();

                Pecuarista oPecurista = pecuaristaBindingSource.Current as Pecuarista;
            }
            catch (Exception ex)
            {
                MetroFramework.MetroMessageBox.Show(this, ex.Message, "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Ejemplo n.º 6
0
        private void getAllCompraGadoItem(int compraGadoId)
        {
            try
            {
                WebServiceMarfrigSoapClient webpec = new WebServiceMarfrigSoapClient();
                compraGadoItemSelectBindingSource.DataSource = webpec.GetCompraGadoItemPorCompraGado(compraGadoId);

                oCompraGadoItem = compraGadoItemSelectBindingSource.Current as CompraGadoItem;
            }
            catch (Exception ex)
            {
                MetroFramework.MetroMessageBox.Show(this, ex.Message, "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Ejemplo n.º 7
0
        private void btnAlterar_Click(object sender, EventArgs e)
        {
            if (txtQuantidade.Text == null)
            {
                MetroFramework.MetroMessageBox.Show(this, "Digite a quantidade.", "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error);
                txtQuantidade.Focus();
                return;
            }

            try
            {
                Convert.ToInt32(txtQuantidade.Text);
            }
            catch (Exception ex)
            {
                MetroFramework.MetroMessageBox.Show(this, "Por favor, digite uma quantidade.", "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error);
                txtQuantidade.Focus();
                return;
            }

            if (txtAnimal.Text == "")
            {
                MetroFramework.MetroMessageBox.Show(this, "Por favor, selecione um animal.", "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            WebServiceMarfrigSoapClient wbClient = null;
            CompraGadoItem classcompragadoitem   = null;

            try
            {
                wbClient            = new WebServiceMarfrigSoapClient();
                classcompragadoitem = new WebServiceMarfrig.CompraGadoItem();

                classcompragadoitem.Id           = 1;
                classcompragadoitem.Quantidade   = Convert.ToInt32(txtQuantidade.Text);
                classcompragadoitem.AnimalId     = Convert.ToInt32(metroGrid1.CurrentRow.Cells[0].Value.ToString());
                classcompragadoitem.CompraGadoId = compraGadoId;

                wbClient.InserirCompraGadoItem(classcompragadoitem);
            }
            catch (Exception ex)
            {
                MetroFramework.MetroMessageBox.Show(this, ex.Message, "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            this.Close();
        }
Ejemplo n.º 8
0
        private void frmCompraGado_FormClosed(object sender, FormClosedEventArgs e)
        {
            if (metroGrid1.RowCount < 1 && txtId.Text != "NOVO")
            {
                WebServiceMarfrigSoapClient wbClinet = null;

                try
                {
                    wbClinet = new WebServiceMarfrigSoapClient();
                    wbClinet.DeleteCompraGado(Convert.ToInt32(txtId.Text));
                }
                catch (Exception ex)
                {
                    MetroFramework.MetroMessageBox.Show(this, ex.Message, "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
Ejemplo n.º 9
0
        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);
                }
            }
        }
Ejemplo n.º 10
0
        private void frmRelatorio_Load(object sender, EventArgs e)
        {
            rpRelatorio.Width  = this.Width - 10;
            rpRelatorio.Height = this.Height - 10;

            try
            {
                WebServiceMarfrigSoapClient webclient = new WebServiceMarfrigSoapClient();
                compraGadoConsultaBindingSource.DataSource = webclient.GetRelatorioCompraGado(compraGado);

                CompraGado oCompragado = compraGadoConsultaBindingSource.Current as CompraGado;
            }
            catch (Exception ex)
            {
                MetroFramework.MetroMessageBox.Show(this, ex.Message, "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            this.rpRelatorio.AutoSize = true;

            this.rpRelatorio.RefreshReport();
            this.rpRelatorio.RefreshReport();
        }
Ejemplo n.º 11
0
        private void btnAlterar_Click(object sender, EventArgs e)
        {
            if (txtDescricao.Text.Length <= 0)
            {
                MetroFramework.MetroMessageBox.Show(this, "O nome do animal não pode ficar em branco.", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            else
            {
                if (MetroFramework.MetroMessageBox.Show(this, "Deseja salvar as informações ?", "Aviso", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
                {
                    return;
                }

                WebServiceMarfrigSoapClient wbClinet = null;
                Animal classAnimal = null;

                try
                {
                    wbClinet    = new WebServiceMarfrigSoapClient();
                    classAnimal = new WebServiceMarfrig.Animal();

                    if (txtId.Text != "NOVO" && txtId.Text != "")
                    {
                        classAnimal.Id = Convert.ToInt32(txtId.Text);
                    }
                    else
                    {
                        classAnimal.Id = 1;
                    }

                    classAnimal.Descricao = txtDescricao.Text;

                    try
                    {
                        double.Parse(txtPreco.Text);
                    }
                    catch (Exception)
                    {
                        MetroFramework.MetroMessageBox.Show(this, "Digite um preço para o animal.", "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        txtPreco.Focus();
                        return;
                    }

                    if (double.Parse(txtPreco.Text) > 0)
                    {
                        classAnimal.Preco = double.Parse(txtPreco.Text);
                    }
                    else
                    {
                        MetroFramework.MetroMessageBox.Show(this, "Digite um preço para o animal.", "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        txtPreco.Focus();
                        return;
                    }

                    if (txtId.Text != "NOVO" && txtId.Text != "")
                    {
                        wbClinet.UpdateAnimal(classAnimal);
                    }
                    else
                    {
                        wbClinet.InserirAnimal(classAnimal);

                        txtId.Text        = "";
                        txtDescricao.Text = "";
                        txtPreco.Text     = "0";
                    }

                    GetAllAnimal();
                }
                catch (Exception ex)
                {
                    MetroFramework.MetroMessageBox.Show(this, ex.Message, "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
Ejemplo n.º 12
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;
        }