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);
        }
        public virtual void CreateBaseApplication()
        {
            var ab = new PermitBase()
            {
                JobID         = _jobID,
                RequirementID = _requirementID,
                RequestNumber = RequestNumber,
                RequestBy     = _printingEmployeeID,
                RequestDate   = DateTime.Now,
                StatusID      = (int)NPermitStatus.New,
                Deadline      = DateTime.Now,
                Version       = 1,
            };
            var mp = new MyProjectDetail(_jobID);

            ab.JobTitle    = mp.JobTitle;
            ab.JobNumber   = mp.JobNumber;
            ab.Description = mp.Description;

            var msc = new MySalesJobMasterListCustomer(_jobID);

            msc.SetInstallTo();

            ab.InstallToCustomerID = msc.CustomerID;
            Db.PermitBases.Add(ab);
            Db.SaveChanges();
            NewlyInsertedBaseAppID = ab.BaseAppID;
        }
Exemple #3
0
        private void SetInstallToCustomerID()
        {
            var mjc = new MySalesJobMasterListCustomer(_projectID);

            // Install To
            mjc.SetInstallTo();
            InstallToCustomerID = mjc.CustomerID;
        }
Exemple #4
0
        public void ImportAddressFromCustomer()
        {
            //Subcontract-->Project-->IsInstallTo->Contact and Customer

            var subcontract = new MySubContract(Value.SubContractID);
            var msc         = new MySalesJobMasterListCustomer(subcontract.Value.JobID);

            msc.SetInstallTo();

            if (msc.CustomerID < 1000)
            {
                Result = "Request Failed, No Install to Customer Selected.";
            }
            else
            {
                var myCustomer = new MyCustomer(msc.CustomerID);
                var myContact  = new MyCustomerContact(msc.ContactID);

                string addr = myCustomer.Value.ADDR_1;
                if (!Convert.IsDBNull(myCustomer.Value.ADDR_2))
                {
                    addr = addr + " " + myCustomer.Value.ADDR_2;
                }

                Value.Address = addr;

                Value.City       = myCustomer.Value.CITY;
                Value.Postcode   = myCustomer.Value.ZIPCODE;
                Value.Province   = myCustomer.Value.STATE;
                Value.ShipToName = myCustomer.Value.NAME;

                string attenName = MyConvert.ConvertToString(myContact.Value.CONTACT_HONORIFIC) + " ";
                attenName += MyConvert.ConvertToString(myContact.Value.CONTACT_FIRST_NAME) + " ";
                attenName += MyConvert.ConvertToString(myContact.Value.CONTACT_LAST_NAME);

                Value.AttnName  = attenName.Trim();
                Value.AttnPhone = MyConvert.ConvertToString(myContact.Value.CONTACT_PHONE);

                _db.Entry(Value).State = EntityState.Modified;
                _db.SaveChanges();

                Result = "ok";
            }
        }
