/// <summary>
 /// コンストラクタ
 /// </summary>
 /// <remarks>
 /// 日付範囲指定で検索してデータセットを取得
 /// </remarks>
 public ServiceGetTblReceiptSearchDays(DateTime dateOne, DateTime dateTwo)
     : base(THIS_CLASS_NAME)
 {
     _model = new ModelListForm();
     ((ModelListForm)_model).dateOne = dateOne.ToString();
     ((ModelListForm)_model).dateTwo = dateTwo.ToString();
 }
 /// <summary>
 /// コンストラクタ
 /// </summary>
 /// <remarks>
 /// 親クラスの引数を指定するやり方があっているか不明。
 /// </remarks>
 public ServiceGetTblReceiptAddItemName(DateTime dateOne, DateTime dateTwo, string item)
     : base(THIS_CLASS_NAME)
 {
     _model = new ModelListForm();
     ((ModelListForm)_model).dateOne = dateOne.ToString();
     ((ModelListForm)_model).dateTwo = dateTwo.ToString();
     ((ModelListForm)_model).item    = item.ToString();
 }
 /// <summary>
 /// コンストラクタ
 /// </summary>
 /// <remarks>
 /// 日付範囲と商品名で検索してデータセットを取得
 /// </remarks>
 public ServiceGetTblReceiptSearchDaysAndGoods(DateTime dateOne, DateTime dateTwo, string goods)
     : base(THIS_CLASS_NAME)
 {
     //todo ModelListFormクラスを型にしているため、このServiceGetTblReceiptクラスが汎用的に利用出来てない。見直す。
     _model = new ModelListForm();
     ((ModelListForm)_model).dateOne = dateOne.ToString();
     ((ModelListForm)_model).dateTwo = dateTwo.ToString();
     ((ModelListForm)_model).goods   = goods.ToString();
 }
 /// <summary>
 /// コンストラクタ
 /// </summary>
 /// <remarks>
 /// 年月(yyyymm)で検索してデータセットを取得
 /// </remarks>
 public ServiceGetTblReceiptSearchYearMonth(DateTime dateOne)
     : base(THIS_CLASS_NAME)
 {
     _model = new ModelListForm();
     ((ModelListForm)_model).dateOne = dateOne.ToString();
 }
Пример #5
0
 /// <summary>
 /// テスト用メソッド
 /// </summary>
 /// <remarks>
 /// 新たに作ったクラスを呼出すテスト用のメソッド
 /// </remarks>
 private void GraffitiVoid()
 {
     _model = new ModelListForm();
 }
