コード例 #1
0
 public ActionResult Report22Print(Report22Model model)
 {
     return Pdf(string.Format("/reportsgen/report22/0/?show_printed={0}&choose_month={1}&choose_year={2}&first_print_date={3}&print_all={4}&print_page={5}&dummy=",
                              model.show_printed,
                              model.choose_month,
                              model.choose_year,
                              model.first_print_date,
                              model.print_all,
                              model.print_page), this._report[22].ToString(), true, 90, 155, 0, 0, 0, 0);
 }
コード例 #2
0
        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);
        }
コード例 #3
0
        public ActionResult Report22(Report22Model model)
        {
            if (model != null)
            {
                IEnumerable<report1> maintenances = null;
                var records = from m in this._db.recsys_maintenance
                              join rc in this._db.recsys_relate_customers on m.customer_id equals rc.id into subrc
                              from rc in subrc.DefaultIfEmpty()
                              join r in this._db.recsys_routine on m.master_routine_id equals r.id into subr
                              from r in subr.DefaultIfEmpty()
                              join d in this._db.recsys_district on rc.district2 equals d.id into subd
                              from d in subd.DefaultIfEmpty()
                              where m.status == 1 && m.confirm_date != null && !d.name.Contains("帝琴灣") && !d.name.Contains("爵悅庭")
                              orderby m.start_date
                              select new report1    //maintenance card model
                              {
                                  maintenance_id = m.id,
                                  start_date = m.start_date,
                                  end_date = m.end_date,
                                  model = m.model,
                                  printed = m.printed,
                                  first_print_date = m.first_print_Date,
                                  customer_name = rc.chi_name,
                                  customer_code = rc.customer_code,
                                  address = rc.address2,
                                  telephone = string.IsNullOrEmpty(rc.tel1) ? string.IsNullOrEmpty(rc.tel2)
                                                                              ? string.Empty
                                                                              : rc.tel2
                                                                            : string.IsNullOrEmpty(rc.tel2)
                                                                              ? rc.tel1
                                                                              : rc.tel1 + ", " + rc.tel2,
                                  routine = m.remark
                              };

                #region Filtering
                if (model.show_printed == false) records = records.Where(m => m.printed == 0);
                else if (!string.IsNullOrEmpty(model.first_print_date) && model.show_printed.Value == true)
                {
                    DateTime start_first_print_date = Convert.ToDateTime(DateTime.ParseExact(model.first_print_date, "dd-MM-yyyy", null).ToString("yyyy-MM-dd"));
                    DateTime end_first_print_date = start_first_print_date.AddDays(1);
                    records = records.Where(m => m.first_print_date >= start_first_print_date).Where(m => m.first_print_date < end_first_print_date);
                }

                if (model.choose_year != null && model.choose_year != 0 && model.choose_month != null && model.choose_month != 0)
                {
                    DateTime compareDate = new DateTime(model.choose_year, model.choose_month, 1);  //first day of the chosen month
                    records = records.Where(m => m.end_date >= compareDate);
                    compareDate = compareDate.AddMonths(1).AddTicks(-1);    //last day of the chosen month
                    records = records.Where(m => m.start_date <= compareDate);
                }
                #endregion Filtering

                maintenances = records.ToList();
                if (maintenances.Count() > 20)
                {
                    Report22PageLinkModel pageLinkModel = new Report22PageLinkModel
                    {
                        show_printed = model.show_printed,
                        choose_month = model.choose_month,
                        choose_year = model.choose_year,
                        first_print_date = model.first_print_date,
                        recordCount = maintenances.Count()
                    };
                    return View("Report22PageLink", pageLinkModel);
                }
                else
                {
                    model.print_all = true;
                    model.print_page = 0;
                }
            }
            return this.Report22Print(model);
        }
