Пример #1
0
        private void updateButton_Click(object sender, EventArgs e)
        {
            try
            {
                libraryDataContext ld = new libraryDataContext(@"Data Source=(LocalDB)\v11.0;AttachDbFilename=F:\C# project\LibraryManagementSystem\LibraryManagementSystem\library.mdf;Integrated Security=True;Connect Timeout=30");
                var t = from s in ld.Informations
                        where s.Id == Convert.ToInt32(idTF.Text)
                        select s;

                //libraryDataContext le = new libraryDataContext(@"Data Source=(LocalDB)\v11.0;AttachDbFilename=F:\C# project\LibraryManagementSystem\Library management software(final)\Library management software\Library management software\datatable.mdf;Integrated Security=True;Connect Timeout=30");
                //var zz = from q in le.Borrows
                //         where q.userId == idTF.Text
                //         select q;

                t.First().Name = nameTF.Text;
                //zz.First().name = nameTF.Text;
                t.First().Address  = addTF.Text;
                t.First().Email    = emailTF.Text;
                t.First().MobileNo = phoneTF.Text;
                t.First().Gender   = genderTF.Text;
                ld.SubmitChanges();
                //le.SubmitChanges();
                dataGridView8.DataSource = t.ToList();
            }
            catch (Exception)
            {
                MessageBox.Show("Please Enter ID");
            }
        }
Пример #2
0
        private void addButton_Click(object sender, EventArgs e)
        {
            try
            {
                libraryDataContext lb = new libraryDataContext(@"Data Source=(LocalDB)\v11.0;AttachDbFilename=F:\C# project\LibraryManagementSystem\Library management software(final)\Library management software\Library management software\datatable.mdf;Integrated Security=True;Connect Timeout=30");
                Table t = new Table();
                //string tid = bookIdText.Text;
                //string tname = bookNameText.Text;
                //string tauthore = bookAuthoreTF.Text;
                //string type = btTf.Text;
                //string tcopy = cpyTF.Text;
                if (bookIdText.Text == "" || bookNameText.Text == "" || bookAuthoreTF.Text == "" || btTf.Text == "" || cpyTF.Text == "")
                {
                    MessageBox.Show("Please Check The Fields");
                }
                else
                {
                    t.bookId     = bookIdText.Text;
                    t.bookName   = bookNameText.Text;
                    t.authorName = bookAuthoreTF.Text;
                    t.bookType   = btTf.Text;
                    t.bookCopy   = cpyTF.Text;
                    lb.Tables.InsertOnSubmit(t);
                    lb.SubmitChanges();

                    dataGridView6.DataSource = lb.Tables;
                    MessageBox.Show("Book Added Successfully");
                }
            }
            catch (Exception)
            {
                MessageBox.Show("Please CHeck The Fields Again");
            }
        }
Пример #3
0
        private void deleteUButton_Click(object sender, EventArgs e)
        {
            try
            {
                libraryDataContext lb = new libraryDataContext(@"Data Source=(LocalDB)\v11.0;AttachDbFilename=F:\C# project\LibraryManagementSystem\LibraryManagementSystem\library.mdf;Integrated Security=True;Connect Timeout=30");
                var x = from a in lb.Informations
                        where a.Id == Convert.ToInt32(textBox1.Text)
                        select a;
                if (x.Any())
                {
                    foreach (Information p in x)
                    {
                        lb.Informations.DeleteOnSubmit(p);
                    }

                    lb.SubmitChanges();
                    MessageBox.Show("Member Deleted");
                    //libraryDataContext lb = new libraryDataContext(@"Data Source=(LocalDB)\v11.0;AttachDbFilename=F:\C# project\LibraryManagementSystem\LibraryManagementSystem\library.mdf;Integrated Security=True;Connect Timeout=30");
                    dataGridView3.DataSource = lb.Informations;
                }
                else
                {
                    MessageBox.Show("Fill up the id first");
                }
            }
            catch (Exception)
            {
                MessageBox.Show("Fill Up the id first");
            }
        }
