public belCobr xmlBuscaCobr() { belCobr objCobr = new belCobr(); XmlDocument xCobr = new XmlDocument(); belFat objFat = new belFat(); try { if (xDoc.GetElementsByTagName("cobr").Count > 0) { xCobr.LoadXml(xDoc.GetElementsByTagName("cobr")[0].OuterXml); if (xCobr.GetElementsByTagName("fat").Count > 0) { XmlDocument xFat = new XmlDocument(); xFat.LoadXml(xCobr.GetElementsByTagName("fat")[0].OuterXml); if (xFat.GetElementsByTagName("nFat").Count > 0) { objFat.Nfat = xFat.GetElementsByTagName("nFat")[0].InnerText; } if (xFat.GetElementsByTagName("vOrig").Count > 0) { objFat.Vorig = Convert.ToDecimal(xFat.GetElementsByTagName("vOrig")[0].InnerText.ToString().Replace(".", ",")); } if (xFat.GetElementsByTagName("vDesc").Count > 0) { objFat.Vdesc = Convert.ToDecimal(xFat.GetElementsByTagName("vDesc")[0].InnerText.ToString().Replace(".", ",")); } if (xFat.GetElementsByTagName("vLiq").Count > 0) { objFat.Vliq = Convert.ToDecimal(xFat.GetElementsByTagName("vLiq")[0].InnerText.ToString().Replace(".", ",")); } } List<belDup> lobjDup = new List<belDup>(); for (int i = 0; i < xCobr.GetElementsByTagName("dup").Count; i++) { XmlDocument xDup = new XmlDocument(); xDup.LoadXml(xCobr.GetElementsByTagName("dup")[i].OuterXml); belDup objDup = new belDup(); if (xDup.GetElementsByTagName("nDup").Count > 0) { objDup.Ndup = xDup.GetElementsByTagName("nDup")[0].InnerText; } if (xDup.GetElementsByTagName("dVenc").Count > 0) { objDup.Dvenc = Convert.ToDateTime(xDup.GetElementsByTagName("dVenc")[0].InnerText); } if (xDup.GetElementsByTagName("vDup").Count > 0) { objDup.Vdup = Convert.ToDecimal(xDup.GetElementsByTagName("vDup")[0].InnerText.ToString().Replace(".", ",")); } lobjDup.Add(objDup); } objFat.belDup = lobjDup; objCobr.belFat = objFat; } } catch (Exception ex) { throw new Exception(string.Format("Problemas lendo a Tag Transp, Cobr.: {0}", ex.Message)); } return objCobr; }
public belCobr BuscaFat(string sEmp, string sNF) { belCobr objcobr = new belCobr(); List<belFat> objfats = new List<belFat>(); try { StringBuilder sSql = new StringBuilder(); //Campos do Select sSql.Append("Select "); sSql.Append("doc_ctr.cd_dupli, "); sSql.Append("DOC_CTR.dt_venci, "); sSql.Append("DOC_CTR.vl_doc ,"); sSql.Append("doc_ctr.vl_totdesc, "); sSql.Append("doc_ctr.cd_documento "); //Tabela sSql.Append("From doc_ctr "); //Relacionamentos sSql.Append("INNER JOIN NF ON (NF.cd_empresa = DOC_CTR.cd_empresa) AND "); sSql.Append("(NF.cd_nfseq = DOC_CTR.cd_nfseq) "); //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("') "); //belGerarXML BuscaConexao = new belGerarXML(); //FbConnection Conn = BuscaConexao.Conn; //Conn.Open(); FbCommand cmdFat = new FbCommand(sSql.ToString(), Conn); cmdFat.ExecuteNonQuery(); FbDataReader drFat = cmdFat.ExecuteReader(); sSql.Remove(0, sSql.Length); sSql.Append("Select "); sSql.Append("nf.cd_notafis nFat, "); sSql.Append("coalesce((nf.vl_totnf + nf.vl_desccomer ), 0) vOrig, "); sSql.Append("nf.vl_desccomer vDesc, "); sSql.Append("nf.vl_totnf vLiq "); sSql.Append("from nf "); 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 cmdCob = new FbCommand(sSql.ToString(), Conn); cmdCob.ExecuteNonQuery(); FbDataReader drCob = cmdCob.ExecuteReader(); belFat objfat = new belFat(); while (drCob.Read()) { decimal dvDup = Math.Round(Convert.ToDecimal(drCob["vOrig"].ToString()), 2); decimal dDesc = Math.Round(Convert.ToDecimal(drCob["vDesc"].ToString()), 2); if (drCob["nFat"].ToString().Trim() != "") { objfat.Nfat = TiraSimbolo(drCob["nFat"].ToString(), ""); } objfat.Vorig = dvDup; if (drCob["vDesc"].ToString() != "0") { objfat.Vdesc = Math.Round(Convert.ToDecimal(dDesc.ToString()), 2); //Claudinei - o.s. 24248 - 26/03/2010 } if (drCob["vLiq"].ToString() != "0") { decimal dLiq = Math.Round(Convert.ToDecimal(drCob["vLiq"].ToString()), 2); objfat.Vliq = dLiq; } } List<belDup> objdups = new List<belDup>(); while (drFat.Read()) { belDup objdup = new belDup(); if (drFat["cd_dupli"].ToString() != "") { objdup.Ndup = TiraSimbolo(drFat["cd_dupli"].ToString(), ""); } if (!drFat["dt_venci"].Equals(string.Empty)) { objdup.Dvenc = System.DateTime.Parse(drFat["dt_venci"].ToString()); } decimal dvDup = Math.Round(Convert.ToDecimal(drFat["vl_doc"].ToString()), 2); //Claudinei - o.s. 24248 - 26/03/2010 if (dvDup != 0) { objdup.Vdup = dvDup; } objdups.Add(objdup); } objfat.belDup = objdups; objcobr.belFat = objfat; } catch (Exception Ex) { sExecao = " - Problemas nas Faturas da Nota"; throw new Exception(Ex.Message + sExecao); } return objcobr; }
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); ; } }