示例#1
0
        private void BtnAddProduto_Click(object sender, EventArgs e)
        {
            if (TxtDescri.Text == "")
            {
                MessageBox.Show("Selecione o Produto! Tente Novamente.", "SIG", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                listBox1.Focus();
            }
            else if (TxtQtde.Text == "")
            {
                MessageBox.Show("Digite a Quantidade! Tente Novamente.", "SIG", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);

                TxtQtde.Focus();
            }
            else
            {
                dataGridView1.Rows.Insert(0, TxtCodProduto.Text, TxtDescri.Text, Convert.ToDouble(TxtValorUnit.Text), Convert.ToInt32(TxtQtde.Text));

                double resultado  = 0;
                double acumulador = 0;

                foreach (DataGridViewRow row in dataGridView1.Rows)
                {
                    resultado = (Convert.ToDouble(row.Cells["Valor_Unit"].Value) * Convert.ToDouble(row.Cells["Qtde"].Value));
                    row.Cells["Total_Item"].Value = Convert.ToDouble(resultado);
                    acumulador += Convert.ToDouble(resultado);
                }
                TotalProdutos      = string.Format("{0:C}", acumulador);
                LblValorTotal.Text = TotalProdutos;
                LimpaProduto();
            }
        }
示例#2
0
 public void LimpaProduto()
 {
     TxtDescri.Clear();
     TxtCodProduto.Clear();
     TxtQtde.Clear();
     TxtEstoque.Clear();
     TxtValorUnit.Clear();
 }
示例#3
0
        private void BtnAdicionarProduto_Click(object sender, EventArgs e)
        {
            try
            {
                if (TxtCodigoPedido.Text != "")
                {
                    if (TxtCodigoProduto.Text != "" && TxtNomeProduto.Text != "" && TxtQtde.Text != "" && TxtPaciente.Text != "")
                    {
                        if (novoItemPedido)
                        {
                            double valor = produtoNegocio.ProcurarPorCodigo(Convert.ToInt32(TxtCodigoProduto.Text));

                            if (DtpEntrega.Visible == true)
                            {
                                DgvItensProduto.Rows.Add("", TxtCodigoProduto.Text, TxtNomeProduto.Text, TxtPaciente.Text, valor, TxtQtde.Text, valor * Convert.ToInt32(TxtQtde.Text), DtpEntrega.Text);
                            }
                            else
                            {
                                DgvItensProduto.Rows.Add("", TxtCodigoProduto.Text, TxtNomeProduto.Text, TxtPaciente.Text, valor, TxtQtde.Text, valor * Convert.ToInt32(TxtQtde.Text), "");
                            }

                            LimparCampos();
                            SomarGridPedido();
                            CbxEntrega.Checked         = false;
                            BtnRemover.Visible         = true;
                            BtnEditar.Visible          = true;
                            BtnEntrega.Visible         = true;
                            BtnFinalizarPedido.Visible = true;
                            BtnAdicionarProduto.Text   = "Adicionar Produto";
                        }
                        else
                        {
                            double valor            = produtoNegocio.ProcurarPorCodigo(Convert.ToInt32(TxtCodigoProduto.Text));
                            int    codigoitempedido = 0;

                            if (DgvItensProduto.Rows[DgvItensProduto.CurrentRow.Index].Cells[0].Value.ToString() != "")
                            {
                                codigoitempedido = Convert.ToInt32(DgvItensProduto.Rows[DgvItensProduto.CurrentRow.Index].Cells[0].Value);
                            }

                            //DgvItensProduto.Rows[DgvItensProduto.CurrentRow.Index].Cells[7].Value = DtpEntrega.Value;

                            //DgvItensProduto.Rows.RemoveAt(DgvItensProduto.CurrentRow.Index);

                            if (DtpEntrega.Visible == true)
                            {
                                if (codigoitempedido != 0)
                                {
                                    DgvItensProduto.Rows[DgvItensProduto.CurrentRow.Index].Cells[0].Value = codigoitempedido;
                                    DgvItensProduto.Rows[DgvItensProduto.CurrentRow.Index].Cells[1].Value = TxtCodigoProduto.Text;
                                    DgvItensProduto.Rows[DgvItensProduto.CurrentRow.Index].Cells[2].Value = TxtNomeProduto.Text;
                                    DgvItensProduto.Rows[DgvItensProduto.CurrentRow.Index].Cells[3].Value = TxtPaciente.Text;
                                    DgvItensProduto.Rows[DgvItensProduto.CurrentRow.Index].Cells[4].Value = valor;
                                    DgvItensProduto.Rows[DgvItensProduto.CurrentRow.Index].Cells[5].Value = TxtQtde.Text;
                                    DgvItensProduto.Rows[DgvItensProduto.CurrentRow.Index].Cells[6].Value = valor * Convert.ToInt32(TxtQtde.Text);
                                    DgvItensProduto.Rows[DgvItensProduto.CurrentRow.Index].Cells[7].Value = DtpEntrega.Text;
                                }
                                else
                                {
                                    DgvItensProduto.Rows[DgvItensProduto.CurrentRow.Index].Cells[0].Value = "";
                                    DgvItensProduto.Rows[DgvItensProduto.CurrentRow.Index].Cells[1].Value = TxtCodigoProduto.Text;
                                    DgvItensProduto.Rows[DgvItensProduto.CurrentRow.Index].Cells[2].Value = TxtNomeProduto.Text;
                                    DgvItensProduto.Rows[DgvItensProduto.CurrentRow.Index].Cells[3].Value = TxtPaciente.Text;
                                    DgvItensProduto.Rows[DgvItensProduto.CurrentRow.Index].Cells[4].Value = valor;
                                    DgvItensProduto.Rows[DgvItensProduto.CurrentRow.Index].Cells[5].Value = TxtQtde.Text;
                                    DgvItensProduto.Rows[DgvItensProduto.CurrentRow.Index].Cells[6].Value = valor * Convert.ToInt32(TxtQtde.Text);
                                    DgvItensProduto.Rows[DgvItensProduto.CurrentRow.Index].Cells[7].Value = "";
                                }
                            }
                            else
                            {
                                if (codigoitempedido != 0)
                                {
                                    DgvItensProduto.Rows[DgvItensProduto.CurrentRow.Index].Cells[0].Value = codigoitempedido;
                                    DgvItensProduto.Rows[DgvItensProduto.CurrentRow.Index].Cells[1].Value = TxtCodigoProduto.Text;
                                    DgvItensProduto.Rows[DgvItensProduto.CurrentRow.Index].Cells[2].Value = TxtNomeProduto.Text;
                                    DgvItensProduto.Rows[DgvItensProduto.CurrentRow.Index].Cells[3].Value = TxtPaciente.Text;
                                    DgvItensProduto.Rows[DgvItensProduto.CurrentRow.Index].Cells[4].Value = valor;
                                    DgvItensProduto.Rows[DgvItensProduto.CurrentRow.Index].Cells[5].Value = TxtQtde.Text;
                                    DgvItensProduto.Rows[DgvItensProduto.CurrentRow.Index].Cells[6].Value = valor * Convert.ToInt32(TxtQtde.Text);
                                    DgvItensProduto.Rows[DgvItensProduto.CurrentRow.Index].Cells[7].Value = "";
                                    //DgvItensProduto.Rows.Add(codigoitempedido, TxtCodigoProduto.Text, TxtNomeProduto.Text, TxtPaciente.Text, valor, TxtQtde.Text, valor * Convert.ToInt32(TxtQtde.Text), "");
                                }
                                else
                                {
                                    DgvItensProduto.Rows[DgvItensProduto.CurrentRow.Index].Cells[0].Value = "";
                                    DgvItensProduto.Rows[DgvItensProduto.CurrentRow.Index].Cells[1].Value = TxtCodigoProduto.Text;
                                    DgvItensProduto.Rows[DgvItensProduto.CurrentRow.Index].Cells[2].Value = TxtNomeProduto.Text;
                                    DgvItensProduto.Rows[DgvItensProduto.CurrentRow.Index].Cells[3].Value = TxtPaciente.Text;
                                    DgvItensProduto.Rows[DgvItensProduto.CurrentRow.Index].Cells[4].Value = valor;
                                    DgvItensProduto.Rows[DgvItensProduto.CurrentRow.Index].Cells[5].Value = TxtQtde.Text;
                                    DgvItensProduto.Rows[DgvItensProduto.CurrentRow.Index].Cells[6].Value = valor * Convert.ToInt32(TxtQtde.Text);
                                    DgvItensProduto.Rows[DgvItensProduto.CurrentRow.Index].Cells[7].Value = "";
                                    //DgvItensProduto.Rows.Add("", TxtCodigoProduto.Text, TxtNomeProduto.Text, TxtPaciente.Text, valor, TxtQtde.Text, valor * Convert.ToInt32(TxtQtde.Text), "");
                                }
                            }

                            LimparCampos();
                            SomarGridPedido();
                            CbxEntrega.Checked         = false;
                            BtnRemover.Visible         = true;
                            BtnEditar.Visible          = true;
                            BtnEntrega.Visible         = true;
                            BtnFinalizarPedido.Visible = true;
                            BtnAdicionarProduto.Text   = "Adicionar Produto";
                            BtnCancelar.Visible        = true;
                            novoItemPedido             = true;
                            DgvItensProduto.Enabled    = true;
                            BtnCancelar.Visible        = true;
                            BtnCancelarVoltar.Visible  = false;
                        }
                    }
                    else
                    {
                        if (TxtCodigoProduto.Enabled == false)
                        {
                            if (CbxEntrega.Checked)
                            {
                                DgvItensProduto.Rows[DgvItensProduto.CurrentRow.Index].Cells[7].Value = DtpEntrega.Value;
                            }
                            else
                            {
                                DgvItensProduto.Rows[DgvItensProduto.CurrentRow.Index].Cells[7].Value = "";
                            }

                            BtnAdicionarProduto.Text = "Adicionar Produto";
                            HabilitarBotoes();
                        }
                        else
                        {
                            if (TxtCodigoProduto.Text == "")
                            {
                                MessageBox.Show("Digite o Código do produto!", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                TxtCodigoProduto.Focus();
                            }
                            else if (TxtNomeProduto.Text == "")
                            {
                                MessageBox.Show("Digite o Nome do produto!", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                TxtNomeProduto.Focus();
                            }
                            else if (TxtQtde.Text == "")
                            {
                                MessageBox.Show("Digite a quantidade de produto!", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                TxtQtde.Focus();
                            }
                            else if (TxtPaciente.Text == "")
                            {
                                MessageBox.Show("Digite o nome do Paciente que fez o pedido do produto!", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                TxtPaciente.Focus();
                            }
                        }
                    }
                }
                else
                {
                    MessageBox.Show("Digite o código do pedido", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    TxtCodigoPedido.Focus();
                }
            }
            catch
            {
                MessageBox.Show("Não foi possível salvar o produto, digite novamente.", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }