Beispiel #1
0
        private void LerEncerrante()
        {
            if (bsBico.Count > 0)
            {
                (bsBico.DataSource as CamadaDados.PostoCombustivel.Cadastros.TList_BicoBomba).FindAll(p => p.St_processar).ForEach(p =>
                {
                    if (tcpClient == null)
                    {
                        p.Qtd_encerrante = TAutomacao.LerEncerranteBico(rCfgPosto.Tp_concentrador, p.Enderecofisicobico, "L");
                    }
                    else
                    {
                        string comando = "&T" + p.Enderecofisicobico.Trim() + "L";
                        comando        = "(" + comando + TCompanytec.CalcularChecksum(comando) + ")";
                        string ret     = this.SendLan(comando);
                        if (!string.IsNullOrEmpty(ret))
                        {
                            if (ret.Trim().Length.Equals(16))
                            {
                                p.Qtd_encerrante = decimal.Parse(comando.Substring(5, 8)) / 100;
                            }
                        }
                    }
                });

                bsBico.ResetBindings(true);
            }
        }
Beispiel #2
0
 private void AlterarPreco()
 {
     if (bsBico.Count > 0)
     {
         List <CamadaDados.PostoCombustivel.Cadastros.TRegistro_BicoBomba> lista =
             (bsBico.DataSource as CamadaDados.PostoCombustivel.Cadastros.TList_BicoBomba).FindAll(p => p.St_processar);
         if ((lista.Count > 0) &&
             (vl_preco.Value != decimal.Zero))
         {
             string aux  = string.Empty;
             string virg = string.Empty;
             lista.ForEach(p =>
             {
                 if (tcpClient == null)
                 {
                     if (TAutomacao.AlteraPrecoUnitBico(rCfgPosto.Tp_concentrador, p.Enderecofisicobico, vl_preco.Value))
                     {
                         aux += virg + p.Ds_label;
                         virg = ",";
                     }
                 }
                 else
                 {
                     string comando = "&U" + p.Enderecofisicobico.Trim() + "00" + vl_preco.Value.ToString("N3", new System.Globalization.CultureInfo("pt-BR")).SoNumero();
                     comando        = "(" + comando + TCompanytec.CalcularChecksum(comando) + ")";
                     string ret     = this.SendLan(comando);
                     if ((!ret.Trim().Equals("(U?t)")) && (!ret.Trim().Equals("(U?b)")))
                     {
                         aux += virg + p.Ds_label;
                         virg = ",";
                     }
                 }
             });
             if (!string.IsNullOrEmpty(aux))
             {
                 MessageBox.Show("Preço unitario dos seguintes bicos foram alterados com sucesso.\r\n" +
                                 "Bicos: " + aux.Trim() + "\r\n" +
                                 "O valor no display da bomba sera atualizado na proxima abastecida", "Mensagem", MessageBoxButtons.OK, MessageBoxIcon.Information);
             }
         }
     }
 }
Beispiel #3
0
 private void BloquearBico()
 {
     if (bsBico.Count > 0)
     {
         List <CamadaDados.PostoCombustivel.Cadastros.TRegistro_BicoBomba> lista =
             (bsBico.DataSource as CamadaDados.PostoCombustivel.Cadastros.TList_BicoBomba).FindAll(p => p.St_processar);
         if (lista.Count > 0)
         {
             string aux  = string.Empty;
             string virg = string.Empty;
             lista.ForEach(p =>
             {
                 if (tcpClient == null)
                 {
                     if (TAutomacao.BloquearBico(rCfgPosto.Tp_concentrador, p.Enderecofisicobico))
                     {
                         aux += virg + p.Enderecofisicobico;
                         virg = ",";
                     }
                 }
                 else
                 {
                     string comando = "&M" + p.Enderecofisicobico.Trim() + "B";
                     comando        = "(" + comando + TCompanytec.CalcularChecksum(comando) + ")";
                     string ret     = this.SendLan(comando);
                     if (comando.Length != 5 ? false : comando.Substring(2, 2).Equals(p.Enderecofisicobico.Trim()))
                     {
                         aux += virg + p.Enderecofisicobico;
                         virg = ",";
                     }
                 }
             });
             if (!string.IsNullOrEmpty(aux))
             {
                 MessageBox.Show("Os seguintes bicos foram bloqueados com sucesso.\r\n" +
                                 "Bicos: " + aux.Trim() + ".", "Mensagem", MessageBoxButtons.OK, MessageBoxIcon.Information);
             }
         }
     }
 }