Пример #4
0
        private void button3_Click(object sender, EventArgs e)
        {
            libraryDataContext lr = new libraryDataContext(@"Data Source=(LocalDB)\v11.0;AttachDbFilename=F:\C# project\LibraryManagementSystem\Library management software(final)\Library management software\Library management software\datatable.mdf;Integrated Security=True;Connect Timeout=30");
            var x = from a in lr.Tables
                    where a.bookId == textBox3.Text
                    select a;
            int g = Convert.ToInt32(x.FirstOrDefault().bookCopy);

            g += 1;
            x.First().bookCopy = Convert.ToString(g);
            lr.SubmitChanges();
            var v = from f in lr.Borrows
                    where f.userId == textBox2.Text
                    select f;

            foreach (Borrow oo in v)
            {
                lr.Borrows.DeleteOnSubmit(oo);
            }

            lr.SubmitChanges();
            //UpdateGridView();
        }
Пример #5
0
        // insert data of borrower for admin to monitor the borrowe return the book or not
        private void InsertBorrowerInfoToDatabase()
        {
            borrowD = borrowDate.Value.ToString("dd-mm-yyyy");
            returnD = returnDate.Value.ToString("dd-mm-yyyy");

            libraryDataContext borrowBook = new libraryDataContext(@"Data Source=(LocalDB)\v11.0;AttachDbFilename=F:\C# project\LibraryManagementSystem\Library management software(final)\Library management software\Library management software\datatable.mdf;Integrated Security=True;Connect Timeout=30");
            Borrow             borrowInfo = new Borrow
            {
                name       = getNameLbl.Text,
                userId     = getUserIdLbl.Text,
                bookId     = BookIdTF.Text,
                borrowDate = borrowD,
                returnDate = returnD,
                totalDays  = dateDiffTF.Text
            };

            //borrowInfo.BookBorrowInfos.InsertOnSubmit();
            borrowBook.Borrows.InsertOnSubmit(borrowInfo);
            borrowBook.SubmitChanges();
        }
Пример #6
0
 private void uupdateButton_Click(object sender, EventArgs e)
 {
     try
     {
         libraryDataContext ll = new libraryDataContext(@"Data Source=(LocalDB)\v11.0;AttachDbFilename=F:\C# project\LibraryManagementSystem\Library management software(final)\Library management software\Library management software\datatable.mdf;Integrated Security=True;Connect Timeout=30");
         var f = from l in ll.Tables
                 where l.bookId == bidTF.Text
                 select l;
         int x = Convert.ToInt32(f.FirstOrDefault().bookCopy);
         x += Convert.ToInt32(cpTF.Text);
         f.First().bookCopy = Convert.ToString(x);
         ll.SubmitChanges();
         MessageBox.Show("Book Copy Added Successfully");
         dataGridView2.DataSource = f.ToList();
         cpTF.Text  = "";
         bidTF.Text = "";
     }
     catch (Exception)
     {
         MessageBox.Show("Check ID");
     }
 }
Пример #7
0
        private void button2_Click(object sender, EventArgs e)
        {
            libraryDataContext lb = new libraryDataContext(@"Data Source=(LocalDB)\v11.0;AttachDbFilename=F:\C# project\LibraryManagementSystem\Library management software(final)\Library management software\Library management software\datatable.mdf;Integrated Security=True;Connect Timeout=30");
            var x = from a in lb.Tables
                    where a.bookId == delBookIdTF.Text
                    select a;

            if (x.Any())
            {
                foreach (Table p in x)
                {
                    lb.Tables.DeleteOnSubmit(p);
                }

                lb.SubmitChanges();
                MessageBox.Show("Book Deleted");
                UpdateGridView();
            }
            else
            {
                MessageBox.Show("Fill up the id first");
            }
        }
