Example #1
0
        public void Add(
            string name,
            int packageDuesInMonth,
            bool isActive,
            bool isOpenEnd,
            decimal freezeFee,
            IEnumerable <PackageDetailViewModel> detail)
        {
            PackageHeader head = new PackageHeader();

            head.Name = name;
            head.PackageDuesInMonth = packageDuesInMonth;
            head.IsActive           = isActive;
            head.OpenEnd            = isOpenEnd;
            head.FreezeFee          = freezeFee;
            EntityHelper.SetAuditFieldForInsert(head, HttpContext.Current.User.Identity.Name);
            ctx.PackageHeaders.InsertOnSubmit(head);
            foreach (PackageDetailViewModel item in detail)
            {
                PackageDetail obj = new PackageDetail();
                obj.ItemID    = item.ItemID;
                obj.PackageID = item.PackageID;
                obj.Quantity  = item.Quantity;
                obj.UnitPrice = item.UnitPrice;
                head.PackageDetails.Add(obj);
                ctx.PackageDetails.InsertOnSubmit(obj);
            }
            ctx.SubmitChanges();
        }
Example #2
0
        public void DoMonthlyClosing(int branchID, int month, int year)
        {
            MonthlyClosing monthlyClosing = ctx.MonthlyClosings.SingleOrDefault(
                closing => closing.BranchID == branchID &&
                closing.ClosingMonth == month &&
                closing.ClosingYear == year);

            if (monthlyClosing == null)
            {
                monthlyClosing              = new MonthlyClosing();
                monthlyClosing.BranchID     = branchID;
                monthlyClosing.ClosingMonth = month;
                monthlyClosing.ClosingYear  = year;
                monthlyClosing.IsClosed     = true;
                EntityHelper.SetAuditFieldForInsert(monthlyClosing, HttpContext.Current.User.Identity.Name);
                ctx.MonthlyClosings.InsertOnSubmit(monthlyClosing);
            }
            else
            {
                monthlyClosing.IsClosed = true;
                EntityHelper.SetAuditFieldForUpdate(monthlyClosing, HttpContext.Current.User.Identity.Name);
            }

            MonthlyClosingHistory closingHist = new MonthlyClosingHistory();

            closingHist.BranchID    = branchID;
            closingHist.IsClosing   = true;
            closingHist.UserName    = HttpContext.Current.User.Identity.Name;
            closingHist.CreatedWhen = DateTime.Now;

            ctx.SubmitChanges();
        }
Example #3
0
        public void Add(
            string customerCode,
            string connection,
            string name,
            DateTime?birthDate,
            string idCardNo,
            string email,
            string phone1,
            string phone2,
            string photo)
        {
            Customer customer = ctx.Customers.SingleOrDefault(cust => cust.Barcode == customerCode);

            if (customer != null)
            {
                Person obj = new Person();
                obj.Connection = connection;
                obj.Name       = name;
                obj.BirthDate  = birthDate;
                obj.IDCardNo   = idCardNo;
                obj.Phone1     = phone1;
                obj.Phone2     = phone2;
                obj.Photo      = photo;
                obj.Customer   = customer;
                EntityHelper.SetAuditFieldForInsert(obj, HttpContext.Current.User.Identity.Name);
                ctx.Persons.InsertOnSubmit(obj);
                ctx.SubmitChanges();
            }
        }
Example #4
0
        public void Add(string description)
        {
            Area area = new Area();

            area.Description = description;
            EntityHelper.SetAuditFieldForInsert(area, HttpContext.Current.User.Identity.Name);
            ctx.Areas.InsertOnSubmit(area);
            ctx.SubmitChanges();
        }
Example #5
0
        public void Add(string description)
        {
            ItemType obj = new ItemType();

            obj.Description = description;
            EntityHelper.SetAuditFieldForInsert(obj, HttpContext.Current.User.Identity.Name);
            ctx.ItemTypes.InsertOnSubmit(obj);
            ctx.SubmitChanges();
        }
Example #6
0
 public void DeleteBillingHistoryByProcessDate(DateTime date)
 {
     foreach (var billing in ctx.BillingHeaders.Where(b => b.ProcessDate == date))
     {
         ctx.BillingDetails.DeleteAllOnSubmit(billing.BillingDetails);
         ctx.BillingHeaders.DeleteOnSubmit(billing);
     }
     ctx.SubmitChanges();
 }
