Beispiel #1
0
        private void Libextendbook_Load(object sender, EventArgs e)
        {
            context = new LibrarySevenAEntities();
            List <BookTransaction> lbt = new List <BookTransaction>();

            try
            {
                lbt = context.BookTransactions.Where(x => x.MemberID == memberID).ToList();
                if (lbt.Count > 0)
                {
                    List <object> lbtd = new List <object>();
                    for (int i = 0; i < lbt.Count; i++)
                    {
                        int temp = Convert.ToInt32(lbt[i].TransactionID.ToString());
                        var q    = from x in context.BookTransDetails
                                   where x.TransactionID == temp && x.RentalStatus == false
                                   select new { x.TransactionID, x.BookID, x.book.BookTitle, x.DateDue };
                        if (q.ToList().Count > 0)
                        {
                            object bktd = q.ToList().First();
                            lbtd.Add(bktd);
                        }
                    }
                    dataGridView1.DataSource = lbtd;
                    this.dataGridView1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
                }
            }
            catch (InvalidOperationException)
            {
                MessageBox.Show("No previous transaction found!");
            }
        }
Beispiel #2
0
        private void MainForm_Load(object sender, EventArgs e)
        {
            LibrarySevenAEntities context = new LibrarySevenAEntities();
            Employee emp = context.Employees.Where(x => x.EmployeeID == temp1.empid).ToList().First();
            string   str = emp.EmployeeName.ToString();

            label1.Text = "Welcome! " + str;
        }
        private void ShowDitailButton_Click(object sender, EventArgs e)
        {
            context = new LibrarySevenAEntities();
            int TrID = Convert.ToInt32(dataGridView1.CurrentRow.Cells[0].Value.ToString());
            var q    = context.BookTransDetails.Where(x => x.TransactionID == TrID);

            dataGridView2.DataSource         = q.ToList();
            dataGridView2.Columns[5].Visible = false;
            dataGridView2.Columns[6].Visible = false;
        }
Beispiel #4
0
        private void ExtendButton_Click(object sender, EventArgs e)
        {
            DateTime datedue = Convert.ToDateTime(dataGridView1.CurrentRow.Cells[3].Value.ToString());
            int      TrID    = Convert.ToInt32(dataGridView1.CurrentRow.Cells[0].Value.ToString());
            int      BID     = Convert.ToInt32(dataGridView1.CurrentRow.Cells[1].Value.ToString());

            context = new LibrarySevenAEntities();
            var             QBT = context.BookTransactions.Where(x => x.TransactionID == TrID);
            BookTransaction bk  = QBT.First();

            if (bk.OriginalDateDue == datedue)
            {
                var             QBTD = context.BookTransDetails.Where(x => x.TransactionID == TrID && x.BookID == BID);
                BookTransDetail btd  = QBTD.First();
                btd.DateDue = datedue.AddDays(21);
                context.SaveChanges();
                //refresh
                context = new LibrarySevenAEntities();
                List <BookTransaction> lbt = new List <BookTransaction>();
                lbt = context.BookTransactions.Where(x => x.MemberID == memberID).ToList();
                if (lbt.Count > 0)
                {
                    List <object> lbtd = new List <object>();

                    for (int i = 0; i < lbt.Count; i++)
                    {
                        int temp = Convert.ToInt32(lbt[i].TransactionID.ToString());
                        var q    = from x in context.BookTransDetails
                                   where x.TransactionID == temp && x.RentalStatus == false
                                   select new { x.TransactionID, x.BookID, x.book.BookTitle, x.DateDue };
                        if (q.ToList().Count > 0)
                        {
                            object bktd = q.ToList().First();
                            lbtd.Add(bktd);
                        }
                    }
                    dataGridView1.DataSource = lbtd;
                    this.dataGridView1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
                }
            }
            else
            {
                MessageBox.Show("Unable to extend, this book has previously been extended");
            }
        }
Beispiel #5
0
 private void EditDetailsForm_Load(object sender, EventArgs e)
 {
     this.WindowState = FormWindowState.Maximized;
     context          = new LibrarySevenAEntities();
     m                = context.Members.Where(x => x.MemberID == A.ID).ToList().First();
     ID.Text          = m.MemberID.ToString();
     Name1.Text       = m.MemberName;
     Type.Text        = m.MemberType;
     Gender.Text      = m.Gender;
     Age.Text         = m.Age.ToString();
     Address.Text     = m.Address;
     Country.Text     = m.Country;
     Postalcode.Text  = m.PostalCode;
     ContactNum.Text  = m.ContactNumber;
     cBTitle.Text     = m.ContactTitle;
     EmaiAddress.Text = m.EmailAddress;
     Remark.Text      = m.Remarks;
 }
