Beispiel #1
0
        private void btnConfirmar_Click(object sender, EventArgs e)
        {
            try
            {
                if (Convert.ToDecimal(CorpoNotaFiscalForm.PreencherTextBoxComZero(this.txtQuantidade)) == 0)
                {
                    this.txtQuantidade.Focus();
                    throw new Exception("Quantidade não pode ser ZERO !");
                }
                else if (Convert.ToDecimal(CorpoNotaFiscalForm.PreencherTextBoxComZero(this.txtQuantidadeEmbalagem)) == 0)
                {
                    this.txtQuantidadeEmbalagem.Focus();
                    throw new Exception("Quantidade por Embalagem não pode ser ZERO !");
                }
                else if (Convert.ToDecimal(CorpoNotaFiscalForm.PreencherTextBoxComZero(this.txtValorUnitario)) == Convert.ToDecimal(0))
                {
                    this.txtValorUnitario.Focus();
                    this.txtValorUnitario.SelectAll();
                    throw new Exception("Custo unitário não pode ser igual á ZERO !");
                }
                else
                {
                    var retorno = new NotaFiscalDAO().ProdutoNotaFiscalManter(new ProdutoNotaFiscalModel
                    {
                        NotaFiscal             = this.notaFiscalModel,
                        Produto                = this.produtoModel,
                        Quantidade             = Convert.ToDecimal(this.txtQuantidade.Text),
                        QuantidadePorEmbalagem = Convert.ToDecimal(this.txtQuantidadeEmbalagem.Text),
                        ValorUnitario          = Convert.ToDecimal(this.txtValorUnitario.Text),
                        CustoSemImposto        = Convert.ToDecimal(this.txtCustoSemImposto.Text.Replace("R$", "")),
                        CustoComImposto        = Convert.ToDecimal(this.txtCustoComImposto.Text.Replace("R$", "")),
                        ValorTotalDoDesconto   = Convert.ToDecimal(this.txtValorDesconto.Text),
                        ValorTotalDoIcmsSt     = Convert.ToDecimal(this.txtValorIcmsSt.Text),
                        ValorTotalDoIpi        = Convert.ToDecimal(this.txtVAlorIpi.Text),
                        Observacao             = this.txtObservacao.Text
                    });
                    //
                    switch (retorno)
                    {
                    case "INSERT OK":
                        Mensagens.MensagemInformacao("Produto gravado com Sucesso !");
                        this.Close();
                        break;

                    case "UPDATE OK":
                        Mensagens.MensagemInformacao("Produto atualizado com Sucesso !");
                        this.Close();
                        break;

                    default:
                        Mensagens.MensagemErro(retorno);
                        break;
                    }
                }
            }
            catch (Exception exception)
            {
                Mensagens.MensagemErro(exception.Message);
            }
        }
Beispiel #2
0
 private void btnNovoLancamento_Click(object sender, EventArgs e)
 {
     try
     {
         using (var f = new CorpoNotaFiscalForm(null, AcaoForm.NovoLancamento))
         {
             f.ShowDialog();
             this.CarregarDatagrid();
         }
     }
     catch (Exception exception)
     {
         Mensagens.MensagemErro(exception.Message);
     }
 }
Beispiel #3
0
 //
 //
 private void CalcularCusto()
 {
     try
     {
         this.txtQuantidade.Text = CorpoNotaFiscalForm.PreencherTextBoxComZero(this.txtQuantidade);
         if (Convert.ToDecimal(CorpoNotaFiscalForm.PreencherTextBoxComZero(this.txtQuantidadeEmbalagem)) == Convert.ToDecimal(0.0))
         {
             this.txtQuantidadeEmbalagem.Text = Convert.ToDecimal(1).ToString();
         }
         this.txtValorUnitario.Text = CorpoNotaFiscalForm.PreencherTextBoxComZero(this.txtValorUnitario);
         this.txtValorIcmsSt.Text   = CorpoNotaFiscalForm.PreencherTextBoxComZero(this.txtValorIcmsSt);
         this.txtVAlorIpi.Text      = CorpoNotaFiscalForm.PreencherTextBoxComZero(this.txtVAlorIpi);
         this.txtValorDesconto.Text = CorpoNotaFiscalForm.PreencherTextBoxComZero(this.txtValorDesconto);
         //
         this.txtQuantidadeTotal.Text = (Convert.ToDecimal(this.txtQuantidade.Text) *
                                         Convert.ToDecimal(this.txtQuantidadeEmbalagem.Text)).ToString("G", NumberFormatInfo.CurrentInfo);
         //
         var valorTotal = Convert.ToDecimal(this.txtValorUnitario.Text) *
                          Convert.ToDecimal(this.txtQuantidade.Text);
         //
         var custoSemImposto = (valorTotal - Convert.ToDecimal(this.txtValorDesconto.Text)) /
                               Convert.ToDecimal(this.txtQuantidadeTotal.Text);
         //
         var custoComImposto = (valorTotal - Convert.ToDecimal(this.txtValorDesconto.Text)
                                + Convert.ToDecimal(this.txtVAlorIpi.Text) +
                                Convert.ToDecimal(this.txtValorIcmsSt.Text)) /
                               Convert.ToDecimal(this.txtQuantidadeTotal.Text);
         //
         this.txtCustoSemImposto.Text   = custoSemImposto.ToString("C2");
         this.txtCustoComImposto.Text   = custoComImposto.ToString("C2");
         this.txtValorTotalProduto.Text = (custoComImposto * Convert.ToDecimal(this.txtQuantidadeTotal.Text)).ToString("C2");
     }
     catch (Exception exception)
     {
         Mensagens.MensagemErro(exception.Message);
     }
 }
 private void txtValorTotal_Leave(object sender, EventArgs e)
 {
     this.txtValorTotal.Text = CorpoNotaFiscalForm.PreencherTextBoxComZero(this.txtValorTotal);
 }