Example #7
0
    public void Add(string name)
    {
        School school = new School();

        school.Name = name;
        EntityHelper.SetAuditFieldForInsert(school, HttpContext.Current.User.Identity.Name);
        ctx.Schools.InsertOnSubmit(school);
        ctx.SubmitChanges();
    }
        public void Add(string description, string color, string backgroundColor)
        {
            CustomerStatus obj = new CustomerStatus();

            obj.Description = description;
            obj.Color       = color + "|" + backgroundColor;
            EntityHelper.SetAuditFieldForInsert(obj, HttpContext.Current.User.Identity.Name);
            ctx.CustomerStatus.InsertOnSubmit(obj);
            ctx.SubmitChanges();
        }
        public void Add(string description, bool isLastState, int changeStatusIDTo)
        {
            DocumentType docType = new DocumentType();

            docType.Description = description;
            docType.IsLastState = isLastState;
            docType.ChangeCustomerStatusIDTo = changeStatusIDTo == 0 ? (int?)null : changeStatusIDTo;
            ctx.DocumentTypes.InsertOnSubmit(docType);
            ctx.SubmitChanges();
        }
        public void Add(string description, short autoPayDay, bool isActive)
        {
            BillingType bil = new BillingType();

            bil.Description = description;
            bil.AutoPayDay  = autoPayDay;
            bil.IsActive    = isActive;
            EntityHelper.SetAuditFieldForInsert(bil, HttpContext.Current.User.Identity.Name);
            ctx.BillingTypes.InsertOnSubmit(bil);
            ctx.SubmitChanges();
        }
Example #11
0
        public void AddOrUpdateProspect(int id,
                                        int branchID,
                                        string firstName,
                                        string lastName,
                                        DateTime date,
                                        string identityNo,
                                        string phone1,
                                        string phone2,
                                        string email,
                                        DateTime?dateOfBirth,
                                        int consultantID,
                                        string source,
                                        string sourceRef,
                                        string notes,
                                        bool enableFreeTrial,
                                        DateTime?freeTrialFrom,
                                        DateTime?freeTrialTo)
        {
            var prospect = id == 0 ? new Prospect() : ctx.Prospects.Single(prosp => prosp.ID == id);

            prospect.BranchID           = branchID;
            prospect.FirstName          = firstName;
            prospect.LastName           = lastName;
            prospect.Date               = date;
            prospect.IdentityNo         = identityNo;
            prospect.Phone1             = phone1;
            prospect.Phone2             = phone2;
            prospect.Email              = email;
            prospect.DateOfBirth        = dateOfBirth;
            prospect.ConsultantID       = consultantID;
            prospect.ProspectSource     = source;
            prospect.ProspectRef        = sourceRef;
            prospect.Notes              = notes;
            prospect.FreeTrialValidFrom = enableFreeTrial
                ? freeTrialFrom.GetValueOrDefault(DateTime.Today)
                : (DateTime?)null;
            prospect.FreeTrialValidTo = enableFreeTrial
                ? freeTrialTo.GetValueOrDefault(DateTime.Today)
                : (DateTime?)null;


            if (id == 0)
            {
                ctx.Prospects.InsertOnSubmit(prospect);
                EntityHelper.SetAuditFieldForInsert(prospect, HttpContext.Current.User.Identity.Name);
            }
            else
            {
                EntityHelper.SetAuditFieldForUpdate(prospect, HttpContext.Current.User.Identity.Name);
            }

            ctx.SubmitChanges();
        }
Example #12
0
        public void Add(
            string name,
            bool isActive)
        {
            Bank bank = new Bank();

            bank.Name     = name;
            bank.IsActive = isActive;
            EntityHelper.SetAuditFieldForInsert(bank, HttpContext.Current.User.Identity.Name);
            ctx.Banks.InsertOnSubmit(bank);
            ctx.SubmitChanges();
        }
