Example #1
0
 private void TFMaterialMud_Load(object sender, EventArgs e)
 {
     this.Icon = Utils.ResourcesUtils.TecnoAliance_ICO;
     pDados.set_FormatZero();
     bsMaterialMud.AddNew();
     //Buscar Almoxarifado
     CamadaDados.Almoxarifado.TList_CadAlmoxarifado lAlmox =
         new CamadaDados.Almoxarifado.TCD_CadAlmoxarifado().Select(
             new Utils.TpBusca[]
     {
         new Utils.TpBusca()
         {
             vNM_Campo = string.Empty,
             vOperador = "exists",
             vVL_Busca = "(select 1 from tb_amx_almox_x_empresa x " +
                         "where x.id_almox = a.id_almox " +
                         "and x.cd_empresa = '" + Cd_empresa.Trim() + "')"
         }
     }, 0, string.Empty);
     if (lAlmox.Count == 1)
     {
         id_almox.Text = lAlmox[0].Id_almoxString;
         ds_almox.Text = lAlmox[0].Ds_almoxarifado;
     }
     CD_Produto.Focus();
 }
Example #2
0
 private void Quantidade_Leave(object sender, EventArgs e)
 {
     Sub_Total.Value   = Quantidade.Value * Vl_Unitario.Value;
     VL_Desconto.Value = CalcularDescEspecial();
     VL_Total.Value    = Sub_Total.Value - VL_Desconto.Value + vl_acrescimo.Value;
     if (Sub_Total.Value > decimal.Zero)
     {
         Pc_DescontoItem.Value = Math.Round(decimal.Divide(decimal.Multiply(VL_Desconto.Value, 100), Sub_Total.Value), 5, MidpointRounding.AwayFromZero);
         pc_acrescimo.Value    = Math.Round(decimal.Divide(decimal.Multiply(vl_acrescimo.Value, 100), Sub_Total.Value), 5, MidpointRounding.AwayFromZero);
     }
     if (St_consumoInterno)
     {
         //Buscar Almoxarifado
         object obj =
             new CamadaDados.Almoxarifado.TCD_CadAlmoxarifado().BuscarEscalar(
                 new TpBusca[]
         {
             new TpBusca()
             {
                 vNM_Campo = string.Empty,
                 vOperador = "exists",
                 vVL_Busca = "(select 1 from tb_amx_almox_x_empresa x " +
                             "where x.id_almox = a.id_almox " +
                             "and x.cd_empresa = '" + CD_Empresa.Trim() + "')"
             }
         }, "a.id_almox");
         if (obj == null && string.IsNullOrEmpty(obj.ToString()))
         {
             throw new Exception("Não existe almoxarifado cadastrado para empresa " + CD_Empresa.Trim());
         }
         //Buscar Saldo Almoxarifado
         decimal saldo = CamadaNegocio.Almoxarifado.TCN_SaldoAlmoxarifado.ConsultaSaldoAlmox(CD_Empresa,
                                                                                             obj.ToString(),
                                                                                             CD_Produto.Text,
                                                                                             null);
         if (saldo < Quantidade.Value)
         {
             MessageBox.Show("Não existe saldo suficiente para gravar movimentação.\r\n" +
                             "Item: " + CD_Produto.Text.Trim() + "\r\n" +
                             "Saldo Atual: " + saldo.ToString("N3", new System.Globalization.CultureInfo("pt-BR")) + "\r\n" +
                             "Qtde Requerida: " + Quantidade.Value.ToString("N3", new System.Globalization.CultureInfo("pt-BR")), "Mensagem",
                             MessageBoxButtons.OK, MessageBoxIcon.Information);
             Quantidade.Value = saldo;
             Quantidade.Focus();
         }
     }
 }
