Exemplo n.º 1
0
        public string ispDollarsOnly(string strVal)
        {
            string r = string.Empty;

            if (string.IsNullOrEmpty(strVal))
            {
                r = "";
            }
            else
            {
                r = VB.CDbl(strVal).ToString();
            }
            return(r);
        }
Exemplo n.º 2
0
        //'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
        public void PopulateXML(string sSection, object vData, XmlDocument oTmplXML, ref XmlDocument oDataXML)
        {
            string[]    lData = null;
            int         iCounter = 0;
            int         lStrLen = 0, lTotalStrLen = 0, lStrLenSum = 0;
            XmlNode     lChildNode = null;
            int         lPercision = 0;
            XmlDocument lobjXML    = new XmlDocument();

            lobjXML.LoadXml(xUtil.ispXmlGetRecordXml(oTmplXML, sSection, 0));
            if (VB.IsArray(vData))
            {
                string[] tempData = (string[])vData;
                lData = new string[tempData.Length];
                for (int i = 0; i < tempData.Length; i++)
                {
                    lData[i] = tempData[i];
                }
            }
            else
            {
                lData    = new string[1];
                lData[0] = vData.ToString();
            }

            iCounter = lData.Length;

            for (int i = 0; i < iCounter; i++)
            {
                lStrLenSum   = 1;
                lTotalStrLen = VB.len(lData[i]);
                lData[i]     = lData[i] + VB.space(Util.GetInt(lobjXML.DocumentElement.Attributes.GetNamedItem("LENGTH").InnerText) - VB.len(lData[i]));
                for (int j = 0; j < lobjXML.DocumentElement.ChildNodes.Count; j++)
                {
                    lChildNode           = lobjXML.DocumentElement.ChildNodes.Item(j);
                    lChildNode.InnerText = string.Empty;
                }
                if (lTotalStrLen > 0)
                {
                    for (int j = 0; j < lobjXML.DocumentElement.ChildNodes.Count; j++)
                    {
                        lChildNode           = lobjXML.DocumentElement.ChildNodes.Item(j);
                        lStrLen              = Util.GetInt(lChildNode.Attributes.GetNamedItem("LENGTH").InnerText);
                        lChildNode.InnerText = VB.mid(lData[i], lStrLenSum, lStrLen).Trim();
                        if (lChildNode.Attributes.GetNamedItem("TYPE").InnerText == "N" && VB.IsNumeric(lChildNode.InnerText))
                        {
                            if (lChildNode.Attributes.GetNamedItem("PERCISION") != null)
                            {
                                lPercision           = Util.GetInt(lChildNode.Attributes.GetNamedItem("PERCISION").InnerText);
                                lChildNode.InnerText = Util.GetString(VB.CDbl(VB.Left(lChildNode.InnerText, lStrLen - lPercision) + "." + VB.Right(lChildNode.InnerText, lPercision)));
                            }
                            else
                            {
                                lChildNode.InnerText = Util.GetString(VB.CDbl(lChildNode.InnerText));
                            }
                        }
                        else if (lChildNode.Attributes.GetNamedItem("TYPE").InnerText == "D")
                        {
                            if (VB.CSng(lChildNode.InnerText) == 0)
                            {
                                lChildNode.InnerText = string.Empty;
                            }
                            else
                            {
                                lChildNode.InnerText = VB.FormatDate(lChildNode.InnerText);
                            }
                        }
                        else if (lChildNode.Attributes.GetNamedItem("TYPE").InnerText == "C")
                        {
                            if (VB.instr(1, lChildNode.InnerText, "-") != 0)
                            {
                                lChildNode.InnerText = lChildNode.InnerText.Replace("-", "");
                                lChildNode.InnerText = "-" + lChildNode.InnerText;
                            }
                            if (VB.CSng(lChildNode.InnerText) == 0)
                            {
                                lChildNode.InnerText = string.Empty;
                            }
                            else
                            {
                                if (VB.instr(1, lChildNode.InnerText, "-") != 0)
                                {
                                    lChildNode.InnerText = VB.Left(lChildNode.InnerText, lStrLen - 2) + "." + VB.Right(lChildNode.InnerText, 2);
                                }
                                lChildNode.InnerText = VB.FormatCurrency(lChildNode.InnerText, 2);
                            }
                        }
                        else if (lChildNode.Attributes.GetNamedItem("TYPE").InnerText == "P" && VB.IsNumeric(lChildNode.InnerText))
                        {
                            if (VB.CSng(lChildNode.InnerText) == 0)
                            {
                                lChildNode.InnerText = string.Empty;
                            }
                            else
                            {
                                lChildNode.InnerText = CopMvcUtil.GetString(VB.Clng(lChildNode.InnerText));
                            }
                        }
                        lStrLenSum = lStrLenSum + lStrLen;
                    }
                }
                if ((lTotalStrLen == 0 && i == 0) || lTotalStrLen != 0)
                {
                    if (i == 0)
                    {
                        xUtil.ispXmlReplaceNode(ref oDataXML, sSection, i, lobjXML, sSection, i);
                    }
                    else
                    {
                        xUtil.ispAppendNodeXml(ref oDataXML, "*", 0, lobjXML, sSection, 0);
                    }
                }
            }
        }