private void btnDel_Click(object sender, EventArgs e)
        {
            string       qq2    = mtextUID.Text.TrimStart(new Char[] { '0' });
            DialogResult result = MessageBox.Show("Confirm Delete?", "Warning!", MessageBoxButtons.YesNo);

            if (result == DialogResult.Yes)
            {
                SA45TEAM01ALibraryEntities context = new SA45TEAM01ALibraryEntities();
                User a = context.Users.Where(x => x.User_ID.ToString() == qq2).FirstOrDefault();

                using (TransactionScope ts = new TransactionScope())
                {
                    a.Status = "Inactive";
                    context.SaveChanges();
                    ts.Complete();
                }

                btnSearch.Visible          = true;
                mtextUID.Text              = String.Empty;
                mtextUID.BackColor         = System.Drawing.SystemColors.Window;
                mtextUID.ReadOnly          = false;
                lblName.Visible            = false;
                lblEmail.Visible           = false;
                lblPN.Visible              = false;
                txtName.Visible            = false;
                txtEmail.Visible           = false;
                mtextPN.Visible            = false;
                btnDel.Visible             = false;
                btnClear.Visible           = false;
                toolStripStatusLabel1.Text = "Input User_ID and click Search";

                Messages A = new Messages();
                A.SaveMessage();
            }
        }
Esempio n. 2
0
        private void Save_Click(object sender, EventArgs e)
        {
            newAuthor = txtAuthor.Text;
            newTitle  = txtAuthor.Text;
            newYP     = Convert.ToInt32(cmbYear.SelectedText);
            newGenre  = txtGenre.Text;
            newLG     = txtLanguage.Text;
            newISBN   = txbISBN.Text;

            int a = int.Parse(mtxtBID.Text);
            SA45TEAM01ALibraryEntities d = new SA45TEAM01ALibraryEntities();
            booklist b = d.booklists.Where(x => x.Book_ID == a).First();

            if ((b.Author != newAuthor) || (b.Title != newTitle) || (b.Year_of_Publication != newYP) || (b.Category != newGenre) || (b.Language != newLG) || (b.ISBN != newISBN))
            {
                b.Author = newAuthor;
                b.Title  = newTitle;
                b.Year_of_Publication = newYP;
                b.Category            = newGenre;
                b.Language            = newLG;
                b.ISBN = newISBN;
                d.SaveChanges();

                Messages A = new Messages();
                A.SaveMessage();
            }
            else
            {
                MessageBox.Show("Please make edits in order to Save or click Cancel to Return to Books Menu");
            }
        }
Esempio n. 3
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (txtTitle.Text.Length < 1 && ((txtEmail.Text.Length < 5) || (mtxtMN.Text.Length < 8)))
            {
                MessageBox.Show("Requires at least a valid name and contact");
            }
            else
            {
                SA45TEAM01ALibraryEntities context = new SA45TEAM01ALibraryEntities();
                User newUser = new User();
                using (TransactionScope ts = new TransactionScope())
                {
                    newUser.Name     = txtTitle.Text;
                    newUser.Email    = txtEmail.Text;
                    newUser.Phone_no = int.Parse(mtxtMN.Text);
                    newUser.Category = cmbMemType.Text;

                    context.Users.Add(newUser);
                    context.SaveChanges();
                    ts.Complete();
                }

                Messages A = new Messages();
                A.SaveMessage();
                txtTitle.Clear();
                txtEmail.Clear();
                mtxtMN.Clear();
            }
        }
Esempio n. 4
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            if (getSInputs() > 0)
            {
                using (TransactionScope ts = new TransactionScope())
                {
                    SA45TEAM01ALibraryEntities c = new SA45TEAM01ALibraryEntities();
                    booklist a = new booklist();
                    a.ISBN                = txtTitle.Text.ToString();
                    a.Title               = txtTitle.Text.ToString();
                    a.Language            = txtLanguage.Text.ToString();
                    a.Category            = txtGenre.Text.ToString();
                    a.Author              = txtAuthor.Text.ToString();
                    a.Year_of_Publication = Convert.ToInt32(cmbYear.SelectedText);//Convert.ToInt32(cmbYear.Text);
                    c.booklists.Add(a);
                    c.SaveChanges();
                    ts.Complete();
                }

                Messages A = new Messages();
                A.SaveMessage();
            }
            else
            {
                MessageBox.Show("Please Add in Relevant info before Adding new Books");
            }
        }
