-
Notifications
You must be signed in to change notification settings - Fork 0
/
belNumeroNF.cs
96 lines (74 loc) · 2.63 KB
/
belNumeroNF.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using HLP.Dao;
using FirebirdSql.Data.FirebirdClient;
using System.Data;
namespace HLP.bel
{
public class belNumeroNF
{
private string _nfseq;
public string Nfseq
{
get { return _nfseq; }
set { _nfseq = value; }
}
private string _cdnotafis;
public string Cdnotafis
{
get { return _cdnotafis; }
set { _cdnotafis = value; }
}
public bool bNfSeqValida { get; set; }
public List<belNumeroNF> GeraNumeroNF(List<string> lsNFSEq, string sProximaNF, string sEmpresa)
{
StringBuilder sSql = new StringBuilder();
sSql.Append("select ");
sSql.Append("nf.cd_nfseq ");
sSql.Append("From nf ");
sSql.Append("where ");
sSql.Append("((nf.cd_notafis is null) or (nf.cd_notafis = '')) and (");
sSql.Append("nf.cd_empresa ='");
sSql.Append(sEmpresa);
sSql.Append("') and (");
sSql.Append("nf.cd_nfseq in('");
int iCont = 0;
foreach (var sNfseq in lsNFSEq)
{
iCont++;
sSql.Append(sNfseq);
if (lsNFSEq.Count > iCont)
{
sSql.Append("','");
}
}
sSql.Append("')) ");
sSql.Append("Order by nf.cd_empresa, nf.cd_nfseq ");
//Claudinei - o.s. sem - 11/03/2010
belGerarXML BuscaConexao = new belGerarXML();
FbConnection Conn = BuscaConexao.Conn;
if (Conn.State != ConnectionState.Open)
{
Conn.Open();
}
//Fim - Claudinei - o.s. sem - 11/03/2010
FbCommand cmd = new FbCommand(sSql.ToString(), Conn);
cmd.ExecuteNonQuery();
FbDataReader dr = cmd.ExecuteReader();
Int32 iNumeroNF = Convert.ToInt32(sProximaNF);
List<belNumeroNF> objNumeroNFs = new List<belNumeroNF>();
//dr = AcessoDados.ExecuteReader(sSql.ToString(), CommandType.Text);
while (dr.Read())
{
belNumeroNF objNumeroNF = new belNumeroNF();
objNumeroNF._nfseq = dr["cd_nfseq"].ToString();
objNumeroNF.Cdnotafis = iNumeroNF.ToString().PadLeft(6, '0');
objNumeroNFs.Add(objNumeroNF);
iNumeroNF++;
}
return objNumeroNFs;
}
}
}