Пример #8
0
        private void btnSend_Click(object sender, EventArgs e)
        {
            try
            {
                if (ReportTF.Text != "")
                {
                    libraryDataContext dc = new libraryDataContext(@"Data Source=(LocalDB)\v11.0;AttachDbFilename=F:\C# project\LibraryManagementSystem\Library management software(final)\Library management software\Library management software\datatable.mdf;Integrated Security=True;Connect Timeout=30");
                    Review             r  = new Review();
                    r.Id  = Convert.ToInt32(userTF.Text);
                    r.Rev = ReportTF.Text;
                    dc.Reviews.InsertOnSubmit(r);
                    dc.SubmitChanges();


                    ReportTF.Enabled = false;

                    //userTF.Text = userId;

                    //string getMessage = ReportTF.Text;
                    userTF.Text   = "";
                    ReportTF.Text = "";

                    //getMess.Text = getMessage;
                    btnSend.Enabled = false;
                    MessageBox.Show("Message sent successfully");
                }
                else
                {
                    MessageBox.Show("Message sent failed");
                }
            }
            catch (Exception)
            {
                MessageBox.Show("You are already give your review ");
            }
        }
Пример #9
0
        //confirm button
        private void btnConfirm_Click(object sender, EventArgs e)
        {
            //count++;
            //try
            //{
            //    int totalBook = int.Parse(bookCopyTF.Text);
            //    int totalCopy = 0;
            //    totalCopy = totalBook;

            //    if (totalCopy <= 0)
            //    {
            //        MessageBox.Show("Book is not avaliable");
            //    }
            //    else
            //    {
            //        //update
            //        bookCopyTF.Text = totalCopy.ToString();
            //        libraryDataContext update = new libraryDataContext(@"Data Source=(LocalDB)\v11.0;AttachDbFilename=F:\C# project\LibraryManagementSystem\Library management software(final)\Library management software\Library management software\datatable.mdf;Integrated Security=True;Connect Timeout=30");

            //        var x = from a in update.Tables
            //                where a.bookId == BookIdTF.Text
            //                select a;

            //        x.First().bookId = BookIdTF.Text;
            //        x.First().bookName = bookNameTF.Text;
            //        x.First().authorName = authorNameTF.Text;
            //        x.First().bookType = bookTypeTF.Text;
            //        x.First().bookCopy = bookCopyTF.Text;

            //        update.SubmitChanges();
            //        dataGridView1.DataSource = x.ToList();



            //        int days = int.Parse(dateDiffTF.Text);
            //        //days = days +1;
            //        dateDiffTF.Text = days.ToString();

            //        if (day > 7 || day <= 0)
            //        {//|| count == 2 || userName == getNameLbl.Text
            //            totalCopy = totalCopy - 1;
            //            MessageBox.Show("sorry ... order can't be processed");

            //        }
            //        else
            //        {
            //            if (searchTF.Text == "" || BookIdTF.Text == "" || bookNameTF.Text == "" || bookTypeTF.Text == "" || bookCopyTF.Text == "")
            //            {
            //                MessageBox.Show(" Sorry your request is Not confirmed yet :)");

            //            }
            //            else
            //            {

            //                    MessageBox.Show("Welcome sir you borrowed this book for  " + dateDiffTF.Text + "  days");
            //                    InsertBorrowerInfoToDatabase();

            //       }
            //     }
            //   }

            //}
            //catch (Exception)
            //{
            //    if (searchTF.Text == "" || BookIdTF.Text == "" || bookNameTF.Text == "" || bookTypeTF.Text == "" || bookCopyTF.Text == "")
            //    {
            //        MessageBox.Show(" Sorry your request is Not confirmed yet :)");

            //    }

            try
            {
                int totalBook = Convert.ToInt32(bookCopyTF.Text);
                if (searchTF.Text == "" || BookIdTF.Text == "" || bookNameTF.Text == "" || bookTypeTF.Text == "" || bookCopyTF.Text == "")
                {
                    MessageBox.Show(" Sorry your request is Not confirmed yet :)");
                }
                else
                {
                    if (totalBook <= 0)
                    {
                        MessageBox.Show("Book is not avaliable");
                    }
                    else if (totalBook > 0)
                    {
                        day = Convert.ToInt32(dateDiffTF.Text);
                        if (day > 7 || day <= 0)
                        {
                            MessageBox.Show("process can't be possible");
                        }

                        else
                        {
                            totalBook       = totalBook - 1;
                            bookCopyTF.Text = totalBook.ToString();
                            libraryDataContext update = new libraryDataContext(@"Data Source=(LocalDB)\v11.0;AttachDbFilename=F:\C# project\LibraryManagementSystem\Library management software(final)\Library management software\Library management software\datatable.mdf;Integrated Security=True;Connect Timeout=30");

                            var x = from a in update.Tables
                                    where a.bookId == BookIdTF.Text
                                    select a;

                            x.First().bookId     = BookIdTF.Text;
                            x.First().bookName   = bookNameTF.Text;
                            x.First().authorName = authorNameTF.Text;
                            x.First().bookType   = bookTypeTF.Text;
                            x.First().bookCopy   = bookCopyTF.Text;

                            update.SubmitChanges();
                            dataGridView1.DataSource = x.ToList();

                            MessageBox.Show("Welcome " + userId + " your confermation done");
                            InsertBorrowerInfoToDatabase();
                            btnConfirm.Enabled = false;
                        }
                    }
                }
            }
            catch (Exception) {
                MessageBox.Show("Operation not done ");
            }
        }
