Exemplo n.º 1
0
        private void SaveBook_Click(object sender, EventArgs e)
        {
            Modelss.Book bok = new Modelss.Book();

            using (Modelss.KITABXANADB db = new Modelss.KITABXANADB())
            {
            }
            Modelss.Category ct = new Modelss.Category();

            string  bookN   = bookname.Text.ToString();
            string  autor   = cbAuthor.SelectedItem.ToString();
            string  pricee  = bookprice.Text.ToString();
            string  ctg     = categoryCB.SelectedItem.ToString();
            string  countt  = bookcount.Text.ToString();
            decimal dbprice = Convert.ToDecimal(bookprice.Text);

            dgvBooks.Rows.Add(bookN, autor, pricee, ctg, countt);
            bok.CategoryID = 2;
            bok.Name       = bookN;
            bok.Price      = dbprice;
            bok.Count      = Convert.ToInt32(countt);
            using (Modelss.KITABXANADB db = new Modelss.KITABXANADB())
            {
                db.Books.Add(bok);
                db.SaveChanges();
            }
        }
Exemplo n.º 2
0
        private void Order_Load(object sender, EventArgs e)
        {
            using (Modelss.KITABXANADB db = new Modelss.KITABXANADB())
            {
                List <Modelss.Author> aut = db.Authors.ToList();



                List <Modelss.Order> ord = db.Orders.ToList();

                List <Modelss.Client> cll = db.Clients.ToList();
                string ad, ad2;

                string   soyad, soyad2;
                DateTime order, returndate;
                foreach (var item in cll)
                {
                    dgvOrder.Rows.Add(item.Name);
                    ad    = db.Clients.Select(g => g.Name).ToString();
                    soyad = db.Clients.Select(g => g.Surname).ToString();
                }
                foreach (var item in aut)
                {
                    dgvOrder.Rows.Add(item.Name);
                    ad2    = db.Authors.Select(g => g.Name).ToString();
                    soyad2 = db.Authors.Select(g => g.Surname).ToString();
                }
            }
        }
Exemplo n.º 3
0
 private void Books_Load(object sender, EventArgs e)
 {
     using (Modelss.KITABXANADB db = new Modelss.KITABXANADB())
     {
         cbAuthor.DataSource   = db.Authors.Select(g => g.Name).ToList();
         categoryCB.DataSource = db.Categories.Select(g => g.Name).ToList();
     }
 }
        private void Button1_Click(object sender, EventArgs e)
        {
            using (Modelss.KITABXANADB db = new Modelss.KITABXANADB())
            {
                Modelss.Category ctgr = new Modelss.Category();

                ctgr.Name = ctgrtxt.Text;
                db.Categories.Add(ctgr);
                db.SaveChanges();
            }
            ctgDVG.Rows.Add(ctgrtxt.Text);
        }
        public void SearchBook()
        {
            string SearchKey2 = txtBook.Text.Trim().ToLower();

            using (Modelss.KITABXANADB db = new Modelss.KITABXANADB())
            {
                List <Book> findBooks = db.Books.Where(c => c.Name.ToLower().Contains(SearchKey2)).ToList();

                booksData.Rows.Clear();
                foreach (var item2 in findBooks)
                {
                    booksData.Rows.Add(item2.ID, item2.Name, item2.AuthorsBooks, item2.Price, item2.CategoryID, item2.Count);
                }
            }
        }
        public void SearchUser()
        {
            string SearchKey = clSearch.Text.Trim().ToLower();

            using (Modelss.KITABXANADB db = new Modelss.KITABXANADB())
            {
                List <Client> findClients = db.Clients.Where(c => c.Name.ToLower().Contains(SearchKey) || c.Email.ToLower().Contains(SearchKey) || c.Phone.ToLower().Contains(SearchKey) || c.Surname.ToLower().Contains(SearchKey)).ToList();

                ClientsData.Rows.Clear();
                foreach (var item in findClients)
                {
                    ClientsData.Rows.Add(item.ID, item.Name, item.Surname, item.Email, item.Phone);
                }
            }
        }
        public void refreshDataGridView1()
        {
            MessageBox.Show("salam");

            using (Modelss.KITABXANADB db = new Modelss.KITABXANADB())
            {
                booksData.Rows.Clear();
                List <Modelss.Book> books = db.Books.ToList();

                foreach (var book in books)
                {
                    booksData.Rows.Add(book.ID, book.Name, book.AuthorsBooks, book.Price, book.CategoryID, book.Count);
                }
            }
        }
        private void Button1_Click(object sender, EventArgs e)
        {
            using (Modelss.KITABXANADB db = new Modelss.KITABXANADB())
            {
                List <Modelss.Author> authorr = db.Authors.ToList();

                Modelss.Author auth = new Modelss.Author();
                auth.Name    = autname.Text;
                auth.Surname = authSurname.Text;

                db.Authors.Add(auth);
                db.SaveChanges();

                authorDVG.Rows.Add(autname.Text, authSurname.Text);
            }
        }
        private void Button1_Click(object sender, EventArgs e)
        {
            string clName    = CLname.Text;
            string ClSurname = Clsurname.Text;
            string email     = mail.Text;
            string phonee    = tel.Text;

            DVGclient.Rows.Add(clName, ClSurname, email, email, phonee);

            Modelss.Client cl = new Modelss.Client();
            using (Modelss.KITABXANADB db = new Modelss.KITABXANADB())
            {
                cl.Name    = CLname.Text;
                cl.Surname = Clsurname.Text;
                cl.Email   = mail.Text;
                cl.Phone   = tel.Text;
                db.Clients.Add(cl);
                cl.Status = true;
                db.SaveChanges();
            }
        }
        private void Orderbtn_Click(object sender, EventArgs e)
        {
            Modelss.Order ord = new Modelss.Order();

            DateTime orderDate  = DateTime.Now;
            DateTime nextMonth  = orderDate.AddDays(1).AddMonths(1).AddDays(-1);
            int      customerID = Convert.ToInt32(ClientsData.CurrentRow.Cells[0].Value);
            int      bookid     = Convert.ToInt32(booksData.CurrentRow.Cells[0].Value);

            ord.ClientID   = customerID;
            ord.BookID     = bookid;
            ord.OrderDate  = orderDate;
            ord.ReturnDate = nextMonth;

            using (Modelss.KITABXANADB db = new Modelss.KITABXANADB())
            {
                MessageBox.Show("Created Order");
                db.Orders.Add(ord);
                db.SaveChanges();
            }
        }
        public void CreateDVG()
        {
            using (Modelss.KITABXANADB db = new Modelss.KITABXANADB())
            {
                List <Client> clients = db.Clients.ToList();
                foreach (var client in clients)
                {
                    ClientsData.Rows.Add(client.ID, client.Name, client.Surname, client.Email, client.Phone);
                }

                List <Book> books = db.Books.ToList();


                List <AuthorsBook>    authorB = db.AuthorsBooks.ToList();
                List <Modelss.Author> authors = db.Authors.ToList();


                foreach (var book in books)
                {
                    booksData.Rows.Add(book.ID, book.Name, book.AuthorsBooks, book.Price, book.CategoryID, book.Count);
                }
            }
        }