コード例 #4
0
        public ActionResult Report22(Report22Model model)
        {
            if (model != null)
            {
                IEnumerable<report1> maintenances = null;
                var records = from m in this._db.recsys_maintenance
                              join rc in this._db.recsys_relate_customers on m.customer_id equals rc.id into subrc
                              from rc in subrc.DefaultIfEmpty()
                              join r in this._db.recsys_routine on m.master_routine_id equals r.id into subr
                              from r in subr.DefaultIfEmpty()
                              join d in this._db.recsys_district on rc.district2 equals d.id into subd
                              from d in subd.DefaultIfEmpty()
                              where m.status == 1 && m.confirm_date != null && !d.name.Contains("帝琴灣") && !d.name.Contains("爵悅庭")
                              orderby m.start_date
                              select new report1    //maintenance card model
                              {
                                  maintenance_id = m.id,
                                  start_date = m.start_date,
                                  end_date = m.end_date,
                                  model = m.model,
                                  printed = m.printed,
                                  first_print_date = m.first_print_Date,
                                  customer_name = rc.chi_name,
                                  customer_code = rc.customer_code,
                                  address = rc.address2,
                                  telephone = string.IsNullOrEmpty(rc.tel1) ? string.IsNullOrEmpty(rc.tel2)
                                                                              ? string.Empty
                                                                              : rc.tel2
                                                                            : string.IsNullOrEmpty(rc.tel2)
                                                                              ? rc.tel1
                                                                              : rc.tel1 + ", " + rc.tel2,
                                  routine = m.remark
                              };

                //Filtering
                if (model.show_printed == false)
                    records = records.Where(m => m.printed == 0);
                else if(!string.IsNullOrEmpty(model.first_print_date) && model.show_printed.Value == true)
                {
                    DateTime start_first_print_date = Convert.ToDateTime(ConvertDateStringFormat(model.first_print_date, DATEPICKER_DATE_FORMAT, DB_DATE_FORMAT));
                    DateTime end_first_print_date = start_first_print_date.AddDays(1);
                    records = records.Where(m => m.first_print_date >= start_first_print_date).Where(m => m.first_print_date < end_first_print_date);
                }

                if (model.choose_year != null && model.choose_year != 0 && model.choose_month != null && model.choose_month != 0)
                {
                    DateTime compareDate = new DateTime(model.choose_year, model.choose_month, 1);  //first day of the chosen month
                    records = records.Where(m => m.end_date >= compareDate);
                    compareDate = compareDate.AddMonths(1).AddTicks(-1);    //last day of the chosen month
                    records = records.Where(m => m.start_date <= compareDate);
                }
                //Print by page link
                if (model.print_all.HasValue && !model.print_all.Value && model.print_page.HasValue && model.print_page > 0)
                {
                    records = records.Skip((model.print_page.Value - 1) * 20).Take(20);
                }

                maintenances = records.ToList();

                //Getting orders
                foreach (report1 maintenance in maintenances)
                {
                    var orderRecords = from r in this._db.recsys_relate
                                       join o in this._db.recsys_order on r.id2 equals o.id
                                       where r.table1 == "maintenance" && r.table2 == "order" && r.id1 == maintenance.maintenance_id && o.by_system == 1
                                       orderby o.repair_date, o.id
                                       select new report1_order
                                       {
                                           repair_date = o.repair_date
                                       };
                    maintenance.orders = orderRecords.ToList();
                }

                //Show maintenance with 0 order
                //maintenances = maintenances.Where(m => m.orders.Count() >= 0).ToList();

                //Update 'printed' and 'first print date' of the maintenance record
                DateTime firstPrintDate = DateTime.Today;
                foreach (report1 maintenance in maintenances)
                {
                    recsys_maintenance maintenanceRecord = (from m in this._db.recsys_maintenance
                                             where m.id == maintenance.maintenance_id
                                             select m).FirstOrDefault();
                    if (maintenanceRecord != null && maintenanceRecord.printed == 0)
                    {
                        maintenanceRecord.printed = 1;
                        maintenanceRecord.first_print_Date = firstPrintDate;
                    }
                }
                this._db.SaveChanges();

                //Get maintenance card title
                var sysParm = (from s in this._db.recsys_system_parameter
                                      where s.status == 1 && s.name == "maint_card_header"
                                      select s).FirstOrDefault();
                if (sysParm != null) ViewBag.title = sysParm.value;

                return View("~/Views/ReportsGen/Report1.cshtml", maintenances);

            }
            else
            {
                return Content("找不到任何紀錄。");
            }
        }