public void PopulainfCarga(belinfCte objbelinfCte, FbConnection conn, string sCte) { try { StringBuilder sQuery = new StringBuilder(); sQuery.Append("Select "); sQuery.Append("coalesce(conhecim.ds_prodpred,'')proPred, "); sQuery.Append("coalesce(nfconhec.vl_nf,'')vMerc "); sQuery.Append("from conhecim "); sQuery.Append("join nfconhec on conhecim.nr_lanc = nfconhec.nr_lancconhecim "); sQuery.Append("join empresa on conhecim.cd_empresa = empresa.cd_empresa "); sQuery.Append("where conhecim.nr_lanc ='" + sCte + "' "); sQuery.Append("and empresa.cd_empresa ='" + belStatic.CodEmpresaCte + "'"); FbCommand fbConn = new FbCommand(sQuery.ToString(), conn); fbConn.ExecuteNonQuery(); FbDataReader dr = fbConn.ExecuteReader(); objbelinfCte.infCTeNorm = new belinfCTeNorm(); objbelinfCte.infCTeNorm.infCarga = new belinfCarga(); while (dr.Read()) { objbelinfCte.infCTeNorm.infCarga.vCarga += Convert.ToDecimal(dr["vMerc"].ToString().Replace(".", ",")); objbelinfCte.infCTeNorm.infCarga.proPred =belUtil.TiraSimbolo( dr["proPred"].ToString(),""); } } catch (Exception ex) { throw ex; } }
public void ImportaConhecInfCte(belPopulaObjetos objbelObjetos, string sEmp) { this.objbelObjetos = objbelObjetos; try { if (File.Exists(objbelObjetos.sPath)) { File.Delete(objbelObjetos.sPath); } foreach (string sCte in objbelObjetos.objlConhec) { string sNFe = "CTe" + GeraChave(sEmp, sCte); belinfCte objbelinfCte = new belinfCte(); daoIde objDaoide = new daoIde(); daoComp objdaoComp = new daoComp(); daoEmit objDaoemit = new daoEmit(); daoRem objDaorem = new daoRem(); daoDest objDaodest = new daoDest(); daoNf objDaonf = new daoNf(); daoExped objDaoExped = new daoExped(); daoReceb objDaoReceb = new daoReceb(); daoVPrest objDaovPrest = new daoVPrest(); daoImp objDaoImp = new daoImp(); daoinfCarga objDaoinfCTeNorm = new daoinfCarga(); daoinfQ objDaoInfQ = new daoinfQ(); daorodo objDaoRodo = new daorodo(); cx.Open_Conexao(); objDaoide.PopulaIde(sCte, sNFe[sNFe.Length - 1].ToString(), cx.get_Conexao(), objbelinfCte, sNFe); objdaoComp.PopulaComp(objbelinfCte, cx.get_Conexao(), sCte); objDaoemit.PopulaEmit(objbelinfCte, cx.get_Conexao()); objDaorem.PopulaRem(objbelinfCte, cx.get_Conexao(), sCte); objDaodest.PopulaDest(objbelinfCte, cx.get_Conexao(), sCte); objDaonf.PopulaNf(objbelinfCte, cx.get_Conexao(), sCte); objDaoExped.PopulaExped(objbelinfCte, cx.get_Conexao(), sCte); objDaoReceb.PopulaReceb(objbelinfCte, cx.get_Conexao(), sCte); objDaovPrest.PopulaVPrest(objbelinfCte, cx.get_Conexao(), sCte); objDaoImp.PopulaImp(objbelinfCte, cx.get_Conexao(), sCte); objDaoinfCTeNorm.PopulainfCarga(objbelinfCte, cx.get_Conexao(), sCte); objDaoInfQ.PopulainfQ(objbelinfCte, cx.get_Conexao(), sCte); objDaoRodo.PopulaRodo(objbelinfCte, cx.get_Conexao(), sCte); objDaoRodo.PopulaVeiculo(objbelinfCte, cx.get_Conexao(), sCte); objDaoRodo.PopulaMotorista(objbelinfCte, cx.get_Conexao(), sCte); objbelObjetos.objLinfCte.Add(objbelinfCte); } } catch (Exception ex) { throw ex; } finally { cx.Close_Conexao(); } }
public void PopulainfQ(belinfCte objbelinfCte, FbConnection conn, string sCte) { try { StringBuilder sQuery = new StringBuilder(); sQuery.Append("Select "); sQuery.Append("coalesce(nfconhec.cd_um,'')cUnid, "); sQuery.Append("coalesce(nfconhec.ds_especie,'') tpMed, "); sQuery.Append("sum(coalesce(nfconhec.vl_volume,'')) qCarga_Volume, "); sQuery.Append("sum(coalesce(nfconhec.vl_peso,'')) qCarga_Peso "); sQuery.Append("from nfconhec "); sQuery.Append("join empresa on nfconhec.cd_empresa = empresa.cd_empresa "); sQuery.Append("where nfconhec.nr_lancconhecim ='" + sCte + "'"); sQuery.Append("and empresa.cd_empresa ='" + belStatic.CodEmpresaCte + "' "); sQuery.Append("group by coalesce(nfconhec.cd_um,''), coalesce(nfconhec.ds_especie,'')"); FbCommand fbConn = new FbCommand(sQuery.ToString(), conn); fbConn.ExecuteNonQuery(); FbDataReader dr = fbConn.ExecuteReader(); if (objbelinfCte.infCTeNorm == null) { objbelinfCte.infCTeNorm = new belinfCTeNorm(); objbelinfCte.infCTeNorm.infCarga = new belinfCarga(); } objbelinfCte.infCTeNorm.infCarga.infQ = new List<belinfQ>(); while (dr.Read()) { belinfQ objinfQ = new belinfQ(); objinfQ.cUnid = "00"; objinfQ.tpMed = dr["tpMed"].ToString().ToUpper(); objinfQ.qCarga = Convert.ToDecimal(dr["qCarga_Volume"].ToString().Replace(".", ",")); objbelinfCte.infCTeNorm.infCarga.infQ.Add(objinfQ); objinfQ = new belinfQ(); objinfQ.cUnid = dr["cUnid"].ToString(); objinfQ.tpMed = "PESO"; objinfQ.qCarga = Convert.ToDecimal(dr["qCarga_Peso"].ToString().Replace(".", ",")); objbelinfCte.infCTeNorm.infCarga.infQ.Add(objinfQ); } } catch (Exception ex) { throw ex; } }
public void PopulaRodo(belinfCte objbelinfCte, FbConnection conn, string sCte) { try { StringBuilder sQuery = new StringBuilder(); sQuery.Append("Select "); sQuery.Append("coalesce(conhecim.ds_respseg,'')respSeg, "); sQuery.Append("coalesce(empresa.CD_APOBRIG,'')nApol, "); sQuery.Append("coalesce(empresa.cd_rtb,'')RNTRC, "); sQuery.Append("coalesce(conhecim.DT_PREV,'')dPrev, "); sQuery.Append("coalesce(conhecim.CD_LOTA,'')lota "); sQuery.Append("from conhecim "); sQuery.Append("join empresa on conhecim.cd_empresa = empresa.cd_empresa "); sQuery.Append("where conhecim.nr_lanc ='" + sCte + "' "); sQuery.Append("and empresa.cd_empresa ='" + belStatic.CodEmpresaCte + "'"); FbCommand fbConn = new FbCommand(sQuery.ToString(), conn); fbConn.ExecuteNonQuery(); FbDataReader dr = fbConn.ExecuteReader(); objbelinfCte.infCTeNorm.seg = new belseg(); objbelinfCte.infCTeNorm.rodo = new belrodo(); while (dr.Read()) { objbelinfCte.infCTeNorm.seg.respSeg = dr["respSeg"].ToString() != "" ? dr["respSeg"].ToString().Substring(0, 1) : ""; objbelinfCte.infCTeNorm.seg.nApol = dr["nApol"].ToString() != "" ? util.TiraSimbolo(dr["nApol"].ToString()) : ""; objbelinfCte.infCTeNorm.rodo.RNTRC = dr["RNTRC"].ToString(); objbelinfCte.infCTeNorm.rodo.dPrev = dr["dPrev"].ToString(); objbelinfCte.infCTeNorm.rodo.lota = dr["lota"].ToString(); } } catch (Exception ex) { throw ex; } }
public void PopulaComp(belinfCte objbelinfCte, FbConnection conn, string sCte) { StringBuilder sQuery = new StringBuilder(); sQuery.Append("select conhecim.ds_obs from conhecim "); sQuery.Append("where conhecim.nr_lanc = '" + sCte + "' and conhecim.cd_empresa = '" + belStatic.CodEmpresaCte + "' "); FbCommand comando = new FbCommand(sQuery.ToString(), conn); FbDataReader Reader = comando.ExecuteReader(); Byte[] blob = null; MemoryStream ms = new MemoryStream(); string texto = ""; while (Reader.Read()) { blob = new Byte[(Reader.GetBytes(0, 0, null, 0, int.MaxValue))]; try { Reader.GetBytes(0, 0, blob, 0, blob.Length); } catch { texto = ""; } ms = new MemoryStream(blob); } StreamReader Ler = new StreamReader(ms); Ler.ReadLine(); while (Ler.Peek() != -1) { texto += Ler.ReadLine(); } belcompl objcomp = null; if (texto != "") { objcomp = new belcompl(); objcomp.ObsCont.Xcampo = "OBSERVACAO"; objcomp.ObsCont.Xtexto = texto; } objbelinfCte.compl = objcomp; }
public void PopulaNf(belinfCte objbelinfCte, FbConnection conn, string sCte) { try { StringBuilder sQuery = new StringBuilder(); sQuery.Append("Select "); sQuery.Append("coalesce(nfconhec.st_tiponf,'')Tipo, "); sQuery.Append("coalesce(nfconhec.cd_mod,'01')mod, "); sQuery.Append("coalesce(nfconhec.cd_chave,'')chave, "); sQuery.Append("coalesce(nfconhec.desc_outros,'')descOutros, "); sQuery.Append("coalesce(nfconhec.cd_serie,'')serie, "); sQuery.Append("coalesce(nfconhec.cd_nf,'')nDoc, "); sQuery.Append("coalesce(nfconhec.dt_emi,'')dEmi, "); sQuery.Append("coalesce(nfconhec.vl_basecalc,'')vBC, "); sQuery.Append("coalesce(nfconhec.vl_totalicms,'')vICMS, "); sQuery.Append("coalesce(nfconhec.vl_basecalcst,'')vBCST, "); sQuery.Append("coalesce(nfconhec.vl_totalicmsst,'')vST, "); sQuery.Append("coalesce(nfconhec.vl_nf,'')vProd, "); sQuery.Append("coalesce(nfconhec.cd_cfop,'')nCFOP "); sQuery.Append("from nfconhec "); sQuery.Append("join empresa on nfconhec.cd_empresa = empresa.cd_empresa "); sQuery.Append("where nfconhec.nr_lancconhecim ='" + sCte + "'"); sQuery.Append("and empresa.cd_empresa ='" + belStatic.CodEmpresaCte + "'"); FbCommand fbConn = new FbCommand(sQuery.ToString(), conn); fbConn.ExecuteNonQuery(); FbDataReader dr = fbConn.ExecuteReader(); objbelinfCte.rem.infNF = new List<belinfNF>(); objbelinfCte.rem.infNFe = new List<belinfNFe>(); objbelinfCte.rem.infOutros = new List<belinfOutros>(); while (dr.Read()) { switch (dr["Tipo"].ToString()) { case "N": belinfNF infNf = new belinfNF(); infNf.mod = dr["mod"].ToString(); infNf.serie = dr["serie"].ToString(); infNf.nDoc = dr["nDoc"].ToString(); infNf.dEmi = dr["dEmi"].ToString() != "" ? (Convert.ToDateTime(dr["dEmi"].ToString())).ToString("dd/MM/yyyy") : ""; infNf.vBC = dr["vBC"].ToString() != "" ? dr["vBC"].ToString().Replace(",", ".") : "0.00"; infNf.vICMS = dr["vICMS"].ToString() != "" ? dr["vICMS"].ToString().Replace(",", ".") : "0.00"; infNf.vBCST = dr["vBCST"].ToString() != "" ? dr["vBCST"].ToString().Replace(",", ".") : "0.00"; infNf.vST = dr["vST"].ToString() != "" ? dr["vST"].ToString().Replace(",", ".") : "0.00"; infNf.vProd = dr["vProd"].ToString() != "" ? dr["vProd"].ToString().Replace(",", ".") : "0.00"; infNf.vNF = dr["vProd"].ToString() != "" ? dr["vProd"].ToString().Replace(",", ".") : "0.00"; infNf.nCFOP = dr["nCFOP"].ToString() != "" ? Convert.ToInt32(dr["nCFOP"]).ToString() : "0"; objbelinfCte.rem.infNF.Add(infNf); break; case "E": belinfNFe infNfe = new belinfNFe(); infNfe.chave = dr["chave"].ToString(); infNfe.nDoc = dr["nDoc"].ToString(); objbelinfCte.rem.infNFe.Add(infNfe); break; case "00": belinfOutros infDeclaracao = new belinfOutros(); infDeclaracao.tpDoc = "00"; infDeclaracao.nDoc = dr["nDoc"].ToString(); infDeclaracao.dEmi = dr["dEmi"].ToString() != "" ? (Convert.ToDateTime(dr["dEmi"].ToString())).ToString("dd/MM/yyyy") : ""; infDeclaracao.vDocFisc = dr["vProd"].ToString() != "" ? dr["vProd"].ToString().Replace(",", ".") : "0.00"; objbelinfCte.rem.infOutros.Add(infDeclaracao); break; case "10": belinfOutros infDutoviario = new belinfOutros(); infDutoviario.tpDoc = "00"; infDutoviario.nDoc = dr["nDoc"].ToString(); infDutoviario.dEmi = dr["dEmi"].ToString() != "" ? (Convert.ToDateTime(dr["dEmi"].ToString())).ToString("dd/MM/yyyy") : ""; infDutoviario.vDocFisc = dr["vProd"].ToString() != "" ? dr["vProd"].ToString().Replace(",", ".") : "0.00"; objbelinfCte.rem.infOutros.Add(infDutoviario); break; case "99": belinfOutros infOutros = new belinfOutros(); infOutros.tpDoc = "99"; infOutros.descOutros = dr["descOutros"].ToString(); infOutros.nDoc = dr["nDoc"].ToString(); infOutros.dEmi = dr["dEmi"].ToString() != "" ? (Convert.ToDateTime(dr["dEmi"].ToString())).ToString("dd/MM/yyyy") : ""; infOutros.vDocFisc = dr["vProd"].ToString() != "" ? dr["vProd"].ToString().Replace(",", ".") : "0.00"; objbelinfCte.rem.infOutros.Add(infOutros); break; default: throw new Exception("A nota " + dr["nDoc"].ToString() + " do Conhecimento " + objbelinfCte.ide.nCT + " não tem Tipo selecionado(NF, NF-e, Declaração, Dutoviário, Outros)"); } } } catch (Exception ex) { throw ex; } }
public void PopulaDest(belinfCte objbelinfCte, FbConnection conn, string sCte) { try { StringBuilder sQuery = new StringBuilder(); sQuery.Append("Select "); sQuery.Append("coalesce(remetent.cd_cgc,'')CNPJ, "); sQuery.Append("coalesce(remetent.cd_cpf,'')CPF, "); sQuery.Append("coalesce(remetent.cd_insest,'')IE, "); sQuery.Append("coalesce(remetent.nm_social,'')xNome, "); sQuery.Append("coalesce(remetent.cd_fone,'')fone, "); sQuery.Append("coalesce(remetent.cd_isuf,'')ISUF, "); sQuery.Append("coalesce (cidades.cd_municipio,'')cMun, "); sQuery.Append("coalesce(remetent.ds_ende,'')xLgr, "); sQuery.Append("coalesce(remetent.nr_end,'')nro, "); sQuery.Append("coalesce(remetent.ds_bairro,'')xBairro, "); sQuery.Append("coalesce(remetent.nm_cida,'')xMun, "); sQuery.Append("coalesce(remetent.cd_cep,'')CEP, "); sQuery.Append("coalesce(remetent.cd_uf,'')UF, "); sQuery.Append("coalesce(remetent.cd_pais,'')cPais "); sQuery.Append("from remetent "); sQuery.Append("join conhecim on conhecim.cd_destinat = remetent.cd_remetent "); sQuery.Append("join empresa on conhecim.cd_empresa = empresa.cd_empresa "); sQuery.Append("left join cidades on remetent.nm_cida = cidades.nm_cidnor and cidades.cd_ufnor = remetent.cd_uf "); sQuery.Append("where conhecim.nr_lanc ='" + sCte + "'"); sQuery.Append("and empresa.cd_empresa='" + belStatic.CodEmpresaCte + "'"); FbCommand fbConn = new FbCommand(sQuery.ToString(), conn); fbConn.ExecuteNonQuery(); FbDataReader dr = fbConn.ExecuteReader(); dr.Read(); objbelinfCte.dest = new beldest(); objbelinfCte.dest.enderDest = new belenderDest(); objbelinfCte.dest.CNPJ = util.TiraSimbolo(dr["CNPJ"].ToString()); objbelinfCte.dest.CPF = util.TiraSimbolo(dr["CPF"].ToString()); objbelinfCte.dest.IE = util.TiraSimbolo(dr["IE"].ToString()); objbelinfCte.dest.xNome = belUtil.TiraSimbolo(dr["xNome"].ToString(), ""); objbelinfCte.dest.fone = util.TiraSimbolo(dr["fone"].ToString()); objbelinfCte.dest.ISUF = dr["ISUF"].ToString(); objbelinfCte.dest.enderDest.xLgr = belUtil.TiraSimbolo(dr["xLgr"].ToString(), ""); objbelinfCte.dest.enderDest.nro = dr["nro"].ToString(); objbelinfCte.dest.enderDest.xBairro = belUtil.TiraSimbolo(dr["xBairro"].ToString(), ""); objbelinfCte.dest.enderDest.xMun = belUtil.TiraSimbolo(dr["xMun"].ToString(), ""); objbelinfCte.dest.enderDest.UF = dr["UF"].ToString(); objbelinfCte.dest.enderDest.cMun = dr["cMun"].ToString(); objbelinfCte.dest.enderDest.CEP = util.TiraSimbolo(dr["CEP"].ToString()); objbelinfCte.dest.enderDest.xPais = "Brasil"; objbelinfCte.dest.enderDest.cPais = "1058"; } catch (Exception ex) { throw ex; } }
private void CriaObjAlter() { try { List<belinfCte> objList = new List<belinfCte>(); for (int i = 0; i < this.objObjetos.objLinfCte.Count; i++) { belinfCte objbelinfCte = new belinfCte(); belinfCte obj = this.objObjetos.objLinfCte[i]; #region Identificacao objbelinfCte.id = obj.id; objbelinfCte.ide = new belide(); objbelinfCte.ide.cUF = obj.ide.cUF; objbelinfCte.ide.cCT = obj.ide.cCT; objbelinfCte.ide.CFOP = obj.ide.CFOP; objbelinfCte.ide.natOp = obj.ide.natOp; objbelinfCte.ide.forPag = obj.ide.forPag; objbelinfCte.ide.mod = obj.ide.mod; objbelinfCte.ide.serie = obj.ide.serie; objbelinfCte.ide.nCT = obj.ide.nCT; objbelinfCte.ide.tpImp = obj.ide.tpImp; objbelinfCte.ide.tpEmis = belStatic.bModoContingencia == true ? "2" : "1"; objbelinfCte.ide.cDV = obj.ide.cDV; objbelinfCte.ide.tpAmb = obj.ide.tpAmb; objbelinfCte.ide.tpCTe = obj.ide.tpCTe; objbelinfCte.ide.procEmi = obj.ide.procEmi; objbelinfCte.ide.verProc = obj.ide.verProc; objbelinfCte.ide.cMunEnv = obj.ide.cMunEnv; objbelinfCte.ide.xMunEnv = obj.ide.xMunEnv; objbelinfCte.ide.UFEnv = obj.ide.UFEnv; objbelinfCte.ide.modal = obj.ide.modal; objbelinfCte.ide.tpServ = obj.ide.tpServ; objbelinfCte.ide.cMunIni = obj.ide.cMunIni; objbelinfCte.ide.xMunIni = obj.ide.xMunIni; objbelinfCte.ide.UFIni = obj.ide.UFIni; objbelinfCte.ide.cMunFim = obj.ide.cMunFim; objbelinfCte.ide.xMunFim = obj.ide.xMunFim; objbelinfCte.ide.UFFim = obj.ide.UFFim; objbelinfCte.ide.retira = obj.ide.retira; objbelinfCte.ide.xDetRetira = obj.ide.xDetRetira; #endregion #region compl if (obj.compl != null) { objbelinfCte.compl = new belcompl(); objbelinfCte.compl.ObsCont.Xcampo = obj.compl.ObsCont.Xcampo; objbelinfCte.compl.ObsCont.Xtexto = obj.compl.ObsCont.Xtexto; } #endregion #region Tomador if (obj.ide.toma03 != null) { objbelinfCte.ide.toma03 = new beltoma03(); objbelinfCte.ide.toma03.toma = obj.ide.toma03.toma; } else if (obj.ide.toma04 != null) { objbelinfCte.ide.toma04 = new beltoma04(); objbelinfCte.ide.toma04.toma = obj.ide.toma04.toma; objbelinfCte.ide.toma04.CNPJ = obj.ide.toma04.CNPJ; objbelinfCte.ide.toma04.CPF = obj.ide.toma04.CPF; objbelinfCte.ide.toma04.IE = obj.ide.toma04.IE; objbelinfCte.ide.toma04.xNome = obj.ide.toma04.xNome; objbelinfCte.ide.toma04.xFant = obj.ide.toma04.xFant; objbelinfCte.ide.toma04.fone = obj.ide.toma04.fone; objbelinfCte.ide.toma04.enderToma = new belenderToma(); objbelinfCte.ide.toma04.enderToma.xLgr = obj.ide.toma04.enderToma.xLgr; objbelinfCte.ide.toma04.enderToma.nro = obj.ide.toma04.enderToma.nro; objbelinfCte.ide.toma04.enderToma.xCpl = obj.ide.toma04.enderToma.xCpl; objbelinfCte.ide.toma04.enderToma.xBairro = obj.ide.toma04.enderToma.xBairro; objbelinfCte.ide.toma04.enderToma.cMun = obj.ide.toma04.enderToma.cMun; objbelinfCte.ide.toma04.enderToma.xMun = obj.ide.toma04.enderToma.xMun; objbelinfCte.ide.toma04.enderToma.CEP = obj.ide.toma04.enderToma.CEP; objbelinfCte.ide.toma04.enderToma.UF = obj.ide.toma04.enderToma.UF; objbelinfCte.ide.toma04.enderToma.cPais = obj.ide.toma04.enderToma.cPais; objbelinfCte.ide.toma04.enderToma.xPais = obj.ide.toma04.enderToma.xPais; } #endregion #region Emitente objbelinfCte.emit = new belemit(); objbelinfCte.emit.CNPJ = obj.emit.CNPJ; objbelinfCte.emit.IE = obj.emit.IE; objbelinfCte.emit.xNome = obj.emit.xNome; objbelinfCte.emit.xFant = obj.emit.xFant; objbelinfCte.emit.enderEmit = new belenderEmit(); objbelinfCte.emit.enderEmit.xLgr = obj.emit.enderEmit.xLgr; objbelinfCte.emit.enderEmit.nro = obj.emit.enderEmit.nro; objbelinfCte.emit.enderEmit.xCpl = obj.emit.enderEmit.xCpl; objbelinfCte.emit.enderEmit.xBairro = obj.emit.enderEmit.xBairro; objbelinfCte.emit.enderEmit.cMun = obj.emit.enderEmit.cMun; objbelinfCte.emit.enderEmit.xMun = obj.emit.enderEmit.xMun; objbelinfCte.emit.enderEmit.CEP = obj.emit.enderEmit.CEP; objbelinfCte.emit.enderEmit.UF = obj.emit.enderEmit.UF; objbelinfCte.emit.enderEmit.fone = obj.emit.enderEmit.fone; #endregion #region Remetente objbelinfCte.rem = new belrem(); objbelinfCte.rem.CNPJ = obj.rem.CNPJ; objbelinfCte.rem.CPF = obj.rem.CPF; objbelinfCte.rem.IE = obj.rem.IE; objbelinfCte.rem.xNome = obj.rem.xNome; objbelinfCte.rem.xFant = obj.rem.xFant; objbelinfCte.rem.fone = obj.rem.fone; objbelinfCte.rem.enderReme = new belenderReme(); objbelinfCte.rem.enderReme.xLgr = obj.rem.enderReme.xLgr; objbelinfCte.rem.enderReme.nro = obj.rem.enderReme.nro; objbelinfCte.rem.enderReme.xCpl = obj.rem.enderReme.xCpl; objbelinfCte.rem.enderReme.xBairro = obj.rem.enderReme.xBairro; objbelinfCte.rem.enderReme.cMun = obj.rem.enderReme.cMun; objbelinfCte.rem.enderReme.xMun = obj.rem.enderReme.xMun; objbelinfCte.rem.enderReme.CEP = obj.rem.enderReme.CEP; objbelinfCte.rem.enderReme.UF = obj.rem.enderReme.UF; objbelinfCte.rem.enderReme.xPais = obj.rem.enderReme.xPais; objbelinfCte.rem.enderReme.cPais = obj.rem.enderReme.cPais; #endregion #region Destinatario objbelinfCte.dest = new beldest(); objbelinfCte.dest.CNPJ = obj.dest.CNPJ; objbelinfCte.dest.CPF = obj.dest.CPF; objbelinfCte.dest.IE = obj.dest.IE; objbelinfCte.dest.xNome = obj.dest.xNome; objbelinfCte.dest.fone = obj.dest.fone; objbelinfCte.dest.ISUF = obj.dest.ISUF; objbelinfCte.dest.enderDest = new belenderDest(); objbelinfCte.dest.enderDest.xLgr = obj.dest.enderDest.xLgr; objbelinfCte.dest.enderDest.nro = obj.dest.enderDest.nro; objbelinfCte.dest.enderDest.xCpl = obj.dest.enderDest.xCpl; objbelinfCte.dest.enderDest.xBairro = obj.dest.enderDest.xBairro; objbelinfCte.dest.enderDest.cMun = obj.dest.enderDest.cMun; objbelinfCte.dest.enderDest.xMun = obj.dest.enderDest.xMun; objbelinfCte.dest.enderDest.CEP = obj.dest.enderDest.CEP; objbelinfCte.dest.enderDest.UF = obj.dest.enderDest.UF; objbelinfCte.dest.enderDest.xPais = obj.dest.enderDest.xPais; objbelinfCte.dest.enderDest.cPais = obj.dest.enderDest.cPais; #endregion #region Expedidor if (obj.exped != null) { objbelinfCte.exped = new belexped(); objbelinfCte.exped.CNPJ = obj.exped.CNPJ; objbelinfCte.exped.CPF = obj.exped.CPF; objbelinfCte.exped.IE = obj.exped.IE; objbelinfCte.exped.xNome = obj.exped.xNome; objbelinfCte.exped.fone = obj.exped.fone; objbelinfCte.exped.enderExped = new belenderExped(); objbelinfCte.exped.enderExped.xLgr = obj.exped.enderExped.xLgr; objbelinfCte.exped.enderExped.nro = obj.exped.enderExped.nro; objbelinfCte.exped.enderExped.xCpl = obj.exped.enderExped.xCpl; objbelinfCte.exped.enderExped.xBairro = obj.exped.enderExped.xBairro; objbelinfCte.exped.enderExped.cMun = obj.exped.enderExped.cMun; objbelinfCte.exped.enderExped.xMun = obj.exped.enderExped.xMun; objbelinfCte.exped.enderExped.CEP = obj.exped.enderExped.CEP; objbelinfCte.exped.enderExped.UF = obj.exped.enderExped.UF; objbelinfCte.exped.enderExped.xPais = obj.exped.enderExped.xPais; objbelinfCte.exped.enderExped.cPais = obj.exped.enderExped.cPais; } #endregion #region Recebedor if (obj.receb != null) { objbelinfCte.receb = new belreceb(); objbelinfCte.receb.CNPJ = obj.receb.CNPJ; objbelinfCte.receb.CPF = obj.receb.CPF; objbelinfCte.receb.IE = obj.receb.IE; objbelinfCte.receb.xNome = obj.receb.xNome; objbelinfCte.receb.fone = obj.receb.fone; objbelinfCte.receb.enderReceb = new belenderReceb(); objbelinfCte.receb.enderReceb.xLgr = obj.receb.enderReceb.xLgr; objbelinfCte.receb.enderReceb.nro = obj.receb.enderReceb.nro; objbelinfCte.receb.enderReceb.xCpl = obj.receb.enderReceb.xCpl; objbelinfCte.receb.enderReceb.xBairro = obj.receb.enderReceb.xBairro; objbelinfCte.receb.enderReceb.cMun = obj.receb.enderReceb.cMun; objbelinfCte.receb.enderReceb.xMun = obj.receb.enderReceb.xMun; objbelinfCte.receb.enderReceb.CEP = obj.receb.enderReceb.CEP; objbelinfCte.receb.enderReceb.UF = obj.receb.enderReceb.UF; objbelinfCte.receb.enderReceb.xPais = obj.receb.enderReceb.xPais; objbelinfCte.receb.enderReceb.cPais = obj.receb.enderReceb.cPais; } #endregion #region Informacoes da NF objbelinfCte.rem.infNF = new List<belinfNF>(); for (int j = 0; j < obj.rem.infNF.Count; j++) { belinfNF nf = new belinfNF(); nf.mod = obj.rem.infNF[j].mod; nf.nDoc = obj.rem.infNF[j].nDoc; nf.serie = obj.rem.infNF[j].serie; nf.dEmi = obj.rem.infNF[j].dEmi; nf.vBC = obj.rem.infNF[j].vBC; nf.vICMS = obj.rem.infNF[j].vICMS; nf.vBCST = obj.rem.infNF[j].vBCST; nf.vST = obj.rem.infNF[j].vST; nf.vProd = obj.rem.infNF[j].vProd; nf.vNF = obj.rem.infNF[j].vNF; nf.nCFOP = Convert.ToInt32(obj.rem.infNF[j].nCFOP).ToString(); objbelinfCte.rem.infNF.Add(nf); } objbelinfCte.rem.infNFe = new List<belinfNFe>(); for (int n = 0; n < obj.rem.infNFe.Count; n++) { belinfNFe nfe = new belinfNFe(); nfe.chave = obj.rem.infNFe[n].chave; objbelinfCte.rem.infNFe.Add(nfe); } #endregion #region Outros Documentos objbelinfCte.rem.infOutros = new List<belinfOutros>(); for (int j = 0; j < obj.rem.infOutros.Count; j++) { belinfOutros infOutros = new belinfOutros(); infOutros.tpDoc = obj.rem.infOutros[j].tpDoc; infOutros.descOutros = obj.rem.infOutros[j].descOutros; infOutros.nDoc = obj.rem.infOutros[j].nDoc; infOutros.dEmi = obj.rem.infOutros[j].dEmi; infOutros.vDocFisc = obj.rem.infOutros[j].vDocFisc; objbelinfCte.rem.infOutros.Add(infOutros); } #endregion #region Valores objbelinfCte.vPrest = new belvPrest(); objbelinfCte.vPrest.vTPrest = obj.vPrest.vTPrest; objbelinfCte.vPrest.vRec = obj.vPrest.vRec; objbelinfCte.vPrest.Comp = obj.vPrest.Comp; objbelinfCte.imp = new belimp(); objbelinfCte.imp.ICMS = new belICMS(); if (obj.imp.ICMS.ICMS00 != null) { objbelinfCte.imp.ICMS.ICMS00 = new belICMS00(); objbelinfCte.imp.ICMS.ICMS00.CST = obj.imp.ICMS.ICMS00.CST; objbelinfCte.imp.ICMS.ICMS00.vBC = obj.imp.ICMS.ICMS00.vBC; objbelinfCte.imp.ICMS.ICMS00.pICMS = obj.imp.ICMS.ICMS00.pICMS; objbelinfCte.imp.ICMS.ICMS00.vICMS = obj.imp.ICMS.ICMS00.vICMS; } else if (obj.imp.ICMS.ICMS20 != null) { objbelinfCte.imp.ICMS.ICMS20 = new belICMS20(); objbelinfCte.imp.ICMS.ICMS20.CST = obj.imp.ICMS.ICMS20.CST; objbelinfCte.imp.ICMS.ICMS20.pRedBC = obj.imp.ICMS.ICMS20.pRedBC; objbelinfCte.imp.ICMS.ICMS20.vBC = obj.imp.ICMS.ICMS20.vBC; objbelinfCte.imp.ICMS.ICMS20.pICMS = obj.imp.ICMS.ICMS20.pICMS; objbelinfCte.imp.ICMS.ICMS20.vICMS = obj.imp.ICMS.ICMS20.vICMS; } else if (obj.imp.ICMS.ICMS45 != null) { objbelinfCte.imp.ICMS.ICMS45 = new belICMS45(); objbelinfCte.imp.ICMS.ICMS45.CST = obj.imp.ICMS.ICMS45.CST; } else if (obj.imp.ICMS.ICMS60 != null) { objbelinfCte.imp.ICMS.ICMS60 = new belICMS60(); objbelinfCte.imp.ICMS.ICMS60.CST = obj.imp.ICMS.ICMS60.CST; objbelinfCte.imp.ICMS.ICMS60.vBCSTRet = obj.imp.ICMS.ICMS60.vBCSTRet; objbelinfCte.imp.ICMS.ICMS60.vICMSSTRet = obj.imp.ICMS.ICMS60.vICMSSTRet; objbelinfCte.imp.ICMS.ICMS60.pICMSSTRet = obj.imp.ICMS.ICMS60.pICMSSTRet; objbelinfCte.imp.ICMS.ICMS60.vCred = obj.imp.ICMS.ICMS60.vCred; } else if (obj.imp.ICMS.ICMS90 != null) { objbelinfCte.imp.ICMS.ICMS90 = new belICMS90(); objbelinfCte.imp.ICMS.ICMS90.CST = obj.imp.ICMS.ICMS90.CST; objbelinfCte.imp.ICMS.ICMS90.pRedBC = obj.imp.ICMS.ICMS90.pRedBC; objbelinfCte.imp.ICMS.ICMS90.vBC = obj.imp.ICMS.ICMS90.vBC; objbelinfCte.imp.ICMS.ICMS90.pICMS = obj.imp.ICMS.ICMS90.pICMS; objbelinfCte.imp.ICMS.ICMS90.vICMS = obj.imp.ICMS.ICMS90.vICMS; objbelinfCte.imp.ICMS.ICMS90.vCred = obj.imp.ICMS.ICMS90.vCred; } else if (obj.imp.ICMS.ICMSOutraUF != null) { objbelinfCte.imp.ICMS.ICMSOutraUF = new belICMSOutraUF(); objbelinfCte.imp.ICMS.ICMSOutraUF.CST = obj.imp.ICMS.ICMSOutraUF.CST; objbelinfCte.imp.ICMS.ICMSOutraUF.pRedBCOutraUF = obj.imp.ICMS.ICMSOutraUF.pRedBCOutraUF; objbelinfCte.imp.ICMS.ICMSOutraUF.vBCOutraUF = obj.imp.ICMS.ICMSOutraUF.vBCOutraUF; objbelinfCte.imp.ICMS.ICMSOutraUF.pICMSOutraUF = obj.imp.ICMS.ICMSOutraUF.pICMSOutraUF; objbelinfCte.imp.ICMS.ICMSOutraUF.vICMSOutraUF = obj.imp.ICMS.ICMSOutraUF.vICMSOutraUF; } #endregion #region InformacoesCarga objbelinfCte.infCTeNorm = new belinfCTeNorm(); objbelinfCte.infCTeNorm.infCarga = new belinfCarga(); objbelinfCte.infCTeNorm.infCarga.vCarga = obj.infCTeNorm.infCarga.vCarga; objbelinfCte.infCTeNorm.infCarga.proPred = obj.infCTeNorm.infCarga.proPred; objbelinfCte.infCTeNorm.infCarga.xOutCat = obj.infCTeNorm.infCarga.xOutCat; objbelinfCte.infCTeNorm.infCarga.infQ = new List<belinfQ>(); for (int j = 0; j < obj.infCTeNorm.infCarga.infQ.Count; j++) { belinfQ objInfQ = new belinfQ(); objInfQ.cUnid = obj.infCTeNorm.infCarga.infQ[j].cUnid; objInfQ.tpMed = obj.infCTeNorm.infCarga.infQ[j].tpMed; objInfQ.qCarga = obj.infCTeNorm.infCarga.infQ[j].qCarga; objbelinfCte.infCTeNorm.infCarga.infQ.Add(objInfQ); } #endregion #region Rodoviario objbelinfCte.infCTeNorm.seg = new belseg(); objbelinfCte.infCTeNorm.rodo = new belrodo(); objbelinfCte.infCTeNorm.seg.respSeg = obj.infCTeNorm.seg.respSeg; objbelinfCte.infCTeNorm.seg.nApol = obj.infCTeNorm.seg.nApol; objbelinfCte.infCTeNorm.rodo.RNTRC = obj.infCTeNorm.rodo.RNTRC; objbelinfCte.infCTeNorm.rodo.dPrev = obj.infCTeNorm.rodo.dPrev; objbelinfCte.infCTeNorm.rodo.lota = obj.infCTeNorm.rodo.lota; #endregion #region Veiculo objbelinfCte.infCTeNorm.rodo.veic = new List<belveic>(); for (int v = 0; v < obj.infCTeNorm.rodo.veic.Count; v++) { belveic veic = new belveic(); veic.RENAVAM = obj.infCTeNorm.rodo.veic[v].RENAVAM; veic.placa = obj.infCTeNorm.rodo.veic[v].placa; veic.tara = obj.infCTeNorm.rodo.veic[v].tara; veic.capKG = obj.infCTeNorm.rodo.veic[v].capKG; veic.capM3 = obj.infCTeNorm.rodo.veic[v].capM3; veic.tpProp = obj.infCTeNorm.rodo.veic[v].tpProp; veic.tpVeic = obj.infCTeNorm.rodo.veic[v].tpVeic; veic.tpRod = obj.infCTeNorm.rodo.veic[v].tpRod; veic.tpCar = obj.infCTeNorm.rodo.veic[v].tpCar; veic.UF = obj.infCTeNorm.rodo.veic[v].UF; if (obj.infCTeNorm.rodo.veic[v].prop != null) { veic.prop = new belprop(); veic.prop.CPFCNPJ = obj.infCTeNorm.rodo.veic[v].prop.CPFCNPJ; veic.prop.RNTRC = obj.infCTeNorm.rodo.veic[v].prop.RNTRC; veic.prop.xNome = obj.infCTeNorm.rodo.veic[v].prop.xNome; veic.prop.IE = obj.infCTeNorm.rodo.veic[v].prop.IE; veic.prop.UF = obj.infCTeNorm.rodo.veic[v].prop.UF; veic.prop.tpProp = obj.infCTeNorm.rodo.veic[v].prop.tpProp; } objbelinfCte.infCTeNorm.rodo.veic.Add(veic); } if (obj.infCTeNorm.rodo.moto != null) { objbelinfCte.infCTeNorm.rodo.moto = new belmoto(); objbelinfCte.infCTeNorm.rodo.moto.xNome = obj.infCTeNorm.rodo.moto.xNome; objbelinfCte.infCTeNorm.rodo.moto.CPF = obj.infCTeNorm.rodo.moto.CPF; } #endregion objList.Add(objbelinfCte); } this.objObjetosAlter = new belPopulaObjetos(objObjetos.sEmp, objObjetos.objlConhec, objObjetos.cUf, objObjetos.cert); this.objObjetosAlter.objLinfCte = objList; this.objObjetosAlter.sFormEmiss = objObjetos.sFormEmiss; this.objObjetosAlter.sNomeArq = objObjetos.sNomeArq; this.objObjetosAlter.sPath = objObjetos.sPath; } catch (Exception ex) { KryptonMessageBox.Show(null, _sMessageException + (ex.InnerException != null ? ex.InnerException.Message : ex.Message).ToString(), "CT-e - AVISO", MessageBoxButtons.OK, MessageBoxIcon.Information); ; } }
public void PopulaEmit(belinfCte objbelinfCte, FbConnection conn) { try { StringBuilder sQuery = new StringBuilder(); sQuery.Append("Select "); sQuery.Append("coalesce (empresa.cd_cgc,'')CNPJ, "); sQuery.Append("coalesce (empresa.cd_insest,'') IE, "); sQuery.Append("empresa.nm_empresa xNome, "); sQuery.Append("empresa.nm_guerra xFant, "); sQuery.Append("coalesce (empresa.ds_endnor,'') xLgr, "); sQuery.Append("coalesce (empresa.ds_endcomp,'')xCpl, "); sQuery.Append("coalesce (empresa.nr_end,'')nro, "); sQuery.Append("empresa.nm_bairronor xBairro, "); sQuery.Append("coalesce (cidades.cd_municipio,'')cMun, "); sQuery.Append("empresa.nm_cidnor xMun, "); sQuery.Append("coalesce (empresa.cd_cepnor,'')CEP, "); sQuery.Append("coalesce (empresa.cd_ufnor,'') UF, "); sQuery.Append("coalesce (empresa.cd_fonenor,'')fone "); sQuery.Append("from empresa "); sQuery.Append("left join cidades on empresa.nm_cidnor = cidades.nm_cidnor and cidades.cd_ufnor = empresa.cd_ufnor "); sQuery.Append("where empresa.cd_empresa = '" + belStatic.CodEmpresaCte + "'"); FbCommand fbConn = new FbCommand(sQuery.ToString(), conn); fbConn.ExecuteNonQuery(); FbDataReader dr = fbConn.ExecuteReader(); dr.Read(); objbelinfCte.emit = new belemit(); objbelinfCte.emit.enderEmit = new belenderEmit(); objbelinfCte.emit.CNPJ = util.TiraSimbolo(dr["CNPJ"].ToString()); objbelinfCte.emit.IE = util.TiraSimbolo(dr["IE"].ToString()); objbelinfCte.emit.xNome = belUtil.TiraSimbolo(dr["xNome"].ToString(), ""); objbelinfCte.emit.xFant = belUtil.TiraSimbolo(dr["xFant"].ToString(), ""); objbelinfCte.emit.enderEmit.xLgr = belUtil.TiraSimbolo(dr["xLgr"].ToString(), ""); objbelinfCte.emit.enderEmit.nro = dr["nro"].ToString(); objbelinfCte.emit.enderEmit.xCpl = dr["xCpl"].ToString(); objbelinfCte.emit.enderEmit.xBairro = belUtil.TiraSimbolo(dr["xBairro"].ToString(), ""); objbelinfCte.emit.enderEmit.UF = dr["UF"].ToString(); objbelinfCte.emit.enderEmit.xMun = belUtil.TiraSimbolo(dr["xMun"].ToString(), ""); objbelinfCte.emit.enderEmit.cMun = dr["cMun"].ToString(); objbelinfCte.emit.enderEmit.CEP = dr["CEP"].ToString() != "" ? util.TiraSimbolo(dr["CEP"].ToString()) : ""; if (dr["fone"].ToString() != "") { objbelinfCte.emit.enderEmit.fone = util.TiraSimbolo(dr["fone"].ToString()); } } catch (Exception ex) { throw ex; } }
public void PopulaImp(belinfCte objbelinfCte, FbConnection conn, string sCte) { try { StringBuilder sQuery = new StringBuilder(); sQuery.Append("Select "); sQuery.Append("coalesce (conhecim.cd_sittrib,'') CST, "); sQuery.Append("coalesce (conhecim.vl_redbase,'') pRedBC, "); sQuery.Append("coalesce (conhecim.vl_base,'') vBC, "); sQuery.Append("coalesce (conhecim.vl_aliq,'') pICMS, "); sQuery.Append("coalesce (conhecim.vl_icms,'') vICMS "); sQuery.Append("From conhecim "); sQuery.Append("join empresa on conhecim.cd_empresa = empresa.cd_empresa "); sQuery.Append("Where conhecim.nr_lanc = '" + sCte + "'"); sQuery.Append("And empresa.cd_empresa = '" + belStatic.CodEmpresaCte + "'"); FbCommand fbConn = new FbCommand(sQuery.ToString(), conn); fbConn.ExecuteNonQuery(); FbDataReader dr = fbConn.ExecuteReader(); while (dr.Read()) { objbelinfCte.imp = new belimp(); objbelinfCte.imp.ICMS = new belICMS(); switch (dr["CST"].ToString()) { case "000": objbelinfCte.imp.ICMS.ICMS00 = new belICMS00(); objbelinfCte.imp.ICMS.ICMS00.CST = "00"; objbelinfCte.imp.ICMS.ICMS00.vBC = dr["vBC"].ToString().Replace(",", "."); objbelinfCte.imp.ICMS.ICMS00.pICMS = dr["pICMS"].ToString().Replace(",", "."); objbelinfCte.imp.ICMS.ICMS00.vICMS = dr["vICMS"].ToString().Replace(",", "."); break; case "020": objbelinfCte.imp.ICMS.ICMS20 = new belICMS20(); objbelinfCte.imp.ICMS.ICMS20.CST = "20"; objbelinfCte.imp.ICMS.ICMS20.pRedBC = dr["pRedBC"].ToString().Replace(",", "."); objbelinfCte.imp.ICMS.ICMS20.vBC = dr["vBC"].ToString().Replace(",", "."); objbelinfCte.imp.ICMS.ICMS20.pICMS = dr["pICMS"].ToString().Replace(",", "."); objbelinfCte.imp.ICMS.ICMS20.vICMS = dr["vICMS"].ToString().Replace(",", "."); break; case "040": PopulaCst45(objbelinfCte, "40"); break; case "041": PopulaCst45(objbelinfCte, "41"); break; case "051": PopulaCst45(objbelinfCte, "51"); break; case "060": objbelinfCte.imp.ICMS.ICMS60 = new belICMS60(); objbelinfCte.imp.ICMS.ICMS60.CST = "60"; objbelinfCte.imp.ICMS.ICMS60.vBCSTRet = dr["vBC"].ToString().Replace(",", "."); objbelinfCte.imp.ICMS.ICMS60.vICMSSTRet = dr["vICMS"].ToString().Replace(",", "."); objbelinfCte.imp.ICMS.ICMS60.pICMSSTRet = dr["pICMS"].ToString().Replace(",", "."); break; case "090": objbelinfCte.imp.ICMS = new belICMS(); objbelinfCte.imp.ICMS.ICMS90 = new belICMS90(); objbelinfCte.imp.ICMS.ICMS90.CST = "90"; objbelinfCte.imp.ICMS.ICMS90.pRedBC = dr["pRedBC"].ToString().Replace(",", "."); objbelinfCte.imp.ICMS.ICMS90.vBC = dr["vBC"].ToString().Replace(",", "."); objbelinfCte.imp.ICMS.ICMS90.pICMS = dr["pICMS"].ToString().Replace(",", "."); objbelinfCte.imp.ICMS.ICMS90.vICMS = dr["vICMS"].ToString().Replace(",", "."); break; default: throw new Exception("O Conhecimento " + objbelinfCte.ide.nCT + " não tem Situação Tributária Válida!"); } } } catch (Exception ex) { throw ex; } }
private static void PopulaCst45(belinfCte objbelinfCte, string CST) { objbelinfCte.imp.ICMS.ICMS45 = new belICMS45(); objbelinfCte.imp.ICMS.ICMS45.CST = CST; }
public void PopulaVeiculo(belinfCte objbelinfCte, FbConnection conn, string sCte) { try { objbelinfCte.infCTeNorm.rodo.veic = new List<belveic>(); if (objbelinfCte.infCTeNorm.rodo.lota == "1") { for (int tot = 0; tot < objbelinfCte.ide.Veiculo.Count; tot++) { StringBuilder sQuery = new StringBuilder(); sQuery.Append("Select "); sQuery.Append("coalesce(veiculo.cd_renavam,'')RENAVAM, "); sQuery.Append("coalesce(veiculo.cd_placa,'')placa, "); sQuery.Append("coalesce(veiculo.cd_tara,'0.00')tara, "); sQuery.Append("coalesce(veiculo.cd_tonela,'0.00')capKG, "); sQuery.Append("coalesce(veiculo.cd_m3,'0.00')capM3, "); sQuery.Append("coalesce(veiculo.st_tpproprietario,'')tpProp, "); sQuery.Append("coalesce(veiculo.cd_tipo,'')tpVeic, "); sQuery.Append("coalesce(veiculo.st_rodado,'')tpRod, "); sQuery.Append("coalesce(veiculo.st_carroceria,'')tpCar, "); sQuery.Append("coalesce(veiculo.cd_uf,'')UF "); sQuery.Append("from veiculo "); sQuery.Append("where veiculo.cd_veiculo ='" + objbelinfCte.ide.Veiculo[tot] + "' "); FbCommand fbConn = new FbCommand(sQuery.ToString(), conn); fbConn.ExecuteNonQuery(); FbDataReader dr = fbConn.ExecuteReader(); while (dr.Read()) { belveic veic = new belveic(); veic.RENAVAM = dr["RENAVAM"].ToString(); veic.placa = dr["placa"].ToString(); veic.tara = dr["tara"].ToString().Substring(0, dr["tara"].ToString().IndexOf('.')); veic.capKG = dr["capKG"].ToString().Substring(0, dr["capKG"].ToString().IndexOf('.')); veic.capM3 = dr["capM3"].ToString().Substring(0, dr["capM3"].ToString().IndexOf('.')); veic.tpProp = dr["tpProp"].ToString(); veic.tpVeic = dr["tpVeic"].ToString(); veic.tpRod = dr["tpRod"].ToString(); veic.tpCar = dr["tpCar"].ToString(); veic.UF = dr["UF"].ToString(); objbelinfCte.infCTeNorm.rodo.veic.Add(veic); } dr.Dispose(); if (objbelinfCte.infCTeNorm.rodo.veic[tot].tpProp == "T") { sQuery = new StringBuilder(); sQuery.Append("Select "); sQuery.Append("coalesce(veiculo.cd_cgc,'')CPF, "); sQuery.Append("coalesce(veiculo.cd_rtb,'')RNTRC, "); sQuery.Append("coalesce(veiculo.nm_proprie,'')xNome, "); sQuery.Append("coalesce(veiculo.cd_ie,'ISENTO')IE, "); sQuery.Append("coalesce(veiculo.cd_uf,'')UF, "); sQuery.Append("coalesce(veiculo.ST_TPPROP,'')tpProp "); sQuery.Append("from veiculo "); sQuery.Append("where veiculo.cd_veiculo ='" + objbelinfCte.ide.Veiculo[tot] + "' "); fbConn = new FbCommand(sQuery.ToString(), conn); fbConn.ExecuteNonQuery(); dr = fbConn.ExecuteReader(); objbelinfCte.infCTeNorm.rodo.veic[tot].prop = new belprop(); while (dr.Read()) { objbelinfCte.infCTeNorm.rodo.veic[tot].prop.CPFCNPJ = util.TiraSimbolo(dr["CPF"].ToString()); objbelinfCte.infCTeNorm.rodo.veic[tot].prop.RNTRC = dr["RNTRC"].ToString(); objbelinfCte.infCTeNorm.rodo.veic[tot].prop.xNome = belUtil.TiraSimbolo(dr["xNome"].ToString(), ""); objbelinfCte.infCTeNorm.rodo.veic[tot].prop.IE = util.TiraSimbolo(dr["IE"].ToString()); objbelinfCte.infCTeNorm.rodo.veic[tot].prop.UF = dr["UF"].ToString(); objbelinfCte.infCTeNorm.rodo.veic[tot].prop.tpProp = dr["tpProp"].ToString(); } dr.Dispose(); } } } } catch (Exception ex) { throw ex; } }
public void PopulaMotorista(belinfCte objbelinfCte, FbConnection conn, string sCte) { try { if (objbelinfCte.infCTeNorm.rodo.veic.Count() > 0) { StringBuilder sQuery = new StringBuilder(); sQuery.Append("Select "); sQuery.Append("coalesce(motorista.nm_motoris,'')xNome, "); sQuery.Append("coalesce(motorista.cd_cgc,'')CPF "); sQuery.Append("from motorista "); sQuery.Append("where motorista.cd_motoris ='" + objbelinfCte.ide.Motorista + "' "); FbCommand fbConn = new FbCommand(sQuery.ToString(), conn); fbConn.ExecuteNonQuery(); FbDataReader dr = fbConn.ExecuteReader(); if (objbelinfCte.infCTeNorm.rodo.lota == "1") { objbelinfCte.infCTeNorm.rodo.moto = new belmoto(); } while (dr.Read()) { objbelinfCte.infCTeNorm.rodo.moto = new belmoto(); objbelinfCte.infCTeNorm.rodo.moto.xNome = belUtil.TiraSimbolo(dr["xNome"].ToString(), ""); objbelinfCte.infCTeNorm.rodo.moto.CPF = util.TiraSimbolo(dr["CPF"].ToString()); } } } catch (Exception ex) { throw ex; } }
public void PopulaIde(string sCte, string sDigVerif, FbConnection conn, belinfCte objbelinfCte, string sId) { try { StringBuilder sQuery = new StringBuilder(); sQuery.Append("select "); sQuery.Append("coalesce(conhecim.cd_consignat,'')cd_consignat, "); sQuery.Append("coalesce(empresa.cd_ufnor,'') cUF,"); sQuery.Append("coalesce(conhecim.cd_respons,'') Tomador,"); sQuery.Append("coalesce(conhecim.nr_lanc,'') cCT,"); sQuery.Append("coalesce(conhecim.cd_cfop,'') CFOP,"); sQuery.Append("coalesce(natop.ds_natop,'') natOp ,"); sQuery.Append("coalesce(conhecim.cd_serie,'') serie,"); sQuery.Append("coalesce(conhecim.cd_conheci,'') nCT,"); sQuery.Append("coalesce(empresa.nm_cidnor,'') xMunEmi,"); sQuery.Append("coalesce(empresa.cd_ufnor,'') UFEmi,"); sQuery.Append("coalesce(cidade1.cd_municipio,'') cMunIni,"); sQuery.Append("coalesce(conhecim.ds_cidcole,'') xMunIni,"); sQuery.Append("coalesce(conhecim.cd_ufcole,'') UFIni,"); sQuery.Append("coalesce(destino.cd_uf,'') UFFim, "); sQuery.Append("coalesce(cidade2.cd_municipio,'') cMunFim,"); sQuery.Append("coalesce(conhecim.ds_calc,'') xMunFim,"); sQuery.Append("coalesce(conhecim.st_forpag,'1') forPag,"); sQuery.Append("coalesce(conhecim.cd_veiculo,'') Veiculo,"); sQuery.Append("coalesce(conhecim.cd_veiculo2,'') Veiculo2,"); sQuery.Append("coalesce(conhecim.cd_veiculo3,'') Veiculo3,"); sQuery.Append("coalesce(conhecim.cd_veiculo4,'') Veiculo4,"); sQuery.Append("coalesce(conhecim.cd_motoris,'') Motorista "); sQuery.Append("from conhecim left join natop on conhecim.cd_cfop = natop.cd_cfop "); sQuery.Append("left join empresa on conhecim.cd_empresa = empresa.cd_empresa "); sQuery.Append("left join remetent destino on (destino.cd_remetent = conhecim.cd_redes and conhecim.cd_redes is not null) "); sQuery.Append("or (destino.cd_remetent = conhecim.cd_destinat and conhecim.cd_redes is null) "); sQuery.Append("left join clifor on conhecim.cd_clifor = clifor.cd_clifor "); sQuery.Append("left join cidades cidade1 on cidade1.nm_cidnor = conhecim.ds_cidcole and cidade1.cd_ufnor = conhecim.cd_ufcole "); sQuery.Append("left join cidades cidade2 on cidade2.nm_cidnor = conhecim.ds_calc and cidade2.cd_ufnor = destino.cd_uf "); sQuery.Append("where empresa.cd_empresa ='" + belStatic.CodEmpresaCte); sQuery.Append("' and conhecim.nr_lanc ='" + sCte + "'"); FbCommand fbConn = new FbCommand(sQuery.ToString(), conn); fbConn.ExecuteNonQuery(); FbDataReader dr = fbConn.ExecuteReader(); dr.Read(); objbelinfCte.ide = new belide(); bel.belUF objbelUF = new bel.belUF(); objbelinfCte.id = sId; objbelinfCte.ide.cUF = objbelUF.RetornaCUF(dr["cUF"].ToString()); objbelinfCte.ide.cCT = dr["cCT"].ToString(); objbelinfCte.ide.CFOP = dr["CFOP"].ToString(); objbelinfCte.ide.natOp = dr["natOp"].ToString().Length > 60 ? dr["natOp"].ToString().Substring(0, 60) : dr["natOp"].ToString(); objbelinfCte.ide.forPag = Convert.ToInt32(dr["forPag"]); objbelinfCte.ide.mod = "57"; objbelinfCte.ide.serie = belStatic.bModoContingencia == true ? "900" : "1"; objbelinfCte.ide.nCT = dr["nCT"].ToString(); objbelinfCte.ide.tpImp = "1"; objbelinfCte.ide.tpEmis = belStatic.bModoContingencia == true ? "5" : "1"; objbelinfCte.ide.cDV = sDigVerif; objbelinfCte.ide.tpAmb = Convert.ToString(belStatic.TpAmb); objbelinfCte.ide.tpCTe = 0; objbelinfCte.ide.procEmi = 0; objbelinfCte.ide.verProc = "1.04"; objbelinfCte.ide.xMunEnv = dr["xMunEmi"].ToString(); objbelinfCte.ide.UFEnv = dr["UFEmi"].ToString(); objbelinfCte.ide.cMunEnv = RetornaCodigoCidade(objbelinfCte.ide.xMunEnv, objbelinfCte.ide.UFEnv, conn); objbelinfCte.ide.modal = "01"; objbelinfCte.ide.tpServ = 0; objbelinfCte.ide.xMunIni = dr["xMunIni"].ToString(); objbelinfCte.ide.UFIni = dr["UFIni"].ToString(); objbelinfCte.ide.cMunIni = dr["cMunIni"].ToString(); objbelinfCte.ide.xMunFim = dr["xMunFim"].ToString(); objbelinfCte.ide.UFFim = dr["UFFim"].ToString(); objbelinfCte.ide.cMunFim = dr["cMunFim"].ToString(); objbelinfCte.ide.retira = 0; objbelinfCte.ide.xDetRetira = null; if (dr["Veiculo"].ToString() != "") { objbelinfCte.ide.Veiculo.Add(dr["Veiculo"].ToString()); } if (dr["Veiculo2"].ToString() != "") { objbelinfCte.ide.Veiculo.Add(dr["Veiculo2"].ToString()); } if (dr["Veiculo3"].ToString() != "") { objbelinfCte.ide.Veiculo.Add(dr["Veiculo3"].ToString()); } if (dr["Veiculo4"].ToString() != "") { objbelinfCte.ide.Veiculo.Add(dr["Veiculo4"].ToString()); } objbelinfCte.ide.Motorista = dr["Motorista"].ToString(); string sTipoTomador = dr["Tomador"].ToString(); switch (sTipoTomador) { case "R": objbelinfCte.ide.toma03 = new beltoma03(); objbelinfCte.ide.toma03.toma = "0"; break; case "D": objbelinfCte.ide.toma03 = new beltoma03(); objbelinfCte.ide.toma03.toma = "3"; break; default: objbelinfCte.ide.toma04 = new beltoma04(); if (dr["cd_consignat"].ToString() != "") { CarregaToma4(dr["cd_consignat"].ToString(), objbelinfCte.ide.toma04, conn); } else { throw new Exception("Não foi selecionado um Consignatário no sistema"); } break; } } catch (Exception ex) { throw ex; } }
public void PopulaVPrest(belinfCte objbelinfCte, FbConnection conn, string sCte) { try { StringBuilder sQuery = new StringBuilder(); sQuery.Append("Select "); sQuery.Append("coalesce (conhecim.vl_total,'') vTPrest, "); sQuery.Append("coalesce (conhecim.vl_frcubagem,'') FRETECUBAGEM, "); sQuery.Append("coalesce (conhecim.vl_frpeso,'') FRETEPESO, "); sQuery.Append("coalesce (conhecim.vl_cat,'') CAT, "); sQuery.Append("coalesce (conhecim.vl_desp,'') DESPACHO, "); sQuery.Append("coalesce (conhecim.vl_pedagio,'') PEDAGIO, "); sQuery.Append("coalesce (conhecim.vl_outros,'') OUTROS, "); sQuery.Append("coalesce (conhecim.vl_adval,'') ADME, "); sQuery.Append("coalesce (conhecim.vl_entcole,'') ENTREGA, "); sQuery.Append("coalesce (conhecim.vl_frvalor,'') FRETEVALOR "); sQuery.Append("From conhecim "); sQuery.Append("join empresa on conhecim.cd_empresa = empresa.cd_empresa "); sQuery.Append("Where conhecim.nr_lanc = '" + sCte + "'"); sQuery.Append("And empresa.cd_empresa = '" + belStatic.CodEmpresaCte + "'"); FbCommand fbConn = new FbCommand(sQuery.ToString(), conn); fbConn.ExecuteNonQuery(); FbDataReader dr = fbConn.ExecuteReader(); objbelinfCte.vPrest = new belvPrest(); objbelinfCte.vPrest.Comp = new List<belComp >(); while (dr.Read()) { objbelinfCte.vPrest.vTPrest = dr["vTPrest"].ToString(); objbelinfCte.vPrest.vRec = dr["vTPrest"].ToString(); belComp Comp = new belComp(); if (dr["FRETEVALOR"].ToString() != "0.00") { Comp = new belComp(); Comp.xNome = "FRETE VALOR"; Comp.vComp = dr["FRETEVALOR"].ToString(); objbelinfCte.vPrest.Comp.Add(Comp); } if (dr["FRETECUBAGEM"].ToString() != "0.00") { Comp = new belComp(); Comp.xNome = "FRETE CUBAGEM"; Comp.vComp = dr["FRETECUBAGEM"].ToString(); objbelinfCte.vPrest.Comp.Add(Comp); } if (dr["FRETEPESO"].ToString() != "0.00") { Comp = new belComp(); Comp.xNome = "FRETE PESO"; Comp.vComp = dr["FRETEPESO"].ToString(); objbelinfCte.vPrest.Comp.Add(Comp); } if (dr["CAT"].ToString() != "0.00") { Comp = new belComp(); Comp.xNome = "CAT"; Comp.vComp = dr["CAT"].ToString(); objbelinfCte.vPrest.Comp.Add(Comp); } if (dr["DESPACHO"].ToString() != "0.00") { Comp = new belComp(); Comp.xNome = "DESPACHO"; Comp.vComp = dr["DESPACHO"].ToString(); objbelinfCte.vPrest.Comp.Add(Comp); } if (dr["PEDAGIO"].ToString() != "0.00") { Comp = new belComp(); Comp.xNome = "PEDAGIO"; Comp.vComp = dr["PEDAGIO"].ToString(); objbelinfCte.vPrest.Comp.Add(Comp); } if (dr["OUTROS"].ToString() != "0.00") { Comp = new belComp(); Comp.xNome = "OUTROS"; Comp.vComp = dr["OUTROS"].ToString(); objbelinfCte.vPrest.Comp.Add(Comp); } if (dr["ADME"].ToString() != "0.00") { Comp = new belComp(); Comp.xNome = "ADME"; Comp.vComp = dr["ADME"].ToString(); objbelinfCte.vPrest.Comp.Add(Comp); } if (dr["ENTREGA"].ToString() != "0.00") { Comp = new belComp(); Comp.xNome = "ENTREGA"; Comp.vComp = dr["ENTREGA"].ToString(); objbelinfCte.vPrest.Comp.Add(Comp); } } } catch (Exception ex) { throw ex; } }