Esempio n. 5
0
        private void btnSubmit_Click(object sender, EventArgs e)
        {
            int rV = 0;

            foreach (DataGridViewRow dg in dataGridView1.Rows)
            {
                if (Convert.ToBoolean(dg.Cells[0].Value) == true)
                {
                    rV++;
                }
            }
            if (rV > 0 && (txtName.Text.Length > 0))
            {
                DialogResult result = new DialogResult();
                result = MessageBox.Show("Proceed with borrowing?", "Borrowing books", MessageBoxButtons.YesNo);

                if (result == DialogResult.Yes)
                {
                    SA45TEAM01ALibraryEntities context = new SA45TEAM01ALibraryEntities();

                    using (TransactionScope ts = new TransactionScope())
                    {
                        foreach (DataGridViewRow dgRow in dataGridView1.Rows)
                        {
                            if (dgRow.Cells[0].Value != null)
                            {
                                int selected1  = Convert.ToInt32(dgRow.Cells[3].Value.ToString());
                                int newIssueID = context.Issue_Details.Select(x => x.Issue_ID).Max() + 1;

                                Issue_Details id = new Issue_Details();
                                id.Issue_ID      = newIssueID;
                                id.Issue_Date    = DateTime.Today.ToString();
                                id.Due_Date      = DateTime.Today.AddDays(20).ToString();
                                id.Book_ID       = selected1;
                                id.User_ID       = Convert.ToInt32(txtID.Text.ToString());
                                id.Rental_Status = "OUT";
                                id.Return_Date   = null;

                                context.Issue_Details.Add(id);
                                string uid = txtID.Text;
                                User   m   = context.Users.Where(x => x.User_ID.ToString() == uid).First();
                                m.Book_due++;
                                context.SaveChanges();
                            }
                        }
                        ts.Complete();
                    }
                    FormBorrow();
                }
            }
            else if (rV > 0)
            {
                MessageBox.Show("Please input a valid user id");
            }
            else
            {
                MessageBox.Show("Please select checkboxes for books to borrow");
            }
        }
        private void btnReceive_Click(object sender, EventArgs e)
        {
            bool isBlank = true;

            foreach (DataGridViewRow dgRow in dataGridView1.Rows)
            {
                DataGridViewCheckBoxCell CbxCell = (DataGridViewCheckBoxCell)dgRow.Cells[0];
                if (Convert.ToBoolean(CbxCell.Value) == false)
                {
                    isBlank = true;
                }
                else
                {
                    isBlank = false; break;
                }
            }

            if (isBlank == true)
            {
                MessageBox.Show("Select books first");
            }
            else
            {
                DialogResult result = new DialogResult();
                result = MessageBox.Show("Are Books received?", "Receiving Books", MessageBoxButtons.YesNo);
                if (result == DialogResult.Yes)
                {
                    foreach (DataGridViewRow dgRow1 in dataGridView1.Rows)
                    {
                        if (Convert.ToBoolean(dgRow1.Cells[0].Value))
                        {
                            using (TransactionScope ts = new TransactionScope())
                            {
                                string sID = dgRow1.Cells[1].Value.ToString();
                                string uID = dgRow1.Cells[4].Value.ToString();

                                Issue_Details id = context.Issue_Details.Where(x => x.Issue_ID.ToString() == sID && x.User_ID.ToString() == uID).First();
                                id.Rental_Status = "IN";
                                id.Return_Date   = DateTime.Today.ToString();

                                User u = context.Users.Where(x => x.User_ID.ToString() == uID).First();
                                u.Book_due--;

                                context.SaveChanges();
                                ts.Complete();
                            }
                        }

                        toolStripStatusLabel2.Text = "Changes Updated.";
                    }
                }
                else
                {
                    FormRefresh();
                }
            }
        }
        private void btnDelete_Click(object sender, EventArgs e)
        {
            //SA45TEAM01ALibraryEntities d = new SA45TEAM01ALibraryEntities();

            //int a = int.Parse(Book_ID);
            //booklist b = d.booklists.Where(x => x.Book_ID == a).First();
            //b.Disposed = "Yes";
            //d.SaveChanges();
            //MessageBox.Show("Deleted Successfully");

            int rV = 0;

            foreach (DataGridViewRow dg in dataGridView1.Rows)
            {
                if (Convert.ToBoolean(dg.Cells[0].Value) == true)
                {
                    rV++;
                }
            }
            if (rV > 0)
            {
                DialogResult dr = MessageBox.Show("Confirm Deletion for these row(s)?", "Warning!", MessageBoxButtons.YesNo);
                if (dr == DialogResult.Yes)
                {
                    SA45TEAM01ALibraryEntities context = new SA45TEAM01ALibraryEntities();
                    foreach (DataGridViewRow dg in dataGridView1.Rows)
                    {
                        if (Convert.ToBoolean(dg.Cells[0].Value) == true)
                        {
                            int      x2 = Convert.ToInt32(dg.Cells[3].Value);
                            var      q  = context.booklists.Where(x => x.Book_ID == x2).FirstOrDefault();
                            booklist A  = q;
                            using (TransactionScope ts = new TransactionScope())
                            {
                                q.Disposed = "Yes";
                                context.SaveChanges();
                                ts.Complete();
                            }
                        }
                    }
                    Messages newM = new Messages();
                    newM.SaveMessage();
                    newDataPlease();
                }
            }
            else
            {
                MessageBox.Show("Please select checkbox(es) to delete first");
            }
        }
        private void btnDelete_Click(object sender, EventArgs e)
        {
            int rV = 0;

            foreach (DataGridViewRow dg in dataGridView1.Rows)
            {
                if (Convert.ToBoolean(dg.Cells[0].Value) == true)
                {
                    rV++;
                }
            }
            if (rV > 0)
            {
                DialogResult dr = MessageBox.Show("Confirm Deletion for these row(s)?", "Warning!", MessageBoxButtons.YesNo);
                if (dr == DialogResult.Yes)
                {
                    SA45TEAM01ALibraryEntities context = new SA45TEAM01ALibraryEntities();
                    foreach (DataGridViewRow dg in dataGridView1.Rows)
                    {
                        if (Convert.ToBoolean(dg.Cells[0].Value) == true)
                        {
                            int  x2 = Convert.ToInt32(dg.Cells[1].Value);
                            var  q  = context.Users.Where(x => x.User_ID == x2).FirstOrDefault();
                            User A  = q;
                            using (TransactionScope ts = new TransactionScope())
                            {
                                q.Status = "Inactive";
                                context.SaveChanges();
                                ts.Complete();
                            }
                        }
                    }
                    Messages newM = new Messages();
                    newM.SaveMessage();
                    btnRefresh_click();
                }
            }
            else
            {
                this.Hide();
                var newDMForm = new DeleteMember();
                newDMForm.Closed += (s, args) => this.Close();
                newDMForm.Show();
            }
        }
