Example #1
0
        private void bookMenuView_Click(object sender, EventArgs e)
        {
            var f = new BookForm(1);

            foreach (Control c in f.tabControl.Controls)
            {
                c.Enabled = false;
            }

            using (context = new LibContext(LibConnection.GetConnString()))
            {
                DataGridViewRow selectedRow = viewBooks.SelectedRows[0];
                int             value       = (int)selectedRow.Cells[4].Value;
                f.book = context.books.Where(b => b.bID == value).First();

                f.authors = from a in context.authors

                            where a.bID == value

                            where a.bID == (int)selectedRow.Cells[4].Value

                            select a;
                f.fillForm();
            }
            f.FormClosed += new FormClosedEventHandler(BookForm_Closed);
            f.Show();
        }
Example #2
0
 private void btnAllLang_Click(object sender, EventArgs e)
 {
     using (context = new LibContext(LibConnection.GetConnString()))
     {
         var langs = context.langs.Select(l => new { Code = l.code, Name = l.name });
         viewBooks.DataSource = langs;
     }
 }
Example #3
0
        private void menuItemDeleteLang_Click(object sender, EventArgs e)
        {
            using (context = new LibContext(LibConnection.GetConnString()))
            {
                var lang = context.langs.Where(l => l.code == viewBooks.SelectedRows[0].Cells[0].Value.ToString().Trim()).First();

                context.langs.DeleteOnSubmit(lang);
                context.SubmitChanges();
            }
            btnAllLang_Click(sender, e);
        }
Example #4
0
        public MainForm()
        {
            InitializeComponent();
            using (context = new LibContext(LibConnection.GetConnString()))
            {
                Random rand = new Random();

                int temp  = rand.Next() % 10 + 1;
                var quote = from b in context.quotes_
                            where b.QID == temp
                            select b.quote;
                string a = quote.FirstOrDefault();
                label1.Text = a;
            }
        }
Example #5
0
 private void btnAllReaders_Click(object sender, EventArgs e)
 {
     using (context = new LibContext(LibConnection.GetConnString()))
     {
         var tabe = context.readers_.Select(c => new
         {
             Name          = c.name,
             Middle_Name   = c.middleName,
             Surname       = c.surname,
             PassportSeria = c.passport,
             OpenDate      = c.openDate,
             CloseDate     = c.closeDate
         }).Distinct();
         viewBooks.DataSource        = tabe;
         viewBooks.RowHeadersVisible = false;
     }
 }