예제 #1
0
 /// <summary>
 /// Add new borrow info to the database with BID, and UID
 /// </summary>
 /// <param name="sBID"></param>
 /// <param name="sUID"></param>
 /// <returns></returns>
 public bool add_new_borrow(string sBID, string sUID, DateTime dtBorrowDate, int returnafter)
 {
     try
     {
         //setups
         var         data    = new Borrow_Data(sBID, sUID, dtBorrowDate, returnafter);
         DAL_Account account = new DAL_Account();
         DAL_Book    book    = new DAL_Book();
         book.init_client();
         account.init_client();
         data.BrID = create_new_id();
         //minus 1 book from the database
         Book_Data bookdata = book.retrieve_book_data(sBID);
         bookdata.left -= 1;
         book.update_book_data(bookdata);
         //update user brid
         account.add_brid(sUID, data.BrID);
         //add new borrow info
         SetResponse response = client.Set(sBorrowTable_path + data.BrID, data);
         Borrow_Data result   = response.ResultAs <Borrow_Data>();
         if (result != null)
         {
             return(true);
         }
     }
     catch (Exception)
     {
     }
     return(false);
 }
예제 #2
0
        public void set_value_from_item(Borrow_Data selected_borrow_data)
        {
            data = selected_borrow_data;
            string uid, bid, borrowdate, username, bookname;

            username = UserNameTextBlock.Text + "null";
            bookname = BookNameTextBlock.Text + "null";
            uid      = this.UIDTextBlock.Text + data.UID;
            if (user_control.Get_Single_UserInfo(data.UID) != null && admin_control.retrieve_book_data(data.BID) != null)
            {
                username = this.UserNameTextBlock.Text + user_control.Get_Single_UserInfo(data.UID).name;
                bookname = this.BookNameTextBlock.Text + admin_control.retrieve_book_data(data.BID).name;
            }
            bid                           = this.BIDTextBlock.Text + data.BID;
            borrowdate                    = BorrowDateTextBlock.Text + data.borrow_date.ToString();
            this.UIDTextBlock.Text        = uid;
            this.UserNameTextBlock.Text   = username;
            this.BIDTextBlock.Text        = bid;
            this.BookNameTextBlock.Text   = bookname;
            this.BorrowDateTextBlock.Text = borrowdate;
            if (data.packed == false)
            {
                PackedButton.IsEnabled = true;
            }
        }
예제 #3
0
        /// <summary>
        /// retrieve specific borrow data by sBrID
        /// </summary>
        /// <param name="sBrID"></param>
        /// <returns></returns>
        public Borrow_Data retrieve_borrow_data(string sBrID)
        {
            var retrieve_response = client.Get(sBorrowTable_path + sBrID);

            if (retrieve_response.Body != "null")
            {
                Borrow_Data data = retrieve_response.ResultAs <Borrow_Data>();
                return(data);
            }
            return(null);
        }
예제 #4
0
        public bool update_returned_to(bool bBool, Borrow_Data brData)
        {
            brData.returned = true;
            FirebaseResponse update_response = client.Update(sBorrowTable_path + brData.BrID, brData);

            if (update_response != null)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
예제 #5
0
        public BorrowedPage()
        {
            InitializeComponent();
            List <string> BrID_List = User_Control.get_user_BrID(Data_Context.currentAccount);

            Console.WriteLine(Data_Context.currentAccount.BrID);
            foreach (string Data in BrID_List)
            {
                Borrow_Data Brwdata = User_Control.retrieve_borrow_data(Data);
                try
                {
                    Book_Data data = User_Control.retrieve_book_data(Brwdata.BID);
                    brwedbook.Add(data);
                }
                catch (Exception)
                {
                }
            }
            if (brwedbook.Count > 0)
            {
                IBook.ItemsSource = brwedbook;
            }
        }
예제 #6
0
 public bool update_packed_to(bool bValue, Borrow_Data data)
 {
     Borrow_DAL.init_client();
     return(Borrow_DAL.update_packed_to(bValue, data));
 }