Beispiel #6
0
        private void Login_Click(object sender, EventArgs e)
        {
            LibrarySevenAEntities context = new LibrarySevenAEntities();

            try
            {
                var s = Convert.ToInt16(MemberIDTextBox.Text);
                if (context.Employees.Where(x => x.EmployeeID == s).ToList().Count > 0)
                {
                    Employee m = context.Employees.Where(x => x.EmployeeID == s).ToList().First();
                    if (m.EmployeePassword == MemberPasswordTextBox.Text)
                    {
                        temp1.empid = s;
                        MainForm f = new MainForm();
                        f.Show();
                        MemberIDTextBox.Text       = "";
                        MemberPasswordTextBox.Text = "";
                        this.Hide();
                    }
                    else
                    {
                        lblPasswordError.Text = "Incorrect Password/ User ID";
                    }
                }
                else
                {
                    MessageBox.Show("User ID is incorrect!");
                }
            }
            catch (OverflowException)
            {
                lblError.Text = "User ID is a 4 digit number";
            }
            catch (FormatException)
            {
                lblError.Text = "User ID is numerical";
            }
        }
Beispiel #7
0
        private void Login_Click(object sender, EventArgs e)
        {
            LibrarySevenAEntities context = new LibrarySevenAEntities();

            try
            {
                var s = Convert.ToInt16(MemberIDTextBox.Text);
                if (context.Members.Where(x => x.MemberID == s).ToList().Count > 0)
                {
                    Member m = context.Members.Where(x => x.MemberID == s).ToList().First();
                    if (m.Password == MemberPasswordTextBox.Text)
                    {
                        A.ID = s;
                        CustomerInterfaceForm CIF = new CustomerInterfaceForm();
                        CIF.Show();
                        MemberIDTextBox.Text       = "";
                        MemberPasswordTextBox.Text = "";
                    }
                    else
                    {
                        lblPasswordError.Text = "Incorrect Password/ User ID";
                    }
                }
                else
                {
                    MessageBox.Show("UserID is incorrect!");
                }
            }
            catch (OverflowException)
            {
                lblError.Text = "User ID is a 4 digit number";
            }catch (FormatException)
            {
                lblError.Text = "User ID is numerical";
            }
        }
 private void SearchButton_Click(object sender, EventArgs e)
 {
     try
     {
         context = new LibrarySevenAEntities();
         if (TransactionIDTextBox.Text != "")
         {
             int j = Convert.ToInt32(TransactionIDTextBox.Text);
             var q = context.BookTransactions.Where(x => x.TransactionID == j);
             dataGridView1.DataSource               = q.ToList();
             dataGridView1.Columns[4].Visible       = false;
             dataGridView1.Columns[5].Visible       = false;
             this.dataGridView1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
         }
         else
         {
             if (BookIDTextBox.Text == "")
             {
                 if (MemberIDTextBox.Text == "")
                 {
                     var q = context.BookTransactions;
                     dataGridView1.DataSource               = q.ToList();
                     dataGridView1.Columns[4].Visible       = false;
                     dataGridView1.Columns[5].Visible       = false;
                     this.dataGridView1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
                 }
                 else if (MemberIDTextBox.Text != "")
                 {
                     short j = Convert.ToInt16(MemberIDTextBox.Text);
                     var   q = context.BookTransactions.Where(x => x.MemberID == j);
                     dataGridView1.DataSource               = q.ToList();
                     dataGridView1.Columns[4].Visible       = false;
                     dataGridView1.Columns[5].Visible       = false;
                     this.dataGridView1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
                 }
             }
             else
             {
                 List <BookTransDetail> LBTD = new List <BookTransDetail>();
                 int w = Convert.ToInt32(BookIDTextBox.Text);
                 LBTD = context.BookTransDetails.Where(x => x.BookID == w).ToList();
                 if (LBTD.Count > 0)
                 {
                     List <BookTransaction> LBKT = new List <BookTransaction>();
                     if (MemberIDTextBox.Text == "")
                     {
                         for (int i = 0; i < LBTD.Count; i++)
                         {
                             int             temp = Convert.ToInt32(LBTD[i].TransactionID.ToString());
                             var             q    = context.BookTransactions.Where(x => x.TransactionID == temp);
                             BookTransaction bkt  = q.ToList().First();
                             LBKT.Add(bkt);
                         }
                     }
                     else
                     {
                         for (int i = 0; i < LBTD.Count; i++)
                         {
                             int temp = Convert.ToInt32(LBTD[i].TransactionID.ToString());
                             int j    = Convert.ToInt16(MemberIDTextBox.Text);
                             var q    = context.BookTransactions.Where(x => x.TransactionID == temp &&
                                                                       x.MemberID == j);
                             if (q.ToList().Count > 0)
                             {
                                 BookTransaction bkt = q.ToList().First();
                                 LBKT.Add(bkt);
                             }
                         }
                     }
                     dataGridView1.DataSource               = LBKT;
                     dataGridView1.Columns[4].Visible       = false;
                     dataGridView1.Columns[5].Visible       = false;
                     this.dataGridView1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
                 }
             }
         }
     }
     catch (Exception ex)
     {
         if (ex is FormatException || ex is InvalidOperationException)
         {
             lblInputError.Text = "Incorrect Input, please check your search values";
             return;
         }
     }
 }