Esempio n. 1
0
        public TooltipQuotedEnquiry(SentEnquiry se, BHDmini b)
        {
            Full_Reference = se.FullReference;
            Bkg_Name       = b.NAME;
            Date_Entered   = b.DATE_ENTERED.ToString("dd/MM/yyyy");
            Date_Sent      = se.DateSent.ToString("dd/MM/yyyy");
            Deadline       = se.maxNbDaysQuoting.ToString();
            if (se.maxNbDaysQuoting == 9999 || se.maxNbDaysQuoting == -1)
            {
                Deadline = b.UDTEXT4.Trim();
            }

            Work_Days_Quoting = se.nbDaysQuoting.ToString();
        }
Esempio n. 2
0
        private IList <SentEnquiry> AddSentEnquiries(IEnumerable <IGrouping <int?, BStage> > groupedBStages, Dictionary <string, string> consultNames)
        {
            IList <SentEnquiry> listSentEnquiries = new List <SentEnquiry>();

            foreach (var gp in groupedBStages)
            {
                // count nbDaysQuoting
                // count nbDaysContracting
                // check the date sent and add an objet sentEnquiry

                int      bhdId       = gp.FirstOrDefault().BHD_ID.Value;
                DateTime dateEntered = gp.OrderBy(bs => bs.FromDate)
                                       .First()
                                       .FromDate;
                SentEnquiry se = new SentEnquiry()
                {
                    BHD_ID = bhdId, Date_Entered = dateEntered
                };
                bool hasQuoted     = false;
                bool hasContracted = false;



                foreach (BStage bs in gp.OrderBy(bs => bs.FromDate))
                {
                    // if quoting
                    if (CompSpec.BookingStageCodes[bookingStage.pendingSalesBDOPS].Contains(bs.Status.Trim()))
                    {
                        // calculate and add the number of days
                        // add the consultant if not already there
                        se.nbDaysQuoting += DatesUtilities.GetNbWorkingDays(bs.FromDate, bs.ToDate);
                        if (!se.dictQuoting.ContainsKey(bs.Consultant.Trim()))
                        {
                            se.dictQuoting.Add(bs.Consultant.Trim(), consultNames[bs.Consultant.Trim()]);
                        }
                        hasQuoted = true;
                    }

                    // if contracting
                    if (CompSpec.BookingStageCodes[bookingStage.pendingContract].Contains(bs.Status.Trim()))
                    {
                        // calculate and add the number of days
                        // add the consultant if not already there
                        se.nbDaysContracting += DatesUtilities.GetNbWorkingDays(bs.FromDate, bs.ToDate);
                        if (!se.dictContracting.ContainsKey(bs.Consultant.Trim()))
                        {
                            se.dictContracting.Add(bs.Consultant.Trim(), consultNames[bs.Consultant.Trim()]);
                        }
                        hasContracted = true;
                    }

                    // if past the "sent" stage (not pending) and was preceded by quoting or contracting stages
                    if (!CompSpec.BookingStageCodes[bookingStage.pending].Contains(bs.Status.Trim()))
                    {
                        bool isOneDayer = bs.FromDate == dateEntered;
                        // create a new SentEnquiry object and add it to the list
                        if (hasQuoted || hasContracted || isOneDayer)
                        {
                            se.FullReference = bs.FullReference;
                            se.Department    = CompSpec.RetrieveDepartment(se.FullReference);

                            //  add the consultant name if not there :
                            if (!se.dictQuoting.ContainsKey(bs.Consultant.Trim()))
                            {
                                se.dictQuoting.Add(bs.Consultant.Trim(), consultNames[bs.Consultant.Trim()]);
                            }

                            // 12/06/2017 clean dictQuoting and dictContracting of unassigned if there is at least one consultant
                            if (se.dictQuoting.Count >= 2)
                            {
                                se.dictQuoting.Remove("");
                            }
                            if (se.dictContracting.Count >= 2)
                            {
                                se.dictContracting.Remove("");
                            }


                            se.DateSent = bs.FromDate;
                            se.nbDaysQuoting++; // the day counts as being quoting

                            listSentEnquiries.Add(se);

                            // reset
                            se = new SentEnquiry()
                            {
                                BHD_ID = bhdId, Date_Entered = dateEntered
                            };
                            hasQuoted     = false;
                            hasContracted = false;
                        }
                    }
                }
            }

            return(listSentEnquiries);
        }