private void OnAddNewMember(object sender, RoutedEventArgs e)
        {
            String memberName = txtMemberName.Text;
            String memberFee  = txtMemberFee.Text;

            if (memberName == "")
            {
                MessageBox.Show("Bạn chưa nhập tên thành viên");
                txtMemberFee.Text = "";
                return;
            }
            else if (memberFee == "")
            {
                MessageBox.Show("Bạn chưa nhập tiền thu");
                txtMemberName.Text = "";
                return;
            }

            ThanhVien thanhVien = new ThanhVien();

            int memberCount = (thanhVienDAOlmpl.GetAllThanhVien().Count() + members.Count() + 1);

            thanhVien.MaThanhVien  = memberCount.ToString();
            thanhVien.TenThanhVien = memberName;

            members.Add(thanhVien);
            trip_memberList.Add(new CHUYENDI_THANHVIEN()
            {
                MaChuyenDi  = this.maChuyenDi,
                MaThanhVien = thanhVien.MaThanhVien,
                TienThu     = Int32.Parse(memberFee)
            });

            thanhVien_TienThu.Add(new ThanhVien_TienThu(thanhVien.TenThanhVien, memberFee));

            txtMemberName.Text = "";
            txtMemberFee.Text  = "";
        }
Beispiel #2
0
        private void filterByMember()
        {
            cdList.Clear();
            foreach (var trip in cdDao.GetAllChuyenDi())
            {
                cdList.Add(trip);
            }
            String filterQuery = keywordTextBox.Text;

            if (!filterQuery.Equals(""))
            {
                String unSignLowerMemberName            = ConvertToUnSign(filterQuery.ToLower());
                ChuyenDiThanhVienDAOImpl  tripMemberDAO = new ChuyenDiThanhVienDAOImpl();
                List <CHUYENDI_THANHVIEN> trip_members  = tripMemberDAO.GetCHUYENDI_THANHVIENList();

                ThanhVienDAOlmpl memberDAO = new ThanhVienDAOlmpl();
                List <ThanhVien> members   = memberDAO.GetAllThanhVien();

                for (int i = 0; i < members.Count(); i++)
                {
                    ThanhVien member = members[i];
                    String    unSignLowerMemberNameItem = ConvertToUnSign(member.TenThanhVien.ToLower());
                    if (!unSignLowerMemberNameItem.Contains(unSignLowerMemberName))
                    {
                        members.Remove(member);
                        i--;
                    }
                }

                for (int i = 0; i < trip_members.Count(); i++)
                {
                    CHUYENDI_THANHVIEN trip_member = trip_members[i];
                    for (int j = 0; j < members.Count(); j++)
                    {
                        if (trip_member.MaThanhVien.Equals(members[j].MaThanhVien))
                        {
                            break;
                        }

                        if (j == members.Count() - 1)
                        {
                            trip_members.Remove(trip_member);
                            i--;
                        }
                    }
                }

                for (int i = 0; i < cdList.Count(); i++)
                {
                    ChuyenDi trip = cdList[i];
                    for (int j = 0; j < trip_members.Count(); j++)
                    {
                        if (trip.MaChuyenDi.Equals(trip_members[j].MaChuyenDi))
                        {
                            break;
                        }

                        if (j == trip_members.Count() - 1)
                        {
                            i--;
                            tripVM.TripList.Remove(trip);
                        }
                    }
                }
            }
        }