示例#1
0
 public Add_Member()
 {
     InitializeComponent();
     mb = new Member_Detail();
     mbController.addMember(mb);
     txt_member_id.Text = mb.member_id.ToString();
 }
        public MemberQuickView(int member_id)
        {
            InitializeComponent();
            this.member_id   = member_id;
            memberController = new MemberController();

            member               = memberController.findMemberById(member_id);
            txt_firstname.Text   = member.first_name;
            txt_lastname.Text    = member.last_name;
            txt_phonenumber.Text = member.phone_number;
            txt_address.Text     = member.address;

            dpdob.SelectedDate = member.dob;
            txt_member_id.Text = member.member_id + "";


            if (member.photo != null)
            {
                image_member.Source = Convertor.ToImage(member.photo);
            }
            else
            {
                image_member.Source = new BitmapImage(new Uri(@"image/profile3.jpg", UriKind.Relative));
            }
        }
        private void Row_DoubleClick(object sender, MouseButtonEventArgs e)
        {
            var           item   = dataGrid.SelectedItem;
            Book_Detail   bk     = new Book_Detail();
            Member_Detail member = new Member_Detail();
            Issue_Detail  issue  = new Issue_Detail();


            if (issue.GetType().Equals(item.GetType()) == true)
            {
                issue = (Issue_Detail)dataGrid.SelectedItem;
                bk    = bookController.findByBookID((int)issue.book_id);
                if (!bk.title.Equals(""))
                {
                    lbl_availablility_replace.Content  = bk.no_of_copies;
                    lbl_book_name_replace.Content      = bk.title;
                    lbl_book_publisher_replace.Content = bk.publisher;
                    lbl_cat_replace.Content            = bk.category;
                    lbl_isbn_replace.Content           = bk.isbn;

                    if (bk.image != null)
                    {
                        BitmapImage image = Convertor.ToImage(bk.image);
                        image_book_detail.Source = image;
                    }
                    else
                    {
                        image_book_detail.Source = new BitmapImage(new Uri(@"image/profile3.jpg", UriKind.Relative));
                    }
                }
            }
        }
        private void btn_check_member_Click(object sender, RoutedEventArgs e)
        {
            string memberID = txt_memberid.Text;
            int    num;

            if (!memberID.Equals("") || !memberID.Equals(null))
            {
                Boolean parseSuccess = int.TryParse(memberID, out num);

                if (parseSuccess)
                {
                    // int id = Util.StandardID_Generator.idExtractorGenerator(memID);
                    //  Console.Write("ID :" + id + "mem ID" + memID);
                    member_detail = memberController.findMemberById(num);

                    if (member_detail != null)
                    {
                        lbl_member_id.Content    = member_detail.member_id;
                        lbl_student_name.Content = member_detail.first_name + " " + member_detail.last_name;
                        lbl_phone_number.Content = member_detail.phone_number;
                        txt_bookid.Focus();
                        if (member_detail.photo != null)
                        {
                            BitmapImage image = Convertor.ToImage(member_detail.photo);
                            image_member.Source = image;
                        }
                        else
                        {
                            image_member.Source = new BitmapImage(new Uri(@"image/profile3.jpg", UriKind.Relative));
                        }
                    }
                    else
                    {
                        MessageBox.Show("No User Found");
                    }
                }
                else
                {
                    MessageBox.Show("failed to parse");
                }
            }
            else
            {
                MessageBox.Show("Please insert member ID");
            }
        }
示例#5
0
        private void Row_DoubleClick(object sender, MouseButtonEventArgs e)
        {
            var           item   = data_book_grid.SelectedItem;
            Book_Detail   bk     = new Book_Detail();
            Member_Detail member = new Member_Detail();
            Issue_Detail  issue  = new Issue_Detail();

            if (bk.GetType().Equals(item.GetType()) == true)
            {
                bk = (Book_Detail)data_book_grid.SelectedItem;
                new View_Book_Details(bk.book_id).Show();
            }
            if (member.GetType().Equals(item.GetType()) == true)
            {
                member = (Member_Detail)data_book_grid.SelectedItem;
                new MemberQuickView(member.member_id).Show();
            }
            if (issue.GetType().Equals(item.GetType()) == true)
            {
                issue = (Issue_Detail)data_book_grid.SelectedItem;
            }
        }
示例#6
0
        private void btn_addmember_Click(object sender, RoutedEventArgs e)
        {
            string   firstName = txt_firstname.Text.Trim();
            string   lastName  = txt_lastname.Text;
            DateTime?dob       = null;

            try
            {
                dob = dpdob.SelectedDate.Value;
            }
            catch {
                MessageBox.Show("select date of Birth");
            }

            string email      = txt_email.Text;
            string address    = txt_address.Text;
            string phone      = txt_phonenumber.Text;
            string addmission = txt_admissionnumber.Text;

            Member_Detail md = new Member_Detail();

            md.first_name       = firstName;
            md.last_name        = lastName;
            md.email            = email;
            md.admission_number = addmission;
            md.address          = address;
            md.phone_number     = phone;
            md.dob = dob;

            if (image != null)
            {
                md.photo = Convertor.imageToByteArray(image);
            }

            Member_Validator validator = new Member_Validator();

            FluentValidation.Results.ValidationResult results = validator.Validate(md);
            Console.WriteLine("validation result " + results.IsValid);
            if (!results.IsValid)
            {
                foreach (var failure in results.Errors)
                {
                    MessageBox.Show(failure.ErrorMessage);
                }
            }
            else
            {
                //      if (firstName == null || firstName == "" || lastName == null || lastName == "" || address == null || address == "" || addmission == 0 )

                //    else {
                isNewMemberAdded = mbController.updateMember(md);

                if (isNewMemberAdded)
                {
                    MessageBox.Show("New Member Added");
                }
                else
                {
                    MessageBox.Show("Failed to Add New Member");
                }
            }
        }
        private void btn_check_member_Click_1(object sender, RoutedEventArgs e)
        {
            if (txt_memberid.Text.Equals(null) || txt_memberid.Text.Equals(""))
            {
                MessageBox.Show("Text Filed is empty");
            }
            else
            {
                string memberidStr = txt_memberid.Text.Trim();

                int memberid;

                bool parseResult = int.TryParse(memberidStr, out memberid);

                if (parseResult)
                {
                    Member_Detail memberDetail = memberContoller.findMemberById(memberid);

                    if (memberDetail != null)
                    {
                        lbl_member_id.Content    = memberDetail.member_id;
                        lbl_student_name.Content = memberDetail.first_name + " " + memberDetail.last_name;
                        lbl_phone_number.Content = memberDetail.phone_number;

                        if (memberDetail.photo != null)
                        {
                            byte[]      imageByte = memberDetail.photo;
                            BitmapImage mem_image = ToImage(imageByte);
                            image_member.Source = mem_image;
                        }

                        else
                        {
                            image_member.Source = new BitmapImage(new Uri(@"image/profile3.jpg", UriKind.Relative));
                        }



                        List <Issue_Detail> issueDetails = issueContoller.getReturnBookDetail(memberid);

                        if (issueDetails.Count > 0)
                        {
                            dataGrid.ItemsSource = issueContoller.getReturnBookDetail(memberid);
                            Console.WriteLine("Returned book count " + issueDetails.Count);
                        }
                        else
                        {
                            MessageBox.Show("No books to Return for the current user");
                        }
                    }
                    else
                    {
                        MessageBox.Show("no such member");
                    }
                }
                else
                {
                    MessageBox.Show("Please input a number");
                }
            }
        }