示例#1
0
        protected TempXSDJ GetTempXSDJ(strDanju danju)
        {
            int num;

            if (danju.str.Count < 7)
            {
                for (num = danju.str.Count; num < 7; num++)
                {
                    danju.str.Add("");
                }
            }
            TempXSDJ pxsdj = new TempXSDJ {
                Djh = danju.str[0]
            };
            int result = 0;

            if (!int.TryParse(danju.str[1], out result))
            {
                throw new CustomException("传入txt格式不正确");
            }
            pxsdj.Sphs   = result;
            pxsdj.Gfmc   = danju.str[2];
            pxsdj.Gfsh   = danju.str[3];
            pxsdj.Gfdzdh = danju.str[4];
            pxsdj.Gfyhzh = danju.str[5];
            pxsdj.Bz     = danju.str[6];
            if (danju.str.Count > 7)
            {
                pxsdj.Fhr = danju.str[7];
            }
            if (danju.str.Count > 8)
            {
                pxsdj.Skr = danju.str[8];
            }
            if (danju.str.Count > 9)
            {
                pxsdj.Qdspmc = danju.str[9];
            }
            if ((danju.str.Count > 10) && !string.IsNullOrEmpty(danju.str[10]))
            {
                DateTime now = DateTime.Now;
                DateTime.TryParse(danju.str[10], out now);
                pxsdj.Djrq = now.Date;
            }
            if (danju.str.Count > 11)
            {
                pxsdj.Xfyhzh = danju.str[11];
            }
            if (danju.str.Count > 12)
            {
                pxsdj.Xfdzdh = danju.str[12];
            }
            if (danju.str.Count > 13)
            {
                pxsdj.SFZJY = CommonTool.ToStringBool(danju.str[13]);
            }
            if (danju.str.Count > 14)
            {
                pxsdj.HYSY = CommonTool.ToBoolString(danju.str[14]);
            }
            for (num = 0; num < danju.mingxi.Count; num++)
            {
                TempXSDJ_MX item = this.GetTempXSDJ_MX(danju.mingxi[num], pxsdj.Djh, num + 1);
                if (item != null)
                {
                    pxsdj.Mingxi.Add(item);
                }
            }
            return(pxsdj);
        }
示例#2
0
        public strBiao JieXiShuXing()
        {
            strBiao biao = new strBiao();

            string[]      strArray = File.ReadAllLines(this.path, ToolUtil.GetEncoding());
            List <string> list     = new List <string>();

            for (int i = 0; i < strArray.Length; i++)
            {
                if (!((strArray[i].Trim().Trim(new char[1]).Length == 0) || strArray[i].Trim().StartsWith("//")))
                {
                    list.Add(strArray[i]);
                }
            }
            int num2 = 0;

            if (list.Count < 2)
            {
                throw new CustomException("001");
            }
            string row = list[num2];

            if (row.Contains("~~"))
            {
                if (!row.Substring(0, row.IndexOf(this.SplitStr)).Equals(this.BeginStr))
                {
                    throw new CustomException("001");
                }
            }
            else if (row.Contains(" ") | row.Contains(","))
            {
                this.SplitStr = " ";
            }
            if (this.SplitStr.Equals("~~"))
            {
                biao.str = this.StringSplit(row);
            }
            else
            {
                num2 = -1;
            }
            while (true)
            {
                bool flag = true;
                num2++;
                if (num2 >= list.Count)
                {
                    return(biao);
                }
                row = list[num2];
                strDanju item = new strDanju {
                    str = this.StringSplit(row)
                };
                int result = 0;
                if (item.str.Count > 1)
                {
                    if (!int.TryParse(item.str[1], out result))
                    {
                        base.errorResolver.AddError("单据商品行数有错误", item.str[0], 1, false);
                    }
                    else
                    {
                        base.errorResolver.ImportTotal++;
                        while (0 < result--)
                        {
                            num2++;
                            int lineNum = int.Parse(item.str[1]) - result;
                            if (num2 < list.Count)
                            {
                                strMingxi mingxi = new strMingxi {
                                    str = this.StringSplit(list[num2])
                                };
                                item.mingxi.Add(mingxi);
                            }
                            else
                            {
                                base.errorResolver.AddError("缺少商品行", item.str[0], lineNum, false);
                                flag = false;
                            }
                        }
                        if (flag)
                        {
                            biao.danju.Add(item);
                        }
                        else
                        {
                            base.errorResolver.AbandonCount++;
                        }
                    }
                }
                else
                {
                    base.errorResolver.AddError("单据仅有单据号", item.str[0], 1, false);
                }
            }
        }