Exemple #5
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);
        }
        public void ImportAddressFromCustomer(string importCustomerType)
        {
            //Subcontract-->Project-->IsInstallTo->Contact and Customer
            var workorder = new MyWorkorder(Value.WoID);
            var msc       = new MySalesJobMasterListCustomer(workorder.Value.jobID);

            if (importCustomerType == "InstallTo")
            {
                msc.SetInstallTo();
            }

            if (importCustomerType == "QuoteTo")
            {
                msc.SetQuoteTo();
            }

            if (importCustomerType == "BillTo")
            {
                msc.SetBillTo();
            }

            var mc = new MyCustomer(msc.CustomerID);

            _customer = mc.Value;
            var mcc = new MyCustomerContact(msc.ContactID);

            _contact = mcc.Value;


            if (_customer != null)
            {
                string addr = _customer.ADDR_1;
                if (!Convert.IsDBNull(_customer.ADDR_2))
                {
                    addr = addr + " " + _customer.ADDR_2;
                }

                Value.Address = addr;

                Value.City       = _customer.CITY;
                Value.Postcode   = _customer.ZIPCODE;
                Value.Province   = _customer.STATE;
                Value.ShipToName = _customer.NAME;

                string attenName = MyConvert.ConvertToString(_contact.CONTACT_HONORIFIC) + " ";
                attenName += MyConvert.ConvertToString(_contact.CONTACT_FIRST_NAME) + " ";
                attenName += MyConvert.ConvertToString(_contact.CONTACT_LAST_NAME);

                Value.AttnName  = attenName.Trim();
                Value.AttnPhone = MyConvert.ConvertToString(_contact.CONTACT_PHONE);


                //For Delivery Note

                Value.DeliveryDate = DateTime.Today;

                Value.WorkorderNumber = workorder.Value.WorkorderNumber;


                var emp = new FsEmployee(Convert.ToInt32(workorder.Value.Sales));

                Value.AeName  = emp.NickName;
                Value.AePhone = emp.GetCompanyPhoneExtension();


                Value.InvoiceNumber = workorder.GetInvoices();

                Value.NoteTypeID = 0;


                _db.Entry(Value).State = EntityState.Modified;
                _db.SaveChanges();

                Result = "ok";
            }
            else
            {
                Result = "Could not find the specified Customer.";
            }
        }
        public override string IsValidated()
        {
            var    b = true;
            string validationResult = "";

            //Number of Sign
            if (MyConvert.ConvertToDouble(Value.NumberOfSigns) == 0)
            {
                validationResult += "Number of Signs required." + System.Environment.NewLine;
                b = false;
            }

            //Estimated Value
            if (MyConvert.ConvertToDouble(Value.ProjectValueEstimated) == 0)
            {
                validationResult += "Estimated Project Valued  required." + 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);
                if (MyConvert.ConvertToString(mc.Value.ADDR_1).Length < 5)
                {
                    validationResult += "No Installation Address  " + System.Environment.NewLine;
                    b = false;
                }
            }


            //Landlord
            if (Value.LandlordID < 1000)
            {
                validationResult += "Enter a Landlord Please  " + System.Environment.NewLine;
                b = false;
            }
            else
            {
                var landlord = _db.PermitLandlords.Find(Value.LandlordID);
                //Company Name
                if (MyConvert.ConvertToString(landlord.NAME).Length < 5)
                {
                    validationResult += "Landlord Name Required" + System.Environment.NewLine;
                    b = false;
                }
                //Address
                if (MyConvert.ConvertToString(landlord.ADDR_1).Length < 5)
                {
                    validationResult += "Landlord Address Required " + System.Environment.NewLine;
                    b = false;
                }

                if (MyConvert.ConvertToString(landlord.CITY).Length < 3)
                {
                    validationResult += "Landlord City Required " + System.Environment.NewLine;
                    b = false;
                }

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

            //Landlord Contact
            if (Value.LandlordContactID < 1000)
            {
                validationResult += "Enter a Landlord Contact  " + System.Environment.NewLine;
                b = false;
            }
            else
            {
                var contact = _db.PermitLandlordContacts.Find(Value.LandlordContactID);
                var l1      = MyConvert.ConvertToString(contact.CONTACT_FIRST_NAME).Length;
                var l2      = MyConvert.ConvertToString(contact.CONTACT_LAST_NAME).Length;
                if (l1 + l2 < 2)
                {
                    validationResult += "Landlord Contact Name Required" + System.Environment.NewLine;
                    b = false;
                }
                if (MyConvert.ConvertToString(contact.CONTACT_PHONE).Length < 9)
                {
                    validationResult += "Landlord Contact Phone Required" + System.Environment.NewLine;
                    b = false;
                }
            }

            //Document Attached
            var requiredDocuemntTypes = new int[] { 10, 12, 14, 16 };

            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;
                }
            }

            return(b ? "ok" : validationResult);
        }
Exemple #8
0
        private string IsValidated()
        {
            var    b = true;
            string validationResult = "";


            var msc = new MySalesJobMasterListCustomer(Value.JobID);

            msc.SetInstallTo();

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

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


            if (Value.ContactPerson1 == 0)
            {
                validationResult += "Contact person required." + System.Environment.NewLine;
                b = false;
            }

            if (MyConvert.IsDate(Value.TargetDate))
            {
                if (Value.TargetDate <= DateTime.Today)
                {
                    validationResult += "Target Date should not be early than today. " + System.Environment.NewLine;
                    b = false;
                }
            }
            else
            {
                validationResult += "Invalid Target Date format. " + System.Environment.NewLine;
                b = false;
            }


            if (!MyString.IsStringLengthLongerThan(3, Value.BudgetProvideBy))
            {
                validationResult += "Budget Provide By Whom Required." + System.Environment.NewLine;
                b = false;
            }

            if (!MyString.IsStringLengthLongerThan(3, Value.Requirement))
            {
                validationResult += "Please Enter Requirement." + System.Environment.NewLine;
                b = false;
            }

            var budgetAmount = 100;

            if (Value.RequirementID >= 6530)
            {
                budgetAmount = 100;                                     //1
            }

            if (Value.Budget < budgetAmount)
            {
                validationResult += "Normal Job Budget should >=$100, other Job Budget >=$100 " + System.Environment.NewLine;
                b = false;
            }



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