Ejemplo n.º 1
0
        public void Carrega(string seqNF, bool pbIndustri, bool bEX)
        {
            try
            {
                decimal dTotbaseICMS  = 0;
                decimal dTotValorICMS = 0;
                decimal dTotPis       = 0;
                decimal dTotCofins    = 0;
                decimal dTotServ      = 0;
                decimal dTotBCISS     = 0;
                decimal dTotISS       = 0;
                decimal dTotPisISS    = 0;
                decimal dTotCofinsISS = 0;

                DataRow drTotais = BuscaTotais(seqNF, pbIndustri, bEX);

                if ((pbIndustri) && (Acesso.NM_EMPRESA != "TECNOZ"))
                {
                    dTotbaseICMS = Math.Round(Convert.ToDecimal(drTotais["vBCST"].ToString()), 2);
                }
                if ((pbIndustri) && (Acesso.NM_EMPRESA == "MOGPLAST"))
                {
                    dTotbaseICMS = Math.Round(Convert.ToDecimal(drTotais["vBC"].ToString()), 2);
                }
                dTotbaseICMS          = Math.Round(Convert.ToDecimal(drTotais["vBC"].ToString()), 2);
                this.belIcmstot.Vbc   = Math.Round(Convert.ToDecimal(dTotbaseICMS.ToString()), 2);
                dTotValorICMS         = Math.Round(Convert.ToDecimal(drTotais["vICMS"].ToString()), 2);
                this.belIcmstot.Vicms = Math.Round(Convert.ToDecimal(dTotValorICMS.ToString()), 2);
                if (!drTotais["vBCST"].Equals(string.Empty))
                {
                    decimal dvBCST = Math.Round(Convert.ToDecimal(drTotais["vBCST"].ToString()), 2);
                    this.belIcmstot.Vbcst = dvBCST;
                }
                if (!drTotais["vST"].Equals(string.Empty))
                {
                    decimal dvST = Math.Round(Convert.ToDecimal(drTotais["vST"].ToString()), 2);
                    this.belIcmstot.Vst = (Acesso.CD_EMPRESA != "LORENZON" ? dvST : 0);
                }
                if (drTotais["vProd"].ToString() != "")
                {
                    decimal dvProd = Math.Round(Convert.ToDecimal(drTotais["vProd"].ToString()), 2);
                    this.belIcmstot.Vprod = dvProd;
                }
                else
                {
                    this.belIcmstot.Vprod = 0;
                }
                if (!drTotais["vFrete"].Equals(string.Empty))
                {
                    decimal dvFrete = Math.Round(Convert.ToDecimal(drTotais["vFrete"].ToString()), 2);
                    this.belIcmstot.Vfrete = dvFrete;
                }
                if (!drTotais["vSeg"].Equals(string.Empty))
                {
                    decimal dvSeg = Math.Round(Convert.ToDecimal(drTotais["vSeg"].ToString()), 2);
                    this.belIcmstot.Vseg = dvSeg;
                }
                decimal dvDesc = Math.Round(Convert.ToDecimal(drTotais["vDesc"].ToString()), 2);
                this.belIcmstot.Vdesc = dvDesc;
                if (!drTotais["vII"].Equals(string.Empty))
                {
                    decimal dvII = Math.Round(Convert.ToDecimal(drTotais["vII"].ToString()), 2);
                    this.belIcmstot.Vii = dvII;
                }
                if (!drTotais["vIPI"].Equals(string.Empty))
                {
                    decimal dvIPI = Math.Round(Convert.ToDecimal(drTotais["vIPI"].ToString()), 2);
                    this.belIcmstot.Vipi = (Acesso.NM_EMPRESA != "LORENZON" ? dvIPI : 0);
                }
                if (Acesso.TP_INDUSTRIALIZACAO == 2)
                {
                    dTotPis = Math.Round(Convert.ToDecimal(drTotais["vPIS"].ToString()), 2);
                }
                this.belIcmstot.Vpis = Math.Round(Convert.ToDecimal(drTotais["vPIS"].ToString()), 2);
                if (Acesso.TP_INDUSTRIALIZACAO == 2)
                {
                    dTotCofins = Math.Round(Convert.ToDecimal(drTotais["vCOFINS"].ToString()), 2);
                }
                this.belIcmstot.Vcofins = Math.Round(Convert.ToDecimal(dTotCofins.ToString()), 2);
                if (!drTotais["vOutro"].Equals(string.Empty))
                {
                    decimal dvOutro = Math.Round(Convert.ToDecimal(drTotais["vOutro"].ToString()), 2);
                    this.belIcmstot.Voutro = dvOutro;
                }
                if (!drTotais["vNF"].Equals(string.Empty))
                {
                    decimal dvNF = Math.Round(Convert.ToDecimal(drTotais["vNF"].ToString()), 2);
                    this.belIcmstot.Vnf = dvNF;
                }
                if (Acesso.TP_INDUSTRIALIZACAO == 2)
                {
                    dTotServ = Math.Round(Convert.ToDecimal(drTotais["vServ"].ToString()), 2);
                }
                if (dTotServ != 0)
                {
                    belIssqntot objisstot = new belIssqntot();
                    if (dTotServ != 0)
                    {
                        objisstot.Vserv = Math.Round(Convert.ToDecimal(dTotServ.ToString()), 2);
                    }
                    if (Acesso.TP_INDUSTRIALIZACAO == 2)
                    {
                        dTotBCISS = Math.Round(Convert.ToDecimal(drTotais["vServ"].ToString()), 2);
                    }
                    if (dTotBCISS != 0)
                    {
                        objisstot.Vbc = Math.Round(Convert.ToDecimal(dTotBCISS.ToString()), 2);
                    }
                    if (Acesso.TP_INDUSTRIALIZACAO == 2)
                    {
                        dTotISS = Math.Round(Convert.ToDecimal(drTotais["Viss"].ToString()), 2);
                    }
                    if (dTotISS != 0)
                    {
                        objisstot.Viss = Math.Round(Convert.ToDecimal(dTotISS.ToString()), 2);
                    }
                    if (Acesso.TP_INDUSTRIALIZACAO == 2)
                    {
                        dTotPisISS = Math.Round(Convert.ToDecimal(drTotais["PisIss"].ToString()), 2);
                    }
                    if (dTotPisISS != 0)
                    {
                        objisstot.Vpis = Math.Round(Convert.ToDecimal(dTotPisISS.ToString()), 2);
                    }
                    if (Acesso.TP_INDUSTRIALIZACAO == 2)
                    {
                        dTotCofinsISS = Math.Round(Convert.ToDecimal(drTotais["cofinsIss"].ToString()), 2);
                    }
                    if (dTotCofinsISS != 0)
                    {
                        objisstot.Vcofins = Math.Round(Convert.ToDecimal(dTotCofinsISS.ToString()), 2);
                    }
                    this.belIssqntot = objisstot;
                }
            }
            catch (Exception)
            {
                throw;
            }
        }
