Exemplo n.º 1
0
        public belTransp xmlBuscaTransp()
        {
            belTransp objTransp = new belTransp();
            XmlDocument xTransp = new XmlDocument();

            try
            {
                xTransp.LoadXml(xDoc.GetElementsByTagName("transp")[0].OuterXml);

                objTransp.Modfrete = xTransp.GetElementsByTagName("modFrete")[0].InnerText;

                XmlDocument xTransporta = new XmlDocument();

                if (xTransp.GetElementsByTagName("transporta")[0] != null)
                {
                    xTransporta.LoadXml(xTransp.GetElementsByTagName("transporta")[0].OuterXml);

                    belTransportadora objTransportadora = new belTransportadora();
                    if (xTransporta.GetElementsByTagName("CNPJ").Count > 0)
                    {
                        objTransportadora.Cnpj = xTransporta.GetElementsByTagName("CNPJ")[0].InnerText;
                    }
                    if (xTransporta.GetElementsByTagName("CPF").Count > 0)
                    {
                        objTransportadora.Cpf = xTransporta.GetElementsByTagName("CPF")[0].InnerText;
                    }
                    if (xTransporta.GetElementsByTagName("xNome").Count > 0)
                    {
                        objTransportadora.Xnome = xTransporta.GetElementsByTagName("xNome")[0].InnerText;
                    }
                    if (xTransporta.GetElementsByTagName("IE").Count > 0)
                    {
                        objTransportadora.Ie = xTransporta.GetElementsByTagName("IE")[0].InnerText;
                    }
                    if (xTransporta.GetElementsByTagName("xEnder").Count > 0)
                    {
                        objTransportadora.Xender = xTransporta.GetElementsByTagName("xEnder")[0].InnerText;
                    }
                    if (xTransporta.GetElementsByTagName("xMun").Count > 0)
                    {
                        objTransportadora.Xmun = xTransporta.GetElementsByTagName("xMun")[0].InnerText;
                    }
                    if (xTransporta.GetElementsByTagName("UF").Count > 0)
                    {
                        objTransportadora.Uf = xTransporta.GetElementsByTagName("UF")[0].InnerText;
                    }

                    objTransp.belTransportadora = objTransportadora;
                }



                if (xTransp.GetElementsByTagName("retTransp").Count > 0)
                {
                    XmlDocument xRetTransp = new XmlDocument();
                    xRetTransp.LoadXml(xTransp.GetElementsByTagName("retTransp")[0].OuterXml);

                    belRetTransp objRetTransp = new belRetTransp();
                    if (xRetTransp.GetElementsByTagName("vServ").Count > 0)
                    {
                        objRetTransp.Vserv = Convert.ToDecimal(xRetTransp.GetElementsByTagName("vServ")[0].InnerText.ToString().Replace(".", ","));
                    }
                    if (xRetTransp.GetElementsByTagName("vBCRet").Count > 0)
                    {
                        objRetTransp.Vbvret = Convert.ToDecimal(xRetTransp.GetElementsByTagName("vBCRet")[0].InnerText.ToString().Replace(".", ","));
                    }
                    if (xRetTransp.GetElementsByTagName("pICMSRet").Count > 0)
                    {
                        objRetTransp.Picmsret = Convert.ToDecimal(xRetTransp.GetElementsByTagName("pICMSRet")[0].InnerText.ToString().Replace(".", ","));
                    }
                    if (xRetTransp.GetElementsByTagName("vICMSRet").Count > 0)
                    {
                        objRetTransp.Vicmsret = Convert.ToDecimal(xRetTransp.GetElementsByTagName("vICMSRet")[0].InnerText.ToString().Replace(".", ","));
                    }
                    if (xRetTransp.GetElementsByTagName("CFOP").Count > 0)
                    {
                        objRetTransp.Cfop = xRetTransp.GetElementsByTagName("CFOP")[0].InnerText;
                    }
                    if (xRetTransp.GetElementsByTagName("cMunFG").Count > 0)
                    {
                        objRetTransp.Cmunfg = xRetTransp.GetElementsByTagName("cMunFG")[0].InnerText;
                    }
                    objTransp.belRetTransp = objRetTransp;

                }

                if (xTransp.GetElementsByTagName("veicTransp").Count > 0)
                {
                    XmlDocument xveicTransp = new XmlDocument();
                    xveicTransp.LoadXml(xTransp.GetElementsByTagName("veicTransp")[0].OuterXml);

                    belVeicTransp objVeictransp = new belVeicTransp();
                    if (xveicTransp.GetElementsByTagName("placa").Count > 0)
                    {
                        objVeictransp.Placa = xveicTransp.GetElementsByTagName("placa")[0].InnerText;
                    }

                    if (xveicTransp.GetElementsByTagName("UF").Count > 0)
                    {
                        objVeictransp.Uf = xveicTransp.GetElementsByTagName("UF")[0].InnerText;
                    }

                    if (xveicTransp.GetElementsByTagName("RNTC").Count > 0)
                    {
                        objVeictransp.Rntc = xveicTransp.GetElementsByTagName("RNTC")[0].InnerText;
                    }

                    objTransp.belVeicTransp = objVeictransp;
                }

                if (xTransp.GetElementsByTagName("reboque").Count > 0)
                {
                    XmlDocument xReboque = new XmlDocument();
                    xReboque.LoadXml(xTransp.GetElementsByTagName("reboque")[0].OuterXml);

                    belReboque objReboque = new belReboque();

                    if (xReboque.GetElementsByTagName("placa").Count > 0)
                    {
                        objReboque.Placa = xReboque.GetElementsByTagName("placa")[0].InnerText;
                    }
                    if (xReboque.GetElementsByTagName("UF").Count > 0)
                    {
                        objReboque.Uf = xReboque.GetElementsByTagName("UF")[0].InnerText;
                    }
                    if (xReboque.GetElementsByTagName("RNTC").Count > 0)
                    {
                        objReboque.Rntc = xReboque.GetElementsByTagName("RNTC")[0].InnerText;
                    }

                    objTransp.belReboque = objReboque;

                }

                if (xTransp.GetElementsByTagName("vol").Count > 0)
                {
                    XmlDocument xVol = new XmlDocument();
                    xVol.LoadXml(xTransp.GetElementsByTagName("vol")[0].OuterXml);

                    belVol objVol = new belVol();

                    if (xVol.GetElementsByTagName("qVol").Count > 0)
                    {
                        objVol.Qvol = Convert.ToDecimal(xVol.GetElementsByTagName("qVol")[0].InnerText.ToString().Replace(".", ","));
                    }

                    if (xVol.GetElementsByTagName("esp").Count > 0)
                    {
                        objVol.Esp = xVol.GetElementsByTagName("esp")[0].InnerText;
                    }

                    if (xVol.GetElementsByTagName("marca").Count > 0)
                    {
                        objVol.Marca = xVol.GetElementsByTagName("marca")[0].InnerText;
                    }

                    if (xVol.GetElementsByTagName("nVol").Count > 0)
                    {
                        objVol.Nvol = xVol.GetElementsByTagName("nVol")[0].InnerText;//Danner - o.s. 24432 - 04/05/2010
                    }

                    if (xVol.GetElementsByTagName("pesoL").Count > 0)
                    {
                        objVol.PesoL = Convert.ToDecimal(xVol.GetElementsByTagName("pesoL")[0].InnerText.ToString().Replace(".", ","));
                    }

                    if (xVol.GetElementsByTagName("pesoB").Count > 0)
                    {
                        objVol.PesoB = Convert.ToDecimal(xVol.GetElementsByTagName("pesoB")[0].InnerText.ToString().Replace(".", ","));
                    }

                    objTransp.belVol = objVol;

                }

                if (xTransp.GetElementsByTagName("lacres").Count > 0)
                {
                    XmlDocument xLacres = new XmlDocument();
                    xLacres.LoadXml(xTransp.GetElementsByTagName("lacres")[0].OuterXml);

                    belLacres objLacres = new belLacres();

                    if (xLacres.GetElementsByTagName("nLacre").Count > 0)
                    {
                        objLacres.Nlacre = xLacres.GetElementsByTagName("nLacre")[0].InnerText;
                    }

                    objTransp.belLacres = objLacres;

                }


            }
            catch (Exception ex)
            {

                throw new Exception(string.Format("Problemas lendo a Tag Transp, Erro.: {0}",
                                                  ex.Message));
            }

            return objTransp;

        }
Exemplo n.º 2
0
        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); ;
            }

        }