Ejemplo n.º 1
0
        public MemberAccountViewModel(ProtoBridge bridge, StaffAccountBLL currUser)
            : base(LibraryScreens.TRANSACTIONS, bridge, currUser)
        {
            int chosenId = (int)Application.Current.Properties["EnteredMemId"];
            _chosenMem = bridge.MemberMgr.GetByID(chosenId);

            if (_chosenMem == null)
            {
                Console.Beep();
            }
            else
            {
                MemberID = _chosenMem.ItemID.ToString();
                MemberName = _chosenMem.FirstName + " " + _chosenMem.MiddleName + " " + _chosenMem.LastName;
                TimeSpan ts = DateTime.Now - _chosenMem.JoinDate;
                Age = (ts.Days/365).ToString();
                Address = _chosenMem.Contact.AddressLine1 + " " + _chosenMem.Contact.AddressLine2 + " " + _chosenMem.Contact.AddressLine3
                    + " " + _chosenMem.Contact.City + " " + _chosenMem.Contact.Pin + " " + _chosenMem.Contact.StateOrProvince + " " + _chosenMem.Contact.Country;
                Gender = _chosenMem.Gender;
                JoinDate = _chosenMem.JoinDate.ToString();

                List<TransactionBLL> transs = bridge.TransactionMgr.GetMemberTransactions(_chosenMem.ItemID);

                string err;
                bridge.TransactionMgr.IssueBook(120, chosenId, out err);
                if (err != null)
                    MessageBox.Show(err);

                foreach (TransactionBLL t in transs)
                {
                    if (t.ReturnedOn == null)
                        TransHistory.Add(new TransactionDetails(bridge, t, true));
                    else
                        CurrentTrans.Add(new TransactionDetails(bridge, t, false));
                }

            }
        }
        public static void MemberDalToBll(ProtoLibEntities context, MemberBLL bllMember, Member dalMember)
        {
            bllMember.ItemID = dalMember.MemberID;

            bllMember.FirstName = dalMember.FirstName;
            bllMember.MiddleName = dalMember.MiddleName;
            bllMember.LastName = dalMember.LastName;
            bllMember.DateOfBirth = dalMember.DateOfBirth;
            bllMember.JoinDate = dalMember.JoinDate;
            bllMember.Gender = dalMember.Gender;

            //FIXME: copy image binary data to BLL object
            bllMember.Portrait = dalMember.Portrait;

            bllMember.Contact.AddressLine1 = dalMember.Contact.AddLine1;
            bllMember.Contact.AddressLine2 = dalMember.Contact.AddLine2;
            bllMember.Contact.AddressLine3 = dalMember.Contact.AddLine3;
            bllMember.Contact.Phone1 = dalMember.Contact.Phone1;
            bllMember.Contact.Phone2 = dalMember.Contact.Phone2;
            bllMember.Contact.Email = dalMember.Contact.Email;
            bllMember.Contact.Website = dalMember.Contact.Website;
            bllMember.Contact.Pin = dalMember.Contact.Pin;
            bllMember.Contact.City = dalMember.Contact.City.City1;
            bllMember.Contact.StateOrProvince = dalMember.Contact.City.StateOrProvince;
            bllMember.Contact.Country = dalMember.Contact.City.Country;
        }
        public static void MemberBllToDal(ProtoLibEntities context, MemberBLL bllMember, Member dalMember)
        {
            dalMember.FirstName = bllMember.FirstName;
            dalMember.MiddleName = bllMember.MiddleName;
            dalMember.LastName = bllMember.LastName;
            dalMember.DateOfBirth = bllMember.DateOfBirth;
            dalMember.JoinDate = bllMember.JoinDate;
            dalMember.Gender = bllMember.Gender;

            //FIXME: copy image binary data to BLL object
            dalMember.Portrait = bllMember.Portrait;

            dalMember.Contact.AddLine1 = bllMember.Contact.AddressLine1;
            dalMember.Contact.AddLine2 = bllMember.Contact.AddressLine2;
            dalMember.Contact.AddLine3 = bllMember.Contact.AddressLine3;
            dalMember.Contact.Phone1 = bllMember.Contact.Phone1;
            dalMember.Contact.Phone2 = bllMember.Contact.Phone2;
            dalMember.Contact.Email = bllMember.Contact.Email;
            dalMember.Contact.Website = bllMember.Contact.Website;
            dalMember.Contact.Pin = bllMember.Contact.Pin;

            City city = (from c in context.Cities where c.City1 == bllMember.Contact.City select c).FirstOrDefault();

            if (city == null)
            {
                dalMember.Contact.City = new City();
                dalMember.Contact.City.City1 = bllMember.Contact.City;
                dalMember.Contact.City.StateOrProvince = bllMember.Contact.StateOrProvince;
                dalMember.Contact.City.Country = bllMember.Contact.Country;
            }
            else
            {
                dalMember.Contact.City = city;
            }
        }