Example #1
0
        public void AreRequiredFieldsDone()
        {
            vWorklist wList = PageContext.vWorklists.FirstOrDefault(x => x.CARId == CAR.CARId);

            if (wList != null && wList.CurStepName == "Create")
            {
                CARMaster eCar = PageContext.CARMasters.FirstOrDefault(x => x.CARId == CAR.CARId);

                var hasProjTitle          = !string.IsNullOrWhiteSpace(eCar.ProjectTitle);
                var hasOrgId              = !string.IsNullOrWhiteSpace(eCar.OrgId);
                var hasProjManagerId      = (eCar.ProjManagerId != null);
                var hasCostCenterNumber   = !string.IsNullOrWhiteSpace(eCar.CostCenterNumber);
                var hasCurrencyTypeId     = (eCar.CurrencyTypeId != null);
                var hasProjTypeId         = !string.IsNullOrWhiteSpace(eCar.ProjectTypeId);
                var hasPillarId           = !string.IsNullOrWhiteSpace(eCar.PillarId);
                var hasStartDate          = (eCar.StartDate != null);
                var hasEndDate            = (eCar.EndDate != null);
                var hasInCapPlanFlag      = (eCar.InCapPlanFlag != null);
                var hasSubstitutionFlag   = (eCar.SubstitutionFlag != null);
                var hasAssetsAffectedFlag = (eCar.AssetsAffectedFlag != null);
                var hasCompBidsFlag       = (eCar.CompBidsFlag != null);
                var hasVendorContractFlag = (eCar.VendorContractFlag != null);
                var hasExcessCapacityFlag = (eCar.ExcessCapacityFlag != null);
                var hasSpecMaintFlag      = (eCar.SpecMaintFlag != null);
                var hasExcessMaintFlag    = (eCar.ExcessMaintFlag != null);
                var hasLeaseReqFlag       = (eCar.LeaseReqFlag != null);
                var hasSimplePaybackFlag  = (eCar.SimplePaybackFlag != null);
                //If Lease is Required, then check other required fields, otherwise pass them
                var hasLeaseOwnFlag           = (eCar.LeaseReqFlag == true) ? (eCar.LeaseOwnFlag != null) : true;
                var hasLeaseBargainOptionFlag = (eCar.LeaseReqFlag == true) ? (eCar.LeaseBargainOptionFlag != null) : true;
                var hasLeaseNPVFlag           = (eCar.LeaseReqFlag == true) ? (eCar.LeaseNPVFlag != null) : true;

                TabsEnabled = (hasOrgId && hasProjTitle && hasProjManagerId && hasCostCenterNumber && hasProjTypeId && hasCurrencyTypeId &&
                               hasPillarId && hasStartDate && hasEndDate && hasInCapPlanFlag && hasSubstitutionFlag && hasAssetsAffectedFlag &&
                               hasCompBidsFlag && hasVendorContractFlag && hasExcessCapacityFlag && hasSpecMaintFlag && hasExcessMaintFlag &&
                               hasLeaseReqFlag && hasSimplePaybackFlag && hasLeaseOwnFlag && hasLeaseBargainOptionFlag && hasLeaseNPVFlag);
            }
        }
Example #2
0
        protected void cbCreateCAR_Callback(object source, CallbackEventArgs e)
        {
            // Create a new CAR here and redirect to its page...
            eCAR3Entities pContext = new eCAR3Entities();
            CARMaster     pCAR     = new CARMaster();

            string[] parameters = e.Parameter.Split(';');

            string orgInformation   = parameters[0]; // orgId + '|' + locName + '|' + orgPath;
            string orgId            = orgInformation.Split('|')[0];
            string orgLocationName  = orgInformation.Split('|')[1];
            string orgPath          = orgInformation.Split('|')[2];
            var    divisonCharacter = orgPath.Substring(0, 1).ToUpper();

            //var threeCharacterLocation = orgLocationName.Replace(/\s +/ g, '').replace(/\./ g, '').substring(0, 3).toUpperCase();
            var threeCharacterLocation   = orgLocationName.Substring(0, 3).ToUpper();
            var twoDigitYear             = DateTime.Now.Year.ToString().Substring(2, 2); // produces two digit year -- Ex. 2019 = "19"
            var threeDigitUniqueSequence = "XXX";                                        // The database trigger will make this a unique sequential number.
            var projectNumber            = divisonCharacter + '-' + threeCharacterLocation + '-' + twoDigitYear + '-' + threeDigitUniqueSequence;

            string pillarInformation = parameters[1]; // pillarId + '|' + pillarName + '|' + decr;
            string pillarId          = pillarInformation.Split('|')[0];
            string pillarName        = pillarInformation.Split('|')[1];
            string pillarDescr       = pillarInformation.Split('|')[2];

            pCAR.OrgId           = orgId;
            pCAR.ProjectNumber   = projectNumber;
            pCAR.CreatedByUserId = UserId;
            pCAR.CreatedByName   = UserDisplayName;
            pCAR.ProjectTitle    = txtTitle.Text;
            pCAR.CreateTime      = DateTime.Now;
            pCAR.ProjectTypeId   = cbProjectType.Value.ToString(); // Set the dropdown ProjectTypeId
            pCAR.InterestRate    = 0.000;                          // Updated Interest Rate to 0.000
            pCAR.ExchangeRate    = 0;                              // Updated Exchange Rate to 0
            pCAR.UsefulLifeYears = 0;                              // Updated Useful Life Years to 0
            pCAR.LeaseTermYears  = 0;                              // Updated Lease Term Years to 0
            pCAR.NPV             = 0;                              // Updated NPV to 0
            pCAR.IRR             = 0;                              // Updated IRR to 0
            pCAR.CurrencyTypeId  = 1;                              // Updated Currency Type to U.S. Dollar

            //Set Desc fields to empty
            pCAR.ProjectDesc          = "";
            pCAR.ProjectReason        = "";
            pCAR.ProjectJustification = "";
            pCAR.FiscalYear           = DateTime.Now.Year;      // Updated Fiscal Year to current year
            pCAR.PillarId             = pillarId;               // Set the dropdown PillarId
            pCAR.Status = "Active";

            pContext.CARMasters.Add(pCAR);
            pContext.SaveChanges(); // TODD: If we could remove this it may speed things up a bit.

            // We now have the CAR Id
            AddCostSheet(pContext, pCAR.CARId, 1);
            AddCostSheet(pContext, pCAR.CARId, 2);
            AddCostSheet(pContext, pCAR.CARId, 3);
            AddCostSheet(pContext, pCAR.CARId, 4);

            // Bootstrap the workflow process
            // This should probably not be here
            // This should be a function in the workflow engine!
            WFEngine pEngine = GetWFEngine();

            WF pWF = pEngine.CreateWorkflow(pCAR.CARId);

            // This call assigns the workflow to an individual user
            string sURL = pEngine.Assign(pWF, "Create", "CREATE", UserId, null, pCAR.CARId.ToString());

            // Redirect the users browser to the newly create CAR.
            //ASPxWebControl.RedirectOnCallback(sURL); // I removed this because the line below may be a tiny bit faster.
            cbCreateCAR.JSProperties ["cp_result"] = sURL; // Return to the client side where the JavaScript redirects to this CAR page.
        }