private void btn_search_Click(object sender, EventArgs e) //Klicka på sökknappen
        {
            BibliotechController bc = new BibliotechController();

            if (txt_title.Text.Length > 0)
            {
                BibliotechDAL bd = new BibliotechDAL();
                DataTable     d  = bd.SearchTitle(txt_title.Text);
                DrawBookResults(d);
            }
            else if (txt_isbn.Text.Length > 0)
            {
                BibliotechDAL bd = new BibliotechDAL();
                DataTable     d  = bd.SearchIsbn(txt_isbn.Text);
                DrawBookResults(d);
            }
            else if (txt_author.Text.Length > 0)
            {
                BibliotechDAL bd = new BibliotechDAL();
                DataTable     d  = bd.SearchAuthor(txt_author.Text);
                DrawBookResults(d);
            }
            else
            {
                MessageBox.Show("Fyll i ett av sökfälten");
            }
        }
        private void btn_edituser_Click(object sender, EventArgs e) // Button edit user
        {
            int    i  = grid_results_adm.CurrentRow.Index;
            string id = grid_results_adm["UserID", i].Value.ToString(); //TODO update
            BibliotechController bc    = new BibliotechController();
            EditUserView         aForm = new EditUserView(id);

            aForm.Show();
        }
        private void btn_loan_Click(object sender, EventArgs e)   //Button loan book
        {
            int    i                = grid_results_adm.CurrentRow.Index;
            string isbn             = grid_results_adm["Isbn", i].Value.ToString();
            int    copy             = (int)grid_results_adm["CopyNbr", i].Value;
            BibliotechController bc = new BibliotechController();

            bc.LoanBook(isbn, copy, us.UserId);
            FillViewBooks();
        }
        private void btn_AddAuthor_Click(object sender, EventArgs e)
        {
            BibliotechController bc = new BibliotechController();

            bc.AddAuthor(txt_newAuthorName.Text);
            BibliotechDAL dbUser = new BibliotechDAL();
            DataTable     a      = dbUser.AllAuthors();

            cmb_authors.DataSource    = a;
            cmb_authors.DisplayMember = "AuthorName";
            cmb_authors.ValueMember   = "AuthorID";
        }
        private void btn_AddBook_Click(object sender, EventArgs e)
        {
            BibliotechController bc = new BibliotechController();

            if (txt_addtitle.Text != "" && txt_addisbn.Text != "")
            {
                bc.AddBook(txt_addtitle.Text, Convert.ToInt32(cmb_authors.SelectedValue.ToString()), txt_addisbn.Text);
            }
            else
            {
                MessageBox.Show("Fyll i ISBN och boktitel");
            }
        }
Esempio n. 6
0
        public EditUserView(string id)
        {
            InitializeComponent();
            thisUser = id;
            BibliotechController bc = new BibliotechController();
            User u = bc.UserInfo(id);

            txt_editfname.Text = u.UserFirstName;
            txt_editlname.Text = u.UserLastName;
            txt_editdebt.Text  = u.Debt.ToString();
            txt_editpw.Text    = u.UserPassword;
            cmb_admin.Text     = u.Admin;
        }
        private void btn_userloan_Click(object sender, EventArgs e)
        {
            int    i                = grid_results.CurrentRow.Index;
            string isbn             = grid_results["Isbn", i].Value.ToString();
            int    copy             = (int)grid_results["CopyNbr", i].Value;
            BibliotechController bc = new BibliotechController();
            BibliotechDAL        bd = new BibliotechDAL();
            int s = bd.CheckAvailability(isbn, copy);

            if (s == 1)
            {
                MessageBox.Show("Boken är utlånad");
            }
            else
            {
                bc.LoanBook(isbn, copy, us.UserId);
                ShowLoans();
            }
        }
 private void btn_Login_Click(object sender, EventArgs e)
 {
     if (txt_UserName.Text == "" || txt_Password.Text == "")
     {
         MessageBox.Show("Skriv in både användarnamn och lösenord");
         return;
     }
     try
     {
         BibliotechController bc = new BibliotechController();
         User u = bc.DoLogin(txt_UserName.Text, txt_Password.Text);
         if (u != null)
         {
             if (u.UserPassword == txt_Password.Text)
             {
                 if (u.Admin == "TRUE")
                 {
                     BibliotechAdminView aForm = new BibliotechAdminView(txt_UserName.Text);
                     aForm.Show();
                     this.Hide();
                 }
                 else
                 {
                     BibliotechCustView fm = new BibliotechCustView(txt_UserName.Text);
                     fm.Show();
                     this.Hide();
                 }
             }
             else
             {
                 MessageBox.Show("Fel personnummer eller lösenord");
             }
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
        private void btn_register_Click(object sender, EventArgs e) // Click add user
        {
            BibliotechController bc = new BibliotechController();

            bc.AddUser(txt_pnr.Text, txt_fname.Text, txt_lname.Text, txt_pword.Text, box_admin.Text.ToString());
        }