Beispiel #1
0
        /// <summary>
        /// 月ごとの表示用データ作成
        /// </summary>
        /// <param name="dataLists">週ごとの収入と支出データ</param>
        /// <returns>表示用文字列データ作成</returns>
        public static List <string[]> GetDisplayDataList(List <MonthDataList> dataLists)
        {
            List <string[]> vs = new List <string[]>();

            try
            {
                if (dataLists == null)
                {
                    return(null);
                }

                for (int i = 0; i < MAX_MONTH_COUNT; i++)
                {
                    MonthDataList monthData = dataLists[i];

                    string[] dataListStr =
                    {
                        monthData.Id + "月",
                        monthData.Income.ToString(),
                        monthData.Spending.ToString()
                    };

                    vs.Add(dataListStr);
                }
            }
            catch
            {
                //string s = e.Message;
                OriginMBox.MBoxErrorOK(AppConst.MONTHDATA_MESSAGE);
                return(null);
            }
            return(vs);
        }
Beispiel #2
0
        /// <summary>
        /// 月ごとの収入と支出データ管理データ取得
        /// </summary>
        /// <returns></returns>
        public static List <MonthDataList> SelectDisplayList(int year, int userId)
        {
            List <MonthDataList> monthDataList = new List <MonthDataList>();

            using (NpgSqlDBManager dBManager = new NpgSqlDBManager())
            {
                try
                {
                    string sql = "select * from public.\"MonthDataList\" where \"userId\" = " + userId;

                    DataSet   dataSet = dBManager.GetDataSet(sql);
                    DataTable table   = dataSet.Tables[0];
                    if (table.Rows.Count < 1)
                    {
                        return(null);
                    }

                    for (int i = 0; i < table.Rows.Count; i++)
                    {
                        DateTime date = DateTime.Parse(table.Rows[i][CREATEDATE_STR].ToString());
                        if (year != date.Year)
                        {
                            continue;
                        }

                        MonthDataList monthData = new MonthDataList();
                        monthData.InitDataRow(table.Rows[i]);

                        monthDataList.Add(monthData);
                    }

                    //データが12か月分あるか確認
                    if (monthDataList.Count != MAX_MONTH_COUNT)
                    {
                        return(null);
                    }
                }
                catch
                {
                    dBManager.RollBack();
                    dBManager.Close();
                    OriginMBox.MBoxErrorOK(AppConst.MONTHDATA_MESSAGE);
                    return(null);
                }
            }
            return(monthDataList);
        }
Beispiel #3
0
        /// <summary>
        /// ベースデータから月ごとのデータ作成
        /// </summary>
        /// <param name="dataLists">ベースデータ</param>
        /// <param name="dateTimeLists">週の始まりと終わりのデータリスト</param>
        /// <returns></returns>
        public static List <MonthDataList> CreateMonthDataList(List <int[]> dataLists, DateTime nowDate, int userId)
        {
            List <MonthDataList> monthDataLists = new List <MonthDataList>();

            try
            {
                if (dataLists == null)
                {
                    return(null);
                }
                if (dataLists[0].Length != MAX_MONTH_COUNT)
                {
                    return(null);
                }
                if (dataLists[1].Length != MAX_MONTH_COUNT)
                {
                    return(null);
                }

                //収入と支出データ作成
                int[] incomes   = dataLists[0];
                int[] spendings = dataLists[1];

                int count = 1;
                for (int i = 0; i < MAX_MONTH_COUNT; i++)
                {
                    MonthDataList monthData = new MonthDataList
                    {
                        Id         = count,
                        Income     = incomes[i],
                        Spending   = spendings[i],
                        CreateDate = nowDate,
                        UserId     = userId
                    };
                    monthDataLists.Add(monthData);
                    count++;
                }
            }
            catch
            {
                //string s = e.Message;
                OriginMBox.MBoxErrorOK(AppConst.MONTHDATA_MESSAGE2);
                return(null);
            }
            return(monthDataLists);
        }