Пример #6
0
        /// <summary>
        /// GridView1に値をセットする際に
        /// </summary>
        private void SetGridView1FromDataSet_Graffiti01()
        {
            //--- 日付範囲のチェック ---
            if (txtSearchDayOne.Text != string.Empty & txtSearchDayTwo.Text != string.Empty)
            {
                if (DateTime.Parse(txtSearchDayOne.Text) > DateTime.Parse(txtSearchDayTwo.Text))
                {
                    //todo 14/05/10 とりあえず、終了日を開始日と同じに変える
                    txtSearchDayTwo.Text = txtSearchDayOne.Text;
                }
            }

            //--- 検索する日付でDataSetを取得する
            //todo 14/05/06 日付の判定はViewが良いのか?それとも、Serviceか?検討する。Viewはどこまでif文を使わず処理できるようにするかの方が良いか?
            if (txtSearchDayOne.Text == string.Empty &
                txtSearchDayTwo.Text == string.Empty &
                txtSearchItem.Text == string.Empty &
                txtSearchGoods.Text == string.Empty)
            {
                // 全件検索
                _model = new ModelListForm();
            }
            else if (txtSearchDayOne.Text != string.Empty &
                     txtSearchDayTwo.Text == string.Empty &
                     txtSearchItem.Text == string.Empty &
                     txtSearchGoods.Text == string.Empty)
            {
                // 開始日のみ指定検索
                _model = new ModelListForm(DateTime.Parse(txtSearchDayOne.Text));
            }
            else if (txtSearchDayOne.Text != string.Empty &
                     txtSearchDayTwo.Text != string.Empty &
                     txtSearchItem.Text == string.Empty &
                     txtSearchGoods.Text == string.Empty)
            {
                // 日付範囲指定検索
                _model = new ModelListForm(
                    DateTime.Parse(txtSearchDayOne.Text),
                    DateTime.Parse(txtSearchDayTwo.Text));
            }
            else if (txtSearchDayOne.Text != string.Empty &
                     txtSearchDayTwo.Text != string.Empty &
                     txtSearchItem.Text != string.Empty &
                     txtSearchGoods.Text == string.Empty)
            {
                // 日付範囲指定と品目名で検索
                _model = new ModelListForm(
                    DateTime.Parse(txtSearchDayOne.Text),
                    DateTime.Parse(txtSearchDayTwo.Text),
                    txtSearchItem.Text,
                    true);
            }
            else if (txtSearchDayOne.Text != string.Empty &
                     txtSearchDayTwo.Text != string.Empty &
                     txtSearchItem.Text == string.Empty &
                     txtSearchGoods.Text != string.Empty)
            {
                // 日付範囲指定と商品名で検索
                _model = new ModelListForm(
                    DateTime.Parse(txtSearchDayOne.Text),
                    DateTime.Parse(txtSearchDayTwo.Text),
                    txtSearchGoods.Text);
            }
            else if (txtSearchDayOne.Text == string.Empty &
                     txtSearchDayTwo.Text == string.Empty &
                     txtSearchItem.Text != string.Empty &
                     txtSearchGoods.Text != string.Empty)
            {
                // 品目名と商品名で検索
                // TODO 品目名と商品名だけで検索するサービスを追加する
                _model = new ModelListForm();
            }
            else if (txtSearchDayOne.Text == string.Empty &
                     txtSearchDayTwo.Text == string.Empty &
                     txtSearchItem.Text != string.Empty &
                     txtSearchGoods.Text == string.Empty)
            {
                // 品目名で検索
                // TODO 品目名だけで検索するサービスを追加する
                _model = new ModelListForm();
            }
            else if (txtSearchDayOne.Text == string.Empty &
                     txtSearchDayTwo.Text == string.Empty &
                     txtSearchItem.Text == string.Empty &
                     txtSearchGoods.Text != string.Empty)
            {
                // 商品名で検索
                _model = new ModelListForm(txtSearchGoods.Text);
            }

            // TODO テスト用 +++++++++++++++
            //for (int i = 0; i < 100000; i++)
            //{
            //    System.Data.DataRow dr = _model.dsKakeibo.tblReceipt.NewRow();
            //    //dr = _model.dsKakeibo.tblReceipt.Rows[600];
            //    dr[0] = System.DateTime.Now;
            //    dr[1] = 1;
            //    dr[2] = "交際費";
            //    dr[3] = "松や";
            //    dr[4] = 500;
            //    dr[5] = _model.dsKakeibo.tblReceipt.Rows.Count + i;
            //    dr[6] = false;
            //    dr[7] = 0;

            //    _model.dsKakeibo.tblReceipt.Rows.Add(dr);
            //}
            // +++++++++++++++

            //--- 初期処理を呼ぶ ---
            init();

            //--- 合計金額を集計する ---
            string price = string.Empty;

            price = _model.dsKakeibo.tblReceipt.Compute("Sum(PRICE)", "").ToString();   // TODO tblReceiptのままだと合計されない
            if (price != string.Empty)
            {
                txtSumPrice.Text = string.Format("{0:C}", int.Parse(price));
            }
            else
            {
                txtSumPrice.Text = string.Format("{0:C}", "0");;
            }
            //txtSumPrice.Text = string.Format("{0,9:C}", int.Parse(price)); todo 14/5/6 これだと左側に隙間が出来るなぜか?
        }
