示例#1
0
        public void PopulaNf(belinfCte objbelinfCte, string sCte)
        {
            try
            {
                DataTable dt = BuscaDadosNf(sCte);
                //objbelinfCte.infCTeNorm = new belinfCTeNorm();
                foreach (DataRow dr in dt.Rows)
                {
                    switch (dr["Tipo"].ToString())
                    {
                        case "N":
                            belinfNF infNf = new belinfNF();
                            infNf.mod = dr["mod"].ToString();
                            infNf.serie = dr["serie"].ToString();
                            infNf.nDoc = dr["nDoc"].ToString();
                            infNf.dEmi = dr["dEmi"].ToString() != "" ? (Convert.ToDateTime(dr["dEmi"].ToString())).ToString("dd/MM/yyyy") : "";
                            infNf.vBC = dr["vBC"].ToString() != "" ? dr["vBC"].ToString().Replace(",", ".") : "0.00";
                            infNf.vICMS = dr["vICMS"].ToString() != "" ? dr["vICMS"].ToString().Replace(",", ".") : "0.00";
                            infNf.vBCST = dr["vBCST"].ToString() != "" ? dr["vBCST"].ToString().Replace(",", ".") : "0.00";
                            infNf.vST = dr["vST"].ToString() != "" ? dr["vST"].ToString().Replace(",", ".") : "0.00";
                            infNf.vProd = dr["vProd"].ToString() != "" ? dr["vProd"].ToString().Replace(",", ".") : "0.00";
                            infNf.vNF = dr["vProd"].ToString() != "" ? dr["vProd"].ToString().Replace(",", ".") : "0.00";
                            infNf.nCFOP = dr["nCFOP"].ToString() != "" ? Convert.ToInt32(dr["nCFOP"]).ToString() : "0";

                            objbelinfCte.infCTeNorm.infDoc.infNF.Add(infNf);
                            break;

                        case "E":
                            belinfNFe infNfe = new belinfNFe();
                            infNfe.chave = dr["chave"].ToString();
                            infNfe.nDoc = dr["nDoc"].ToString();
                            objbelinfCte.infCTeNorm.infDoc.infNFe.Add(infNfe);
                            break;

                        case "00":
                            belinfOutros infDeclaracao = new belinfOutros();
                            infDeclaracao.tpDoc = "00";
                            infDeclaracao.nDoc = dr["nDoc"].ToString();
                            infDeclaracao.dEmi = dr["dEmi"].ToString() != "" ? (Convert.ToDateTime(dr["dEmi"].ToString())).ToString("dd/MM/yyyy") : "";
                            infDeclaracao.vDocFisc = dr["vProd"].ToString() != "" ? dr["vProd"].ToString().Replace(",", ".") : "0.00";

                            objbelinfCte.infCTeNorm.infDoc.infOutros.Add(infDeclaracao);
                            break;

                        case "10":
                            belinfOutros infDutoviario = new belinfOutros();
                            infDutoviario.tpDoc = "00";
                            infDutoviario.nDoc = dr["nDoc"].ToString();
                            infDutoviario.dEmi = dr["dEmi"].ToString() != "" ? (Convert.ToDateTime(dr["dEmi"].ToString())).ToString("dd/MM/yyyy") : "";
                            infDutoviario.vDocFisc = dr["vProd"].ToString() != "" ? dr["vProd"].ToString().Replace(",", ".") : "0.00";

                            objbelinfCte.infCTeNorm.infDoc.infOutros.Add(infDutoviario);
                            break;

                        case "99":
                            belinfOutros infOutros = new belinfOutros();
                            infOutros.tpDoc = "99";
                            infOutros.descOutros = dr["descOutros"].ToString();
                            infOutros.nDoc = dr["nDoc"].ToString();
                            infOutros.dEmi = dr["dEmi"].ToString() != "" ? (Convert.ToDateTime(dr["dEmi"].ToString())).ToString("dd/MM/yyyy") : "";
                            infOutros.vDocFisc = dr["vProd"].ToString() != "" ? dr["vProd"].ToString().Replace(",", ".") : "0.00";

                            objbelinfCte.infCTeNorm.infDoc.infOutros.Add(infOutros);
                            break;

                        default:
                            throw new Exception("A nota " + dr["nDoc"].ToString() + " do Conhecimento " + objbelinfCte.ide.nCT + " não tem Tipo selecionado(NF, NF-e, Declaração, Dutoviário, Outros)");
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
示例#2
0
        private void SalvarAlteracao()
        {
            try
            {
                belinfCte objInfCte = (belinfCte)bsNotas.Current;

                #region Identificacao
                objInfCte.ide.cUF = txtcUF.Text;
                objInfCte.ide.cCT = txtcCT.Text;
                objInfCte.ide.CFOP = txtCFOP.Text;
                objInfCte.ide.natOp = txtnatOp.Text;
                objInfCte.ide.forPag = cboforPag.SelectedIndex;
                objInfCte.ide.mod = txtmod.Text;
                objInfCte.ide.serie = txtserie.Text;
                objInfCte.ide.nCT = txtnCT.Text;
                switch (cbotpEmis.SelectedIndex)
                {
                    case 0: objInfCte.ide.tpEmis = "1";
                        break;
                    case 1: objInfCte.ide.tpEmis = "5";
                        break;


                    default: objInfCte.ide.tpEmis = "";
                        break;
                }

                objInfCte.ide.cDV = txtcDV.Text;
                objInfCte.ide.tpCTe = cbotpCTe.SelectedIndex;
                objInfCte.ide.verProc = txtverProc.Text;
                objInfCte.ide.cMunEnv = txtcMunEmi.Text;
                objInfCte.ide.xMunEnv = txtxMunEmi.Text;
                objInfCte.ide.UFEnv = txtUFEmi.Text;
                objInfCte.ide.modal = "0" + (cbomodal.SelectedIndex + 1).ToString();
                objInfCte.ide.tpServ = cbotpServ.SelectedIndex;
                objInfCte.ide.cMunIni = txtcMunIni.Text;
                objInfCte.ide.xMunIni = txtxMunIni.Text;
                objInfCte.ide.UFIni = txtUFIni.Text;
                objInfCte.ide.cMunFim = txtcMunFim.Text;
                objInfCte.ide.xMunFim = txtxMunFim.Text;
                objInfCte.ide.UFFim = txtUFFim.Text;
                objInfCte.ide.retira = cboretira.SelectedIndex;


                #endregion

                #region Tomador
                objInfCte.ide.toma03 = null;

                objInfCte.ide.toma04 = null;

                if (cbotoma.SelectedIndex != -1)
                {
                    if (cbotoma.SelectedIndex != 4)
                    {
                        objInfCte.ide.toma03 = new beltoma03();
                        objInfCte.ide.toma03.toma = cbotoma.SelectedIndex.ToString();
                    }
                    else
                    {
                        objInfCte.ide.toma04 = new beltoma04();
                        objInfCte.ide.toma04.enderToma = new belenderToma();
                        objInfCte.ide.toma04.toma = cbotoma.SelectedIndex.ToString();

                        string sCnpj = mskCNPJtoma.Text;
                        if (sCnpj != "")
                        {
                            if (mskCNPJtoma.Text.Length == 14)
                            {
                                objInfCte.ide.toma04.CNPJ = sCnpj;
                            }
                            else if (mskCNPJtoma.Text.Length == 11)
                            {
                                objInfCte.ide.toma04.CPF = sCnpj;
                            }
                        }
                        objInfCte.ide.toma04.IE = txtIEToma.Text;
                        objInfCte.ide.toma04.xNome = txtxNomeToma.Text;
                        objInfCte.ide.toma04.xFant = txtxFantToma.Text;
                        if (txtfoneToma.Text != "")
                        {
                            objInfCte.ide.toma04.fone = txtfoneToma.Text;
                        }
                        objInfCte.ide.toma04.enderToma.xLgr = txtxLgrToma.Text;
                        objInfCte.ide.toma04.enderToma.nro = txtnroToma.Text;
                        objInfCte.ide.toma04.enderToma.xCpl = txtxCplToma.Text;
                        objInfCte.ide.toma04.enderToma.xBairro = txtxBairroToma.Text;
                        if (txtcMunToma.Text != "")
                        {
                            objInfCte.ide.toma04.enderToma.cMun = txtcMunToma.Text;
                        }
                        objInfCte.ide.toma04.enderToma.xMun = txtxMunToma.Text;

                        string sCep = mskCEPToma.Text.Replace(" ", "").Replace("-", "");
                        objInfCte.ide.toma04.enderToma.CEP = sCep;

                        objInfCte.ide.toma04.enderToma.UF = txtUFToma.Text;
                        if (txtcPaisToma.Text != "")
                        {
                            objInfCte.ide.toma04.enderToma.cPais = txtcPaisToma.Text;
                        }
                        objInfCte.ide.toma04.enderToma.xPais = txtxPaisToma.Text;

                    }
                }
                #endregion

                #region Emitente

                objInfCte.emit.CNPJ = mskCNPJEmit.Text.Replace(" ", "").Replace("-", "").Replace("/", "").Replace(".", ""); ;
                objInfCte.emit.IE = txtIEEmit.Text;
                objInfCte.emit.xNome = txtxNomeEmit.Text;
                objInfCte.emit.xFant = txtxFantEmit.Text;

                objInfCte.emit.enderEmit.xLgr = txtxLgrEmit.Text;
                objInfCte.emit.enderEmit.nro = txtnroEmit.Text;
                objInfCte.emit.enderEmit.xCpl = txtxCplEmit.Text;
                objInfCte.emit.enderEmit.xBairro = txtxBairroEmit.Text;
                if (txtcMunEmit.Text != "")
                {
                    objInfCte.emit.enderEmit.cMun = txtcMunEmit.Text;
                }
                objInfCte.emit.enderEmit.xMun = txtxMunEmit.Text;

                string sCepemit = mskCEPEmit.Text.Replace(" ", "").Replace("-", "");
                if (sCepemit != "")
                {
                    objInfCte.emit.enderEmit.CEP = sCepemit;
                }
                objInfCte.emit.enderEmit.UF = txtUFEmit.Text;
                if (txtfoneEmit.Text != "")
                {
                    objInfCte.emit.enderEmit.fone = txtfoneEmit.Text;
                }

                #endregion

                #region Remetente
                objInfCte.rem = new belrem();
                objInfCte.rem.enderReme = new belenderReme();

                if (objInfCte.rem.CNPJ != "")
                {
                    if (mskCNPJrem.Text.Length == 14)
                    {
                        objInfCte.rem.CNPJ = mskCNPJrem.Text;
                    }
                }
                else if (objInfCte.rem.CPF != "")
                {
                    if (mskCNPJrem.Text.Length == 11)
                    {
                        objInfCte.rem.CPF = mskCNPJrem.Text;
                    }
                }
                else
                {
                    if (mskCNPJrem.Text.Length == 14)
                    {
                        objInfCte.rem.CNPJ = mskCNPJrem.Text;
                    }
                    else if (mskCNPJrem.Text.Length == 11)
                    {
                        objInfCte.rem.CPF = mskCNPJrem.Text;
                    }
                }
                objInfCte.rem.IE = txtIErem.Text;
                objInfCte.rem.xNome = txtxNomerem.Text;
                objInfCte.rem.xFant = txtxFantrem.Text;
                objInfCte.rem.fone = txtfonerem.Text;


                objInfCte.rem.enderReme.xLgr = txtxLgrrem.Text;
                objInfCte.rem.enderReme.nro = txtnrorem.Text;
                objInfCte.rem.enderReme.xCpl = txtxCplrem.Text;
                objInfCte.rem.enderReme.xBairro = txtxBairrorem.Text;
                objInfCte.rem.enderReme.cMun = txtcMunrem.Text;
                objInfCte.rem.enderReme.xMun = txtxMunrem.Text;
                objInfCte.rem.enderReme.CEP = mskCEPrem.Text;
                objInfCte.rem.enderReme.UF = txtUFrem.Text;
                objInfCte.rem.enderReme.xPais = xPaisrem.Text;
                objInfCte.rem.enderReme.cPais = txtcPaisrem.Text;

                #endregion

                #region Destinatario

                objInfCte.dest = new beldest();
                objInfCte.dest.enderDest = new belenderDest();

                if (objInfCte.dest.CNPJ != "")
                {
                    if (mskCNPJdest.Text.Length == 14)
                    {
                        objInfCte.dest.CNPJ = mskCNPJdest.Text;
                    }
                }
                else if (objInfCte.dest.CPF != "")
                {
                    if (mskCNPJdest.Text.Length == 11)
                    {
                        objInfCte.dest.CPF = mskCNPJdest.Text;
                    }
                }
                else
                {
                    if (mskCNPJdest.Text.Length == 14)
                    {
                        objInfCte.dest.CNPJ = mskCNPJdest.Text;
                    }
                    else if (mskCNPJdest.Text.Length == 11)
                    {
                        objInfCte.dest.CPF = mskCNPJdest.Text;
                    }
                }

                objInfCte.dest.IE = txtIEdest.Text;
                objInfCte.dest.xNome = txtxNomedest.Text;
                objInfCte.dest.fone = txtfonedest.Text;
                objInfCte.dest.ISUF = txtISUFdest.Text;


                objInfCte.dest.enderDest.xLgr = txtxLgrdest.Text;
                objInfCte.dest.enderDest.nro = txtnrodest.Text;
                objInfCte.dest.enderDest.xCpl = txtxCpldest.Text;
                objInfCte.dest.enderDest.xBairro = txtxBairrodest.Text;
                objInfCte.dest.enderDest.cMun = txtcMundest.Text;
                objInfCte.dest.enderDest.xMun = txtxMundest.Text;
                objInfCte.dest.enderDest.CEP = mskCEPdest.Text;
                objInfCte.dest.enderDest.UF = txtUFdest.Text;
                objInfCte.dest.enderDest.xPais = txtxPaisdest.Text;
                objInfCte.dest.enderDest.cPais = txtcPaisdest.Text;

                #endregion

                #region Expedidor
                if (objInfCte.exped != null)
                {
                    if (objInfCte.exped.CNPJ != "")
                    {
                        if (mskCNPJexped.Text.Length == 14)
                        {
                            objInfCte.exped.CNPJ = mskCNPJexped.Text;
                        }
                    }
                    else if (objInfCte.exped.CPF != "")
                    {
                        if (mskCNPJexped.Text.Length == 11)
                        {
                            objInfCte.exped.CPF = mskCNPJexped.Text;
                        }
                    }
                    else
                    {
                        if (mskCNPJexped.Text.Length == 14)
                        {
                            objInfCte.exped.CNPJ = mskCNPJexped.Text;
                        }
                        else if (mskCNPJexped.Text.Length == 11)
                        {
                            objInfCte.exped.CPF = mskCNPJexped.Text;
                        }
                    }

                    objInfCte.exped.IE = txtIEexped.Text;
                    objInfCte.exped.xNome = txtxNomeexped.Text;
                    objInfCte.exped.fone = txtfoneexped.Text;


                    objInfCte.exped.enderExped.xLgr = txtxLgrexped.Text;
                    objInfCte.exped.enderExped.nro = txtnroexped.Text;
                    objInfCte.exped.enderExped.xBairro = txtxBairroexped.Text;
                    objInfCte.exped.enderExped.xCpl = txtxCplexped.Text;
                    objInfCte.exped.enderExped.cMun = txtcMunexped.Text;
                    objInfCte.exped.enderExped.xMun = txtxMunexped.Text;
                    objInfCte.exped.enderExped.CEP = mskCEPexped.Text;
                    objInfCte.exped.enderExped.UF = txtUFexped.Text;
                    objInfCte.exped.enderExped.xPais = txtxPaisexped.Text;
                    objInfCte.exped.enderExped.cPais = txtcPaisexped.Text;

                }


                #endregion

                #region Recebedor
                if (objInfCte.receb != null)
                {
                    if (objInfCte.receb.CNPJ != "")
                    {
                        if (mskCpfCnpfreceb.Text.Length == 14)
                        {
                            objInfCte.receb.CNPJ = mskCpfCnpfreceb.Text;
                        }
                    }
                    else if (objInfCte.receb.CPF != "")
                    {
                        if (mskCpfCnpfreceb.Text.Length == 11)
                        {
                            objInfCte.receb.CPF = mskCpfCnpfreceb.Text;
                        }
                    }
                    else
                    {
                        if (mskCpfCnpfreceb.Text.Length == 14)
                        {
                            objInfCte.receb.CNPJ = mskCpfCnpfreceb.Text;
                        }
                        else if (mskCpfCnpfreceb.Text.Length == 11)
                        {
                            objInfCte.receb.CPF = mskCpfCnpfreceb.Text;
                        }
                    }

                    objInfCte.receb.IE = txtIEreceb.Text;
                    objInfCte.receb.xNome = txtxNomereceb.Text;
                    objInfCte.receb.fone = txtfonereceb.Text;

                    objInfCte.receb.enderReceb.xLgr = txtxLgrreceb.Text;
                    objInfCte.receb.enderReceb.nro = txtnroreceb.Text;
                    objInfCte.receb.enderReceb.xBairro = txtxBairroreceb.Text;
                    objInfCte.receb.enderReceb.xCpl = txtxCplreceb.Text;
                    objInfCte.receb.enderReceb.cMun = txtcMunreceb.Text;
                    objInfCte.receb.enderReceb.xMun = txtxMunreceb.Text;
                    objInfCte.receb.enderReceb.CEP = mskCEPreceb.Text;
                    objInfCte.receb.enderReceb.UF = txtUFreceb.Text;
                    objInfCte.receb.enderReceb.xPais = txtxPaisreceb.Text;
                    objInfCte.receb.enderReceb.cPais = txtcPaisreceb.Text;

                }


                #endregion

                #region Informacoes da NF

                //objInfCte.infCTeNorm.infDoc.infNF = new List<belinfNF>();
                //for (int j = 0; j < gridNfNormal.RowCount; j++)
                //{
                //    belinfNF nf = new belinfNF();

                //    switch (gridNfNormal.Rows[j].Cells["mod"].Value.ToString())
                //    {
                //        case "01 - NF Modelo 01/1A e Avulsa": nf.mod = "01";
                //            break;
                //        case "04 - NF de Produtor": nf.mod = "04";
                //            break;
                //    }
                //    nf.nDoc = gridNfNormal.Rows[j].Cells["nDoc"].Value == null ? "" : gridNfNormal.Rows[j].Cells["nDoc"].Value.ToString();
                //    nf.serie = gridNfNormal.Rows[j].Cells["serie"].Value == null ? "" : gridNfNormal.Rows[j].Cells["serie"].Value.ToString();
                //    nf.dEmi = gridNfNormal.Rows[j].Cells["dEmi"].Value == null ? "" : gridNfNormal.Rows[j].Cells["dEmi"].Value.ToString();
                //    nf.vBC = gridNfNormal.Rows[j].Cells["vBC"].Value == null ? "" : gridNfNormal.Rows[j].Cells["vBC"].Value.ToString().Replace(",", ".");
                //    nf.vICMS = gridNfNormal.Rows[j].Cells["vICMS"].Value == null ? "" : gridNfNormal.Rows[j].Cells["vICMS"].Value.ToString().Replace(",", ".");
                //    nf.vBCST = gridNfNormal.Rows[j].Cells["vBCST"].Value == null ? "" : gridNfNormal.Rows[j].Cells["vBCST"].Value.ToString().Replace(",", ".");
                //    nf.vST = gridNfNormal.Rows[j].Cells["vST"].Value == null ? "" : gridNfNormal.Rows[j].Cells["vST"].Value.ToString().Replace(",", ".");
                //    nf.vProd = gridNfNormal.Rows[j].Cells["vProd"].Value == null ? "" : gridNfNormal.Rows[j].Cells["vProd"].Value.ToString().Replace(",", ".");
                //    nf.vNF = gridNfNormal.Rows[j].Cells["vNF"].Value == null ? "" : gridNfNormal.Rows[j].Cells["vNF"].Value.ToString().Replace(",", ".");
                //    nf.nCFOP = gridNfNormal.Rows[j].Cells["nCFOP"].Value == null ? "" : gridNfNormal.Rows[j].Cells["nCFOP"].Value.ToString();
                //    objInfCte.infCTeNorm.infDoc.infNF.Add(nf);
                //}
                objInfCte.infCTeNorm.infDoc.infNF = this.bsInfNF.DataSource as List<belinfNF>; // 2.0

                objInfCte.infCTeNorm.infDoc.infNFe = this.bsInfNFe.DataSource as List<belinfNFe>; //2.0
                //for (int n = 0; n < gridNfe.RowCount; n++)
                //{
                //    belinfNFe nfe = new belinfNFe();
                //    nfe.chave = gridNfe.Rows[n].Cells[0].Value == null ? "" : gridNfe.Rows[n].Cells[0].Value.ToString();

                //    objInfCte.infCTeNorm.infDoc.infNFe.Add(nfe);
                //}



                #endregion

                #region Outros Documentos

                objInfCte.infCTeNorm.infDoc.infOutros = new List<belinfOutros>();
                for (int j = 0; j < gridDocumentos.RowCount; j++)
                {
                    belinfOutros infOutros = new belinfOutros();
                    switch (gridDocumentos.Rows[j].Cells["tpDoc"].Value.ToString())
                    {
                        case "00 - Declaração":
                            infOutros.tpDoc = "00";
                            break;
                        case "10 - Dutoviário":
                            infOutros.tpDoc = "10";
                            break;
                        case "99 - Outros":
                            infOutros.tpDoc = "99";
                            break;
                    }
                    infOutros.descOutros = gridDocumentos.Rows[j].Cells["descOutros"].Value == null ? "" : gridDocumentos.Rows[j].Cells["descOutros"].Value.ToString();
                    infOutros.nDoc = gridDocumentos.Rows[j].Cells["nDoc_"].Value == null ? "" : gridDocumentos.Rows[j].Cells["nDoc_"].Value.ToString();
                    infOutros.dEmi = gridDocumentos.Rows[j].Cells["dEmi_"].Value == null ? "" : gridDocumentos.Rows[j].Cells["dEmi_"].Value.ToString();
                    infOutros.vDocFisc = gridDocumentos.Rows[j].Cells["vDocFisc"].Value == null ? "" : gridDocumentos.Rows[j].Cells["vDocFisc"].Value.ToString().Replace(",", ".");

                    objInfCte.infCTeNorm.infDoc.infOutros.Add(infOutros);
                }

                #endregion

                #region Valores

                objInfCte.vPrest.vTPrest = nudvTPrest.Value.ToString().Replace(",", ".");
                objInfCte.vPrest.vRec = nudvRec.Value.ToString().Replace(",", ".");

                objInfCte.vPrest.Comp = new List<belComp>();
                belComp Comp = new belComp();

                #region Componentes
                if (nudvFrete.Value > 0)
                {
                    Comp.xNome = "FRETE VALOR";
                    Comp.vComp = nudvFrete.Text.Replace(",", ".");
                    objInfCte.vPrest.Comp.Add(Comp);
                }
                if (nudFreteCubagem.Value > 0)
                {
                    Comp = new belComp();
                    Comp.xNome = "FRETE CUBAGEM";
                    Comp.vComp = nudFreteCubagem.Text.Replace(",", ".");
                    objInfCte.vPrest.Comp.Add(Comp);
                }

                if (nudFretePeso.Value > 0)
                {
                    Comp = new belComp();
                    Comp.xNome = "FRETE PESO";
                    Comp.vComp = nudFretePeso.Text.Replace(",", ".");
                    objInfCte.vPrest.Comp.Add(Comp);
                }

                if (nudCat.Value > 0)
                {
                    Comp = new belComp();
                    Comp.xNome = "CAT";
                    Comp.vComp = nudCat.Text.Replace(",", ".");
                    objInfCte.vPrest.Comp.Add(Comp);
                }

                if (nudDespacho.Value > 0)
                {
                    Comp = new belComp();
                    Comp.xNome = "DESPACHO";
                    Comp.vComp = nudDespacho.Text.Replace(",", ".");
                    objInfCte.vPrest.Comp.Add(Comp);
                }

                if (nudPedagio.Value > 0)
                {
                    Comp = new belComp();
                    Comp.xNome = "PEDAGIO";
                    Comp.vComp = nudPedagio.Text.Replace(",", ".");
                    objInfCte.vPrest.Comp.Add(Comp);
                }

                if (nudOutros.Value > 0)
                {
                    Comp = new belComp();
                    Comp.xNome = "OUTROS";
                    Comp.vComp = nudOutros.Text.Replace(",", ".");
                    objInfCte.vPrest.Comp.Add(Comp);
                }

                if (nudAdme.Value > 0)
                {
                    Comp = new belComp();
                    Comp.xNome = "ADME";
                    Comp.vComp = nudAdme.Text.Replace(",", ".");
                    objInfCte.vPrest.Comp.Add(Comp);
                }

                if (nudEntrega.Value > 0)
                {
                    Comp = new belComp();
                    Comp.xNome = "ENTREGA";
                    Comp.vComp = nudEntrega.Text.Replace(",", ".");
                    objInfCte.vPrest.Comp.Add(Comp);
                }

                if (nudGris.Value > 0)
                {
                    Comp = new belComp();
                    Comp.xNome = "GRIS";
                    Comp.vComp = nudGris.Text.Replace(",", ".");
                    objInfCte.vPrest.Comp.Add(Comp);
                }

                if (nudValoraAdic.Value > 0)
                {
                    Comp = new belComp();
                    Comp.xNome = "VALOR ADICIONAL";
                    Comp.vComp = nudValoraAdic.Text.Replace(",", ".");
                    objInfCte.vPrest.Comp.Add(Comp);
                }
                #endregion




                objInfCte.imp.ICMS = new belICMS();
                if (cboCST.SelectedIndex == 0)
                {
                    objInfCte.imp.ICMS.ICMS00 = new belICMS00();
                    objInfCte.imp.ICMS.ICMS00.CST = "00";
                    objInfCte.imp.ICMS.ICMS00.vBC = nudvBC.Value.ToString().Replace(",", ".");
                    objInfCte.imp.ICMS.ICMS00.pICMS = nudpICMS.Value.ToString().Replace(",", ".");
                    objInfCte.imp.ICMS.ICMS00.vICMS = nudvICMS.Value.ToString().Replace(",", ".");
                }
                else if (cboCST.SelectedIndex == 1)
                {
                    objInfCte.imp.ICMS.ICMS20 = new belICMS20();
                    objInfCte.imp.ICMS.ICMS20.CST = "20";
                    objInfCte.imp.ICMS.ICMS20.pRedBC = nudpRedBC.Value.ToString().Replace(",", ".");
                    objInfCte.imp.ICMS.ICMS20.vBC = nudvBC.Value.ToString().Replace(",", ".");
                    objInfCte.imp.ICMS.ICMS20.pICMS = nudpICMS.Value.ToString().Replace(",", ".");
                    objInfCte.imp.ICMS.ICMS20.vICMS = nudvICMS.Value.ToString().Replace(",", ".");
                }
                else if (cboCST.SelectedIndex == 2 || cboCST.SelectedIndex == 3 || cboCST.SelectedIndex == 4)
                {
                    objInfCte.imp.ICMS.ICMS45 = new belICMS45();
                    switch (cboCST.SelectedIndex)
                    {
                        case 2: objInfCte.imp.ICMS.ICMS45.CST = "40";
                            break;
                        case 3: objInfCte.imp.ICMS.ICMS45.CST = "41";
                            break;
                        case 4: objInfCte.imp.ICMS.ICMS45.CST = "51";
                            break;
                    }
                }
                else if (cboCST.SelectedIndex == 5)
                {
                    objInfCte.imp.ICMS.ICMS60 = new belICMS60();
                    objInfCte.imp.ICMS.ICMS60.CST = "60";
                    objInfCte.imp.ICMS.ICMS60.vBCSTRet = nudvBC.Value.ToString().Replace(",", ".");
                    objInfCte.imp.ICMS.ICMS60.vICMSSTRet = nudvICMS.Value.ToString().Replace(",", ".");
                    objInfCte.imp.ICMS.ICMS60.pICMSSTRet = nudpICMS.Value.ToString().Replace(",", ".");
                }
                else if (cboCST.SelectedIndex == 6)
                {
                    objInfCte.imp.ICMS.ICMS90 = new belICMS90();
                    objInfCte.imp.ICMS.ICMS90.CST = "90";
                    objInfCte.imp.ICMS.ICMS90.pRedBC = nudpRedBC.Value.ToString().Replace(",", ".");
                    objInfCte.imp.ICMS.ICMS90.vBC = nudvBC.Value.ToString().Replace(",", ".");
                    objInfCte.imp.ICMS.ICMS90.pICMS = nudpICMS.Value.ToString().Replace(",", ".");
                    objInfCte.imp.ICMS.ICMS90.vICMS = nudvICMS.Value.ToString().Replace(",", ".");
                }
                else if (cboCST.SelectedIndex == 7)
                {
                    objInfCte.imp.ICMS.ICMSOutraUF = new belICMSOutraUF();
                    objInfCte.imp.ICMS.ICMSOutraUF.CST = "90";
                    objInfCte.imp.ICMS.ICMSOutraUF.pRedBCOutraUF = nudpRedBC.Value.ToString().Replace(",", ".");
                    objInfCte.imp.ICMS.ICMSOutraUF.vBCOutraUF = nudvBC.Value.ToString().Replace(",", ".");
                    objInfCte.imp.ICMS.ICMSOutraUF.pICMSOutraUF = nudpICMS.Value.ToString().Replace(",", ".");
                    objInfCte.imp.ICMS.ICMSOutraUF.vICMSOutraUF = nudvICMS.Value.ToString().Replace(",", ".");
                }



                #endregion

                #region InformacoesCarga

                objInfCte.infCTeNorm.infCarga.vCarga = nudvMerc.Value;
                objInfCte.infCTeNorm.infCarga.proPred = txtproPred.Text;
                objInfCte.infCTeNorm.infCarga.xOutCat = txtxOutCat.Text;


                objInfCte.infCTeNorm.infCarga.infQ = bsInfQ.DataSource as List<belinfQ>;

                //for (int j = 0; j < gridinfQ.RowCount; j++)
                //{
                //    belinfQ obj = new belinfQ();
                //    if (gridinfQ.Rows[j].Cells[0].Value == null)
                //    {
                //        obj.cUnid = "";
                //    }
                //    else
                //    {
                //        switch (gridinfQ.Rows[j].Cells[0].Value.ToString())
                //        {
                //            case "00-M3": obj.cUnid = "00";
                //                break;
                //            case "01-KG": obj.cUnid = "01";
                //                break;
                //            case "02-Ton": obj.cUnid = "02";
                //                break;
                //            case "03-Unidade": obj.cUnid = "03";
                //                break;
                //            case "04-Litros": obj.cUnid = "04";
                //                break;
                //        }
                //    }
                //    if (gridinfQ.Rows[j].Cells[1].Value == null)
                //    {
                //        obj.tpMed = "";
                //    }
                //    else
                //    {
                //        obj.tpMed = gridinfQ.Rows[j].Cells[1].Value.ToString();
                //    }
                //    if (gridinfQ.Rows[j].Cells[2].Value == null)
                //    {
                //        obj.qCarga = 0;
                //    }
                //    else
                //    {
                //        obj.qCarga = Convert.ToDecimal(gridinfQ.Rows[j].Cells[2].Value.ToString());
                //    }

                //    objInfCte.infCTeNorm.infCarga.infQ.Add(obj);
                //}

                #endregion

                #region Rodoviario

                objInfCte.infCTeNorm.seg.respSeg = cborespSeg.SelectedIndex != -1 ? cborespSeg.SelectedIndex.ToString() : "";

                objInfCte.infCTeNorm.rodo.dPrev = mskdPrev.Text.Replace(" ", "").Replace("/", "").Replace('_', ' ').Trim() != "" ? Convert.ToDateTime(mskdPrev.Text).ToShortDateString() : "";
                objInfCte.infCTeNorm.seg.nApol = txtnApol.Text;
                objInfCte.infCTeNorm.rodo.RNTRC = txtRNTRC.Text;
                objInfCte.infCTeNorm.rodo.lota = cbolota.SelectedIndex != -1 ? cbolota.SelectedIndex.ToString() : "";

                #endregion

                #region Veiculo

                if (objInfCte.infCTeNorm.rodo.veic.Count() > 0)
                {
                    if (VerificaCamposVeiculo() || objInfCte.infCTeNorm.rodo.lota == "1")
                    {
                        belveic veic = (belveic)bsVeiculos.Current;

                        veic.RENAVAM = txtRENAVAM.Text;
                        veic.placa = txtplaca.Text;
                        veic.tara = nudtara.Value.ToString();
                        veic.capKG = nudcapKG.Value.ToString();
                        veic.capM3 = nudcapM3.Value.ToString();
                        switch (cbotpProp.SelectedIndex)
                        {
                            case 0:
                                veic.tpProp = "P";
                                break;
                            case 1:
                                veic.tpProp = "T";
                                break;
                            default:
                                veic.tpProp = "";
                                break;
                        }
                        veic.tpVeic = cbotpVeic.SelectedIndex != -1 ? cbotpVeic.SelectedIndex.ToString() : "";
                        veic.tpRod = cbotpRod.SelectedIndex != -1 ? "0" + cbotpRod.SelectedIndex.ToString() : "";
                        veic.tpCar = cbotpCar.SelectedIndex != -1 ? "0" + cbotpCar.SelectedIndex.ToString() : "";
                        veic.UF = txtUF.Text;

                        if (veic.tpProp == "T")
                        {
                            veic.prop = new belprop();
                            veic.prop.CPFCNPJ = txtCPFprop.Text;
                            veic.prop.RNTRC = txtRNTRCprop.Text;
                            veic.prop.xNome = txtxNomeprop.Text;
                            veic.prop.IE = txtIEprop.Text;
                            veic.prop.UF = txtUFprop.Text;
                            veic.prop.tpProp = cbotpPropprop.SelectedIndex != -1 ? cbotpCar.SelectedIndex.ToString() : "";
                        }
                        else
                        {
                            veic.prop = null;
                        }
                    }
                }

                if (VerificaCamposProprietarioVeiculo() || objInfCte.infCTeNorm.rodo.lota == "1")
                {
                    objInfCte.infCTeNorm.rodo.moto = new belmoto();
                    objInfCte.infCTeNorm.rodo.moto.xNome = txtxNomemoto.Text;
                    objInfCte.infCTeNorm.rodo.moto.CPF = txtCPFmoto.Text;
                }
                else
                {
                    objInfCte.infCTeNorm.rodo.moto = null;
                }

                #endregion

                #region Obs
                objInfCte.compl.ObsCont.xTexto = objInfCte.compl.ObsCont.xTexto;
                #endregion

                VerificaCampos();

            }
            catch (Exception ex)
            {
                new HLPexception(ex);
            }
        }