示例#1
0
 public BillingProvider(FitnessEntities context,
                        IPrincipal principal,
                        ILogger logger,
                        AutoNumberProvider autoNumberProvider,
                        InvoiceProvider invoiceProvider) : base(context, principal)
 {
     this.logger             = logger;
     this.autoNumberProvider = autoNumberProvider;
     this.invoiceProvider    = invoiceProvider;
 }
 public DocumentProvider(FitnessEntities context, IPrincipal principal, AutoNumberProvider autoNumberProvider) : base(context, principal)
 {
     this.autoNumberProvider = autoNumberProvider;
 }
示例#3
0
 public PurchaseOrderProvider(FitnessEntities context, IPrincipal principal, AutoNumberProvider autoNumberProvider, EmployeeProvider employeeProvider, ItemProvider itemProvider) : base(context, principal)
 {
     this.autoNumberProvider = autoNumberProvider;
     this.employeeProvider   = employeeProvider;
     this.itemProvider       = itemProvider;
 }
        public void Add(
            DateTime date,
            bool useExistingBarcode,
            string barcode,
            bool isTransfer,
            string firstName,
            string LastName,
            DateTime dateOfBirth,
            string identityCardNo,
            int?occupationID,
            int branchID,
            int packageID,
            DateTime?purchaseDate,
            DateTime effectiveDate,
            int billingTypeID,
            int billingCardTypeID,
            int billingBankID,
            string billingCardNo,
            string billingCardHolderName,
            string billingCardHolderID,
            DateTime cardExpiredDate,
            char status,
            int billingItemID,
            decimal duesAmount,
            decimal additionalDuesAmount,
            DateTime?nextDuesDate,
            DateTime expiredDate,
            string homePhone,
            string cellphone,
            string workphone,
            string mailingAddress,
            string zipCodeMailingAddress,
            string address,
            string zipCode,
            int areaID,
            bool fatherIsExist,
            string fatherName,
            string fatherIDCardNo,
            DateTime?fatherBirthDate,
            string fatherCellPhone,
            string fatherEmail,
            bool motherIsExist,
            string motherName,
            string motherIDCardNo,
            DateTime?motherBirthDate,
            string motherCellPhone,
            string motherEmail,
            string notes,
            string contractType)
        {
            PackageHeader package = context.PackageHeaders.SingleOrDefault(pkg => pkg.ID == packageID);

            if (package != null)
            {
                //nextDuesDate = effectiveDate.AddMonths(package.PackageDuesInMonth);
                var      autoNumberProvider = new AutoNumberProvider(context, principal);
                Customer cust = null;
                if (useExistingBarcode)
                {
                    cust = context.Customers.Single(c => c.Barcode == barcode);
                }
                else
                {
                    cust                = new Customer();
                    cust.Barcode        = autoNumberProvider.Generate(branchID, "CU", 0, 0);
                    cust.FirstName      = firstName;
                    cust.LastName       = LastName;
                    cust.DateOfBirth    = dateOfBirth;
                    cust.IDCardNo       = identityCardNo;
                    cust.OccupationID   = occupationID;
                    cust.HomeBranchID   = branchID;
                    cust.HomePhone      = homePhone;
                    cust.CellPhone1     = cellphone;
                    cust.WorkPhone      = workphone;
                    cust.BillingTypeID  = billingTypeID;
                    cust.AreaID         = areaID == 0 ? (int?)null : areaID;
                    cust.MailingAddress = mailingAddress;
                    cust.MailingZipCode = zipCodeMailingAddress;
                    cust.Address        = address;
                    cust.ZipCode        = zipCode;
                    if (billingTypeID != 1) // auto payment
                    {
                        cust.BankID           = billingBankID;
                        cust.CreditCardTypeID = billingCardTypeID;
                        cust.CardHolderName   = billingCardHolderName;
                        cust.CardHolderID     = billingCardHolderID;
                        cust.CardNo           = billingCardNo;
                        cust.ExpiredDate      = cardExpiredDate;
                    }
                    else
                    {
                        cust.BankID           = (int?)null;
                        cust.CreditCardTypeID = (int?)null;
                        cust.CardHolderName   = null;
                        cust.CardHolderID     = null;
                        cust.CardNo           = null;
                        cust.ExpiredDate      = (DateTime?)null;
                    }
                    EntityHelper.SetAuditFieldForInsert(cust, principal.Identity.Name);
                    context.Add(cust);

                    autoNumberProvider.Increment("CU", branchID, 0);
                }

                var contract = new Contract();
                contract.ContractNo    = autoNumberProvider.Generate(branchID, "CO", date.Month, date.Year);
                contract.Date          = date;
                contract.Customer      = cust;
                contract.BranchID      = branchID;
                contract.PackageHeader = package;
                //contract.PurchaseDate = purchaseDate;
                contract.VoidDate             = null;
                contract.EffectiveDate        = effectiveDate;
                contract.BillingItemID        = billingItemID == 0 ? (int?)null : billingItemID;
                contract.DuesAmount           = duesAmount;
                contract.AdditionalDuesAmount = additionalDuesAmount;
                contract.NextDuesDate         = nextDuesDate.GetValueOrDefault();
                //contract.ExpiredDate = expiredDate;
                contract.ExpiredDate   = effectiveDate.AddMonths(package.PackageDuesInMonth);
                contract.BillingTypeID = billingTypeID;
                contract.Status        = status.ToString();
                contract.Notes         = notes;
                contract.DuesInMonth   = package.PackageDuesInMonth;
                if (isTransfer)
                {
                    contract.ContractType = 'T';
                }
                else
                {
                    contract.ContractType = useExistingBarcode ? Convert.ToChar(contractType) : (char?)null;
                }
                EntityHelper.SetAuditFieldForInsert(contract, principal.Identity.Name);
                context.Add(contract);


                if (!useExistingBarcode)
                {
                    if (fatherIsExist)
                    {
                        Person person = new Person();
                        person.Connection = 'F';
                        person.Name       = fatherName;
                        person.IDCardNo   = fatherIDCardNo;
                        person.Phone1     = fatherCellPhone;
                        person.BirthDate  = fatherBirthDate;
                        person.Email      = fatherEmail;
                        person.Customer   = cust;
                        EntityHelper.SetAuditFieldForInsert(person, principal.Identity.Name);
                        context.Add(person);
                    }

                    if (motherIsExist)
                    {
                        Person person = new Person();
                        person.Connection = 'M';
                        person.Name       = motherName;
                        person.IDCardNo   = motherIDCardNo;
                        person.Phone1     = motherCellPhone;
                        person.BirthDate  = motherBirthDate;
                        person.Email      = motherEmail;
                        person.Customer   = cust;
                        EntityHelper.SetAuditFieldForInsert(person, principal.Identity.Name);
                        context.Add(person);
                    }
                }

                autoNumberProvider.Increment("CO", branchID, date.Year);
                context.SaveChanges();

                //contract.VoidDate = null;
                //context.SaveChanges();
            }
        }
示例#5
0
 public InvoiceProvider(FitnessEntities context, IPrincipal principal, AutoNumberProvider autoNumberProvider, PaymentProvider paymentProvider)
     : base(context, principal)
 {
     this.autoNumberProvider = autoNumberProvider;
     this.paymentProvider    = paymentProvider;
 }