Esempio n. 1
0
        private RatingRecord GetSupplierDataByCID(int CID, int SiteID)
        {
            RatingRecord   Rec  = new RatingRecord();
            SelectSiteGDIS gdis = selectGDIS.Where(g => g.SiteID.Equals(SiteID)).FirstOrDefault();

            using (Repository Rep = new Repository())
            {
                Rec = (from site in Rep.Context.SPFS_SITES
                       join spend in Rep.Context.SPFS_SPEND_SUPPLIERS on site.SiteID equals spend.SiteID
                       join sup in Rep.Context.SPFS_SUPPLIERS on spend.CID equals sup.CID
                       where spend.SiteID == SiteID && spend.CID == CID
                       select new RatingRecord
                {
                    CID = spend.CID,
                    SiteID = spend.SiteID,
                    Gdis_org_entity_ID = site.Gdis_org_entity_ID,
                    Gdis_org_Parent_ID = site.Gdis_org_Parent_ID,
                    Reject_incident_count = spend.Reject_incident_count,
                    Reject_parts_count = spend.Reject_parts_count,
                    SupplierName = sup.Name,
                    DUNS = sup.Duns
                }).FirstOrDefault();


                if (Rec == null)
                {
                    Rec = (from sup in Rep.Context.SPFS_SUPPLIERS
                           where sup.CID == CID
                           select new RatingRecord
                    {
                        CID = sup.CID,
                        SiteID = SiteID,
                        Gdis_org_entity_ID = gdis.Gdis_org_entity_ID,
                        Gdis_org_Parent_ID = gdis.Gdis_org_Parent_ID,
                        Reject_incident_count = 0,
                        Reject_parts_count = 0,
                        SupplierName = sup.Name,
                        DUNS = sup.Duns
                    }).FirstOrDefault();
                }
            }
            return(Rec);
        }
        private List <RatingRecord> CheckInboundRatings(List <RatingRecord> ratngs, ExcelRatingsViewModel ratingsModel)
        {
            List <RatingRecord> ratings = new List <RatingRecord>();

            foreach (var item in ratngs)
            {
                if (item.Inbound_parts > 0)
                {
                    SelectSiteGDIS gdis = selectGDIS.Where(g => g.SiteID.Equals(ratingsModel.SiteID)).FirstOrDefault();
                    //RatingRecord ratingRecord = new RatingRecord();
                    // ratingRecord.CID = int.TryParse(item.CID,)
                    item.Gdis_org_entity_ID = gdis.Gdis_org_entity_ID;
                    item.Gdis_org_Parent_ID = gdis.Gdis_org_Parent_ID;

                    ratings.Add(item);
                }
            }


            return(ratings);
        }
Esempio n. 3
0
        private ActionResult LoadData(RatingsViewModel ratingModel, bool dataExists)
        {
            CreateListViewBags();
            RatingsViewModel UpdatedModel = new RatingsViewModel();

            // ViewBag.Suppliers = selectSuppliers;  ratingModel.RatingRecords = IncidentSpendOrder(ratingModel);
            if (dataExists)
            {
                UpdatedModel = Merge(ratingModel);

                var rateSuppliers = UpdatedModel.RatingRecords.Select(r => new SelectListItem {
                    Text = r.SupplierName + " CID:" + r.CID, Value = r.CID.ToString()
                }).ToList();
                LoadDropdowns(rateSuppliers);
            }
            else
            {
                UpdatedModel.RatingRecords = IncidentSpendOrder(ratingModel);
                UpdatedModel.isUpload      = false;
                UpdatedModel.Month         = ratingModel.Month;
                UpdatedModel.Year          = ratingModel.Year;
                UpdatedModel.SiteID        = ratingModel.SiteID;
                SelectSiteGDIS gdis = selectGDIS.Where(g => g.SiteID.Equals(ratingModel.SiteID)).FirstOrDefault();

                UpdatedModel.SiteName = gdis.Name;
                var rateSuppliers = ratingModel.RatingRecords.Select(r => new SelectListItem {
                    Text = r.SupplierName + " CID:" + r.CID, Value = r.CID.ToString()
                }).ToList();
                LoadDropdowns(rateSuppliers);
            }



            UpdatedModel.ShowResult     = true;
            UpdatedModel.OldResults     = false;
            UpdatedModel.EditMode       = true;
            TempData["SearchedResults"] = UpdatedModel;

            return(View("Index", UpdatedModel));
        }