Example #3
0
 private void BuscarAlmoxarifado()
 {
     //Buscar Almoxarifado
     CamadaDados.Almoxarifado.TList_CadAlmoxarifado lAlmox =
         new CamadaDados.Almoxarifado.TCD_CadAlmoxarifado().Select(
             new Utils.TpBusca[]
     {
         new Utils.TpBusca()
         {
             vNM_Campo = string.Empty,
             vOperador = "exists",
             vVL_Busca = "(select 1 from tb_amx_almox_x_empresa x " +
                         "where x.id_almox = a.id_almox " +
                         "and x.cd_empresa = '" + cd_empresa.Text.Trim() + "')"
         }
     }, 0, string.Empty);
     if (lAlmox.Count == 1)
     {
         id_almox.Text = lAlmox[0].Id_almoxString;
         ds_almox.Text = lAlmox[0].Ds_almoxarifado;
     }
 }
Example #4
0
        public static string ProcessarMudanca(TRegistro_LanMudanca val, BancoDados.TObjetoBanco banco)
        {
            bool           st_transacao = false;
            TCD_LanMudanca qtb_mud      = new TCD_LanMudanca();

            try
            {
                if (banco == null)
                {
                    st_transacao = qtb_mud.CriarBanco_Dados(true);
                }
                else
                {
                    qtb_mud.Banco_Dados = banco;
                }
                //Gravar Duplicata
                if (val.lDup.Count > 0)
                {
                    TCN_LanDuplicata.GravarDuplicata(val.lDup, false, qtb_mud.Banco_Dados);
                    val.Nr_lancto = val.lDup[0].Nr_lancto;
                }
                //Gravar lançamento almoxarifado
                val.lMaterialMud.ForEach(p =>
                {
                    //Buscar Almoxarifado
                    CamadaDados.Almoxarifado.TList_CadAlmoxarifado lAlmox =
                        new CamadaDados.Almoxarifado.TCD_CadAlmoxarifado().Select(
                            new Utils.TpBusca[]
                    {
                        new Utils.TpBusca()
                        {
                            vNM_Campo = string.Empty,
                            vOperador = "exists",
                            vVL_Busca = "(select 1 from tb_amx_almox_x_empresa x " +
                                        "where x.id_almox = a.id_almox " +
                                        "and x.cd_empresa = '" + val.Cd_empresa.Trim() + "')"
                        }
                    }, 1, string.Empty);
                    if (lAlmox.Count == 0)
                    {
                        throw new Exception("Não existe configuração de almoxarifado para a empresa!");
                    }
                    //Criar registro movimentação
                    CamadaDados.Almoxarifado.TRegistro_Movimentacao rMov =
                        new CamadaDados.Almoxarifado.TRegistro_Movimentacao();
                    rMov.Ds_observacao = "PRODUTO RETIRADO PELO MÓDULO MUDANÇA";
                    rMov.Cd_empresa    = val.Cd_empresa;
                    rMov.Id_almoxstr   = lAlmox[0].Id_almoxString;
                    rMov.Cd_produto    = p.Cd_produto;
                    rMov.Quantidade    = p.Quantidade;
                    rMov.Vl_unitario   = CamadaNegocio.Almoxarifado.TCN_SaldoAlmoxarifado.Vl_Custo_Almox_Prod(val.Cd_empresa,
                                                                                                              lAlmox[0].Id_almoxString,
                                                                                                              p.Cd_produto,
                                                                                                              qtb_mud.Banco_Dados);
                    rMov.Tp_movimento    = "S";
                    rMov.LoginAlmoxarife = Utils.Parametros.pubLogin;
                    rMov.Dt_movimento    = CamadaDados.UtilData.Data_Servidor();
                    rMov.St_registro     = "A";
                    //Gravar Movimentação
                    CamadaNegocio.Almoxarifado.TCN_Movimentacao.Gravar(rMov, qtb_mud.Banco_Dados);
                    //Gravar Material mudança
                    p.Id_movimento = rMov.Id_movimento;
                    TCN_MaterialMud.Gravar(p, qtb_mud.Banco_Dados);
                });
                val.St_registro = "4";//Processada
                //Gravar processamento mudança
                qtb_mud.Gravar(val);
                if (st_transacao)
                {
                    qtb_mud.Banco_Dados.Commit_Tran();
                }
                return("OK");
            }
            catch (Exception ex)
            {
                if (st_transacao)
                {
                    qtb_mud.Banco_Dados.RollBack_Tran();
                }
                throw new Exception("Erro Gravar registro: " + ex.Message.Trim());
            }
            finally
            {
                if (st_transacao)
                {
                    qtb_mud.deletarBanco_Dados();
                }
            }
        }
