Exemplo n.º 1
0
        public string GetValue(string strVal, int intStart, int intLen)
        {
            string r = VB.mid(strVal, intStart, intLen).Trim();

            intStart = intStart + intLen;
            return(r);
        }
Exemplo n.º 2
0
        //'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
        public string Pad0(string sInput)
        {
            string output = string.Empty;

            if (VB.len(sInput) == 1)
            {
                output = "0" + sInput;
            }
            else
            {
                output = sInput;
            }
            return(output);
        }
Exemplo n.º 3
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.º 4
0
        public string ispCurrency(string strVal)
        {
            string r = string.Empty;

            if (string.IsNullOrEmpty(strVal))
            {
                r = "";
            }
            else
            {
                r = VB.FormatCurrency(strVal, 2);
            }
            return(r);
        }
Exemplo n.º 5
0
        public string FormatDate(string strVal)
        {
            string r;

            if (string.IsNullOrEmpty(strVal))
            {
                r = "";
            }
            else
            {
                r = VB.mid(strVal, 5, 2) + "/" + VB.mid(strVal, 7, 2) + "/" + VB.mid(strVal, 1, 4);
            }
            return(r);
        }
Exemplo n.º 6
0
        public string SetNumValue(string strVal, int intLen)
        {
            string r = string.Empty;

            if (VB.len(strVal) > intLen)
            {
                r = VB.Left(strVal, intLen);
            }
            else
            {
                int ln = intLen - VB.len(strVal);
                r = new string('0', ln) + strVal;
            }

            return(r);
        }
Exemplo n.º 7
0
        public string FormatCobolDate(string strVal, int intLen)
        {
            CString r = string.Empty;

            strVal = strVal.Replace("-", "");
            strVal = strVal.Replace("/", "");
            strVal = strVal.Replace(".", "");
            strVal = SetValue(strVal, 8);

            r += VB.Right(strVal, 4);     //gets year
            r += VB.mid(strVal, 1, 2);    //gets month
            r += VB.mid(strVal, 3, 2);    //gets date


            return(r.ToString());
        }
Exemplo n.º 8
0
        public string FormatRefNo(string strVal)
        {
            CString strDate, strHour, strMin, strSec, sDate, strTime;

            if (string.IsNullOrEmpty(strVal))
            {
                return("");
            }
            else
            {
                sDate   = (100000000 - CopMvcUtil.GetLong(strVal.Substring(0, 8))).ToString();
                strTime = (1000000 - CopMvcUtil.GetLong(strVal.Substring(8))).ToString(); //1000000 - mid(strVal,9)

                if (VB.len(strTime) == 5)
                {
                    strTime = "0" + strTime;
                }

                strHour = VB.mid(strTime, 1, 2);
                if (VB.len(strHour) == 1)
                {
                    strHour = "0" + strHour;
                }

                strHour = strHour + ":";

                strMin = VB.mid(strTime, 3, 2);
                if (VB.len(strMin) == 1)
                {
                    strMin = "0" + strMin;
                }
                strMin = strMin + ".";

                strSec = VB.mid(strTime, 5, 2);
                if (VB.len(strSec) == 1)
                {
                    strSec = "0" + strSec;
                }

                strDate = VB.mid(sDate, 5, 2) + "/" + VB.mid(sDate, 7, 2) + "/" + VB.mid(sDate, 1, 4) + " ";

                string r = strDate + strHour + strMin + strSec;

                return(r);
            }
        }
Exemplo n.º 9
0
        public string FormatCobolDate(string strVal, int intLen)
        {
            string  strDate;
            CString r = string.Empty;

            if (string.IsNullOrEmpty(strVal))
            {
                //FormatCobolDate = SetValue(strVal,intLen)
            }
            else
            {
                strVal = strVal.Replace("-", ""); //Replace(strVal,"-","")
                strVal = strVal.Replace("/", ""); //Replace(strVal,"/","")
                strVal = strVal.Replace(".", ""); //Replace(strVal,".","")
                strVal = SetValue(strVal, 8);     //SetValue(strVal,8)

                //r = Right(strVal, 4) & Mid(strVal, 1, 2) & Mid(strVal, 3, 2);

                r += VB.Right(strVal, 4);  //gets year
                r += VB.mid(strVal, 1, 2); //gets month
                r += VB.mid(strVal, 3, 2); //gets date
            }
            return(r.ToString());
        }
Exemplo n.º 10
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);
                    }
                }
            }
        }