Esempio n. 4
0
        private RatingsViewModel Merge(RatingsViewModel RatingModel)
        {
            RatingsViewModel RateModel = new RatingsViewModel();

            List <RatingRecord> ISORecords    = IncidentSpendOrder(RatingModel);
            List <RatingRecord> MergedRecords = new List <RatingRecord>();
            //List<RatingRecord> UnMatchedRecords = new List<RatingRecord>();

            var query = from x in ISORecords
                        join y in RatingModel.RatingRecords
                        on x.CID equals y.CID
                        select new { x, y };

            foreach (var match in query)
            {
                match.x.Inbound_parts    = match.y.Inbound_parts;
                match.x.OTD              = match.y.OTD;
                match.x.OTR              = match.y.OTR;
                match.x.PFR              = match.y.PFR;
                match.x.Temp_Upload_     = match.y.Temp_Upload_;
                match.x.ErrorInformation = match.y.ErrorInformation;
            }

            //  MergedRecords = ISORecords;
            //var unmatch = (from agrr in RatingModel.RatingRecords
            //               where !(ISORecords.Any(i => i.CID == agrr.CID))
            //               select agrr).ToList();
            //if (unmatch != null)
            //{
            //    ISORecords.AddRange(unmatch);
            //}

            MergedRecords = ISORecords;
            foreach (RatingRecord rec in MergedRecords)
            {
                if (rec.Inbound_parts != 0)
                {
                    double ppm = (double)rec.Reject_parts_count / rec.Inbound_parts;
                    rec.PPM = Math.Round(ppm * 1000000);
                    double ipm = (double)rec.Reject_incident_count / rec.Inbound_parts;
                    rec.IPM = Math.Round((ipm * 1000000), 2);
                }
                else
                {
                    rec.PPM = 0;
                    rec.IPM = 0.00;
                }
                if (rec.OTD != 0)
                {
                    double pct = (double)rec.OTR / rec.OTD;
                    rec.PCT = Math.Round(pct * 100);
                }
                else
                {
                    rec.PCT = 0;
                }
            }
            RateModel.RatingRecords = MergedRecords;
            RateModel.isUpload      = false;
            RateModel.Month         = RatingModel.Month;
            RateModel.Year          = RatingModel.Year;
            RateModel.SiteID        = RatingModel.SiteID;
            SelectSiteGDIS gdis = selectGDIS.Where(g => g.SiteID.Equals(RatingModel.SiteID)).FirstOrDefault();

            RateModel.SiteName = gdis.Name;

            return(RateModel);
        }
        private RatingsViewModel Merge(ExcelRatingsViewModel RatingModel)
        {
            List <RatingRecord> Records = (List <RatingRecord>)TempData["RatingRecords"];
            //TempData.Keep("RatingRecords");
            ExcelRatingsViewModel AggregatedModel = AggregateRecords(RatingModel, Records);
            RatingsViewModel      ConvertedModel  = new RatingsViewModel();

            List <RatingRecord> ISORecords = IncidentSpendOrder(RatingModel);
            //List<RatingRecord> HistoryRecords = IncidentSpendOrder(RatingModel);
            List <RatingRecord> MergedRecords    = new List <RatingRecord>();
            List <RatingRecord> UnMatchedRecords = new List <RatingRecord>();

            var query = from x in ISORecords
                        join y in AggregatedModel.RatingRecords
                        on x.CID equals y.CID
                        select new { x, y };

            foreach (var match in query)
            {
                match.x.Inbound_parts         = match.y.Inbound_parts;
                match.x.OTD                   = match.y.OTD;
                match.x.OTR                   = match.y.OTR;
                match.x.PFR                   = match.y.PFR;
                match.x.Reject_incident_count = match.y.Reject_incident_count;
                match.x.Reject_parts_count    = match.y.Reject_parts_count;
                match.x.Temp_Upload_          = match.y.Temp_Upload_;
                match.x.ErrorInformation      = match.y.ErrorInformation;
            }

            //  MergedRecords = ISORecords;
            var unmatch = (from agrr in AggregatedModel.RatingRecords
                           where !(ISORecords.Any(i => i.CID == agrr.CID))
                           select agrr).ToList();

            if (unmatch != null)
            {
                ISORecords.AddRange(unmatch);
            }

            MergedRecords = ISORecords;

            foreach (RatingRecord rec in MergedRecords)
            {
                if (rec.Inbound_parts != 0)
                {
                    double ppm = (double)rec.Reject_parts_count / rec.Inbound_parts;
                    rec.PPM = Math.Round(ppm * 1000000);
                    double ipm = (double)rec.Reject_incident_count / rec.Inbound_parts;
                    rec.IPM = Math.Round((ipm * 1000000), 2);
                }
                else
                {
                    rec.PPM = 0;
                    rec.IPM = 0.00;
                }
                if (rec.OTD != 0)
                {
                    double pct = (double)rec.OTR / rec.OTD;
                    rec.PCT = Math.Round(pct * 100);
                }
                else
                {
                    rec.PCT = 0;
                }
            }
            ConvertedModel.RatingRecords = MergedRecords;
            ConvertedModel.isUpload      = true;
            ConvertedModel.Month         = RatingModel.Month;
            ConvertedModel.Year          = RatingModel.Year;
            ConvertedModel.SiteID        = RatingModel.SiteID;
            SelectSiteGDIS gdis = selectGDIS.Where(g => g.SiteID.Equals(RatingModel.SiteID)).FirstOrDefault();

            ConvertedModel.SiteName = gdis.Name;
            //var count = 0;
            //foreach (var record in GroupedRecords)
            //{
            //    if ((record.ErrorInformation != null ? record.ErrorInformation.Count : 0) > 0)
            //    {
            //        count++;
            //    }
            //}
            return(ConvertedModel);
        }