Example #5
0
        private void ConsultaPreco()
        {
            rProg = null;

            if ((CD_Produto.Text.Trim() != string.Empty) && (CD_Empresa.Trim() != string.Empty) && (CD_TabelaPreco.Trim() != string.Empty) && !St_consumoInterno)
            {
                if (!string.IsNullOrEmpty(Cd_clifor))
                {
                    //Verificar se existe programacao especial de venda
                    rProg = CamadaNegocio.Faturamento.ProgEspecialVenda.TCN_ProgEspecialVenda.BuscarProg(CD_Empresa,
                                                                                                         Cd_clifor,
                                                                                                         CD_Produto.Text,
                                                                                                         CD_TabelaPreco,
                                                                                                         null);
                    if (rProg != null)
                    {
                        if (rProg.Tp_preco.Trim().ToUpper().Equals("C"))//Preco de Custo
                        {
                            Vl_Unitario.Value = CamadaNegocio.Estoque.TCN_LanEstoque.BuscarVlEstoqueUltimaCompra(CD_Empresa,
                                                                                                                 CD_Produto.Text,
                                                                                                                 null);
                            Vl_Unitario.Enabled = CD_TabelaPreco.Trim().Equals(string.Empty) || Vl_Unitario.Value.Equals(decimal.Zero);
                            return;
                        }
                    }
                }
                //Buscar Valor de Venda
                Vl_Unitario.Value = St_alterar ? Vl_Unitario.Value : TCN_LanPrecoItem.Busca_ConsultaPreco(CD_Empresa, CD_Produto.Text, CD_TabelaPreco, null);
                //Buscar custo produto
                vl_custo.Value      = CamadaNegocio.Estoque.TCN_LanEstoque.BuscarVlEstoqueUltimaCompra(CD_Empresa, CD_Produto.Text, null);
                vl_custo.Enabled    = vl_custo.Value.Equals(decimal.Zero) && St_obrigaCusto;
                Vl_Unitario.Enabled = CD_TabelaPreco.Trim().Equals(string.Empty) ||
                                      Vl_Unitario.Value.Equals(decimal.Zero) ||
                                      CamadaNegocio.Diversos.TCN_Usuario_RegraEspecial.ValidaRegra(Utils.Parametros.pubLogin,
                                                                                                   "PERMITIR INFORMAR PREÇO VENDA",
                                                                                                   null);
            }
            else
            {
                //Buscar Almoxarifado
                CamadaDados.Almoxarifado.TList_CadAlmoxarifado lAlmox =
                    new CamadaDados.Almoxarifado.TCD_CadAlmoxarifado().Select(
                        new TpBusca[]
                {
                    new TpBusca()
                    {
                        vNM_Campo = string.Empty,
                        vOperador = "exists",
                        vVL_Busca = "(select 1 from tb_amx_almox_x_empresa x " +
                                    "where x.id_almox = a.id_almox " +
                                    "and x.cd_empresa = '" + CD_Empresa.Trim() + "')"
                    }
                }, 0, string.Empty);
                if (lAlmox.Count > 0)
                {
                    //Buscar Vl.Custo Almoxarifado
                    Vl_Unitario.Value = CamadaNegocio.Almoxarifado.TCN_SaldoAlmoxarifado.Vl_Custo_Almox_Prod(CD_Empresa,
                                                                                                             lAlmox[0].Id_almoxString,
                                                                                                             CD_Produto.Text,
                                                                                                             null);
                }
                Vl_Unitario.Enabled = Vl_Unitario.Value.Equals(decimal.Zero);
            }
        }