コード例 #1
0
        /// <summary>
        /// This method just show plan's data in fields of screen
        /// </summary>
        private void ShowPlan()
        {
            planManager = new PlanManager(this);

            originalPlan = planManager.GetPlan(Convert.ToInt32(Request["PlanId"]));


            txtName.Text = originalPlan.Name;
            ucDateTimeInterval.DateInterval = new DateTimeInterval(originalPlan.AvailableStartDate, originalPlan.AvailableEndDate);

            // cboBranch.SelectedValue = Convert.ToString(originalPlan.BranchId);
            cboApplication.SelectedValue = Convert.ToString(originalPlan.ApplicationId);
            cboPackage.SelectedValue = Convert.ToString(originalPlan.PackageId);
        }
コード例 #2
0
        /// <summary>
        /// This method fill an new plan object and send them to bd for update or insert
        /// </summary>
        private void SavePlan()
        {
            planManager = new PlanManager(this);

            plan = new DataClasses.Plan();
            if(!String.IsNullOrEmpty(Request["PlanId"]))
               plan =  planManager.GetPlan(Convert.ToInt32(Request["PlanId"]));

            plan.Name = txtName.Text;
            plan.AvailableStartDate = ucDateTimeInterval.DateInterval.BeginDate;
            plan.AvailableEndDate = ucDateTimeInterval.DateInterval.EndDate;
            plan.ApplicationId = Convert.ToInt32(cboApplication.SelectedValue);
            plan.PackageId = Convert.ToInt32(cboPackage.SelectedValue);

            planManager.Save(plan);

            Response.Redirect("Plans.aspx");

        }
コード例 #3
0
        /// <summary>
        /// Método usado para criar mais companias, referenciando as novas companias, � 1� compania
        /// Ou compania de referência
        /// </summary>
        /// <param name="company"></param>
        /// <param name="userId"></param>
        /// <param name="companyId"></param>
        /// <returns></returns>
        public InsertCompanyStatus InsertCompany(Company company, int userId, int matrixCompanyId)
        {
            if (GetCompany(company.LegalEntityProfile.CNPJ) != null)
                return InsertCompanyStatus.DuplicateCNPJ;

            var profileManager = new ProfileManager(this);
            LegalEntityProfile original_legalEntityProfile;

            //
            // update the legalEntityProfile
            //
            if (company.LegalEntityProfile != null)
            {
                original_legalEntityProfile = profileManager.GetLegalEntityProfile(company.LegalEntityProfile.CNPJ);
                if (original_legalEntityProfile != null)
                {
                    //update the legalEntityProfile
                    if (!String.IsNullOrEmpty(company.LegalEntityProfile.CompanyName))
                        original_legalEntityProfile.CompanyName = company.LegalEntityProfile.CompanyName;

                    if (!String.IsNullOrEmpty(company.LegalEntityProfile.FantasyName))
                        original_legalEntityProfile.FantasyName = company.LegalEntityProfile.FantasyName;

                    original_legalEntityProfile.Email = company.LegalEntityProfile.Email;
                    original_legalEntityProfile.IE = company.LegalEntityProfile.IE;
                    original_legalEntityProfile.Phone = company.LegalEntityProfile.Phone;
                    original_legalEntityProfile.Address = company.LegalEntityProfile.Address;
                    original_legalEntityProfile.AddressComp = company.LegalEntityProfile.AddressComp;
                    original_legalEntityProfile.AddressNumber = company.LegalEntityProfile.AddressNumber;
                    profileManager.DbContext.SubmitChanges();

                    company.LegalEntityProfile = original_legalEntityProfile;
                }
            }



            //
            //Method to insert a new company
            //
            company.CreatorUserId = userId;
            Insert(company);
            company.ReferenceCompanyId = company.CompanyId;
            company.MatrixId = company.CompanyId;
            if (matrixCompanyId != 0)
            {
                company.ReferenceCompanyId = GetCompany(matrixCompanyId).ReferenceCompanyId;
                company.MatrixId = matrixCompanyId;
            }
            DbContext.SubmitChanges();

            //
            //Method to create a Deposit
            //
            Deposit dep = CreateMatrixDeposit(company.CompanyId);

            //
            //method to create a new role to this company
            //
            Role role = CreateAdminRole(company.CompanyId);

            //
            //method to set all permissions writable to the admin
            //
            var pManager = new PlanManager(this);
            Plan plan = pManager.GetCurrentPlan(company.CompanyId);
            if (plan != null)
            {
                CreatePermissions(plan.PlanId, role.RoleId, company.CompanyId);
            }

            //
            //method to associate the user with the company
            //
            AssociateUser(company.CompanyId, userId, dep.DepositId, /*IsMain*/ true);

            //
            //method to associate the user with the role
            //
            AddUserInRoles(userId, company.CompanyId, role.RoleId);

            //
            // method to create a customer under the Host "Vivina", with the company data of the user
            //
            AddContactInHostCustomer(AddCompanyAsCustomer(company), userId);

            //
            // Configurate the company inserting template of the Best Pratices, Report, etc.
            //
            SetCompanyConfiguration(company);

            //
            // Configure home page
            //
            CreateHomePage(company, userId);

            //SetCompanyPaymentMethods(company);

            return InsertCompanyStatus.Success;
        }