Пример #7
0
        /// <summary>
        /// GridView1に値をセットする
        /// </summary>
        /// <remarks>
        /// TODO 検索方法の組み合わせをもっと分かりやすいロジックに修正する
        ///       見やすく。分かりやすく。修正しやすく。
        ///       ⇒2017/04/16 追記:Modelパッケージにinterfaceを使った試作のReceiptクラスを作成
        ///         これをもとに、if文を使った場合わけから、interfaceを使った場合わけに変えてみる
        ///  *-検索ロジック
        ///  __1.開始日と終了日の範囲のみで検索
        ///  __2.開始日と終了日の範囲と品目名で検索
        ///  __3.開始日と終了日の範囲と商品で検索
        ///  __4.開始日と終了日の範囲と品目名&商品で検索
        ///  __5.品目名のみで検索
        ///  __6.商品のみで検索
        ///  __7.開始日のみで検索(開始日の年月のみで検索)
        /// </remarks>
        private void SetGridView1FromDataSet()
        {
            /*
             *
             * 開始日と終了日の日付範囲を確認
             *
             */
            if (txtSearchDayOne.Text != string.Empty & txtSearchDayTwo.Text != string.Empty)
            {
                if (DateTime.Parse(txtSearchDayOne.Text) > DateTime.Parse(txtSearchDayTwo.Text))
                {
                    //終了日を開始日と同じに変える
                    txtSearchDayTwo.Text = txtSearchDayOne.Text;
                }
            }


            /*
             *  検索項目を参照して値の有無により検索方法を選択する
             *
             *  TODO modelクラス側に検索項目を全て渡しておいて、値の有無によっての検索はmodel側に任せる。
             */
            if (
                (txtSearchDayOne.Text.Length != 0) &
                (txtSearchDayTwo.Text.Length != 0) &
                (txtSearchItem.Text.Length != 0) &
                (txtSearchGoods.Text.Length != 0)
                )
            {
                // 全項目で検索
                _model = new ModelListForm();
            }
            else if (
                (txtSearchDayOne.Text.Length != 0) &
                (txtSearchDayTwo.Text.Length != 0) &
                (txtSearchItem.Text.Length != 0) &
                (txtSearchGoods.Text.Length == 0)
                )
            {
                // 開始日&終了日&品目名の3つで検索
                _model = new ModelListForm(
                    DateTime.Parse(txtSearchDayOne.Text),
                    DateTime.Parse(txtSearchDayTwo.Text),
                    txtSearchItem.Text,
                    true);
            }
            else if (
                (txtSearchDayOne.Text.Length != 0) &
                (txtSearchDayTwo.Text.Length != 0) &
                (txtSearchItem.Text.Length != 0) &
                (txtSearchGoods.Text.Length == 0)
                )
            {
                // 開始日&終了日&商品の3つで検索
                _model = new ModelListForm(
                    DateTime.Parse(txtSearchDayOne.Text),
                    DateTime.Parse(txtSearchDayTwo.Text),
                    txtSearchGoods.Text);
            }
            else if (
                (txtSearchDayOne.Text.Length != 0) &
                (txtSearchDayTwo.Text.Length != 0) &
                (txtSearchItem.Text.Length == 0) &
                (txtSearchGoods.Text.Length == 0)
                )
            {
                // 開始日&終了日の2つで検索
                _model = new ModelListForm(
                    DateTime.Parse(txtSearchDayOne.Text),
                    DateTime.Parse(txtSearchDayTwo.Text));
            }
            else if (
                (txtSearchDayOne.Text.Length != 0) &
                (txtSearchDayTwo.Text.Length == 0) &
                (txtSearchItem.Text.Length == 0) &
                (txtSearchGoods.Text.Length == 0)
                )
            {
                // 開始日のみで検索
                _model = new ModelListForm(DateTime.Parse(txtSearchDayOne.Text));
            }
            else if (
                (txtSearchDayOne.Text.Length == 0) &
                (txtSearchDayTwo.Text.Length == 0) &
                (txtSearchItem.Text.Length != 0) &
                (txtSearchGoods.Text.Length != 0)
                )
            {
                // 品目名と商品のみで検索
                //todo searchResult = "TargetIsItemAndGoods";
            }
            else if (
                (txtSearchDayOne.Text.Length == 0) &
                (txtSearchDayTwo.Text.Length == 0) &
                (txtSearchItem.Text.Length != 0) &
                (txtSearchGoods.Text.Length == 0)
                )
            {
                // 品目名のみで検索
                //todo searchResult = "TargetIsItem";
            }


            //--- 初期処理を呼ぶ ---
            init();

            //--- 合計金額を集計する ---
            string price = string.Empty;

            price = _model.dsKakeibo.tblReceipt.Compute("Sum(PRICE)", "").ToString();   // TODO tblReceiptのままだと合計されない
            if (price != string.Empty)
            {
                txtSumPrice.Text = string.Format("{0:C}", int.Parse(price));
            }
            else
            {
                txtSumPrice.Text = string.Format("{0:C}", "0");;
            }
        }
 /// <summary>
 /// コンストラクタ
 /// </summary>
 /// <remarks>
 /// 親クラスの引数を指定するやり方があっているか不明。
 /// </remarks>
 public ServiceGetTblReceiptSearchGoods(string goods)
     : base(THIS_CLASS_NAME)
 {
     _model = new ModelListForm();
     ((ModelListForm)_model).goods = goods.ToString();
 }