Пример #1
0
        public void Edit(object oldCM, object newCM)
        {
            List <Backend.ClubMember> Allclubmems = itsDAL.ReadFromFile(Elements.ClubMember).Cast <Backend.ClubMember>().ToList();

            //Check for credit card conflict
            if (((Backend.ClubMember)newCM).CreditCard != null && !((Backend.ClubMember)newCM).CreditCard.Equals(((Backend.ClubMember)oldCM).CreditCard))
            {
                foreach (Backend.ClubMember clubmem in Allclubmems)
                {
                    if (clubmem.CreditCard != null && clubmem.CreditCard.CreditNumber == ((Backend.ClubMember)newCM).CreditCard.CreditNumber)
                    {
                        throw new System.Data.DataException("The Credit Card ID allready exist in the system");
                    }
                }
            }
            //preserve the id for the edited clubmember
            ((Backend.ClubMember)newCM).MemberID = ((Backend.ClubMember)oldCM).MemberID;
            List <Backend.User> oldUserList = itsDAL.UserPersonQuery(oldCM);

            Backend.User oldUser = oldUserList.ElementAtOrDefault(0);
            if (oldUser == null)
            {
                throw new NullReferenceException("The clubmember does not exist!");
            }
            User_BL itsUserBL = new User_BL(itsDAL);

            Backend.User newUser = new Backend.User(oldUser);
            newUser.Person = newCM;
            itsUserBL.Remove(oldUser, true);
            this.Remove(oldCM);
            this.Add(newCM);
            itsUserBL.Add(newUser);
        }
Пример #2
0
 /*
  * constructor. recieves the data layer which E_Mart_BL works with directly
  */
 public E_Mart_BL(IDAL dal)
 {
     this.itsDAL         = dal;
     this.prod_bl        = new Product_BL(dal);
     this.employee_bl    = new Employee_BL(dal);
     this.clubMember_bl  = new ClubMember_BL(dal);
     this.department_bl  = new Department_BL(dal);
     this.transaction_bl = new Transaction_BL(dal);
     this.user_bl        = new User_BL(dal);
 }
Пример #3
0
 //constructor
 public BL_Manager(DAL_Manager dal_manager)
 {
     BL_user        = new User_BL(dal_manager.userData);
     BL_clubMember  = new ClubMember_BL(dal_manager.ClubMemberData);
     BL_department  = new Department_BL(dal_manager.departmentData);
     BL_employee    = new Employee_BL(dal_manager.employeeData);
     BL_product     = new Product_BL(dal_manager.productData);
     BL_transaction = new Transaction_BL(dal_manager.transactionData);
     BL_location    = new Location_BL(dal_manager.locationData);
 }
Пример #4
0
 //Constructors:
 public Employee_BL(IDAL dal)
 {
     itsDAL    = dal;
     itsUserBL = new User_BL(itsDAL);
 }