示例#1
0
        private Contract CreateActivateContract(ContractMaint contractMaint,
                                                DateTime?invoiceDate, int?customerID, int?customerLocationID,
                                                string simCardID, string phoneNumber, CTBillEngine engine)
        {
            contractMaint.Clear();
            // Initialize new contract
            Contract contract =
                (Contract)contractMaint.Contracts.Cache.CreateInstance();

            contract = contractMaint.Contracts.Insert(contract);
            // Look up contract template ID
            Contract template = PXSelect <Contract,
                                          Where <Contract.isTemplate, Equal <boolTrue>,
                                                 And <Contract.contractCD, Equal <Required <Contract.contractCD> > > > >
                                .Select(Base, "SIMCARD");

            if (template == null)
            {
                throw new
                      PXException("The SIMCARD contract template was not found.");
            }
            // Set required fields
            contract.TemplateID     = template.ContractID;
            contract.CustomerID     = customerID;
            contract                = contractMaint.Contracts.Update(contract);
            contract.LocationID     = customerLocationID;
            contract.StartDate      = invoiceDate;
            contract.ActivationDate = invoiceDate;
            contract                = contractMaint.Contracts.Update(contract);
            // Store simCardID and phoneNumber into the contract attributes
            foreach (CSAnswers attribute in contractMaint.Answers.Select())
            {
                switch (attribute.AttributeID)
                {
                case "SIMCARDID":
                    attribute.Value = simCardID;
                    contractMaint.Answers.Update(attribute);
                    break;

                case "PHONENUM":
                    attribute.Value = phoneNumber;
                    contractMaint.Answers.Update(attribute);
                    break;
                }
            }
            // Save the generated contract
            contractMaint.Save.Press();
            // Set up and activate the contract
            engine.SetupAndActivate(contract.ContractID, contract.ActivationDate);
            return(contract);
        }
        public virtual IEnumerable ViewContract(PXAdapter adapter)
        {
            if (Contracts.Current != null)
            {
                ContractMaint target = PXGraph.CreateInstance <ContractMaint>();
                target.Clear();
                target.Contracts.Current = Contracts.Current;
                throw new PXRedirectRequiredException(target, true, "ViewContract")
                      {
                          Mode = PXBaseRedirectException.WindowMode.NewWindow
                      };
            }

            return(adapter.Get());
        }
示例#3
0
        public virtual IEnumerable ViewContract(PXAdapter adapter)
        {
            if (Items.Current != null)
            {
                ContractMaint target = PXGraph.CreateInstance <ContractMaint>();
                target.Clear();
                target.Contracts.Current = PXSelect <CT.Contract, Where <CT.Contract.contractID, Equal <Current <ContractsList.contractID> > > > .Select(this);

                throw new PXRedirectRequiredException(target, true, "ViewContract")
                      {
                          Mode = PXBaseRedirectException.WindowMode.NewWindow
                      };
            }

            return(adapter.Get());
        }