public ActionResult Filter(int id)
        {
            object viewModel = null;

            ViewBag.title = this._report[id];
            switch (id)
            {
                case 5:
                    ViewBag.type = new SortedList()
                    {
                        { 1,    "盈電工程有限公司" },
                        { 2,    "盈電機電工程有限公司" }
                    };
                    break;
                case 7:
                    ViewBag.type = new SortedList()
                    {
                        { 1,    "All Billed ACQ" },
                        { 2,    "Billed ACQ with Dummy Invoice Only" },
                        { 3,    "Billed ACQ with invoice Number" }
                    };
                    break;
                case 8:
                    ViewBag.dummy = new SortedList()
                    {
                        { 1,    "All" },
                        { 2,    "With Dummy Invoice" },
                        { 3,    "Without Dummy Invoice" }
                    };
                    break;
                case 9:
                    viewModel = new Report9Model()
                        {
                            types = new Report9ModelType[] { Report9ModelType.Maintenance, Report9ModelType.Quotation }
                        };
                    break;
                case 11:
                    ViewBag.region = this.getRegion();
                    viewModel = new Report11Model()
                    {
                        order_date = DateTime.Today.ToString("dd-MM-yyyy"),
                        //order_date_required = true
                    };
                    break;
                case 12:
                    ViewBag.engineer = this.getEngineer();
                    break;
                case 13:
                    ViewBag.type = new SortedList()
                    {
                        { 1,    "Invoice" },
                        { 2,    "Quotation" }
                    };
                    ViewBag.type2 = new SortedList()
                    {
                        { 1,    "for Maintenance Contract (ACM)" },
                        { 2,    "for Quotation (ACQ)" }
                    };
                    break;
                case 14:
                    ViewBag.type = new SortedList()
                    {
                        { 1,    "All" },
                        { 2,    "T&C Only" },
                        { 3,    "Not T&C Only" },
                        { 4,    "Without Service Date" }
                    };
                    break;
                case 15:
                    ViewBag.region = this.getRegion();
                    break;
                case 16:
                    //ViewBag.type = _bank;
                    break;
                case 17:
                    ViewBag.region = this.getRegion();
                    break;
                case 19:
                    Report19Model repot19model = new Report19Model();
                    repot19model.Modes = new Report19ModelMode[] { Report19ModelMode.By_Category, Report19ModelMode.By_Employee, Report19ModelMode.By_Sub__Contractor, Report19ModelMode.By_Supplier, Report19ModelMode.By_Minor_Work };
                    repot19model.CostCategories = this.getCosts();
                    repot19model.Suppliers = this.getSuppliers();
                    viewModel = repot19model;
                    break;
                case 20:
                    ViewBag.order_status = new SortedList()
                    {
                        { 1, "預約保養" },
                        { 2, "做保養" },
                        { 3, "完成保養" }
                    };
                    break;
                case 21:
                    //ViewBag.district = this.getDistrict();
                    var district = (from d in this._db.recsys_district
                            where d.status == 1 && (d.name == "帝琴灣" || d.name == "爵悅庭")
                            orderby d.region ascending
                            select d);
                    ViewBag.district = Common.array_conv(Common.query(district), "id", "name");
                    break;
                case 22:
                    Report22Model report22Model = new Report22Model();
                    report22Model.show_printed = false;
                    viewModel = report22Model;
                    break;
            }
            return View("Report" + id, viewModel);
        }
 public ActionResult Report19(Report19Model model)
 {
     return new ReportsGenController().Report19(model);
 }
        public ActionResult Report19(Report19Model model)
        {
            ExpenseReportModel reportModel = new ExpenseReportModel()
            {
                CompanyName1 = "REC ENGINEERING COMPANY LIMITED",
                CompanyName2 = "REC ENGINEERING CONTRACTING COMPANY LIMITED",
                Mode = model.Mode,
                PrintingDate = DateTime.Now
            };

            DateTime? start;
            DateTime? end;
            if (!string.IsNullOrEmpty(model.start_date))
            {
                start = DateTime.ParseExact(model.start_date, DATEPICKER_DATE_FORMAT, null);
            }
            else
            {
                start = null;
            }
            if (!string.IsNullOrEmpty(model.end_date))
            {
                end = DateTime.ParseExact(model.end_date, DATEPICKER_DATE_FORMAT, null);
            }
            else
            {
                end = null;
            }

            DateTime? lastUpdate;
            if (!string.IsNullOrEmpty(model.lastUpdateDate))
            {
                lastUpdate = DateTime.ParseExact(model.lastUpdateDate, DATEPICKER_DATE_FORMAT, null);
            }
            else
            {
                lastUpdate = null;
            }

            switch (model.Mode)
            {
                case Report19ModelMode.By_Category:
                    if (model.SelectedCostCategories == null || model.SelectedCostCategories.Count() <= 0)
                        return Content("請選擇Cost Category");
                    else
                        return this.Report19_ByCategory(start, end, model.SelectedCostCategories, lastUpdate, ref reportModel);
                case Report19ModelMode.By_Employee:
                    return this.Report19_ByUser(start, end, lastUpdate, ref reportModel);
                case Report19ModelMode.By_Sub__Contractor:
                    return this.Report19_BySubCon(start, end, lastUpdate, ref reportModel);
                case Report19ModelMode.By_Supplier:
                    if (model.SelectedSuppliers == null || model.SelectedSuppliers.Count() <= 0)
                        return Content("請選擇Supplier");
                    else
                        return this.Report19_BySupplier(start, end, model.SelectedSuppliers, lastUpdate, ref reportModel);
                case Report19ModelMode.By_Minor_Work:
                    var minor_work_cats = (from c in this._db.recsys_cost
                                    where c.status == 1 && c.IsMinorWork == 1
                                    select c.id);
                    int[] minor_work_cats_array = minor_work_cats.ToArray();    //minor-work-category-id
                    if (minor_work_cats_array.Length == 0) return Content("沒有設定Minor Work Category");
                    return this.Report19_ByCategory(start, end, minor_work_cats_array, lastUpdate, ref reportModel);
                default:
                    return Content("請選擇報告模式");
            }
        }