Beispiel #1
0
        private void borrow_event_Click(object sender, RoutedEventArgs e)
        {
            if (flag == Book_state.From)                                                                                                                                                                                             // 대여 ( DB 소유자 변경 )
            {
                if (Data.login_state)                                                                                                                                                                                                // 로그인시에만 대여 가능
                {
                    string query = $"UPDATE `book_l`.`books` SET `Rental_User_ID`='{Data.user.user_id}' WHERE  `Book_ID`={now_book};";                                                                                               //  책 소유자 변경
                    //string query_userhistory = $"UPDATE `book_l`.`books` SET `Rental_User_ID`='{Data.user.user_id}' WHERE  `Book_ID`={now_book};"; //  유저 로그 수정
                    string query_bookhistory = $"INSERT INTO `book_l`.`books_history` (`Book_ID`, `User_ID`, `Book_Name`,`User_Name` ) VALUES ('{now_book}', '{Data.user.user_id}', '{lblname.Content}', '{Data.user.user_name}');"; //  책 로그 추가
                    Data.DB_con.write_query(query + query_bookhistory);

                    MessageBox.Show("대여 되었습니다.");

                    this.Dispatcher.Invoke(DispatcherPriority.Normal, (ThisDelegate) delegate()
                    {
                        //메세지 박스 출력 (완료) 후 화면갱신
                        Book_img.Source        = new BitmapImage();
                        borrow_event.IsEnabled = false;
                        lblname.Content        = "";
                        lblgenre.Content       = "";
                        lblauthor.Content      = "";
                        lblstate.Content       = "";
                    });
                }
                else
                {
                    Login_View login_View = new Login_View();
                    login_View.ShowDialog();
                    if (login_View.DialogResult == true)
                    {
                        Data.login_state = true; // 로그인
                    }
                }
            }
            else // 반남 ( DB 소유자 -> 1 )
            {
                string date = System.DateTime.Now.ToString("yyyy-MM-dd");

                string query      = $"UPDATE `book_l`.`books` SET `Rental_User_ID`='1' WHERE  `Book_ID`={now_book};";                                            //  0 - 로그인 유저(비로그인 생각)  1- 책id
                string query_book = $"UPDATE `book_l`.`books_history` SET `Return_Date`='{date}' WHERE  `Book_ID`={now_book} and `Return_Date` IS NULL LIMIT 1"; // 가장 최근 책 대여 return 날짜 설정 ( 책은 한번에 한권 대여 )
                Data.DB_con.write_query(query + query_book);

                MessageBox.Show("반납 되었습니다.");

                this.Dispatcher.Invoke(DispatcherPriority.Normal, (ThisDelegate) delegate()
                {
                    //메세지 박스 출력 (완료) 후 화면갱신
                    Book_img.Source        = new BitmapImage();
                    borrow_event.IsEnabled = false;
                    lblname.Content        = "";
                    lblgenre.Content       = "";
                    lblauthor.Content      = "";
                    lblstate.Content       = "";
                });
            }
        }
Beispiel #2
0
        private void login_click(object sender, RoutedEventArgs e)
        {
            if (Data.login_state)
            {
                if (MessageBox.Show("로그아웃 하시겠습니까?", "메세지", MessageBoxButton.OKCancel) == MessageBoxResult.OK)
                {
                }
                else
                {
                    return;
                }
                user_name_info.Content    = "";
                user_address_info.Content = "";
                user_email_info.Content   = "";
                user_note_info.Content    = "";

                user_image.Source  = new BitmapImage();
                user_image.Stretch = Stretch.Uniform;

                Data.login_state = false;
                user_btn.Content = "LogIn";

                Set_btn.Visibility = Visibility.Hidden;
            }
            else
            {
                Login_View login_View = new Login_View();
                login_View.ShowDialog();
                if (login_View.DialogResult == true)
                {
                    user_name_info.Content    = Data.user.user_name;
                    user_address_info.Content = Data.user.user_address;
                    user_email_info.Content   = Data.user.user_email;
                    user_note_info.Content    = Data.user.user_note;

                    //MessageBox.Show(System.Environment.CurrentDirectory + @"\User\" + Data.user.user_image);
                    try
                    {
                        user_image.Source = new BitmapImage(new Uri(System.Environment.CurrentDirectory + @"\User\" + Data.user.user_image));
                    }
                    catch
                    {
                        user_image.Source = new BitmapImage(new Uri(@"Resource\User_default.png", UriKind.Relative)); // 이미지 찾기 실패시 기본 이미지 표시
                    }
                    user_image.Stretch = Stretch.Uniform;

                    Data.login_state = true;
                    user_btn.Content = "LogOut";
                    if (Data.user.user_level == "1")
                    {
                        Set_btn.Visibility = Visibility.Visible; // 운영자 계정일때만 Visible
                    }
                }
            }
        }