Пример #10
0
        private void submitButton_Click(object sender, EventArgs e)
        {
            // Check if the point entered is numeric or not
            //if ()
            //{
            //    // Do what you want to do if numeric
            //}
            //else
            //{
            //    // Do what you want to do if not numeric
            //}

            ld = new libraryDataContext(@"Data Source=(LocalDB)\v11.0;AttachDbFilename=F:\C# project\LibraryManagementSystem\LibraryManagementSystem\library.mdf;Integrated Security=True;Connect Timeout=30");
            Information i = new Information();

            //tid=Convert.ToInt32(idTextBox.Text);

            /*this.tname=nameTextBox.Text;
             * this.tpass=passwordTextBox.Text;
             * this.tmbl=mobileTextBox.Text;
             * this.tgen=gender;
             * this.tmail=emailTextBox.Text;
             * this.tut=this.table;*/
            /*if(tname.Equals(null)||tpass.Equals(null)||tmbl.Equals(null)||tgen.Equals(null)||tmail.Equals(null)||tut.Equals(null))
             * {
             *  label8.Text="Please enter all the values";
             * }*/
            if (idTextBox.Text == "" || nameTextBox.Text == "" || passwordTextBox.Text == "" || mobileTextBox.Text == "" || g == "" || emailTextBox.Text == "" || comboBox1.Text == "" || addressTf.Text == "")
            {
                label8.Text = "Please enter all the values Correctly";
            }
            else
            {
                try
                {
                    i.Id       = Convert.ToInt32(idTextBox.Text);
                    i.Name     = nameTextBox.Text;
                    i.Password = passwordTextBox.Text;
                    i.MobileNo = mobileTextBox.Text;
                    i.Gender   = this.g;
                    i.Email    = emailTextBox.Text;
                    i.Type     = this.table;
                    i.Address  = addressTf.Text;

                    if (this.table == "Admin")
                    {
                        var x = from a in ld.Informations
                                where a.Type == "Admin"
                                select a.Type;
                        //var y = from b in ld.Informations
                        //        where b.Type == "User"
                        //        select b.Type;



                        if (x.Any())
                        {
                            MessageBox.Show("Already");
                        }
                        else
                        {
                            ld.Informations.InsertOnSubmit(i);
                            ld.SubmitChanges();
                            this.Hide();
                            MessageBox.Show("Registration Successfull..");
                            Form2 f2 = new Form2();
                            f2.Show();
                        }
                    }
                    else
                    {
                        ld.Informations.InsertOnSubmit(i);
                        ld.SubmitChanges();
                        this.Hide();
                        MessageBox.Show("Registration Successfull..");
                        Form2 f2 = new Form2();
                        f2.Show();
                    }
                }

                catch (Exception)
                {
                    MessageBox.Show("Check Again");
                }
                //try
                //{
                //    i.Id = Convert.ToInt32(idTextBox.Text);
                //    i.Name = nameTextBox.Text;
                //    i.Password = passwordTextBox.Text;
                //    i.MobileNo = mobileTextBox.Text;
                //    i.Gender = this.g;
                //    i.Email = emailTextBox.Text;
                //    i.Type = this.table;
                //    i.Address = addressTf.Text;

                //    var x = from a in ld.Informations
                //            where a.Type == "Admin"
                //            select a.Type;
                //    var y = from b in ld.Informations
                //            where b.Type == "User"
                //            select b.Type;



                //        if (x != null)
                //        {


                //            ld.Informations.InsertOnSubmit(i);
                //            ld.SubmitChanges();
                //            this.Hide();
                //            MessageBox.Show("Registration Successfull..");
                //            Form2 f2 = new Form2();
                //            f2.Show();

                //        }
                //        else
                //        {
                //            if (y.Any() || y != null)
                //            {
                //                ld.Informations.InsertOnSubmit(i);
                //                ld.SubmitChanges();
                //                this.Hide();
                //                MessageBox.Show("Registration Successfull..");
                //                Form2 f2 = new Form2();
                //                f2.Show();
                //            }
                //            else
                //            {
                //                MessageBox.Show("Already");
                //            }

                //        }


                //    }



                //catch (Exception)
                //{
                //    MessageBox.Show("Please enter another id");
                //}
            }



            /*if (this.table == "Admin")
             * {
             *  ld = new libraryDataContext(@"Data Source=(LocalDB)\v11.0;AttachDbFilename=F:\C# project\LibraryManagementSystem\LibraryManagementSystem\library.mdf;Integrated Security=True;Connect Timeout=30");
             *  admin ad = new admin();
             *
             *  try
             *  {
             *      ad.aid = idTextBox.Text;
             *      ad.name = nameTextBox.Text;
             *      ad.password = passwordTextBox.Text;
             *      ad.mobileno = mobileTextBox.Text;
             *      ad.emailid = emailTextBox.Text;
             *      ad.gender = gender;
             *      ld.admins.InsertOnSubmit(ad);
             *      ld.SubmitChanges();
             *  }
             *  catch (DBConcurrencyException)
             *  {
             *      MessageBox.Show("Please Check Your Mobile No.", "Message");
             *  }
             *  catch (NullReferenceException)
             *  {
             *      MessageBox.Show("Please insert all the values", "Message");
             *  }
             *
             *  //MessageBox.Show(idTextBox.Text+nameTextBox.Text+passwordTextBox.Text+mobileTextBox.Text+emailTextBox.Text+gender);
             *
             *
             * }
             * else if (this.table == "User")
             * {
             *  ld = new libraryDataContext(@"Data Source=(LocalDB)\v11.0;AttachDbFilename=F:\C# project\LibraryManagementSystem\LibraryManagementSystem\library.mdf;Integrated Security=True;Connect Timeout=30");
             *  user us = new user();
             *  try
             *  {
             *      us.pid = idTextBox.Text;
             *      us.name = nameTextBox.Text;
             *      us.password = passwordTextBox.Text;
             *      us.mobileno = mobileTextBox.Text;
             *      us.emailid = emailTextBox.Text;
             *      us.gender = gender;
             *      ld.users.InsertOnSubmit(us);
             *      ld.SubmitChanges();
             *  }
             *  catch (DataException)
             *  {
             *      MessageBox.Show("Please Check Your Mobile No.", "Message");
             *  }
             *  catch (NullReferenceException)
             *  {
             *      MessageBox.Show("Please insert all the values", "Message");
             *  }
             *
             * }
             * else
             * {
             *  MessageBox.Show("Please insert the values");
             * }*/
        }