Ejemplo n.º 1
0
        //public IEnumerable<string> GetRirekiFiles()
        //{
        //    // 履歴ファイルリスト
        //    return Directory.EnumerateFiles(rirekiFolderPath, "rireki*.csv");
        //}

        public async Task <int> GetKakeiboData(ModelKakeibo model)
        {
            using (SQLManager manager = SQLManager.GetInstance(dataSource, dataBase, userId, password))
            {
                return(await GetKakeiboData(manager, model));
            }
        }
Ejemplo n.º 2
0
        private async Task <int> GetKakeiboData(SQLManager manager, ModelKakeibo model)
        {
            return(await Task.Run(() =>
            {
                string sql = @"
                    SELECT 
                        seq
                        , hiduke
                        , naiyou
                        , nyukin
                        , shukkin
                        , zankin
                        , bikou
                    FROM kakeibo_rireki
                    WHERE hiduke BETWEEN @from AND @to
                    ";

                Dictionary <string, dynamic> parameters = new Dictionary <string, dynamic>
                {
                    { "from", ControlValuesDictionary["dtpFrom"].ToString("yyyy/MM/dd") },
                    { "to", ControlValuesDictionary["dtpTo"].ToString("yyyy/MM/dd") },
                };

                DataTable dtRireki = manager.Select(sql, parameters);

                model.Zankin = GetZankin(manager);

                model.RirekiTable = dtRireki;

                SetShukeiData(model, dtRireki);

                return dtRireki.Rows.Count;
            }));
        }
Ejemplo n.º 3
0
        public int GetRireki(ModelKakeibo model)
        {
            try
            {
                // csvファイル読込
                // ToListで読み込み処理を確定させる
                CsvFileService csv = CsvFileService.GetInstance();

                List <string[]> list = csv.CsvFileRead(model.RirekiFile, encoding)?.ToList();

                if (list.First() == null)
                {
                    return(-1);
                }

                (DataTable dtRireki, int shunyu, int shishutsu) = ConvertToRirekiDataTable(list);
                model.SumShunyu    = shunyu;
                model.SumShishutsu = shishutsu;

                // 残金は履歴ファイルの最終行を設定
                int.TryParse(list.Last()[EnumRireki.Zankin.GetInt()], out int zankin);
                model.Zankin = zankin;

                // データテーブルを設定
                model.RirekiTable = dtRireki;
                model.ShukeiTable = GetShukeiTable(dtRireki);
            }
            catch (Exception ex)
            {
                // csvファイルのデータが0件・1件の場合 ArgumentNullException
                Debug.WriteLine(ex.Message);
            }
            return(0);
        }
Ejemplo n.º 4
0
 private void SetShukeiData(ModelKakeibo model, DataTable dtRireki)
 {
     model.ShukeiTable = GetShukeiTable(dtRireki);
     int.TryParse(dtRireki.Compute("Sum(nyukin)", null).ToString(), out int sumShunyu);
     int.TryParse(dtRireki.Compute("Sum(shukkin)", null).ToString(), out int sumShishutsu);
     model.SumShunyu    = sumShunyu;
     model.SumShishutsu = sumShishutsu;
 }