Ejemplo n.º 2
0
        public void Carrega(string seqNF, bool pbIndustri, bool bEX)
        {
            try
            {
                decimal dTotbaseICMS = 0;
                decimal dTotValorICMS = 0;
                decimal dTotPis = 0;
                decimal dTotCofins = 0;
                decimal dTotServ = 0;
                decimal dTotBCISS = 0;
                decimal dTotISS = 0;
                decimal dTotPisISS = 0;
                decimal dTotCofinsISS = 0;

                DataRow drTotais = BuscaTotais(seqNF, pbIndustri, bEX);

                if ((pbIndustri) && (Acesso.NM_EMPRESA != "TECNOZ"))
                {
                    dTotbaseICMS = Math.Round(Convert.ToDecimal(drTotais["vBCST"].ToString()), 2);
                }
                if ((pbIndustri) && (Acesso.NM_EMPRESA == "MOGPLAST"))
                {
                    dTotbaseICMS = Math.Round(Convert.ToDecimal(drTotais["vBC"].ToString()), 2);
                }
                dTotbaseICMS = Math.Round(Convert.ToDecimal(drTotais["vBC"].ToString()), 2);
                this.belIcmstot.Vbc = Math.Round(Convert.ToDecimal(dTotbaseICMS.ToString()), 2);
                dTotValorICMS = Math.Round(Convert.ToDecimal(drTotais["vICMS"].ToString()), 2);
                this.belIcmstot.Vicms = Math.Round(Convert.ToDecimal(dTotValorICMS.ToString()), 2);
                if (!drTotais["vBCST"].Equals(string.Empty))
                {
                    decimal dvBCST = Math.Round(Convert.ToDecimal(drTotais["vBCST"].ToString()), 2);
                    this.belIcmstot.Vbcst = dvBCST;
                }
                if (!drTotais["vST"].Equals(string.Empty))
                {
                    decimal dvST = Math.Round(Convert.ToDecimal(drTotais["vST"].ToString()), 2);
                    this.belIcmstot.Vst = (Acesso.CD_EMPRESA != "LORENZON" ? dvST : 0);
                }
                if (drTotais["vProd"].ToString() != "")
                {
                    decimal dvProd = Math.Round(Convert.ToDecimal(drTotais["vProd"].ToString()), 2);
                    this.belIcmstot.Vprod = dvProd;
                }
                else
                {
                    this.belIcmstot.Vprod = 0;
                }
                if (!drTotais["vFrete"].Equals(string.Empty))
                {
                    decimal dvFrete = Math.Round(Convert.ToDecimal(drTotais["vFrete"].ToString()), 2);
                    this.belIcmstot.Vfrete = dvFrete;
                }
                if (!drTotais["vSeg"].Equals(string.Empty))
                {
                    decimal dvSeg = Math.Round(Convert.ToDecimal(drTotais["vSeg"].ToString()), 2);
                    this.belIcmstot.Vseg = dvSeg;
                }
                decimal dvDesc = Math.Round(Convert.ToDecimal(drTotais["vDesc"].ToString()), 2);
                this.belIcmstot.Vdesc = dvDesc;
                if (!drTotais["vII"].Equals(string.Empty))
                {
                    decimal dvII = Math.Round(Convert.ToDecimal(drTotais["vII"].ToString()), 2);
                    this.belIcmstot.Vii = dvII;
                }
                if (!drTotais["vIPI"].Equals(string.Empty))
                {
                    decimal dvIPI = Math.Round(Convert.ToDecimal(drTotais["vIPI"].ToString()), 2);
                    this.belIcmstot.Vipi = (Acesso.NM_EMPRESA != "LORENZON" ? dvIPI : 0);
                }
                if (Acesso.TP_INDUSTRIALIZACAO == 2)
                {
                    dTotPis = Math.Round(Convert.ToDecimal(drTotais["vPIS"].ToString()), 2);
                }
                this.belIcmstot.Vpis = Math.Round(Convert.ToDecimal(drTotais["vPIS"].ToString()), 2);
                if (Acesso.TP_INDUSTRIALIZACAO == 2)
                {
                    dTotCofins = Math.Round(Convert.ToDecimal(drTotais["vCOFINS"].ToString()), 2);
                }
                this.belIcmstot.Vcofins = Math.Round(Convert.ToDecimal(dTotCofins.ToString()), 2);
                if (!drTotais["vOutro"].Equals(string.Empty))
                {
                    decimal dvOutro = Math.Round(Convert.ToDecimal(drTotais["vOutro"].ToString()), 2);
                    this.belIcmstot.Voutro = dvOutro;
                }
                if (!drTotais["vNF"].Equals(string.Empty))
                {
                    decimal dvNF = Math.Round(Convert.ToDecimal(drTotais["vNF"].ToString()), 2);
                    this.belIcmstot.Vnf = dvNF;
                }
                if (Acesso.TP_INDUSTRIALIZACAO == 2)
                {
                    dTotServ = Math.Round(Convert.ToDecimal(drTotais["vServ"].ToString()), 2);
                }
                if (dTotServ != 0)
                {
                    belIssqntot objisstot = new belIssqntot();
                    if (dTotServ != 0)
                    {
                        objisstot.Vserv = Math.Round(Convert.ToDecimal(dTotServ.ToString()), 2);
                    }
                    if (Acesso.TP_INDUSTRIALIZACAO == 2)
                    {
                        dTotBCISS = Math.Round(Convert.ToDecimal(drTotais["vServ"].ToString()), 2);
                    }
                    if (dTotBCISS != 0)
                    {
                        objisstot.Vbc = Math.Round(Convert.ToDecimal(dTotBCISS.ToString()), 2);
                    }
                    if (Acesso.TP_INDUSTRIALIZACAO == 2)
                    {
                        dTotISS = Math.Round(Convert.ToDecimal(drTotais["Viss"].ToString()), 2);
                    }
                    if (dTotISS != 0)
                    {
                        objisstot.Viss = Math.Round(Convert.ToDecimal(dTotISS.ToString()), 2);
                    }
                    if (Acesso.TP_INDUSTRIALIZACAO == 2)
                    {
                        dTotPisISS = Math.Round(Convert.ToDecimal(drTotais["PisIss"].ToString()), 2);
                    }
                    if (dTotPisISS != 0)
                    {
                        objisstot.Vpis = Math.Round(Convert.ToDecimal(dTotPisISS.ToString()), 2);
                    }
                    if (Acesso.TP_INDUSTRIALIZACAO == 2)
                    {
                        dTotCofinsISS = Math.Round(Convert.ToDecimal(drTotais["cofinsIss"].ToString()), 2);
                    }
                    if (dTotCofinsISS != 0)
                    {
                        objisstot.Vcofins = Math.Round(Convert.ToDecimal(dTotCofinsISS.ToString()), 2);
                    }
                    this.belIssqntot = objisstot;
                }                
            }
            catch (Exception)
            {
                throw;
            }

        }