Example #13
0
 public void UpdateRoleMenu(int menuID, string[] roles)
 {
     context.RoleMenus.DeleteAllOnSubmit(
         context.RoleMenus.Where(rm => rm.MenuID == menuID));
     foreach (string roleName in roles)
     {
         RoleMenu rm = new RoleMenu
         {
             MenuID   = menuID,
             RoleName = roleName
         };
         context.RoleMenus.InsertOnSubmit(rm);
     }
     context.SubmitChanges();
 }
Example #14
0
        public void UpdateUserAtBranch(string userName, IEnumerable <int> branchesID)
        {
            ctx.UserAtBranches.DeleteAllOnSubmit(ctx.UserAtBranches.Where(row => row.UserName == userName));

            foreach (int id in branchesID)
            {
                ctx.UserAtBranches.InsertOnSubmit(
                    new UserAtBranch()
                {
                    BranchID = id,
                    UserName = userName
                });
            }

            ctx.SubmitChanges();
        }
Example #15
0
    public void Save(string userName, string url, bool allowAddNew, bool allowUpdate, bool allowDelete, bool allowRead)
    {
        bool isNew = false;
        var  form  = ctx.FormAccesses.SingleOrDefault(frm => frm.FormUrl == url && frm.UserName == userName);

        if (form == null)
        {
            form  = new FormAccess();
            isNew = true;
        }

        form.UserName  = userName;
        form.FormUrl   = url;
        form.CanAddNew = allowAddNew;
        form.CanDelete = allowDelete;
        form.CanRead   = allowRead;
        form.CanUpdate = allowUpdate;

        if (isNew)
        {
            ctx.FormAccesses.InsertOnSubmit(form);
        }

        ctx.SubmitChanges();
    }
    public void DisableAccountCascade(string accountNo, bool isActive)
    {
        ItemAccount account = Get(accountNo);

        account.IsActive = isActive;
        List <ItemAccount> accounts = GetChildAccount(accountNo).ToList();

        if (accounts.Count() == 0)
        {
            return;
        }
        foreach (var item in accounts)
        {
            DisableAccountCascade(item.AccountNo, isActive);
        }
        ctx.SubmitChanges();
    }
Example #17
0
 public void Delete(int[] paymentTypesID)
 {
     using (var ctx = new FitnessDataContext())
     {
         ctx.PaymentTypes.DeleteAllOnSubmit(ctx.PaymentTypes.Where(row => paymentTypesID.Contains(row.ID)));
         ctx.SubmitChanges();
     }
 }
Example #18
0
 public void SetValue(string key, string value)
 {
     using (FitnessDataContext ctx = new FitnessDataContext())
     {
         var configuration = ctx.Configurations.SingleOrDefault(config => config.Key == key);
         configuration.Key   = key;
         configuration.Value = value;
         ctx.SubmitChanges();
     }
 }
Example #19
0
        public void Add(
            string barcode,
            string description,
            int itemAccountID,
            int itemTypeID,
            decimal standardUnitPrice,
            bool isActive)
        {
            Item item = new Item();

            item.Barcode       = barcode;
            item.Description   = description;
            item.ItemAccountID = itemAccountID;
            item.ItemTypeID    = itemTypeID;
            item.UnitPrice     = standardUnitPrice;
            item.IsActive      = isActive;
            ctx.Items.InsertOnSubmit(item);
            EntityHelper.SetAuditFieldForInsert(item, HttpContext.Current.User.Identity.Name);
            ctx.SubmitChanges();
        }
Example #20
0
        public void Add(string userName,
                        string barcode,
                        string firstName,
                        int homeBranchID,
                        string email,
                        bool canApproveDocument)
        {
            Employee emp = new Employee();

            emp.UserName           = userName;
            emp.Barcode            = barcode;
            emp.FirstName          = firstName;
            emp.HomeBranchID       = homeBranchID;
            emp.Email              = email;
            emp.IsActive           = true;
            emp.CanApproveDocument = canApproveDocument;
            EntityHelper.SetAuditFieldForInsert(emp, HttpContext.Current.User.Identity.Name);
            ctx.Employees.InsertOnSubmit(emp);
            ctx.SubmitChanges();
        }
Example #21
0
        public void Update(string formCode, int branchID, int year, int newLastNumber)
        {
            Create(formCode, branchID, year);

            var autoNumber = ctx.AutoNumbers.SingleOrDefault(row => row.FormCode == formCode && row.BranchID == branchID && row.Year == year);

            if (autoNumber != null)
            {
                autoNumber.LastNumber = newLastNumber;
                ctx.SubmitChanges();
            }
        }
