public ActionResult DashboardTechnicalOverview(FormCollection fc)
        {
            if (Session["userid"] == null)
            {
                return(RedirectToAction("Login", "Account"));
            }
            else
            {
                if (WebConfigure.GetLoginPortal() == "true" && Common.GetUserXupj().ToLower() != Session["username"].ToString().ToLower())
                {
                    return(RedirectToAction("Login", "Account"));
                }
                this.setViewBag();
                var modelFormCollection = new GetFormCollectionOverview();

                bool btnPOST = true;
                ViewBag.urlModel = WebConfigure.GetDomain() + "/Dashboard/DashboardTechnicalOverview?filterType=" + fc["filterType"]
                                   + "&Area=" + fc["Area"]
                                   + "&Model=" + fc["Model"]
                                   + "&Family=" + fc["Family"]
                                   + "&Industry=" + fc["Industry"]
                                   + "&SerialNumber=" + fc["SerialNumber"]
                                   + "&Customer=" + fc["Customer"]
                                   + "&SalesOffice=" + fc["SalesOffice"]
                                   + "&deliveryDate=" + fc["deliveryDate"]
                                   + "&purchaseDate=" + fc["purchaseDate"]
                                   + "&repairDate=" + fc["repairDate"]
                                   + "&SMURangeFrom=" + fc["SMURangeFrom"]
                                   + "&SMURangeTo=" + fc["SMURangeTo"]
                                   + "&ModelMEP=" + fc["ModelMEP"]
                                   + "&SerialNumberMEP=" + fc["SerialNumberMEP"]
                                   + "&CustomerMEP=" + fc["CustomerMEP"]
                                   + "&Plant=" + fc["PlantDescription"]
                                   + "&Product=" + fc["Product"]
                                   + "&hid=" + fc["hid"]
                                   + "&rental=" + fc["rental"]
                                   + "&other=" + fc["other"]
                                   + "&btnPOST=" + btnPOST
                ;


                if (Convert.ToInt32(fc["filterType"]) == 1)
                {
                    var strSerialNumber     = (fc["SerialNumber"] != null) ? fc["SerialNumber"] : String.Empty;
                    var strCustomer         = (fc["Customer"] != null) ? fc["Customer"] : String.Empty;
                    var strModel            = (fc["Model"] != null) ? fc["Model"] : String.Empty;
                    var strplantDescription = (fc["PlantDescription"] != null) ? fc["PlantDescription"] : String.Empty;
                    var strplantProduct     = (fc["Product"] != null) ? fc["Product"] : String.Empty;
                    modelFormCollection.Customer     = strCustomer;
                    modelFormCollection.Model        = strModel;
                    modelFormCollection.SerialNumber = strSerialNumber;
                    modelFormCollection.Plant        = strplantDescription;
                    modelFormCollection.Product      = strplantProduct;
                }
                else
                {
                    var purchasedatefrom = "";
                    var purchasedateto   = "";
                    var deliverydatefrom = "";
                    var deliverydateto   = "";
                    var repairdatefrom   = "";
                    var repairdateto     = "";
                    if (fc["purchaseDate"] != null)
                    {
                        var strList = fc["purchaseDate"].Split(' ', 't', 'o', ' ');
                        if (strList.Count() == 5)
                        {
                            purchasedatefrom = strList[0];
                            purchasedateto   = strList[4];
                        }
                        else
                        {
                            purchasedatefrom = strList[0];
                        }
                    }
                    else
                    {
                        purchasedatefrom = "";
                        purchasedateto   = "";
                    }

                    if (fc["deliveryDate"] != null)
                    {
                        var strList = fc["deliveryDate"].Split(' ', 't', 'o', ' ');
                        if (strList.Count() == 5)
                        {
                            deliverydatefrom = strList[0];
                            deliverydateto   = strList[4];
                        }
                        else
                        {
                            deliverydatefrom = strList[0];
                        }
                    }
                    else
                    {
                        deliverydatefrom = "";
                        deliverydateto   = "";
                    }

                    if (fc["repairDate"] != null)
                    {
                        var strList = fc["repairDate"].Split(' ', 't', 'o', ' ');
                        if (strList.Count() == 5)
                        {
                            repairdatefrom = strList[0];
                            repairdateto   = strList[4];
                        }
                        else
                        {
                            repairdatefrom = strList[0];
                        }
                    }
                    else
                    {
                        repairdatefrom = "";
                        repairdateto   = "";
                    }
                    var strArea         = (fc["Area"] != null) ? fc["Area"] : String.Empty;
                    var strSalesOffice  = (fc["SalesOffice"] != null) ? fc["SalesOffice"] : String.Empty;
                    var strCustomer     = (fc["CustomerMEP"] != null) ? fc["CustomerMEP"] : String.Empty;
                    var strFamily       = (fc["Family"] != null) ? fc["Family"] : String.Empty;
                    var strIndustry     = (fc["Industry"] != null) ? fc["Industry"] : String.Empty;
                    var strModel        = (fc["ModelMEP"] != null) ? fc["ModelMEP"] : String.Empty;
                    var strSerialNumber = (fc["SerialNumberMEP"] != null) ? fc["SerialNumberMEP"] : String.Empty;
                    var strSMURangeFrom = (!String.IsNullOrWhiteSpace(fc["SMURangeFrom"])) ? Convert.ToInt32(fc["SMURangeFrom"]) : 0;
                    var strSMURangeTo   = (!String.IsNullOrWhiteSpace(fc["SMURangeTo"])) ? Convert.ToInt32(fc["SMURangeTo"]) : 0;

                    modelFormCollection.Area               = strArea;
                    modelFormCollection.SalesOffice        = strSalesOffice;
                    modelFormCollection.Customer           = strCustomer;
                    modelFormCollection.Family             = strFamily;
                    modelFormCollection.Industry           = strIndustry;
                    modelFormCollection.Model              = strModel;
                    modelFormCollection.SerialNumber       = strSerialNumber;
                    modelFormCollection.SMURangeFrom       = strSMURangeFrom;
                    modelFormCollection.SMURangeTo         = strSMURangeTo;
                    modelFormCollection.PurchaseDateFrom   = purchasedatefrom;
                    modelFormCollection.PurchaseDateEnd    = purchasedateto;
                    modelFormCollection.DeliveryDateEnd    = deliverydateto;
                    modelFormCollection.DeliveryDateFrom   = deliverydatefrom;
                    modelFormCollection.LastRepairDateEnd  = repairdateto;
                    modelFormCollection.LastRepairDateFrom = repairdatefrom;
                }
                var Hid    = (fc["hid"] != null) ? fc["hid"] : "";
                var Rental = (fc["rental"] != null) ? fc["rental"] : "";
                var Others = (fc["other"] != null) ? fc["other"] : "";
                modelFormCollection.HID                = Hid;
                modelFormCollection.Rental             = Rental;
                modelFormCollection.Others             = Others;
                modelFormCollection.paramsModel        = String.Empty;
                modelFormCollection.paramsSerialNumber = String.Empty;
                modelFormCollection.btnPOST            = btnPOST;
                var DataRelatedTicketOverview = getListTableRelatedTROverview(fc, Hid, Rental, Others, fc["model"], null, btnPOST);
                var DataRelatedDPPMOverview   = GetTableRelatedDPPMOverview(fc, Hid, Rental, Others, fc["model"], null, btnPOST);
                ViewBag.TicketDataOverview          = DataRelatedTicketOverview.Item1;
                ViewBag.TicketDataCountOverview     = DataRelatedTicketOverview.Item2;
                ViewBag.RelatedDPPMData             = DataRelatedDPPMOverview.Item1;
                ViewBag.RelatedDPPMDataCount        = DataRelatedDPPMOverview.Item2;
                ViewBag.ModelFormCollectionOverview = modelFormCollection;
                ViewBag.FilterType = Convert.ToInt32(fc["filterType"]);

                return(View());
            }
        }
        public Tuple <List <DPPMSummary>, int> GetTableRelatedDPPMOverviewGet(GetFormCollectionOverview collection, string Hid, string Rental, string Others, string paramsModel = null, string paramsSerialNumber = null, bool btnPOST = false)
        {
            string[] SplitArea         = new string[] { };
            string[] SplitCustomer     = new string[] { };
            string[] SplitFamily       = new string[] { };
            string[] SplitIndustry     = new string[] { };
            string[] SplitSalesOffice  = new string[] { };
            string[] SplitModel        = new string[] { };
            string[] SplitSerialNumber = new string[] { };
            string[] SplitProduct      = new string[] { };
            string[] SplitPlant        = new string[] { };
            var      purchasedatefrom  = "";
            var      purchasedateto    = "";
            var      deliverydatefrom  = "";
            var      deliverydateto    = "";
            var      repairdatefrom    = "";
            var      repairdateto      = "";

            if (collection.FilterType == 1)
            {
                if (!string.IsNullOrWhiteSpace(collection.SerialNumber))
                {
                    SplitSerialNumber = collection.SerialNumber.Split(',');
                }
                if (!string.IsNullOrWhiteSpace(collection.Customer_Name))
                {
                    SplitCustomer = collection.Customer_Name.Split(',');
                }
                if (!string.IsNullOrWhiteSpace(collection.Model))
                {
                    SplitModel = collection.Model.Split(',');
                }
                if (!string.IsNullOrWhiteSpace(collection.Product))
                {
                    SplitProduct = collection.Product.Split(',');
                }
                if (!string.IsNullOrWhiteSpace(collection.Product))
                {
                    SplitPlant = collection.Product.Split(',');
                }
            }
            else
            {
                if (collection.PurchaseDateEnd != null && collection.PurchaseDateFrom != null)
                {
                    var strList = collection.PurchaseDateFrom.Split(' ', 't', 'o', ' ');
                    if (strList.Count() == 5)
                    {
                        purchasedatefrom = strList[0];
                        purchasedateto   = strList[4];
                    }
                    else
                    {
                        purchasedatefrom = strList[0];
                    }
                }
                else
                {
                    purchasedatefrom = "";
                    purchasedateto   = "";
                }

                if (collection.DeliveryDateFrom != null)
                {
                    var strList = collection.DeliveryDateFrom.Split(' ', 't', 'o', ' ');
                    if (strList.Count() == 5)
                    {
                        deliverydatefrom = strList[0];
                        deliverydateto   = strList[4];
                    }
                    else
                    {
                        deliverydatefrom = strList[0];
                    }
                }
                else
                {
                    deliverydatefrom = "";
                    deliverydateto   = "";
                }

                if (collection.LastRepairDateFrom != null)
                {
                    var strList = collection.LastRepairDateFrom.Split(' ', 't', 'o', ' ');
                    if (strList.Count() == 5)
                    {
                        repairdatefrom = strList[0];
                        repairdateto   = strList[4];
                    }
                    else
                    {
                        repairdatefrom = strList[0];
                    }
                }
                else
                {
                    repairdatefrom = "";
                    repairdateto   = "";
                }

                if (!string.IsNullOrWhiteSpace(collection.SerialNumber))
                {
                    SplitSerialNumber = collection.SerialNumber.Split(',');
                }
                if (!string.IsNullOrWhiteSpace(collection.Customer))
                {
                    SplitCustomer = collection.Customer.Split(',');
                }
                if (!string.IsNullOrWhiteSpace(collection.Model))
                {
                    SplitModel = collection.Model.Split(',');
                }
                if (!string.IsNullOrWhiteSpace(collection.Area))
                {
                    SplitArea = collection.Area.Split(',');
                }
                if (!string.IsNullOrWhiteSpace(collection.SalesOffice))
                {
                    SplitSalesOffice = collection.SalesOffice.Split(',');
                }
                if (!string.IsNullOrWhiteSpace(collection.Family))
                {
                    SplitFamily = collection.Family.Split(',');
                }
                if (!string.IsNullOrWhiteSpace(collection.Industry))
                {
                    SplitIndustry = collection.Industry.Split(',');
                }
            }
            string[] dataFiltered = getListSerialNumberFiltered(collection.FilterType, SplitArea, SplitSalesOffice, SplitCustomer, SplitFamily, SplitIndustry, SplitModel, SplitSerialNumber, repairdatefrom, repairdateto, purchasedatefrom, purchasedateto, deliverydatefrom, deliverydateto, collection.SMURangeFrom.ToString(), collection.SMURangeTo.ToString(), SplitProduct, SplitPlant, Hid, Rental, Others, paramsModel, paramsSerialNumber, btnPOST);

            var getData = _DPPMSummaryBs.getDataDPPMSummaryOverview(dataFiltered);

            return(Tuple.Create(getData.Item1, getData.Item2));
        }
        // GET: DashboardTechnicalOverview
        public ActionResult DashboardTechnicalOverview(int filterType = 0, string Area = null, string Model = null, string Family = null, string Industry = null, string SerialNumber = null, string Customer = null, string SalesOffice = null, string deliveryDate = null, string purchaseDate = null, string repairDate = null, string SMURangeFrom = null, string SMURangeTo = null, string ModelMEP = null, string SerialNumberMEP = null, string CustomerMEP = null, string Plant = null, string Product = null, string hid = null, string rental = null, string other = null, string paramsModel = null, string paramsSerialNumber = null, bool btnPOST = false)
        {
            if (Session["userid"] == null)
            {
                return(RedirectToAction("Login", "Account"));
            }
            else
            {
                if (WebConfigure.GetLoginPortal() == "true" && Common.GetUserXupj().ToLower() != Session["username"].ToString().ToLower())
                {
                    return(RedirectToAction("Login", "Account"));
                }
                this.setViewBag();
                var modelFormCollection = new GetFormCollectionOverview();
                var strArea             = Area;
                var strSalesOffice      = SalesOffice;
                var strCustomer         = CustomerMEP;
                var strFamily           = Family;
                var strIndustry         = Industry;
                var strModel            = ModelMEP;
                var strSerialNumber     = SerialNumberMEP;
                var strSMURangeFrom     = SMURangeFrom;
                var strSMURangeTo       = SMURangeTo;
                var strpurchaseDateFrom = String.Empty;
                var strdeliveryDateFrom = String.Empty;
                var strrepairDateFrom   = String.Empty;
                var strpurchaseDateEnd  = String.Empty;
                var strdeliveryDateEnd  = String.Empty;
                var strrepairDateEnd    = String.Empty;
                var Hid             = hid;
                var Rental          = rental;
                var Others          = other;
                var strcustomer     = "";
                var strmodel        = "";
                var strserialnumber = "";
                var strplant        = "";
                var strproduct      = "";
                if (filterType == 1)
                {
                    strcustomer     = Customer;
                    strmodel        = Model;
                    strserialnumber = SerialNumber;
                    strplant        = Plant;
                    strproduct      = Product;
                }
                else
                {
                    strcustomer     = CustomerMEP;
                    strmodel        = ModelMEP;
                    strserialnumber = SerialNumberMEP;
                    if (purchaseDate != null)
                    {
                        var strList = purchaseDate.Split(' ', 't', 'o', ' ');
                        if (strList.Count() == 5)
                        {
                            strpurchaseDateFrom = strList[0];
                            strpurchaseDateEnd  = strList[4];
                        }
                        else
                        {
                            strpurchaseDateFrom = strList[0];
                        }
                    }
                    else
                    {
                        strpurchaseDateFrom = String.Empty;
                        strpurchaseDateEnd  = String.Empty;
                    }

                    if (deliveryDate != null)
                    {
                        var strList = deliveryDate.Split(' ', 't', 'o', ' ');
                        if (strList.Count() == 5)
                        {
                            strdeliveryDateFrom = strList[0];
                            strdeliveryDateEnd  = strList[4];
                        }
                        else
                        {
                            strdeliveryDateFrom = strList[0];
                        }
                    }
                    else
                    {
                        strdeliveryDateFrom = "";
                        strdeliveryDateEnd  = "";
                    }

                    if (repairDate != null)
                    {
                        var strList = repairDate.Split(' ', 't', 'o', ' ');
                        if (strList.Count() == 5)
                        {
                            strrepairDateFrom = strList[0];
                            strrepairDateEnd  = strList[4];
                        }
                        else
                        {
                            strrepairDateFrom = strList[0];
                        }
                    }
                    else
                    {
                        strrepairDateFrom = String.Empty;
                        strrepairDateEnd  = String.Empty;
                    }
                }

                modelFormCollection.HID                = Hid;
                modelFormCollection.Rental             = Rental;
                modelFormCollection.Others             = Others;
                modelFormCollection.Area               = strArea;
                modelFormCollection.SalesOffice        = strSalesOffice;
                modelFormCollection.Customer           = strCustomer;
                modelFormCollection.Family             = strFamily;
                modelFormCollection.Industry           = strIndustry;
                modelFormCollection.Model              = strModel;
                modelFormCollection.SerialNumber       = strSerialNumber;
                modelFormCollection.SMURangeFrom       = String.IsNullOrWhiteSpace(strSMURangeFrom) ? 0 : Convert.ToInt32(strSMURangeFrom);
                modelFormCollection.SMURangeTo         = String.IsNullOrWhiteSpace(strSMURangeTo) ? 0 : Convert.ToInt32(strSMURangeTo);
                modelFormCollection.PurchaseDateFrom   = strpurchaseDateFrom;
                modelFormCollection.DeliveryDateFrom   = strdeliveryDateFrom;
                modelFormCollection.LastRepairDateFrom = strrepairDateFrom;
                modelFormCollection.PurchaseDateEnd    = strpurchaseDateEnd;
                modelFormCollection.DeliveryDateEnd    = strdeliveryDateEnd;
                modelFormCollection.LastRepairDateEnd  = strrepairDateEnd;
                modelFormCollection.Customer           = strcustomer;
                modelFormCollection.Model              = strmodel;
                modelFormCollection.SerialNumber       = strserialnumber;
                modelFormCollection.Product            = strproduct;
                modelFormCollection.Plant              = strplant;

                ViewBag.FilterType = filterType;
                ViewBag.urlModel   = WebConfigure.GetDomain() + "/Dashboard/DashboardTechnicalOverview?filterType=" + filterType
                                     + "&Area=" + Area
                                     + "&Model=" + Model
                                     + "&Family=" + Family
                                     + "&Industry=" + Industry
                                     + "&SerialNumber=" + SerialNumber
                                     + "&Customer=" + Customer
                                     + "&SalesOffice=" + SalesOffice
                                     + "&deliveryDate=" + deliveryDate
                                     + "&purchaseDate=" + purchaseDate
                                     + "&repairDate=" + repairDate
                                     + "&SMURangeFrom=" + SMURangeFrom
                                     + "&SMURangeTo=" + SMURangeTo
                                     + "&ModelMEP=" + ModelMEP
                                     + "&SerialNumberMEP=" + SerialNumberMEP
                                     + "&CustomerMEP=" + CustomerMEP
                                     + "&Plant=" + Plant
                                     + "&Product=" + Product
                                     + "&hid=" + hid
                                     + "&rental=" + rental
                                     + "&other=" + other
                                     + "&btnPOST=" + btnPOST
                ;

                var ModelParams        = "";
                var SerialNumberParams = "";
                if (!String.IsNullOrWhiteSpace(paramsModel))
                {
                    ModelParams = paramsModel;
                    modelFormCollection.paramsModel = ModelParams;
                    ViewBag.Model = ModelParams;
                }
                if (!String.IsNullOrWhiteSpace(paramsSerialNumber))
                {
                    SerialNumberParams = paramsSerialNumber;
                    modelFormCollection.paramsSerialNumber = SerialNumberParams;
                    ViewBag.SerialNumber = SerialNumberParams;
                }
                var RelatedDPPM = GetTableRelatedDPPMOverviewGet(modelFormCollection, Hid, Rental, Others, modelFormCollection.paramsModel, modelFormCollection.paramsSerialNumber, btnPOST);
                var RelatedTR   = getListTableRelatedTROverviewGet(modelFormCollection, Hid, Rental, Others, modelFormCollection.paramsModel, modelFormCollection.paramsSerialNumber, btnPOST);
                ViewBag.RelatedDPPMData         = RelatedDPPM.Item1;
                ViewBag.RelatedDPPMDataCount    = RelatedDPPM.Item2;
                ViewBag.TicketDataOverview      = RelatedTR.Item1;
                ViewBag.TicketDataCountOverview = RelatedTR.Item2;
                ViewBag.FilterType = filterType;
                ViewBag.ModelFormCollectionOverview = modelFormCollection;
                return(View());
            }
        }