Ejemplo n.º 3
0
        public belTotal xmlBuscaTotal()
        {
            belTotal objTotal = new belTotal();
            XmlDocument xTotalN = new XmlDocument();

            try
            {
                switch (xDoc.GetElementsByTagName("total")[0].FirstChild.Name)
                {
                    case "ICMSTot":
                        {
                            xTotalN.LoadXml(xDoc.GetElementsByTagName("ICMSTot")[0].OuterXml);

                            belIcmstot objIcmsTot = new belIcmstot();
                            objIcmsTot.Vbc = Convert.ToDecimal(xTotalN.GetElementsByTagName("vBC")[0].InnerText.ToString().Replace(".", ","));
                            objIcmsTot.Vicms = Convert.ToDecimal(xTotalN.GetElementsByTagName("vICMS")[0].InnerText.ToString().Replace(".", ","));
                            objIcmsTot.Vbcst = Convert.ToDecimal(xTotalN.GetElementsByTagName("vBCST")[0].InnerText.ToString().Replace(".", ","));
                            objIcmsTot.Vst = Convert.ToDecimal(xTotalN.GetElementsByTagName("vST")[0].InnerText.ToString().Replace(".", ","));
                            objIcmsTot.Vprod = Convert.ToDecimal(xTotalN.GetElementsByTagName("vProd")[0].InnerText.ToString().Replace(".", ","));
                            objIcmsTot.Vfrete = Convert.ToDecimal(xTotalN.GetElementsByTagName("vFrete")[0].InnerText.ToString().Replace(".", ","));
                            objIcmsTot.Vseg = Convert.ToDecimal(xTotalN.GetElementsByTagName("vSeg")[0].InnerText.ToString().Replace(".", ","));
                            objIcmsTot.Vdesc = Convert.ToDecimal(xTotalN.GetElementsByTagName("vDesc")[0].InnerText.ToString().Replace(".", ","));
                            objIcmsTot.Vii = Convert.ToDecimal(xTotalN.GetElementsByTagName("vII")[0].InnerText.ToString().Replace(".", ","));
                            objIcmsTot.Vipi = Convert.ToDecimal(xTotalN.GetElementsByTagName("vIPI")[0].InnerText.ToString().Replace(".", ","));
                            objIcmsTot.Vpis = Convert.ToDecimal(xTotalN.GetElementsByTagName("vPIS")[0].InnerText.ToString().Replace(".", ","));
                            objIcmsTot.Vcofins = Convert.ToDecimal(xTotalN.GetElementsByTagName("vCOFINS")[0].InnerText.ToString().Replace(".", ","));
                            objIcmsTot.Voutro = Convert.ToDecimal(xTotalN.GetElementsByTagName("vOutro")[0].InnerText.ToString().Replace(".", ","));
                            objIcmsTot.Vnf = Convert.ToDecimal(xTotalN.GetElementsByTagName("vNF")[0].InnerText.ToString().Replace(".", ","));

                            objTotal.belIcmstot = objIcmsTot;
                            break;
                        }
                    case "ISSQNTot":
                        {
                            xTotalN.LoadXml(xDoc.GetElementsByTagName("ISSQNTot")[0].OuterXml);

                            belIssqntot objIssqntot = new belIssqntot();
                            objIssqntot.Vserv = Convert.ToDecimal(xTotalN.GetElementsByTagName("vServ")[0].InnerText.ToString().Replace(".", ","));
                            objIssqntot.Vbc = Convert.ToDecimal(xTotalN.GetElementsByTagName("vBC")[0].InnerText.ToString().Replace(".", ","));
                            objIssqntot.Viss = Convert.ToDecimal(xTotalN.GetElementsByTagName("vISS")[0].InnerText.ToString().Replace(".", ","));
                            objIssqntot.Vpis = Convert.ToDecimal(xTotalN.GetElementsByTagName("vPIS")[0].InnerText.ToString().Replace(".", ","));
                            objIssqntot.Vcofins = Convert.ToDecimal(xTotalN.GetElementsByTagName("vCONFIS")[0].InnerText.ToString().Replace(".", ","));

                            objTotal.belIssqntot = objIssqntot;

                            break;
                        }
                    case "retTrib":
                        {
                            xTotalN.LoadXml(xDoc.GetElementsByTagName("retTrib")[0].OuterXml);

                            belRetTrib objRettrib = new belRetTrib();
                            objRettrib.Vretpis = Convert.ToDecimal(xTotalN.GetElementsByTagName("vRetPIS")[0].InnerText.ToString().Replace(".", ","));
                            objRettrib.Vretcofins = Convert.ToDecimal(xTotalN.GetElementsByTagName("vRetCOFINS")[0].InnerText.ToString().Replace(".", ","));
                            objRettrib.Vretcsll = Convert.ToDecimal(xTotalN.GetElementsByTagName("vRetCSLL")[0].InnerText.ToString().Replace(".", ","));
                            objRettrib.Vbcirrf = Convert.ToDecimal(xTotalN.GetElementsByTagName("vBCIRRF")[0].InnerText.ToString().Replace(".", ","));
                            objRettrib.Virrf = Convert.ToDecimal(xTotalN.GetElementsByTagName("vIRRF")[0].InnerText.ToString().Replace(".", ","));
                            objRettrib.Vbcretprev = Convert.ToDecimal(xTotalN.GetElementsByTagName("vBCRetPrev")[0].InnerText.ToString().Replace(".", ","));
                            objRettrib.Vretprev = Convert.ToDecimal(xTotalN.GetElementsByTagName("vRetPrev")[0].InnerText.ToString().Replace(".", ","));

                            objTotal.belRetTrib = objRettrib;

                            break;
                        }
                }

            }
            catch (Exception ex)
            {

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

            return objTotal;

        }