private void SearchButtonClicked()
        {
            if (form.StartDate == null || form.EndDate == null)
            {
                helper.MsgBox.Err(KaikeiSystemBody.Properties.Resources.MsgInvalidDate);
                return;
            }
            if (form.TargetKamokuCode == null)
            {
                helper.MsgBox.Err(KaikeiSystemBody.Properties.Resources.MsgInvalidKamoku);
                return;
            }

            models.db.Row kamokuRow = Context.KaikeiDatabase.MTKanjouKamoku.GetRowFromCodeCache(-1, form.TargetKamokuCode);
            if (kamokuRow == null)
            {
                helper.MsgBox.Err(KaikeiSystemBody.Properties.Resources.MsgInvalidKamoku);
                return;
            }
            int kamokuId = (int)kamokuRow.GetLong("id", -1);

            mototyou.Calc(form.StartDate.Value, form.EndDate.Value, kamokuId, form.TargetKaikeiKubun, form.DenpyouSeiriChecked, isHojoKamoku: false);
            form.SetMototyouData(mototyou);
        }
Beispiel #2
0
        private void AddMototyouReport(DataDynamics.ActiveReports.ActiveReport parentReport, int kanjouKamokuId, int parentKamokuId, bool isHojoKamoku)
        {
            models.query.KanjouMototyou mototyou = new models.query.KanjouMototyou(context.KaikeiDatabase);
            mototyou.Calc(
                popup.StartDate.Value,
                popup.EndDate.Value,
                kanjouKamokuId,
                popup.TargetKaikeiKubun,
                renumberDenpyouBangou: false,
                isHojoKamoku: isHojoKamoku);

            int    kaikeiKubun = popup.TargetKaikeiKubun;
            string houjinMei   = context.KaikeiDatabase.MTKaikeiKubun.GetRowFromCache(context.KaikeiDatabase.MTKaikeiKubun.RootNodeId).GetStr("name") as string;
            string shisetsuMei = "";

            if (kaikeiKubun != -1 && kaikeiKubun != context.KaikeiDatabase.MTKaikeiKubun.RootNodeId)
            {
                shisetsuMei = context.KaikeiDatabase.MTKaikeiKubun.GetRowFromCache(kaikeiKubun).GetStr("name") as string;
            }
            models.db.Row kanjouKamokuRow = context.KaikeiDatabase.MTKanjouKamoku.GetFirstRow("where id=" + kanjouKamokuId);
            string        kamokuMei       = kanjouKamokuRow.GetStr("kamoku", "");

            DataDynamics.ActiveReports.ActiveReport report = null;
            if (popup.RenzokuKeishikiChecked)
            {
                report = new views.reports.KanjouMototyou2();
                if (isHojoKamoku == false)
                {
                    (report as views.reports.KanjouMototyou2).SetHeader(houjinMei, shisetsuMei, kamokuMei, "", isHojoMototyou: false);
                }
                else
                {
                    models.db.Row parentKanjouKamokuRow = context.KaikeiDatabase.MTKanjouKamoku.GetFirstRow("where id=" + parentKamokuId);
                    string        parentKamokuMei       = parentKanjouKamokuRow.GetStr("kamoku", "");
                    (report as views.reports.KanjouMototyou2).SetHeader(houjinMei, shisetsuMei, parentKamokuMei, kamokuMei, isHojoMototyou: true);
                }
            }
            else
            {
                report = new views.reports.KanjouMototyou();
                (report as views.reports.KanjouMototyou).SetHeader(houjinMei, shisetsuMei, kamokuMei);
            }

            bool printReport = false;

            if (mototyou.MototyouRows.Count > 0)
            {
                report.DataSource = mototyou.MototyouRows;
                printReport       = true;
            }
            else if (mototyou.ZengetsuKurikoshiGaku != 0)
            {
                // 伝票がない場合、前期繰越の額を印刷する。
                List <models.query.KanjouMototyou.MototyouRow> rows = new List <models.query.KanjouMototyou.MototyouRow>();
                int taisyakuKubunId = (int)kanjouKamokuRow.GetLong("taisyaku_kubun_id", -1);

                long karikataKingaku  = 0;
                long kashikataKingaku = 0;

                switch ((models.constants.MTTaisyakuKubun)taisyakuKubunId)
                {
                case models.constants.MTTaisyakuKubun.KariPlus:
                case models.constants.MTTaisyakuKubun.KariMinus:
                    karikataKingaku = mototyou.ZengetsuKurikoshiGaku;
                    break;

                case models.constants.MTTaisyakuKubun.KashiPlus:
                case models.constants.MTTaisyakuKubun.KashiMinus:
                    kashikataKingaku = mototyou.ZengetsuKurikoshiGaku;
                    break;
                }

                var row = new models.query.KanjouMototyou.MototyouRow(
                    -1,
                    "",
                    -1,
                    DateTime.Now,
                    "",
                    "",
                    karikataKingaku,
                    kashikataKingaku,
                    mototyou.ZengetsuKurikoshiGaku,
                    null,
                    false,
                    mototyou.ZengetsuKurikoshiGaku
                    );
                rows.Add(row);

                if (popup.RenzokuKeishikiChecked)
                {
                    (report as views.reports.KanjouMototyou2).ZenkiKurikoshiOnly = true;
                }
                else
                {
                    (report as views.reports.KanjouMototyou).ZenkiKurikoshiOnly = true;
                }
                report.DataSource = rows;

                printReport = true;
            }

            if (printReport)
            {
                report.Run();
                parentReport.Document.Pages.AddRange(report.Document.Pages.GetRange(0, report.Document.Pages.Count));
            }
        }