public override string IsValidated()
        {
            var    b = true;
            string validationResult = "";

            //Installation Address
            var msc = new MySalesJobMasterListCustomer(BaseValue.JobID);

            msc.SetInstallTo();

            if (msc.CustomerID == 0)
            {
                validationResult += "No Installation Company Selected  " + System.Environment.NewLine;
                b = false;
            }
            else
            {
                var mc = new MyCustomer(msc.CustomerID);

                if (MyConvert.ConvertToString(mc.Value.ADDR_1).Length < 5)
                {
                    validationResult += "No Installation Address  " + System.Environment.NewLine;
                    b = false;
                }
            }


            //Document Attached
            var requiredDocuemntTypes = new int[] { 200 };

            for (int i = 0; i < requiredDocuemntTypes.Length; i++)
            {
                var docTypeID   = requiredDocuemntTypes[i];
                var docAttached = _db.PermitDocuments.Where(x => x.BaseAppID == BaseValue.BaseAppID & x.DocType == docTypeID).ToList();
                if (!docAttached.Any())
                {
                    var docType = _db.PermitDocumentTypes.Find(docTypeID);
                    validationResult += "Document Required: " + docType.TypeName + System.Environment.NewLine;
                    b = false;
                }
            }

            //Leadtime
            if (BaseValue.Deadline <= DateTime.Today)
            {
                validationResult += "Lead time is 5 business days  " + System.Environment.NewLine;
                b = false;
            }
            else
            {
                var endDate = Convert.ToDateTime(BaseValue.Deadline);
                if (MyDateTime.GetDiffHoursOfWeekday(DateTime.Today, endDate) < 24 * NLeadTime)
                {
                    validationResult += "Lead time is 5 business days  " + System.Environment.NewLine;
                    b = false;
                }
            }

            return(b ? "ok" : validationResult);
        }
示例#2
0
        public Boolean GetRush()
        {
            bool b     = false;
            int  hours = MyDateTime.GetDiffHoursOfWeekday(ParameterDispatchingTask.SubmitTime,
                                                          ParameterDispatchingTask.RequiredTime);

            if (hours < ParameterDispatchingTask.LeadTime)
            {
                b = true;
            }
            return(b);
        }
示例#3
0
        private void UpdateNewDueTime(DateTime requiredTime)
        {
            int taskCategory = Convert.ToInt32(_task.TaskType);
            var tp           = new TaskPropertyResponseLeadtime(taskCategory);
            int leadTime     = tp.Leadtime;

            _task.Rush = false;
            int hours = MyDateTime.GetDiffHoursOfWeekday(Convert.ToDateTime(_task.SubmitTime), requiredTime);

            if (hours < leadTime)
            {
                _task.Rush = true;
            }

            _task.RequiredTime   = requiredTime;
            _task.LastUpdateTime = DateTime.Now;

            _db.Entry(_task).State = EntityState.Modified;
            _db.SaveChanges();
        }
示例#4
0
        public override string IsValidated()
        {
            var    b = true;
            string validationResult = "";

            var isCityOfToronto = false;


            //Leadtime
            if (BaseValue.Deadline <= DateTime.Today)
            {
                validationResult += "Lead time is 5 business days  " + System.Environment.NewLine;
                b = false;
            }
            else
            {
                var endDate = Convert.ToDateTime(BaseValue.Deadline);
                if (MyDateTime.GetDiffHoursOfWeekday(DateTime.Today, endDate) < 24 * NLeadTime)
                {
                    validationResult += "Lead time is 5 business days  " + System.Environment.NewLine;
                    b = false;
                }
            }

            if (MyConvert.ConvertToString(Value.OccupationTimeStart).Length < 3)
            {
                validationResult += "Occupation Start Time Required" + System.Environment.NewLine;
                b = false;
            }

            if (MyConvert.ConvertToString(Value.OccupationTimeEnd).Length < 3)
            {
                validationResult += "Occupation End Time Required" + System.Environment.NewLine;
                b = false;
            }

            //
            if (Value.TypeOfTruck == 0)
            {
                validationResult += "Please Fill out Type of Truck  " + System.Environment.NewLine;
                b = false;
            }

            //Installation Address
            var msc = new MySalesJobMasterListCustomer(BaseValue.JobID);

            msc.SetInstallTo();


            if (msc.CustomerID == 0)
            {
                validationResult += "No Installation Company Selected  " + System.Environment.NewLine;
                b = false;
            }
            else
            {
                var mc       = new MyCustomer(msc.CustomerID);
                var customer = mc.Value;

                if (MyConvert.ConvertToString(customer.ADDR_1).Length < 5)
                {
                    validationResult += "No Installation Address  " + System.Environment.NewLine;
                    b = false;
                }
                if (MyConvert.ConvertToString(customer.CITY).Length < 3)
                {
                    validationResult += "Landlord City Required " + System.Environment.NewLine;
                    b = false;
                }
                else
                {
                    isCityOfToronto = GetIsCityOfToronto(customer.CITY);
                }

                if (MyConvert.ConvertToString(customer.ZIPCODE).Length < 4)
                {
                    validationResult += "Landlord Postcode Required " + System.Environment.NewLine;
                    b = false;
                }
            }

            if (MyConvert.ConvertToString(Value.ForemanName).Length < 2)
            {
                validationResult += "Foreman Name Required" + System.Environment.NewLine;
                b = false;
            }

            if (MyConvert.ConvertToString(Value.ForemanPhone).Length < 9)
            {
                validationResult += "Foreman Name Required" + System.Environment.NewLine;
                b = false;
            }



            //301	Insurance	2	30
            //302	Additional Insurance for City of Toronto	2	30

            //Document Attached
            int docTypeID   = 301;
            var docAttached = _db.PermitDocuments.Where(x => x.BaseAppID == BaseValue.BaseAppID & x.DocType == docTypeID).ToList();

            if (!docAttached.Any( ))
            {
                var docType = _db.PermitDocumentTypes.Find(docTypeID);
                validationResult += "Document Required: " + docType.TypeName + System.Environment.NewLine;
                b = false;
            }
            //302	Additional Insurance for City of Toronto	2	30
            if (isCityOfToronto)
            {
                docTypeID   = 302;
                docAttached = _db.PermitDocuments.Where(x => x.BaseAppID == BaseValue.BaseAppID & x.DocType == docTypeID).ToList();
                if (!docAttached.Any())
                {
                    var docType = _db.PermitDocumentTypes.Find(docTypeID);
                    validationResult += "Document Required: " + docType.TypeName + System.Environment.NewLine;
                    b = false;
                }
            }


            return(b ? "ok" : validationResult);
        }