Esempio n. 9
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            string qq2 = mtextUID.Text.TrimStart(new Char[] { '0' });

            if (txtName.Text.Length < 1)
            {
                MessageBox.Show("Please Enter a valid name");
            }
            else
            {
                SA45TEAM01ALibraryEntities context = new SA45TEAM01ALibraryEntities();
                User a = context.Users.Where(x => x.User_ID.ToString() == qq2).FirstOrDefault();
                newName  = txtName.Text;
                newEmail = txtEmail.Text;
                newCat   = cboxCat.Text;
                newPN    = Convert.ToInt32(mtextPN.Text);
                string q  = context.Users.Where(x => x.User_ID.ToString() == qq2).Select(x => x.Name).First();
                string q1 = context.Users.Where(x => x.User_ID.ToString() == qq2).Select(x => x.Email).First();
                int?   q2 = context.Users.Where(x => x.User_ID.ToString() == qq2).Select(x => x.Phone_no).First();
                string q3 = context.Users.Where(x => x.User_ID.ToString() == qq2).Select(x => x.Category).First();

                using (TransactionScope ts = new TransactionScope())
                {
                    if (newName != q)
                    {
                        a.Name = newName;
                    }
                    if (newPN != q2)
                    {
                        a.Phone_no = newPN;
                    }
                    if (newEmail != q1)
                    {
                        a.Email = newEmail;
                    }
                    if (newCat != q3)
                    {
                        a.Category = newCat;
                    }

                    context.SaveChanges();
                    ts.Complete();
                }

                btnSearch.Visible          = true;
                mtextUID.Text              = String.Empty;
                mtextUID.BackColor         = System.Drawing.SystemColors.Window;
                mtextUID.ReadOnly          = false;
                lblName.Visible            = false;
                lblEmail.Visible           = false;
                lblPN.Visible              = false;
                lblCat.Visible             = false;
                txtName.Visible            = false;
                txtEmail.Visible           = false;
                mtextPN.Visible            = false;
                cboxCat.Visible            = false;
                btnSave.Visible            = false;
                btnClear.Visible           = false;
                toolStripStatusLabel1.Text = "Input User_ID and click Search";

                Messages A = new Messages();
                A.SaveMessage();
            }
        }