Exemplo n.º 11
0
        //'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
        public void PopulateBuffer(XmlDocument oXML, string sSection, object vData, ref string gsDebugUp) //Overloaded
        {
            string      liSectCounter = string.Empty;
            XmlDocument lTmplXML      = new XmlDocument();

            lTmplXML.LoadXml(xUtil.ispXmlGetRecordXml(oXML, sSection, 0));
            liSectCounter = xUtil.ispXmlGetRecCount(oXML, sSection, "");
            if (lTmplXML.DocumentElement.GetAttributeNode("OCCURS") != null)
            {
                int    count = 0;
                string sTemp = string.Empty;
                string sData = string.Empty;
                string lYear = string.Empty, lMonth = string.Empty, lDay = string.Empty;
                int    dataLength = 0;
                if (lTmplXML.DocumentElement.GetAttributeNode("LENGTH") != null)
                {
                    int.TryParse(lTmplXML.DocumentElement.GetAttributeNode("LENGTH").InnerText, out dataLength);
                }

                int.TryParse(lTmplXML.DocumentElement.GetAttributeNode("OCCURS").InnerText, out count);
                if (count > 0)
                {
                    for (int j = 0; j < count; j++)
                    {
                        sTemp = string.Empty;
                        sData = string.Empty;
                        int sectcounter = 0;
                        int.TryParse(liSectCounter, out sectcounter);

                        if (j >= sectcounter)
                        {
                            sData = sData + VB.space(dataLength);
                        }
                        else
                        {
                            for (int k = 0; k < lTmplXML.DocumentElement.ChildNodes.Count; k++)
                            {
                                XmlNode lChildNode = lTmplXML.DocumentElement.ChildNodes.Item(k);
                                int.TryParse(lChildNode.Attributes.GetNamedItem("LENGTH").InnerText, out dataLength);
                                sTemp = oXML.DocumentElement.GetElementsByTagName(sSection).Item(j).ChildNodes.Item(k).InnerText.Trim().ToUpper();
                                if (lChildNode.Attributes.GetNamedItem("TYPE").InnerText == "N")
                                {
                                    sData = sData + new string('0', dataLength - VB.len(sTemp)) + sTemp;
                                }
                                else if (lChildNode.Attributes.GetNamedItem("TYPE").InnerText == "C")
                                {
                                    if (VB.IsNumeric(sTemp))
                                    {
                                        sTemp = sTemp.Replace(".", "");
                                        sTemp = sTemp.Replace(",", "");
                                        sTemp = sTemp.Replace("$", "");
                                        sTemp = VB.mid(VB.FormatCurrency(sTemp, 2), 0);
                                    }
                                    sData = sData + new string('0', dataLength - VB.len(sTemp)) + sTemp;
                                    sData = sData + sTemp + VB.space(dataLength - VB.len(sTemp));
                                }
                                else if (lChildNode.Attributes.GetNamedItem("TYPE").InnerText == "D")
                                {
                                    if (VB.IsDate(sTemp))
                                    {
                                        DateTime Tempdate;
                                        DateTime.TryParse(sTemp, out Tempdate);
                                        lYear  = Util.GetString(Tempdate.Year);
                                        lMonth = Util.GetString(Tempdate.Month);
                                        lDay   = Util.GetString(Tempdate.Day);

                                        if (VB.len(lYear) < 4)
                                        {
                                            if (Util.GetInt(lYear) < 20)
                                            {
                                                lYear = "20" + lYear;
                                            }
                                            else
                                            {
                                                lYear = "19" + lYear;
                                            }

                                            if (VB.len(lMonth) < 2)
                                            {
                                                lMonth = "0" + lMonth;
                                            }

                                            if (VB.len(lDay) < 2)
                                            {
                                                lDay = "0" + lDay;
                                            }
                                            sTemp = lYear + lMonth + lDay;
                                        }
                                        else
                                        {
                                            sTemp = string.Empty;
                                        }
                                        sData = sData + sTemp + VB.space(dataLength - VB.len(sTemp));
                                    }
                                    else
                                    {
                                        sData = sData + sTemp + VB.space(dataLength - VB.len(sTemp));
                                    }
                                }
                            }



                            if (VB.IsArray(vData))
                            {
                                string[] tempData = (string[])vData;
                                string[] varray   = new string[tempData.Length];

                                tempData.CopyTo(varray, 0);
                                gsDebugUp = gsDebugUp + sData;
                                varray[j] = sData;
                                vData     = varray;
                            }
                            else
                            {
                                gsDebugUp = gsDebugUp + sData;
                                vData     = sData;
                            }
                        }
                    }
                }
            }
        }
