public belTotal xmlBuscaTotal() { belTotal objTotal = new belTotal(); XmlDocument xTotalN = new XmlDocument(); try { switch (xDoc.GetElementsByTagName("total")[0].FirstChild.Name) { case "ICMSTot": { xTotalN.LoadXml(xDoc.GetElementsByTagName("ICMSTot")[0].OuterXml); belIcmstot objIcmsTot = new belIcmstot(); objIcmsTot.Vbc = Convert.ToDecimal(xTotalN.GetElementsByTagName("vBC")[0].InnerText.ToString().Replace(".", ",")); objIcmsTot.Vicms = Convert.ToDecimal(xTotalN.GetElementsByTagName("vICMS")[0].InnerText.ToString().Replace(".", ",")); objIcmsTot.Vbcst = Convert.ToDecimal(xTotalN.GetElementsByTagName("vBCST")[0].InnerText.ToString().Replace(".", ",")); objIcmsTot.Vst = Convert.ToDecimal(xTotalN.GetElementsByTagName("vST")[0].InnerText.ToString().Replace(".", ",")); objIcmsTot.Vprod = Convert.ToDecimal(xTotalN.GetElementsByTagName("vProd")[0].InnerText.ToString().Replace(".", ",")); objIcmsTot.Vfrete = Convert.ToDecimal(xTotalN.GetElementsByTagName("vFrete")[0].InnerText.ToString().Replace(".", ",")); objIcmsTot.Vseg = Convert.ToDecimal(xTotalN.GetElementsByTagName("vSeg")[0].InnerText.ToString().Replace(".", ",")); objIcmsTot.Vdesc = Convert.ToDecimal(xTotalN.GetElementsByTagName("vDesc")[0].InnerText.ToString().Replace(".", ",")); objIcmsTot.Vii = Convert.ToDecimal(xTotalN.GetElementsByTagName("vII")[0].InnerText.ToString().Replace(".", ",")); objIcmsTot.Vipi = Convert.ToDecimal(xTotalN.GetElementsByTagName("vIPI")[0].InnerText.ToString().Replace(".", ",")); objIcmsTot.Vpis = Convert.ToDecimal(xTotalN.GetElementsByTagName("vPIS")[0].InnerText.ToString().Replace(".", ",")); objIcmsTot.Vcofins = Convert.ToDecimal(xTotalN.GetElementsByTagName("vCOFINS")[0].InnerText.ToString().Replace(".", ",")); objIcmsTot.Voutro = Convert.ToDecimal(xTotalN.GetElementsByTagName("vOutro")[0].InnerText.ToString().Replace(".", ",")); objIcmsTot.Vnf = Convert.ToDecimal(xTotalN.GetElementsByTagName("vNF")[0].InnerText.ToString().Replace(".", ",")); objTotal.belIcmstot = objIcmsTot; break; } case "ISSQNTot": { xTotalN.LoadXml(xDoc.GetElementsByTagName("ISSQNTot")[0].OuterXml); belIssqntot objIssqntot = new belIssqntot(); objIssqntot.Vserv = Convert.ToDecimal(xTotalN.GetElementsByTagName("vServ")[0].InnerText.ToString().Replace(".", ",")); objIssqntot.Vbc = Convert.ToDecimal(xTotalN.GetElementsByTagName("vBC")[0].InnerText.ToString().Replace(".", ",")); objIssqntot.Viss = Convert.ToDecimal(xTotalN.GetElementsByTagName("vISS")[0].InnerText.ToString().Replace(".", ",")); objIssqntot.Vpis = Convert.ToDecimal(xTotalN.GetElementsByTagName("vPIS")[0].InnerText.ToString().Replace(".", ",")); objIssqntot.Vcofins = Convert.ToDecimal(xTotalN.GetElementsByTagName("vCONFIS")[0].InnerText.ToString().Replace(".", ",")); objTotal.belIssqntot = objIssqntot; break; } case "retTrib": { xTotalN.LoadXml(xDoc.GetElementsByTagName("retTrib")[0].OuterXml); belRetTrib objRettrib = new belRetTrib(); objRettrib.Vretpis = Convert.ToDecimal(xTotalN.GetElementsByTagName("vRetPIS")[0].InnerText.ToString().Replace(".", ",")); objRettrib.Vretcofins = Convert.ToDecimal(xTotalN.GetElementsByTagName("vRetCOFINS")[0].InnerText.ToString().Replace(".", ",")); objRettrib.Vretcsll = Convert.ToDecimal(xTotalN.GetElementsByTagName("vRetCSLL")[0].InnerText.ToString().Replace(".", ",")); objRettrib.Vbcirrf = Convert.ToDecimal(xTotalN.GetElementsByTagName("vBCIRRF")[0].InnerText.ToString().Replace(".", ",")); objRettrib.Virrf = Convert.ToDecimal(xTotalN.GetElementsByTagName("vIRRF")[0].InnerText.ToString().Replace(".", ",")); objRettrib.Vbcretprev = Convert.ToDecimal(xTotalN.GetElementsByTagName("vBCRetPrev")[0].InnerText.ToString().Replace(".", ",")); objRettrib.Vretprev = Convert.ToDecimal(xTotalN.GetElementsByTagName("vRetPrev")[0].InnerText.ToString().Replace(".", ",")); objTotal.belRetTrib = objRettrib; break; } } } catch (Exception ex) { throw new Exception(string.Format("Problemas lendo a Tag Total, Erro.: {0}", ex.Message)); } return objTotal; }
public belTotal BuscaTotais(string sEmp, string sNF, belDest objdest) { //belGerarXML BuscaConexao = new belGerarXML(); //FbConnection Conn = BuscaConexao.Conn; belTotal objtot = new belTotal(); try { //Conn.Open(); //Claudinei - o.s. 24352 - 09/04/2010 string sStImpICMS_Em_Subst_NF = BuscaSTICMSEMSUBSTNF(sEmp, sNF, Conn); //Fim - Claudinei - o.s. 24352 - 09/04/2010 string nm_Cliente = string.Empty; using (FbCommand cmd = new FbCommand("select control.cd_conteud from control where control.cd_nivel = '0016'", Conn)) { nm_Cliente = Convert.ToString(cmd.ExecuteScalar()).Trim(); } StringBuilder sSql = new StringBuilder(); //Campos do Select sSql.Append("Select "); sSql.Append("First 1 "); if ((nm_Cliente == "PAVAX") && (objdest.Uf.Equals("EX"))) // DIEGO - OS_24730 { sSql.Append("coalesce(nf.vl_toticms_ii,0) vICMS, "); sSql.Append("coalesce(nf.vl_baseicms_ii,0) vBC, "); } // DIEGO - OS_24730 - 11/08/2010 else { if ((pbIndustri) || (nm_Cliente == "CMENDES")) { if (sStImpICMS_Em_Subst_NF == "S") { sSql.Append("(coalesce(nf.vl_baseicm,0) + coalesce(nf.VL_BICMPROPRIO_SUBST,0)) vBC, "); } else { sSql.Append("coalesce(nf.vl_baseicm,0) vBC, "); } } if (sStImpICMS_Em_Subst_NF == "S") { sSql.Append("(COALESCE(nf.vl_toticms,0) + COALESCE(NF.VL_TICMPROPRIO_SUBST,0)) vICMS, "); //Claudinei - o.s. 24200 - 01/03/2010 sSql.Append("(coalesce(nf.vl_baseicm,0) + coalesce(nf.VL_BICMPROPRIO_SUBST,0)) vBC, "); } else { sSql.Append("COALESCE(nf.vl_toticms,0) vICMS, "); sSql.Append("coalesce(nf.vl_baseicm,0) vBC, "); } } sSql.Append("nf.vl_bicmssu vBCST, "); sSql.Append("nf.vl_icmssub vST, "); if (pbIndustri) { if (sTipoIndustrializacao == "1") { if (objdest.Uf != "EX") { sSql.Append("(select sum(movitem.vl_totbruto) from movitem inner join opereve on (opereve.cd_oper = movitem.cd_oper) where ((movitem.cd_empresa = nf.cd_empresa) and (movitem.cd_nfseq = nf.cd_nfseq)) and (opereve.ST_ESTTERC <> 'S')) vProd, "); } else { sSql.Append("((select sum(movitem.vl_totbruto) from movitem inner join opereve on (opereve.cd_oper = movitem.cd_oper) where ((movitem.cd_empresa = nf.cd_empresa) and (movitem.cd_nfseq = nf.cd_nfseq)) and (opereve.ST_ESTTERC <> 'S'))+(coalesce( nf.vl_impimport,0))) vProd, "); } } else { if (objdest.Uf != "EX") { sSql.Append("coalesce(nf.vl_totprod, 0) vProd, "); } else { sSql.Append("(coalesce(nf.vl_totprod, 0)+(coalesce( nf.vl_impimport,0))) vProd, "); } } } else { if (nm_Cliente != "NAVE_THERM") { if (sTipoIndustrializacao == "1") { if (objdest.Uf != "EX") { sSql.Append(" case when coalesce(opereve.st_hefrete, 'N') = 'N' then "); sSql.Append(" (nf.vl_totprod + nf.vl_desccomer + nf.vl_servico) "); sSql.Append("else "); sSql.Append("(nf.vl_totprod + nf.vl_desccomer ) "); sSql.Append("end vProd,"); } else { sSql.Append(" case when coalesce(opereve.st_hefrete, 'N') = 'N' then "); sSql.Append(" (nf.vl_totprod + nf.vl_desccomer + nf.vl_servico + coalesce( nf.vl_impimport,0)) "); sSql.Append("else "); sSql.Append("(nf.vl_totprod + nf.vl_desccomer + coalesce( nf.vl_impimport,0)) "); sSql.Append("end vProd,"); } } else { if (objdest.Uf != "EX") { sSql.Append("coalesce(nf.vl_totprod, 0) vProd,"); } else { sSql.Append("(coalesce(nf.vl_totprod, 0)+coalesce( nf.vl_impimport,0)) vProd,"); } } } else { sSql.Append("(nf.vl_totprod + nf.vl_servico) vProd, "); if (sStImpICMS_Em_Subst_NF == "S") { if (objdest.Uf != "EX") { sSql.Append("(coalesce(nf.vl_baseicm,0) + coalesce(nf.VL_BICMPROPRIO_SUBST,0)) vBC, "); } else { sSql.Append("(coalesce(nf.vl_baseicm,0) + coalesce(nf.VL_BICMPROPRIO_SUBST,0) + coalesce( nf.vl_impimport,0)) vBC, "); } } else { if (objdest.Uf != "EX") { sSql.Append("coalesce(nf.vl_baseicm,0) vBC, "); } else { sSql.Append("(coalesce(nf.vl_baseicm,0)+ (coalesce( nf.vl_impimport,0)) vBC, "); } } } } sSql.Append("nf.vl_frete vFrete, "); sSql.Append("nf.vl_seg vSeg, "); bool bNfSuframa = VerificaNotaComSuframa(sEmp, sNF, Conn); sSql.Append(bNfSuframa == false ? "nf.vl_desccomer vDesc, " : "(coalesce(nf.vl_cofins_suframa,0)+ coalesce(nf.vl_pis_suframa,0)+ coalesce(nf.vl_desc_suframa,0)) vDesc, "); sSql.Append("nf.vl_impimport vII, "); sSql.Append("nf.vl_totipi vIPI, "); sSql.Append("nf.vl_pis vPIS, "); sSql.Append("nf.vl_cofins vCOFINS, "); sSql.Append("nf.vl_outras vOutro, "); if (sTipoIndustrializacao == "1") { sSql.Append("(select sum(movitem.vl_totbruto) from movitem where ((movitem.cd_empresa = nf.cd_empresa) and (movitem.cd_nfseq = nf.cd_nfseq))) + coalesce(nf.vl_frete,0) vNF, "); //Claudinei - 24162 - 22/02/2010 } else { sSql.Append("nf.vl_totnf vNF, "); } sSql.Append("coalesce(tpdoc.st_pauta,'N') st_pauta "); sSql.Append(", nf.vl_servico vServ "); sSql.Append(", nf.vl_iss Viss "); sSql.Append(", nf.vl_pis_serv PisIss "); sSql.Append(", nf.vl_cofins_serv cofinsIss "); //Tabela sSql.Append("From NF "); //Relacionamentos sSql.Append("inner join movitem on (movitem.cd_empresa = nf.cd_empresa) and (movitem.cd_nfseq = nf.cd_nfseq) "); sSql.Append("inner join opereve on (opereve.cd_oper = movitem.cd_oper)"); sSql.Append("inner join tpdoc on (tpdoc.cd_tipodoc = nf.cd_tipodoc) "); //Where sSql.Append("Where "); sSql.Append("(NF.cd_empresa ='"); sSql.Append(sEmp); sSql.Append("')"); sSql.Append(" and "); sSql.Append("(nf.cd_nfseq = '"); sSql.Append(sNF); sSql.Append("') "); FbCommand cmdTotais = new FbCommand(sSql.ToString(), Conn); cmdTotais.ExecuteNonQuery(); FbDataReader drTotais = cmdTotais.ExecuteReader(); drTotais.Read(); if ((pbIndustri) && (nm_Cliente != "TECNOZ")) { dTotbaseICMS = Math.Round(Convert.ToDecimal(drTotais["vBCST"].ToString()), 2); //Claudinei - o.s. 24248 - 26/03/2010 } if ((pbIndustri) && (nm_Cliente == "MOGPLAST")) { dTotbaseICMS = Math.Round(Convert.ToDecimal(drTotais["vBC"].ToString()), 2); //Claudinei - o.s. 24248 - 26/03/2010 } belIcmstot objicmstot = new belIcmstot(); dTotbaseICMS = Math.Round(Convert.ToDecimal(drTotais["vBC"].ToString()), 2); //Claudinei - o.s. 24248 - 26/03/2010 objicmstot.Vbc = Math.Round(Convert.ToDecimal(dTotbaseICMS.ToString()), 2); //Claudinei - o.s. 24248 - 26/03/2010 dTotValorICMS = Math.Round(Convert.ToDecimal(drTotais["vICMS"].ToString()), 2); //Claudinei - o.s. 24248 - 26/03/2010 objicmstot.Vicms = Math.Round(Convert.ToDecimal(dTotValorICMS.ToString()), 2); //Claudinei - o.s. 24248 - 26/03/2010 if (!drTotais["vBCST"].Equals(string.Empty)) { decimal dvBCST = Math.Round(Convert.ToDecimal(drTotais["vBCST"].ToString()), 2); //Claudinei - o.s. 24248 - 26/03/2010 objicmstot.Vbcst = dvBCST; } if (!drTotais["vST"].Equals(string.Empty)) { decimal dvST = Math.Round(Convert.ToDecimal(drTotais["vST"].ToString()), 2); //Claudinei - o.s. 24248 - 26/03/2010 objicmstot.Vst = dvST; } if (drTotais["vProd"].ToString() != "") { decimal dvProd = Math.Round(Convert.ToDecimal(drTotais["vProd"].ToString()), 2); //Claudinei - o.s. 24248 - 26/03/2010 objicmstot.Vprod = dvProd; } else { objicmstot.Vprod = 0; } if (!drTotais["vFrete"].Equals(string.Empty)) { decimal dvFrete = Math.Round(Convert.ToDecimal(drTotais["vFrete"].ToString()), 2); //Claudinei - o.s. 24248 - 26/03/2010 objicmstot.Vfrete = dvFrete; } if (!drTotais["vSeg"].Equals(string.Empty)) { decimal dvSeg = Math.Round(Convert.ToDecimal(drTotais["vSeg"].ToString()), 2); //Claudinei - o.s. 24248 - 26/03/2010 objicmstot.Vseg = dvSeg; } decimal dvDesc = Math.Round(Convert.ToDecimal(drTotais["vDesc"].ToString()), 2); //Claudinei - o.s. 24248 - 26/03/2010 objicmstot.Vdesc = dvDesc; if (!drTotais["vII"].Equals(string.Empty)) { decimal dvII = Math.Round(Convert.ToDecimal(drTotais["vII"].ToString()), 2); //Claudinei - o.s. 24248 - 26/03/2010 objicmstot.Vii = dvII; } if (!drTotais["vIPI"].Equals(string.Empty)) { decimal dvIPI = Math.Round(Convert.ToDecimal(drTotais["vIPI"].ToString()), 2); //Claudinei - o.s. 24248 - 26/03/2010 objicmstot.Vipi = dvIPI; } if (sTipoIndustrializacao == "2") { dTotPis = Math.Round(Convert.ToDecimal(drTotais["vPIS"].ToString()), 2); //Claudinei - o.s. 24248 - 26/03/2010 } objicmstot.Vpis = Math.Round(Convert.ToDecimal(drTotais["vPIS"].ToString()), 2); //Claudinei - o.s. 24292 - 24/03/2010 //Claudinei - o.s. 24248 - 26/03/2010 if (sTipoIndustrializacao == "2") { dTotCofins = Math.Round(Convert.ToDecimal(drTotais["vCOFINS"].ToString()), 2); //Claudinei - o.s. 24248 - 26/03/2010 } objicmstot.Vcofins = Math.Round(Convert.ToDecimal(dTotCofins.ToString()), 2); //Claudinei - o.s. 24248 - 26/03/2010 if (!drTotais["vOutro"].Equals(string.Empty)) { decimal dvOutro = Math.Round(Convert.ToDecimal(drTotais["vOutro"].ToString()), 2); //Claudinei - o.s. 24248 - 26/03/2010 objicmstot.Voutro = dvOutro; } if (!drTotais["vNF"].Equals(string.Empty)) { decimal dvNF = Math.Round(Convert.ToDecimal(drTotais["vNF"].ToString()), 2); //Claudinei - o.s. 24248 - 26/03/2010 objicmstot.Vnf = dvNF; } objtot.belIcmstot = objicmstot; if (sTipoIndustrializacao == "2") { dTotServ = Math.Round(Convert.ToDecimal(drTotais["vServ"].ToString()), 2); //Claudinei - o.s. 24248 - 26/03/2010 } if (dTotServ != 0) { belIssqntot objisstot = new belIssqntot(); if (dTotServ != 0) { objisstot.Vserv = Math.Round(Convert.ToDecimal(dTotServ.ToString()), 2); //Claudinei - o.s. 24248 - 26/03/2010 } if (sTipoIndustrializacao == "2") { dTotBCISS = Math.Round(Convert.ToDecimal(drTotais["vServ"].ToString()), 2); //Claudinei - o.s. 24248 - 26/03/2010 } if (dTotBCISS != 0) { objisstot.Vbc = Math.Round(Convert.ToDecimal(dTotBCISS.ToString()), 2); //Claudinei - o.s. 24248 - 26/03/2010 } if (sTipoIndustrializacao == "2") { dTotISS = Math.Round(Convert.ToDecimal(drTotais["Viss"].ToString()), 2); //Claudinei - o.s. 24248 - 26/03/2010 } if (dTotISS != 0) { objisstot.Viss = Math.Round(Convert.ToDecimal(dTotISS.ToString()), 2); //Claudinei - o.s. 24248 - 26/03/2010 } if (sTipoIndustrializacao == "2") { dTotPisISS = Math.Round(Convert.ToDecimal(drTotais["PisIss"].ToString()), 2); //Claudinei - o.s. 24248 - 26/03/2010 } if (dTotPisISS != 0) { objisstot.Vpis = Math.Round(Convert.ToDecimal(dTotPisISS.ToString()), 2); //Claudinei - o.s. 24248 - 26/03/2010 } if (sTipoIndustrializacao == "2") { dTotCofinsISS = Math.Round(Convert.ToDecimal(drTotais["cofinsIss"].ToString()), 2); //Claudinei - o.s. 24248 - 26/03/2010 } if (dTotCofinsISS != 0) { objisstot.Vcofins = Math.Round(Convert.ToDecimal(dTotCofinsISS.ToString()), 2); //Claudinei - o.s. 24248 - 26/03/2010 } objtot.belIssqntot = objisstot; } } catch (Exception Ex) { sExecao = " - Problemas nos Totais da Nota"; throw new Exception(Ex.Message + sExecao); } finally { //Conn.Close(); } return objtot; }
private void Gravar() { List<object> lObj = new List<object>(); try { #region IDE objide = new belIde(); objide.Cuf = Convert.ToString(cbxUF.SelectedValue).Trim(); objide.Cnf = txtSeq.Text; objide.Natop = txtNatOp.Text; objide.Indpag = Convert.ToString(cbxIndPag.SelectedIndex).Trim(); objide.Mod = txtMod.Text.Trim(); objide.Serie = txtSerie.Text.Trim(); objide.Nnf = txtNNF.Text.Trim(); objide.Demi = Convert.ToDateTime(mtbDEmi.Text); objide.Dsaient = Convert.ToDateTime(mtbDSaiEnt.Text); objide.Tpnf = Convert.ToString(cbxTpNF.SelectedIndex); objide.Cmunfg = txtCMunFG.Text.Trim(); objide.Tpimp = Convert.ToString((int)cbxtpImp.SelectedIndex + 1); objide.Tpemis = Convert.ToString((int)cbcxTpEmis.SelectedIndex + 1); objide.Cdv = txtCDV.Text.Trim(); objide.Tpamb = Convert.ToString((int)cbxTpAmb.SelectedIndex + 1); objide.Finnfe = Convert.ToString((int)cbxFinNFe.SelectedIndex + 1); objide.Procemi = txtProcEmi.Text.Trim(); objide.Verproc = txtVerProc.Text.Trim(); if (belNFrefBindingSource.Count > 0) // 25360 { List<belNFref> lObjNFref = new List<belNFref>(); for (int i = 0; i < belNFrefBindingSource.Count; i++) { lObjNFref.Add((belNFref)belNFrefBindingSource[i]); if (lObjNFref[i].cUF != null) { if (!HLP.Util.Util.IsNumeric(lObjNFref[i].cUF)) { belUF objuf = new belUF(); lObjNFref[i].cUF = objuf.RetornaCUF((lObjNFref[i].cUF)); lObjNFref[i].CNPJ = (lObjNFref[i].CNPJ).Replace(",", "").Replace("/", "").Replace("-", ""); lObjNFref[i].nNF = (Convert.ToInt32(lObjNFref[i].nNF)).ToString(); } } } objide.belNFref = lObjNFref; } objide.HSaiEnt = dtpHSaiEnt.Value; //NFe_2.0 lObj.Add(objide); #endregion #region Emitente belEmit objemit = new belEmit(); if (cbxPessoaEmit.SelectedIndex == 0) { objemit.Cpf = mtbCpfCnpjEmit.Text; } else { objemit.Cnpj = mtbCpfCnpjEmit.Text; } objemit.Xnome = txtXNomeEmit.Text.Trim(); objemit.Xfant = txtXFantEmit.Text.Trim(); if (txtIEEmit.Text != "") { objemit.Ie = txtIEEmit.Text.Trim(); } if (txtIESTEmit.Text != "") { objemit.Iest = txtIESTEmit.Text.Trim(); } if (txtIM.Text != "") { objemit.Im = txtIM.Text.Trim(); } if (txtCNAE.Text != "") { objemit.Cnae = txtCNAE.Text; } //Endereço objemit.Xlgr = txtEnderEmitXlgr.Text.Trim(); objemit.Nro = txtEnderEmitNum.Text.Trim(); if (txtEnderEmitCompl.Text != "") { objemit.Xcpl = txtEnderEmitCompl.Text.Trim(); } objemit.Xbairro = txtEnderEmitXbairro.Text.Trim(); objemit.Cmun = txtEnderEmitCmun.Text.Trim(); objemit.Xmun = txtEnderEmitXmun.Text.Trim(); objemit.Uf = txtEnderEmitUF.Text.Trim(); objemit.Cpais = txtEnderEmitCpais.Text.Trim(); objemit.Xpais = txtEnderEmitXpais.Text.Trim(); objemit.Cep = mtbEnderEmitCep.Text.Trim(); objemit.Fone = mtbEnderEmitFone.Text.Trim(); switch (cmbCRT.SelectedIndex) // NFe_2.0 { case 0: objemit.CRT = 1; break; case 1: objemit.CRT = 2; break; case 2: objemit.CRT = 3; break; } //Fim - Endereço lObj.Add(objemit); #endregion #region Destinatário belDest objdest = new belDest(); if (mtbCpfCnpjDest.Mask.Equals("00.000.000/0000-00") || mtbCpfCnpjDest.Text.ToString().ToUpper().Equals("EXTERIOR")) { objdest.Cnpj = mtbCpfCnpjDest.Text.Trim(); } else { objdest.Cpf = mtbCpfCnpjDest.Text.Trim(); } objdest.Xnome = (belStatic.TpAmb == 2 ? "NF-E EMITIDA EM AMBIENTE DE HOMOLOGACAO - SEM VALOR FISCAL" : txtXnomeDest.Text.Trim()); objdest.Ie = txtIEDest.Text.Trim();// (belStatic.tpAmb == 2 ? "" : txtIEDest.Text.Trim()); if (txtISUFDest.Text != "") { objdest.Isuf = txtISUFDest.Text.Trim(); } //Endereço objdest.Xlgr = txtEnderDestXlgr.Text.Trim(); objdest.Nro = txtEnderDestNro.Text.Trim(); objdest.Xcpl = txtEnderDestCpl.Text.Trim(); //OS_26347 objdest.Xbairro = txtEnderDestXbairro.Text.Trim(); objdest.Cmun = txtEnderDestCmun.Text.Trim(); objdest.Xmun = txtEnderDestXmun.Text.Trim(); objdest.Uf = txtEnderDestUF.Text.Trim(); objdest.Cpais = txtEnderDestCpais.Text.Trim(); objdest.Xpais = txtEnderDestXpais.Text.Trim(); objdest.Cep = mtbEnderDestCEP.Text.Trim(); if (mtbEnderDestFone.Text.Trim() != "") { objdest.Fone = mtbEnderDestFone.Text.Trim(); } objdest.email = txtEmaildest.Text.Trim(); // NFe_2.0 //Fim - Endereço lObj.Add(objdest); #endregion #region Endereço de Entrega belEndEnt objendent = new belEndEnt(); if (mtbEndEntCNPJ.Text != "") { objendent.Cnpj = mtbEndEntCNPJ.Text.Trim(); objendent.Xlgr = txtEndEntXlgr.Text.Trim(); objendent.Nro = txtEndEntNro.Text.Trim(); objendent.Cmun = txtEndEntCmun.Text.Trim(); objendent.Xmun = txtEndEntXmun.Text.Trim(); objendent.Uf = txtEndEntUF.Text.Trim(); objendent.Xbairro = txtEndEntXbairro.Text.Trim(); //0S_25185 objendent.Xcpl = txtEndEntCpl.Text.Trim();//0S_25185 } lObj.Add(objendent); #endregion #region Detatalhes List<belDet> lObjDet = new List<belDet>(); for (int i = 0; i < dgvDet.RowCount; i++) { belDet objDet = new belDet(); objDet.Nitem = i + 1; #region Prod belProd objprod = new belProd(); objprod.Cean = Convert.ToString(dgvDet["Cean", i].Value); objprod.Ceantrib = Convert.ToString(dgvDet["Ceantrib", i].Value); objprod.Cfop = Convert.ToString(dgvDet["Cfop", i].Value); objprod.Cprod = Convert.ToString(dgvDet["Cprod", i].Value); if (dgvDet["Extipi", i].Value != null) { objprod.Extipi = Convert.ToString(dgvDet["Extipi", i].Value); } if (dgvDet["Genero", i].Value != null) { objprod.Genero = Convert.ToString(dgvDet["Genero", i].Value); } if (Convert.ToString(dgvDet["NCM", i].Value) != "") { objprod.Ncm = Convert.ToString(dgvDet["NCM", i].Value); } objprod.Qcom = Convert.ToDecimal(dgvDet["Qcom", i].Value); objprod.Qtrib = Convert.ToDecimal(dgvDet["Qtrib", i].Value); objprod.Ucom = Convert.ToString(dgvDet["Ucom", i].Value); objprod.Utrib = Convert.ToString(dgvDet["Utrib", i].Value); objprod.Vdesc = Convert.ToDecimal(dgvDet["Vdesc", i].Value); objprod.Vfrete = Convert.ToDecimal(dgvDet["Vfrete", i].Value); objprod.Vprod = Convert.ToDecimal(dgvDet["Vprod", i].Value); objprod.Vseg = Convert.ToDecimal(dgvDet["Vseg", i].Value); objprod.Vuncom = Convert.ToDecimal(dgvDet["Vuncom", i].Value); objprod.Vuntrib = Convert.ToDecimal(dgvDet["Vuntrib", i].Value); objprod.Xprod = Convert.ToString(dgvDet["Xprod", i].Value); objprod.VOutro = Convert.ToDecimal(dgvDet["vOutro", i].Value);// NFe_2.0 objprod.IndTot = Convert.ToInt16(dgvDet["indTot", i].Value); // NFe_2.0 objprod.XPed = dgvDet["xPed", i].Value.ToString(); objprod.NItemPed = dgvDet["nItemPed", i].Value.ToString(); objDet.belProd = objprod; objDet.belProd.belDI = ((List<belDet>)lObjTotNotas[notAtual - 1][4])[i].belProd.belDI; #endregion #region Imposto belImposto objimposto = new belImposto(); #region ICMS belIcms objicms = new belIcms(); if (!HLP.Util.Util.VerificaNovaST(Convert.ToString(dgvDet["CstIcms", i].Value))) { #region cst_antigas switch (Convert.ToString(dgvDet["CstIcms", i].Value)) { case "00": { belIcms00 obj00 = new belIcms00(); obj00.Cst = Convert.ToString(dgvDet["CstIcms", i].Value); obj00.Modbc = Convert.ToString(dgvDet["ModbcIcms", i].Value); obj00.Orig = Convert.ToString(dgvDet["OrigIcms", i].Value); obj00.Picms = Convert.ToDecimal(dgvDet["PicmsIcms", i].Value); obj00.Vbc = Convert.ToDecimal(dgvDet["VbcIcms", i].Value); obj00.Vicms = Convert.ToDecimal(dgvDet["VicmsIcms", i].Value); objicms.belIcms00 = obj00; break; } case "10": { belIcms10 obj10 = new belIcms10(); obj10.Cst = Convert.ToString(dgvDet["CstIcms", i].Value); obj10.Modbc = Convert.ToString(dgvDet["ModbcIcms", i].Value); obj10.Modbcst = Convert.ToDecimal(dgvDet["ModbcstIcms", i].Value); obj10.Orig = Convert.ToString(dgvDet["OrigIcms", i].Value); obj10.Picms = Convert.ToDecimal(dgvDet["PicmsIcms", i].Value); obj10.Picmsst = Convert.ToDecimal(dgvDet["PicmsstIcms", i].Value); obj10.Pmvast = Convert.ToDecimal(dgvDet["PmvastIcms", i].Value); obj10.Predbcst = Convert.ToDecimal(dgvDet["PredbcstIcms", i].Value); obj10.Vbc = Convert.ToDecimal(dgvDet["VbcIcms", i].Value); obj10.Vbcst = Convert.ToDecimal(dgvDet["VbcstIcms", i].Value); obj10.Vicms = Convert.ToDecimal(dgvDet["VicmsIcms", i].Value); obj10.Vicmsst = Convert.ToDecimal(dgvDet["VicmsstIcms", i].Value); objicms.belIcms10 = obj10; break; } case "20": { belIcms20 obj20 = new belIcms20(); obj20.Cst = Convert.ToString(dgvDet["CstIcms", i].Value); obj20.Modbc = Convert.ToString(dgvDet["ModbcIcms", i].Value); obj20.Orig = Convert.ToString(dgvDet["OrigIcms", i].Value); obj20.Picms = Convert.ToDecimal(dgvDet["PicmsIcms", i].Value); obj20.Predbc = Convert.ToDecimal(dgvDet["PredbcIcms", i].Value); obj20.Vbc = Convert.ToDecimal(dgvDet["VbcIcms", i].Value); obj20.Vicms = Convert.ToDecimal(dgvDet["VicmsIcms", i].Value); objicms.belIcms20 = obj20; break; } case "30": { belIcms30 obj30 = new belIcms30(); obj30.Cst = Convert.ToString(dgvDet["CstIcms", i].Value); obj30.Modbcst = Convert.ToDecimal(dgvDet["ModbcstIcms", i].Value); obj30.Orig = Convert.ToString(dgvDet["OrigIcms", i].Value); obj30.Picmsst = Convert.ToDecimal(dgvDet["PicmsstIcms", i].Value); obj30.Pmvast = Convert.ToDecimal(dgvDet["PmvastIcms", i].Value); obj30.Predbcst = Convert.ToDecimal(dgvDet["PredbcstIcms", i].Value); obj30.Vbcst = Convert.ToDecimal(dgvDet["VbcstIcms", i].Value); obj30.Vicmsst = Convert.ToDecimal(dgvDet["VicmsIcms", i].Value); objicms.belIcms30 = obj30; break; } case "40": { belIcms40 obj40 = new belIcms40(); obj40.Cst = Convert.ToString(dgvDet["CstIcms", i].Value); obj40.Orig = Convert.ToString(dgvDet["OrigIcms", i].Value); obj40.Vicms = Convert.ToDecimal(dgvDet["VicmsIcms", i].Value); //NFe_2.0 obj40.motDesICMS = Convert.ToInt16(dgvDet["motDesICMS", i].Value);//NFe_2.0 objicms.belIcms40 = obj40; break; } case "41": { belIcms40 obj40 = new belIcms40(); obj40.Cst = Convert.ToString(dgvDet["CstIcms", i].Value); obj40.Orig = Convert.ToString(dgvDet["OrigIcms", i].Value); obj40.Vicms = Convert.ToDecimal(dgvDet["VicmsIcms", i].Value); //NFe_2.0 obj40.motDesICMS = Convert.ToInt16(dgvDet["motDesICMS", i].Value);//NFe_2.0 objicms.belIcms40 = obj40; break; } case "50": { belIcms40 obj40 = new belIcms40(); obj40.Cst = Convert.ToString(dgvDet["CstIcms", i].Value); obj40.Orig = Convert.ToString(dgvDet["OrigIcms", i].Value); obj40.Vicms = Convert.ToDecimal(dgvDet["VicmsIcms", i].Value); //NFe_2.0 obj40.motDesICMS = Convert.ToInt16(dgvDet["motDesICMS", i].Value);//NFe_2.0 objicms.belIcms40 = obj40; break; } case "51": { belIcms51 obj51 = new belIcms51(); obj51.Cst = Convert.ToString(dgvDet["CstIcms", i].Value); obj51.Modbc = Convert.ToString(dgvDet["ModbcIcms", i].Value); obj51.Orig = Convert.ToString(dgvDet["OrigIcms", i].Value); obj51.Picms = Convert.ToDecimal(dgvDet["PicmsIcms", i].Value); obj51.Predbc = Convert.ToDecimal(dgvDet["PredbcIcms", i].Value); obj51.Vbc = Convert.ToDecimal(dgvDet["VbcIcms", i].Value); obj51.Vicms = Convert.ToDecimal(dgvDet["VicmsIcms", i].Value); objicms.belIcms51 = obj51; break; } //Fim - Danner - o.s. 24189 - 26/02/2010 case "60": { belIcms60 obj60 = new belIcms60(); obj60.Cst = Convert.ToString(dgvDet["CstIcms", i].Value); obj60.Orig = Convert.ToString(dgvDet["OrigIcms", i].Value); obj60.Vbcst = Convert.ToDecimal(dgvDet["VbcstIcms", i].Value); obj60.Vicmsst = Convert.ToDecimal(dgvDet["VicmsstIcms", i].Value); objicms.belIcms60 = obj60; break; } case "70": { belIcms70 obj70 = new belIcms70(); obj70.Cst = Convert.ToString(dgvDet["CstIcms", i].Value); obj70.Modbc = Convert.ToString(dgvDet["ModbcIcms", i].Value); obj70.Modbcst = Convert.ToDecimal(dgvDet["ModbcstIcms", i].Value); obj70.Orig = Convert.ToString(dgvDet["OrigIcms", i].Value); obj70.Picms = Convert.ToDecimal(dgvDet["PicmsIcms", i].Value); obj70.Picmsst = Convert.ToDecimal(dgvDet["PicmsstIcms", i].Value); obj70.Pmvast = Convert.ToDecimal(dgvDet["PmvastIcms", i].Value); obj70.Predbc = Convert.ToDecimal(dgvDet["PredbcIcms", i].Value); obj70.Predbcst = Convert.ToDecimal(dgvDet["PredbcstIcms", i].Value); obj70.Vbc = Convert.ToDecimal(dgvDet["VbcIcms", i].Value); obj70.Vbcst = Convert.ToDecimal(dgvDet["VbcstIcms", i].Value); obj70.Vicms = Convert.ToDecimal(dgvDet["VicmsIcms", i].Value); obj70.Vicmsst = Convert.ToDecimal(dgvDet["VicmsstIcms", i].Value); objicms.belIcms70 = obj70; break; } case "90": { belIcms90 obj90 = new belIcms90(); obj90.Cst = Convert.ToString(dgvDet["CstIcms", i].Value); obj90.Modbc = Convert.ToString(dgvDet["ModbcIcms", i].Value); obj90.Modbcst = Convert.ToDecimal(dgvDet["ModbcstIcms", i].Value); obj90.Orig = Convert.ToString(dgvDet["OrigIcms", i].Value); obj90.Picms = Convert.ToDecimal(dgvDet["PicmsIcms", i].Value); obj90.Picmsst = Convert.ToDecimal(dgvDet["PicmsstIcms", i].Value); obj90.Pmvast = Convert.ToDecimal(dgvDet["PmvastIcms", i].Value); obj90.Predbc = Convert.ToDecimal(dgvDet["PredbcIcms", i].Value); obj90.Predbcst = Convert.ToDecimal(dgvDet["PredbcstIcms", i].Value); obj90.Vbc = Convert.ToDecimal(dgvDet["VbcIcms", i].Value); obj90.Vbcst = Convert.ToDecimal(dgvDet["VbcstIcms", i].Value); obj90.Vicms = Convert.ToDecimal(dgvDet["VicmsIcms", i].Value); obj90.Vicmsst = Convert.ToDecimal(dgvDet["VicmsstIcms", i].Value); objicms.belIcms90 = obj90; break; } } #endregion } else { #region cst_novas switch (HLP.Util.Util.RetornaSTnovaAserUsada(Convert.ToString(dgvDet["CstIcms", i].Value))) { case "101": { belICMSSN101 obj101 = new belICMSSN101(); obj101.CSOSN = Convert.ToString(dgvDet["CstIcms", i].Value); obj101.orig = Convert.ToString(dgvDet["OrigIcms", i].Value); obj101.pCredSN = Convert.ToDecimal(dgvDet["pCredSN", i].Value); obj101.vCredICMSSN = Convert.ToDecimal(dgvDet["vCredICMSSN", i].Value); objicms.belICMSSN101 = obj101; break; } case "102": { belICMSSN102 obj102 = new belICMSSN102(); obj102.CSOSN = Convert.ToString(dgvDet["CstIcms", i].Value); obj102.orig = Convert.ToString(dgvDet["OrigIcms", i].Value); objicms.belICMSSN102 = obj102; break; } case "201": { belICMSSN201 obj201 = new belICMSSN201(); obj201.CSOSN = Convert.ToString(dgvDet["CstIcms", i].Value); obj201.orig = Convert.ToString(dgvDet["OrigIcms", i].Value); obj201.modBCST = Convert.ToInt32(dgvDet["ModbcstIcms", i].Value); obj201.pMVAST = Convert.ToDecimal(dgvDet["PmvastIcms", i].Value); obj201.pRedBCST = Convert.ToDecimal(dgvDet["PredbcstIcms", i].Value); obj201.vBCST = Convert.ToDecimal(dgvDet["VbcstIcms", i].Value); obj201.pICMSST = Convert.ToDecimal(dgvDet["PicmsstIcms", i].Value); obj201.vICMSST = Convert.ToDecimal(dgvDet["VicmsstIcms", i].Value); if (Convert.ToString(dgvDet["CstIcms", i].Value).Equals("101")) { obj201.pCredSN = Convert.ToDecimal(dgvDet["pCredSN", i].Value); obj201.vCredICMSSN = Convert.ToDecimal(dgvDet["vCredICMSSN", i].Value); } objicms.belICMSSN201 = obj201; break; } case "500": { belICMSSN500 obj500 = new belICMSSN500(); obj500.CSOSN = Convert.ToString(dgvDet["CstIcms", i].Value); obj500.orig = Convert.ToString(dgvDet["OrigIcms", i].Value); obj500.vBCSTRet = Convert.ToDecimal(dgvDet["VbcstIcms", i].Value); obj500.vICMSSTRet = Convert.ToDecimal(dgvDet["VicmsstIcms", i].Value); objicms.belICMSSN500 = obj500; break; } case "900": { belICMSSN900 obj900 = new belICMSSN900(); obj900.CSOSN = Convert.ToString(dgvDet["CstIcms", i].Value); obj900.orig = Convert.ToString(dgvDet["OrigIcms", i].Value); //obj900.modBC = Convert.ToInt32(dgvDet["ModbcIcms", i].Value); //obj900.vBC = Convert.ToDecimal(dgvDet["VbcIcms", i].Value); //obj900.pRedBC = Convert.ToDecimal(dgvDet["VicmsstIcms", i].Value); //obj900.pICMS = Convert.ToDecimal(dgvDet["PicmsIcms", i].Value); //obj900.vICMS = Convert.ToDecimal(dgvDet["VicmsIcms", i].Value); //obj900.modBCST = Convert.ToInt32(dgvDet["ModbcstIcms", i].Value); //obj900.pMVAST = Convert.ToDecimal(dgvDet["PmvastIcms", i].Value); //obj900.pRedBCST = Convert.ToDecimal(dgvDet["PredbcstIcms", i].Value); //obj900.vBCST = Convert.ToDecimal(dgvDet["VbcstIcms", i].Value); //obj900.pICMSST = Convert.ToDecimal(dgvDet["PicmsstIcms", i].Value); //obj900.vICMSST = Convert.ToDecimal(dgvDet["VicmsstIcms", i].Value); //obj900.vBCSTRet = Convert.ToDecimal(dgvDet["VbcstIcms", i].Value); //obj900.vICMSSTRet = Convert.ToDecimal(dgvDet["VicmsstIcms", i].Value); //obj900.pCredSN = Convert.ToDecimal(dgvDet["pCredSN", i].Value); //obj900.vCredICMSSN = Convert.ToDecimal(dgvDet["vCredICMSSN", i].Value); objicms.belICMSSN900 = obj900; break; } } #endregion } objimposto.belIcms = objicms; #endregion #region IPI belIpi objipi = new belIpi(); objipi.Cenq = Convert.ToString(dgvDet["CenqIpi", i].Value); string sCSTIPI = Convert.ToString(dgvDet["CstIpi", i].Value); if (sCSTIPI == "00" || sCSTIPI == "49" || sCSTIPI == "50" || sCSTIPI == "99") { belIpitrib objipitrib = new belIpitrib(); objipitrib.Cst = sCSTIPI; objipitrib.Pipi = Convert.ToDecimal(dgvDet["PipiTrib", i].Value); if (Convert.ToDecimal(dgvDet["QunidIpiTrib", i].Value) != 0) { objipitrib.Qunid = Convert.ToString(dgvDet["QunidIpiTrib", i].Value); } objipitrib.Vbc = Convert.ToDecimal(dgvDet["VbcIpiTrib", i].Value); objipitrib.Vipi = Convert.ToDecimal(dgvDet["VipiTrib", i].Value); //Claudinei - o.s. 24192 - 01/03/2010 objipitrib.Vunid = Convert.ToDecimal(dgvDet["VunidTrib", i].Value); objipi.belIpitrib = objipitrib; } else { belIpint objipint = new belIpint(); objipint.Cst = sCSTIPI; objipi.belIpint = objipint; } objimposto.belIpi = objipi; #endregion #region II //if (Convert.ToDecimal(dgvDet["VbcIi", i].Value) != 0) if (objdest.Uf.Equals("EX")) { belIi objii = new belIi(); objii.Vbc = Convert.ToDecimal(dgvDet["VbcIi", i].Value); objii.Vdespadu = Convert.ToDecimal(dgvDet["VdespaduIi", i].Value); objii.Vii = Convert.ToDecimal(dgvDet["Vii", i].Value); objii.Viof = Convert.ToDecimal(dgvDet["ViofIi", i].Value); objimposto.belIi = objii; } #endregion #region PIS belPis objpis = new belPis(); string sCstPis = Convert.ToString(dgvDet["CstPis", i].Value); if (sCstPis == "01" || sCstPis == "02") // aqui { belPisaliq objpisaliq = new belPisaliq(); objpisaliq.Cst = sCstPis; objpisaliq.Ppis = Convert.ToDecimal(dgvDet["Ppis", i].Value); objpisaliq.Vbc = Convert.ToDecimal(dgvDet["VbcPis", i].Value); objpisaliq.Vpis = Convert.ToDecimal(dgvDet["Vpis", i].Value); objpis.belPisaliq = objpisaliq; } else if (sCstPis == "03") { belPisqtde objpisqtde = new belPisqtde(); objpisqtde.Cst = sCstPis; objpisqtde.Valiqprod = Convert.ToDecimal(dgvDet["ValiqprodPis", i].Value); objpisqtde.Qbcprod = Convert.ToDecimal(dgvDet["QbcprodPis", i].Value); objpisqtde.Vpis = Convert.ToDecimal(dgvDet["Vpis", i].Value); objpis.belPisqtde = objpisqtde; } else if (sCstPis == "04" || sCstPis == "06" || sCstPis == "07" || sCstPis == "08" || sCstPis == "09") { belPisnt objpisnt = new belPisnt(); objpisnt.Cst = sCstPis; objpis.belPisnt = objpisnt; } else //if (sCstPis == "99") { belPisoutr objpisoutr = new belPisoutr(); objpisoutr.Cst = sCstPis; objpisoutr.Ppis = Convert.ToDecimal(dgvDet["Ppis", i].Value); objpisoutr.Vbc = Convert.ToDecimal(dgvDet["VbcPis", i].Value); if (Convert.ToDecimal(dgvDet["ValiqprodPis", i].Value) != 0) { objpisoutr.Valiqprod = Convert.ToDecimal(dgvDet["ValiqprodPis", i].Value); //Danner - o.s. 24167 - 22/01/2010 objpisoutr.Qbcprod = Convert.ToDecimal(dgvDet["QbcprodPis", i].Value); //Fim - Danner - o.s. 24167 - 22/01/2010 } //objpisoutr.Vbcprod = Convert.ToString(dgvDet["QbcprodPis", i].Value);//Danner - o.s. 24167 - 22/01/2010 objpisoutr.Vpis = Convert.ToDecimal(dgvDet["Vpis", i].Value); objpis.belPisoutr = objpisoutr; } objimposto.belPis = objpis; #endregion #region COFINS belCofins objcofins = new belCofins(); string sCstCofins = Convert.ToString(dgvDet["CstCofins", i].Value); if (sCstCofins == "01" || sCstCofins == "02") { belCofinsaliq objconfinsaliq = new belCofinsaliq(); objconfinsaliq.Cst = sCstCofins; objconfinsaliq.Pcofins = Convert.ToDecimal(dgvDet["Pcofins", i].Value); objconfinsaliq.Vbc = Convert.ToDecimal(dgvDet["VbcCofins", i].Value); objconfinsaliq.Vcofins = Convert.ToDecimal(dgvDet["Vconfins", i].Value); objcofins.belCofinsaliq = objconfinsaliq; } else if (sCstCofins == "03") { belCofinsqtde objcofinsqtde = new belCofinsqtde(); objcofinsqtde.Cst = sCstCofins; objcofinsqtde.Qbcprod = Convert.ToDecimal(dgvDet["QbcprodCofins", i].Value); objcofinsqtde.Valiqprod = Convert.ToDecimal(dgvDet["ValiqprodCofins", i].Value); objcofinsqtde.Vcofins = Convert.ToDecimal(dgvDet["Vconfins", i].Value); objcofins.belCofinsqtde = objcofinsqtde; } else if (sCstCofins == "04" || sCstCofins == "06" || sCstCofins == "07" || sCstCofins == "08" || sCstCofins == "09") { belCofinsnt objcofinsnt = new belCofinsnt(); objcofinsnt.Cst = sCstCofins; objcofins.belCofinsnt = objcofinsnt; } else //if (sCstCofins == "99") { belCofinsoutr objcofinsoutr = new belCofinsoutr(); objcofinsoutr.Cst = sCstCofins; objcofinsoutr.Pcofins = Convert.ToDecimal(dgvDet["Pcofins", i].Value); objcofinsoutr.Vbc = Convert.ToDecimal(dgvDet["VbcCofins", i].Value); objcofinsoutr.Qbcprod = Convert.ToDecimal(dgvDet["QbcprodCofins", i].Value); objcofinsoutr.Valiqprod = Convert.ToDecimal(dgvDet["ValiqprodCofins", i].Value); objcofinsoutr.Vcofins = Convert.ToDecimal(dgvDet["Vconfins", i].Value); objcofins.belCofinsoutr = objcofinsoutr; } objimposto.belCofins = objcofins; #endregion #region ISSQN if (Convert.ToDecimal(dgvDet["VbcIss", i].Value) != 0) { belIss objiss = new belIss(); objiss.Clistserv = Convert.ToInt64(dgvDet["ClistservIss", i].Value); objiss.Cmunfg = Convert.ToString(dgvDet["CmunfgIss", i].Value); objiss.Valiq = Convert.ToDecimal(dgvDet["ValiqIss", i].Value); objiss.Vbc = Convert.ToDecimal(dgvDet["VbcIss", i].Value); objiss.Vissqn = Convert.ToDecimal(dgvDet["VissqnIss", i].Value); objimposto.belIss = objiss; } #endregion objDet.belImposto = objimposto; #region InfadProd belInfadprod objinfadprod = new belInfadprod(); if (Convert.ToString(dgvDet["Infcpl", i].Value) != "") { objinfadprod.Infadprid = Convert.ToString(dgvDet["Infcpl", i].Value); objDet.belInfadprod = objinfadprod; } #endregion #endregion lObjDet.Add(objDet); } lObj.Add(lObjDet); #endregion #region Totais belTotal objtotal = new belTotal(); //Totais belIcmstot objIcmsTot = new belIcmstot(); objIcmsTot.Vbc = nudVBC.Value; objIcmsTot.Vicms = nudVICMS.Value; objIcmsTot.Vbcst = nudVBCICMSST.Value; objIcmsTot.Vst = nudVST.Value; objIcmsTot.Vprod = nudVProd.Value; //Danner - o.s. 24154 - 18/02/2010 objIcmsTot.Vfrete = nudVFrete.Value; //Fim - Danner - o.s. 24154 - 18/02/2010 objIcmsTot.Vseg = nudVSEG.Value; objIcmsTot.Vdesc = nudVDesc.Value; objIcmsTot.Vii = nudVII.Value; objIcmsTot.Vipi = nudVIPI.Value; objIcmsTot.Vpis = nudVPIS.Value; objIcmsTot.Vcofins = nudVCOFINS.Value; objIcmsTot.Voutro = nudVOutro.Value; objIcmsTot.Vnf = nudVNF.Value; objtotal.belIcmstot = objIcmsTot; //Fim - Totais //ISSQNtot if (flpISSNQ.Enabled != false) { belIssqntot objissqnTot = new belIssqntot(); objissqnTot.Vserv = nudVServ.Value; objissqnTot.Vbc = nudVBCISS.Value; objissqnTot.Viss = nudVISS.Value; objissqnTot.Vpis = nudVPISISS.Value; objissqnTot.Vcofins = nudVCOFINSISS.Value; objtotal.belIssqntot = objissqnTot; } //Fin - ISSQNtot; //retTrib if (flpRetTrib.Enabled != false) { belRetTrib objRetTrib = new belRetTrib(); objRetTrib.Vretpis = nudVPISRet.Value; objRetTrib.Vretcofins = nudVCOFINSRet.Value; objRetTrib.Vretcsll = nudVCSLLRet.Value; objRetTrib.Vbcretprev = nudVBCIRRFRet.Value; objRetTrib.Virrf = nudVIRRFRet.Value; objRetTrib.Vbcirrf = nudVBCIRRFRet.Value; objRetTrib.Vbcretprev = nudVBCRetPrev.Value; objRetTrib.Vretprev = nudVRetPrev.Value; objtotal.belRetTrib = objRetTrib; } lObj.Add(objtotal); //Fim - retTrib #endregion #region Transporte belTransp objtransp = new belTransp(); switch (cbxModFrete.SelectedIndex) //Nfe_2.0 { case 0: objtransp.Modfrete = "0"; break; case 1: objtransp.Modfrete = "1"; break; case 2: objtransp.Modfrete = "2"; break; case 3: objtransp.Modfrete = "9"; break; } //objtransp.Modfrete = Convert.ToString(cbxModFrete.SelectedIndex); //Transportadora belTransportadora objtransportadora = new belTransportadora(); if (cbxPessoaTranp.SelectedIndex == 1) { if (mtbCPJCNPJTransp.Text.Trim() != "") { objtransportadora.Cnpj = mtbCPJCNPJTransp.Text.Trim(); } } else { if (mtbCPJCNPJTransp.Text.Trim() != "") { objtransportadora.Cpf = mtbCPJCNPJTransp.Text.Trim(); } } if (txtXnomeTransp.Text.Trim() != "") { objtransportadora.Xnome = txtXnomeTransp.Text.Trim(); } if (txtIETransp.Text.Trim() != "") { objtransportadora.Ie = txtIETransp.Text.Trim(); } if (txtEnderTransp.Text.Trim() != "") { objtransportadora.Xender = txtEnderTransp.Text.Trim(); } if (txtUFTransp.Text.Trim() != "") { objtransportadora.Uf = txtUFTransp.Text.Trim(); } if (txtXmunTransp.Text.Trim() != "") { objtransportadora.Xmun = txtXmunTransp.Text.Trim(); } objtransp.belTransportadora = objtransportadora; //Fim - Transportadora //VeicTransp if (flpVeicTransp.Enabled != false) { belVeicTransp objVeicTrasnp = new belVeicTransp(); objVeicTrasnp.Placa = mtbPlacaVeicTransp.Text.Trim(); objVeicTrasnp.Uf = txtUFVeicTransp.Text.Trim(); //Danner - o.s. sem - 05/03/2010 if (txtRNTCVeicTransp.Text.Trim() != "") { objVeicTrasnp.Rntc = txtRNTCVeicTransp.Text.Trim(); } //Fim - Danner - o.s. sem - 05/03/2010 objtransp.belVeicTransp = objVeicTrasnp; } //Fim - VeicTransp //Reboque if (flpReboque.Enabled != false) { belReboque objReboque = new belReboque(); objReboque.Placa = mtbPlacaReboque.Text.Trim(); objReboque.Uf = txtUFReboque.Text.Trim(); objReboque.Rntc = txtRNTCReboque.Text.Trim(); objtransp.belReboque = objReboque; } //Fim - Reboque //RetTransp if (flpRetICMS.Enabled != false) { belRetTransp objRetTransp = new belRetTransp(); objRetTransp.Vbvret = nudVBCICMSTransp.Value; objRetTransp.Vserv = nudVServTransp.Value; objRetTransp.Picmsret = nudPICMSTRetTransp.Value; objRetTransp.Vicmsret = nudVICMSRet.Value; objRetTransp.Cmunfg = txtCmunFGTransp.Text.Trim(); objRetTransp.Cfop = txtCFOPTransp.Text.Trim(); objtransp.belRetTransp = objRetTransp; } //Fim - RetTransp if (flpVolumes.Enabled != false) { belVol objVol = new belVol(); objVol.Esp = txtEsp.Text.Trim(); objVol.Marca = txtMarca.Text.Trim(); //Danner - o.s. 24385 - 26/04/2010 if (txtNVol.Text != "") { objVol.Nvol = txtNVol.Text;//Danner - o.s. 24432 - 04/05/2010 } //Fim - Danner - o.s. 24385 - 26/04/2010 objVol.PesoB = nudPesoB.Value; objVol.PesoL = nudPesoL.Value; objVol.Qvol = nudQvol.Value; objtransp.belVol = objVol; } lObj.Add(objtransp); #endregion #region Cobrança belCobr objcobr = new belCobr(); belFat objFat = new belFat(); objFat.Nfat = txtNFat.Text.Trim(); objFat.Vorig = nudVOrigFat.Value; objFat.Vdesc = nudVDescFat.Value; objFat.Vliq = nudVLiqFat.Value; if (dgvDup.RowCount != 0) { List<belDup> lObjDup = new List<belDup>(); for (int i = 0; i < dgvDup.RowCount; i++) { belDup objdup = new belDup(); objdup.Ndup = Convert.ToString(dgvDup[0, i].Value); objdup.Dvenc = Convert.ToDateTime(dgvDup[1, i].Value); objdup.Vdup = Convert.ToDecimal(dgvDup[2, i].Value); lObjDup.Add(objdup); } objFat.belDup = lObjDup; } objcobr.belFat = objFat; lObj.Add(objcobr); #endregion #region Inf Adicionais belInfAdic objinfadic = new belInfAdic(); if (txtInfAdic.Text != "") { objinfadic.Infcpl = txtInfAdic.Text.Trim().Replace(Environment.NewLine, ""); } lObj.Add(objinfadic); #endregion #region exporta belExporta objexporta = new belExporta(); if (cbxUF_embarque.SelectedIndex > 0) { objexporta.Ufembarq = cbxUF_embarque.Text.ToString(); } if (txtLocalEntrega.Text != "") { objexporta.Xlocembarq = txtLocalEntrega.Text; } lObj.Add(objexporta); #endregion lObjTotNotasFinal[notAtual - 1] = lObj; lObjTotNotas[notAtual - 1] = lObjTotNotasFinal[notAtual - 1]; } catch (Exception ex) { KryptonMessageBox.Show(ex.Message); ; } }