Example #22
0
        public void AddCreditCardChangeHistory(int customerID, int creditCardTypeID, string creditCardNo, string creditCardHolderName, string creditCardIDNo, DateTime creditCardExpireDate)
        {
            CreditCardChangeHistory ccChangeHistory = new CreditCardChangeHistory();

            ccChangeHistory.CustomerID            = customerID;
            ccChangeHistory.CreditCardTypeID      = creditCardTypeID;
            ccChangeHistory.CreditCardNo          = creditCardNo;
            ccChangeHistory.CreditCardHolderName  = creditCardHolderName;
            ccChangeHistory.CreditCardExpiredDate = creditCardExpireDate;
            ccChangeHistory.CreditCardIDNo        = creditCardIDNo;
            EntityHelper.SetAuditFieldForUpdate(ccChangeHistory, HttpContext.Current.User.Identity.Name);
            ctx.CreditCardChangeHistories.InsertOnSubmit(ccChangeHistory);
            ctx.SubmitChanges();
        }
Example #23
0
 public void Update(
     int id,
     string description,
     bool isActive)
 {
     using (var ctx = new FitnessDataContext())
     {
         PaymentType pay = ctx.PaymentTypes.Single(row => row.ID == id);
         pay.Description = description;
         pay.IsActive    = isActive;
         EntityHelper.SetAuditFieldForUpdate(pay, HttpContext.Current.User.Identity.Name);
         ctx.SubmitChanges();
     }
 }
Example #24
0
    public string Create(
        DateTime date,
        string invoiceNo,
        IEnumerable <PaymentDetailViewModel> detail)
    {
        string paymentNo = String.Empty;

        var invoice = ctx.InvoiceHeaders.SingleOrDefault(inv => inv.InvoiceNo == invoiceNo);

        if (invoice != null)
        {
            paymentNo = autoNumberProvider.Generate(invoice.BranchID, "PM", date.Month, date.Year);

            PaymentHeader h = new PaymentHeader();
            h.Date      = date;
            h.InvoiceID = invoice.ID;
            h.PaymentNo = paymentNo;
            h.VoidDate  = (DateTime?)null;
            EntityHelper.SetAuditFieldForInsert(h, HttpContext.Current.User.Identity.Name);
            foreach (var model in detail)
            {
                PaymentDetail d = new PaymentDetail();
                d.CreditCardTypeID = model.CreditCardTypeID;
                d.PaymentTypeID    = model.PaymentTypeID;
                d.Amount           = model.Amount;
                d.ApprovalCode     = model.ApprovalCode;
                h.PaymentDetails.Add(d);
                ctx.PaymentHeaders.InsertOnSubmit(h);
            }

            autoNumberProvider.Increment("PM", invoice.BranchID, date.Year);
            ctx.SubmitChanges();
        }

        return(paymentNo);
    }
Example #25
0
 private void Create(string formCode, int branchID, int year)
 {
     using (var ctx = new FitnessDataContext())
     {
         AutoNumber autoNumber = ctx.AutoNumbers.SingleOrDefault(row => row.FormCode == formCode && row.BranchID == branchID && row.Year == year);
         if (autoNumber == null)
         {
             autoNumber            = new AutoNumber();
             autoNumber.BranchID   = branchID;
             autoNumber.FormCode   = formCode;
             autoNumber.Year       = year;
             autoNumber.LastNumber = 0;
             ctx.AutoNumbers.InsertOnSubmit(autoNumber);
             ctx.SubmitChanges();
         }
     }
 }
Example #26
0
    void IBasicCommand.Delete()
    {
        int[] arrayOfID = DynamicControlBinding.GetRowIdForDeletion(gvwMaster);

        try
        {
            using (var ctx = new FitnessDataContext())
            {
                ctx.Alerts.DeleteAllOnSubmit(ctx.Alerts.Where(row => arrayOfID.Contains(row.ID)));
                ctx.SubmitChanges();
            }
        }
        catch (Exception ex)
        {
            DynamicControlBinding.SetLabelTextWithCssClass(lblStatus, ex.Message, LabelStyleNames.ErrorMessage);
            ApplicationLogger.Write(ex);
        }
        ((IBasicCommand)this).Refresh();
    }