Exemplo n.º 12
0
        //'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
        public void PopulateBuffer(XmlDocument oXML, string sSection, ref string[] vData)
        {
            string      liSectCounter = string.Empty;
            XmlDocument lTmplXML      = new XmlDocument();

            lTmplXML.LoadXml(xUtil.ispXmlGetRecordXml(oXML, sSection, 0));
            liSectCounter = xUtil.ispXmlGetRecCount(oXML, sSection, "");
            if (lTmplXML.DocumentElement.GetAttributeNode("OCCURS") != null)
            {
                int    count = 0;
                string sTemp = string.Empty;
                string sData = string.Empty;
                string lYear = string.Empty, lMonth = string.Empty, lDay = string.Empty;
                int    dataLength = 0;
                if (lTmplXML.DocumentElement.GetAttributeNode("LENGTH") != null)
                {
                    dataLength = CopMvcUtil.GetInt(lTmplXML.DocumentElement.GetAttributeNode("LENGTH").InnerText);
                }

                count = CopMvcUtil.GetInt(lTmplXML.DocumentElement.GetAttributeNode("OCCURS").InnerText);
                if (count > 0)
                {
                    for (int j = 0; j < count; j++)
                    {
                        sTemp = string.Empty;
                        sData = string.Empty;
                        int sectcounter = 0;
                        int.TryParse(liSectCounter, out sectcounter);

                        if (j >= sectcounter)
                        {
                            sData = sData + VB.space(dataLength);
                        }
                        else
                        {
                            for (int k = 0; k < lTmplXML.DocumentElement.ChildNodes.Count; k++)
                            {
                                XmlNode lChildNode = lTmplXML.DocumentElement.ChildNodes.Item(k);
                                int     len_lChild = CopMvcUtil.GetInt(lChildNode.Attributes.GetNamedItem("LENGTH").InnerText);
                                sTemp = oXML.DocumentElement.GetElementsByTagName(sSection).Item(j).ChildNodes.Item(k).InnerText.Trim().ToUpper();
                                if (lChildNode.Attributes.GetNamedItem("TYPE").InnerText == "N")
                                {
                                    sData = sData + new string('0', len_lChild - VB.len(sTemp)) + sTemp;
                                }
                                else if (lChildNode.Attributes.GetNamedItem("TYPE").InnerText == "C")
                                {
                                    sTemp = sTemp.Replace(".", "");
                                    sTemp = sTemp.Replace(",", "");
                                    sTemp = sTemp.Replace("$", "");

                                    sData = sData + new string('0', len_lChild - VB.len(sTemp)) + sTemp;
                                }
                                else if (lChildNode.Attributes.GetNamedItem("TYPE").InnerText == "D")
                                {
                                    if (VB.IsDate(sTemp))
                                    {
                                        DateTime Tempdate;
                                        DateTime.TryParse(sTemp, out Tempdate);
                                        lYear  = CopMvcUtil.GetString(Tempdate.Year);
                                        lMonth = CopMvcUtil.GetString(Tempdate.Month);
                                        lDay   = CopMvcUtil.GetString(Tempdate.Day);

                                        if (VB.len(lYear) < 4)
                                        {
                                            if (CopMvcUtil.GetInt(lYear) < 20)
                                            {
                                                lYear = "20" + lYear;
                                            }
                                            else
                                            {
                                                lYear = "19" + lYear;
                                            }
                                        }

                                        if (VB.len(lMonth) < 2)
                                        {
                                            lMonth = "0" + lMonth;
                                        }

                                        if (VB.len(lDay) < 2)
                                        {
                                            lDay = "0" + lDay;
                                        }
                                        sTemp = lYear + lMonth + lDay;
                                    }
                                    else
                                    {
                                        sTemp = string.Empty;
                                    }
                                    sData = sData + sTemp + VB.space(len_lChild - VB.len(sTemp));
                                }
                                else
                                {
                                    sData = sData + sTemp + VB.space(len_lChild - VB.len(sTemp));
                                }
                            }
                        }

                        WriteDebugFile("VALUE_IF_J.txt", j.ToString());

                        string[] varray = new string[j + 1];

                        if (vData != null && vData.Length > 0)
                        {
                            if (vData.Length > varray.Length)
                            {
                                for (int i = 0; i < varray.Length; i++)
                                {
                                    varray[i] = vData[i];
                                }
                            }
                            else
                            {
                                vData.CopyTo(varray, 0);
                            }
                        }
                        varray[j] = sData;
                        vData     = varray;
                    }
                }
            }
        }