Ejemplo n.º 1
0
        private void Edit_user(object sender, RoutedEventArgs e)
        {
            Account_Data data = selected_Account;

            data.account  = UserAccount_txb.Text;
            data.password = PasswordBox.Text;
            data.email    = UserMail_txb.Text;
            data.LCID     = ((ComboBoxItem)libcardCombobox.SelectedItem).Tag.ToString();

            admin_control.Update_User_data(data);

            if (!string.IsNullOrEmpty(oldLCID))
            {
                LibCard_Data oldlibcard = admin_control.Retrive_libcard_data(oldLCID);
                oldlibcard.used = false;
                admin_control.update_libcard_useable(oldlibcard, oldlibcard.used);
            }
            if (!string.IsNullOrEmpty(data.LCID))
            {
                LibCard_Data newlibcard = admin_control.Retrive_libcard_data(data.LCID);
                newlibcard.used = true;
                admin_control.update_libcard_useable(newlibcard, newlibcard.used);
            }

            TestGUI_QLTV.PopUpWindow popup = new TestGUI_QLTV.PopUpWindow();
            popup.PopUpTB.Text = "Updated";
            popup.Owner        = Window.GetWindow(this);
            Window.GetWindow(this).IsHitTestVisible = false;
            popup.Show();
        }
Ejemplo n.º 2
0
 public void set_value_from_item(LibCard_Data data)
 {
     this.selected_libcard = data;
     IDTextBox.Text        = selected_libcard.identity_card;
     NameTextBox.Text      = selected_libcard.name;
     DOBTextBox.Text       = selected_libcard.DOB;
     for (int i = 0; i < this.AccountTypeComboBox.Items.Count; i++)
     {
         if (this.AccountTypeComboBox.Items[i].ToString().Contains(selected_libcard.account_type))
         {
             this.AccountTypeComboBox.SelectedIndex = i;
             bCheck[3] = true;
             enable_addbutton();
         }
     }
     for (int i = 0; i < this.GenderComboBox.Items.Count; i++)
     {
         string sGender;
         if (selected_libcard.gender)
         {
             sGender = "Male";
         }
         else
         {
             sGender = "Female";
         }
         if (this.GenderComboBox.Items[i].ToString().Contains(sGender))
         {
             this.GenderComboBox.SelectedIndex = i;
             bCheck[4] = true;
             enable_addbutton();
         }
     }
 }
Ejemplo n.º 3
0
        /// <summary>
        /// Retrieve libcard data specificly by its LCID, then check its availability
        /// </summary>
        /// <param name="sLCID"></param>
        /// <returns></returns>
        public LibCard_Data retrieve_libcard_data(string sLCID)
        {
            var          retrieve_response = client.Get(sLibCardTable_path + sLCID);
            LibCard_Data data = retrieve_response.ResultAs <LibCard_Data>();

            update_libcard_expiration(data, still_available(data));
            return(data);
        }
Ejemplo n.º 4
0
 /// <summary>
 /// Check libcard availability
 /// </summary>
 /// <param name="libcard"></param>
 /// <returns></returns>
 public bool still_available(LibCard_Data libcard)
 {
     if ((DateTime.Now - libcard.created_date).TotalDays > 30)
     {
         return(false);
     }
     else
     {
         return(true);
     }
 }
Ejemplo n.º 5
0
        public bool update_libcard_usedable(LibCard_Data libcard, bool value)
        {
            libcard.used = value;
            FirebaseResponse response = client.Update(sLibCardTable_path + libcard.LCID, libcard);
            LibCard_Data     data     = response.ResultAs <LibCard_Data>();

            if (data != null)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Ejemplo n.º 6
0
 /// <summary>
 /// Add a new libcard info to the database
 /// </summary>
 /// <param name="sAccountType"></param>
 /// <param name="sIdentityCard"></param>
 /// <param name="sName"></param>
 /// <param name="dDOB"></param>
 /// <param name="bGender"></param>
 /// <returns></returns>
 public bool create_new_libcard(string sAccountType, string sIdentityCard
                                , string sName, string dDOB, bool bGender)
 {
     try
     {
         string sLCID = DateTime.Now.Ticks.ToString().Substring(1);
         var    data  = new LibCard_Data(sAccountType, sIdentityCard, sName, dDOB, bGender);
         data.created_date = DateTime.Now;
         data.LCID         = sLCID;
         SetResponse  response = client.Set(sLibCardTable_path + sLCID, data);
         LibCard_Data result   = response.ResultAs <LibCard_Data>();
         if (result != null)
         {
             return(true);
         }
     }
     catch (Exception) { }
     return(false);
 }
Ejemplo n.º 7
0
 public bool update_libcard(string sLCID, string sAccountType, string sIdentityCard
                            , string sName, string dDOB, bool bGender)
 {
     try
     {
         //get libcard from LCID
         LibCard_Data data = retrieve_libcard_data(sLCID);
         data.account_type  = sAccountType;
         data.identity_card = sIdentityCard;
         data.name          = sName;
         data.DOB           = dDOB;
         data.gender        = bGender;
         //update Libcard info
         FirebaseResponse update_response = client.Update(sLibCardTable_path + sLCID, data);
         LibCard_Data     result          = update_response.ResultAs <LibCard_Data>();
         if (result != null)
         {
             return(true);
         }
     }
     catch (Exception) { }
     return(false);
 }
Ejemplo n.º 8
0
 /// <summary>
 /// transfer libcard data to users and send it to the database
 /// </summary>
 /// <param name="sUID"></param>
 /// <param name="sLCID"></param>
 public bool set_libcard_to_user(string sUID, string sLCID)
 {
     try
     {
         DAL_Libcard Libcard_rep = new DAL_Libcard();
         //get user
         Account_Data user_data = retrieve_user_data(sUID);
         //get libcard
         var          libcard_response = client.Get(Libcard_rep.sLibCardTable_path + sLCID);
         LibCard_Data libcard_data     = libcard_response.ResultAs <LibCard_Data>();
         //set new data
         if (libcard_data.used == true)
         {
             return(false);
         }
         else
         {
             libcard_data.used = true;
         }
         user_data.name          = libcard_data.name;
         user_data.DOB           = libcard_data.DOB;
         user_data.gender        = libcard_data.gender;
         user_data.identity_card = libcard_data.identity_card;
         user_data.account_type  = libcard_data.account_type;
         user_data.LCID          = libcard_data.LCID;
         //send it to the database
         FirebaseResponse libcard_resp    = client.Update("LibCards/" + sLCID, libcard_data);
         FirebaseResponse update_response = client.Update(sAccountTable_path + sUID, user_data);
         Account_Data     result          = update_response.ResultAs <Account_Data>();
         if (result != null)
         {
             return(true);
         }
     }
     catch (Exception) { }
     return(false);
 }
Ejemplo n.º 9
0
 public void update_libcard_useable(LibCard_Data libcard, bool value)
 {
     Libcard_DAL.init_client();
     Libcard_DAL.update_libcard_usedable(libcard, value);
 }