Example #27
0
    void IBasicCommand.Save()
    {
        if (this.IsValid)
        {
            try
            {
                using (var ctx = new FitnessDataContext())
                {
                    Alert entity = RowID == 0 ? new Alert() : ctx.Alerts.Single(row => row.ID == RowID);
                    entity.Description = txtDescription.Text;
                    entity.StartDate   = CalendarPopup1.SelectedValue.Value;
                    entity.EndDate     = chkInfinite.Checked ? null : CalendarPopup2.SelectedValue;
                    entity.Active      = chkActive.Checked;
                    if (RowID == 0)
                    {
                        EntityHelper.SetAuditFieldForInsert(entity, User.Identity.Name);
                        ctx.Alerts.InsertOnSubmit(entity);
                    }
                    else
                    {
                        EntityHelper.SetAuditFieldForUpdate(entity, User.Identity.Name);
                    }

                    ctx.SubmitChanges();
                }

                DynamicControlBinding.SetLabelTextWithCssClass(lblStatus, "Data has been saved.", LabelStyleNames.InfoMessage);
            }
            catch (Exception ex)
            {
                DynamicControlBinding.SetLabelTextWithCssClass(lblStatus, ex.Message, LabelStyleNames.ErrorMessage);
                ApplicationLogger.Write(ex);
            }
            finally
            {
                ((IBasicCommand)this).Refresh();
            }
        }
    }
Example #28
0
        public void Add(
            DateTime date,
            bool useExistingBarcode,
            string barcode,
            bool isTransfer,
            string firstName,
            string LastName,
            DateTime dateOfBirth,
            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,
            DateTime?nextDuesDate,
            DateTime expiredDate,
            string homePhone,
            string cellphone,
            string mailingAddress,
            string zipCodeMailingAddress,
            string address,
            string zipCode,
            int areaID,
            int schoolID,
            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 = ctx.PackageHeaders.SingleOrDefault(pkg => pkg.ID == packageID);

            if (package != null)
            {
                //nextDuesDate = effectiveDate.AddMonths(package.PackageDuesInMonth);
                Customer cust = null;
                if (useExistingBarcode)
                {
                    cust = ctx.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.HomeBranchID   = branchID;
                    cust.HomePhone      = homePhone;
                    cust.CellPhone1     = cellphone;
                    cust.BillingTypeID  = billingTypeID;
                    cust.AreaID         = areaID == 0 ? (int?)null : areaID;
                    cust.SchoolID       = schoolID == 0 ? (int?)null : schoolID;
                    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, HttpContext.Current.User.Identity.Name);
                    ctx.Customers.InsertOnSubmit(cust);

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

                Contract 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.EffectiveDate = effectiveDate;
                contract.BillingItemID = billingItemID == 0 ? (int?)null : billingItemID;
                contract.DuesAmount    = duesAmount;
                contract.NextDuesDate  = nextDuesDate.Value;
                //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 ? contractType : null;
                }
                EntityHelper.SetAuditFieldForInsert(contract, HttpContext.Current.User.Identity.Name);
                ctx.Contracts.InsertOnSubmit(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, HttpContext.Current.User.Identity.Name);
                        ctx.Persons.InsertOnSubmit(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, HttpContext.Current.User.Identity.Name);
                        ctx.Persons.InsertOnSubmit(person);
                    }
                }

                autoNumberProvider.Increment("CO", branchID, date.Year);
                ctx.SubmitChanges();
            }
        }
Example #29
0
 public void Delete(int[] branchesID)
 {
     ctx.Branches.DeleteAllOnSubmit(ctx.Branches.Where(row => branchesID.Contains(row.ID)));
     ctx.SubmitChanges();
 }
Example #30
0
    public void AddParticipant(int classRunningID, int customerID)
    {
        ClassAttendance classAttendance = new ClassAttendance();

        classAttendance.ClassRunningID = classRunningID;
        classAttendance.CustomerID     = customerID;
        classAttendance.IsAttend       = false;
        ctx.ClassAttendances.InsertOnSubmit(classAttendance);
        ctx.SubmitChanges();
    }