示例#1
0
        private void btnBookUp_Click(object sender, EventArgs e)
        {
            if (gvBookUp.Rows[0] is null || gvBookUp.Rows[0].Cells[0].Value is null)
            {
                MessageBox.Show("Update etmek ucun Kitab cedvelde yoxdur");
                return;
            }
            string name        = gvBookUp.Rows[0].Cells[1].Value.ToString();
            Book   choosenBook = _context.Books.FirstOrDefault(u => u.Name == name);

            if (nmbPric.Text != "")
            {
                choosenBook.Prise = Convert.ToDecimal(nmbPric.Text);
                MessageBox.Show("Qiymet Yenilendi");
            }
            if (nmbCount.Text != "")
            {
                int diff = Convert.ToInt32(nmbCount.Text) - choosenBook.Quantity;
                choosenBook.Quantity          = Convert.ToInt32(nmbCount.Text);
                choosenBook.AvaliableQuantity = choosenBook.AvaliableQuantity + diff;
                MessageBox.Show("Kitab Sayi Yenilendi");
            }
            _context.SaveChanges();
            txtFindBook.Clear();
            gvBookUp.Rows.Clear();
        }
        private void btnRgsRegister_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(txtFullNam.Text))
            {
                MessageBox.Show("Ad ve soyadizi yazin");
                return;
            }

            if (string.IsNullOrEmpty(txtRgsUserName.Text))
            {
                MessageBox.Show("Nick daxil edin");
                return;
            }
            if (string.IsNullOrEmpty(txtLgnPassword.Text))
            {
                MessageBox.Show("Sifre daxil edin");
                return;
            }
            if (string.IsNullOrEmpty(txtMail.Text))
            {
                MessageBox.Show("Elektron unvaninizi daxil edin");
                return;
            }
            if (string.IsNullOrEmpty(cmbStatus.Text))
            {
                MessageBox.Show("Level secin");
                return;
            }
            string encPassword = Encryption.Encrypt(txtLgnPassword.Text);

            if (cmbStatus.Text == "Admin" || cmbStatus.Text == "Moderator")
            {
                User user = new User()
                {
                    Fullname = txtFullNam.Text,
                    Username = txtRgsUserName.Text,
                    Password = encPassword,
                    Email    = txtMail.Text,
                    Level    = (cmbStatus.Text == "Admin") ? userLevel.Admin : userLevel.Moderator,
                    Status   = true
                };
                _context.Users.Add(user);
                _context.SaveChanges();
                MessageBox.Show("Qeydiyyat ugurla aparildi");
            }
            else
            {
                MessageBox.Show("Level Duzgun Secilmeyib");
                return;
            }

            this.Close();
        }
        private void btnAddBook_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(txtNameBook.Text))
            {
                MessageBox.Show("Kitab adi daxil edin");
                return;
            }
            if (string.IsNullOrEmpty(cmbAuthorBook.Text))
            {
                MessageBox.Show("Yazici secin");
                return;
            }
            if (string.IsNullOrEmpty(cmbJanraBook.Text))
            {
                MessageBox.Show("Janr secin");
                return;
            }
            if (string.IsNullOrEmpty(dtpDateBook.Text))
            {
                MessageBox.Show("Tarix secin");
                return;
            }
            if (txtPriceBook.Text == "0")
            {
                MessageBox.Show("Kitab Qiymetini daxil edin");
                return;
            }
            if (txtQuantityBook.Text == "0")
            {
                MessageBox.Show("Kitab sayi daxil edin");
                return;
            }
            BookJanra  janraid  = _context.BookJanras.FirstOrDefault(u => u.Name == cmbJanraBook.Text);
            BookAuthor authorId = _context.BookAuthors.FirstOrDefault(u => u.Name == cmbAuthorBook.Text);
            Book       book     = new Book()
            {
                Name              = txtNameBook.Text,
                AuthorId          = Convert.ToInt32(authorId.Id),
                JanraId           = Convert.ToInt32(janraid.Id),
                PurchaseDate      = dtpDateBook.Value,
                Prise             = txtPriceBook.Value,
                Quantity          = Convert.ToInt32(txtQuantityBook.Value),
                AvaliableQuantity = Convert.ToInt32(txtQuantityBook.Value)
            };

            _context.Books.Add(book);
            _context.SaveChanges();
            MessageBox.Show("Kitab Elave olundu");
        }
示例#4
0
        private void DgvRtrn_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.ColumnIndex == 7 && !(dgvRtrn.Rows[e.RowIndex].Cells[6].Value is null))
            {
                string row = dgvRtrn.Rows[e.RowIndex].Cells[0].Value.ToString();

                Order returnedOrder = _context.Orders.Include("Book").Include("Person").FirstOrDefault(u => u.Id.ToString() == row && u.Status == true);
                returnedOrder.Person.BooksHave--;
                returnedOrder.Book.AvaliableQuantity++;
                returnedOrder.Status = false;
                _context.SaveChanges();
                MessageBox.Show("Kitab Qaytarildi");
                txtSearchCostumerName.Clear();
                dgvRtrn.Rows.Clear();
            }
        }
示例#5
0
        private void btnAuthorAdd_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(txtAuthor.Text))
            {
                MessageBox.Show("Yazici Elave Edin");
                return;
            }
            BookAuthor bookAuthor = new BookAuthor
            {
                Name = txtAuthor.Text
            };

            _context.BookAuthors.Add(bookAuthor);
            _context.SaveChanges();
            dgvAuthors.Rows.Clear();
            FillAuthors();
        }
        private void btnJanraAdd_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(txtJanra.Text))
            {
                MessageBox.Show("Janr Elave Edin");
                return;
            }
            BookJanra bookJanra = new BookJanra
            {
                Name = txtJanra.Text
            };

            _context.BookJanras.Add(bookJanra);
            _context.SaveChanges();
            dgvJanras.Rows.Clear();
            FillJanras();
        }
示例#7
0
        private void BtnFOCreate_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(txtFoBookName.Text))
            {
                MessageBox.Show("Kitab Secilmeyib");
                return;
            }
            if (txtFoDeadline.Value < txtFoOrderDate.Value)
            {
                MessageBox.Show("Deadline satis tarixinden sonra olmalidir!");
                return;
            }

            Book   book   = _context.Books.FirstOrDefault(u => u.Name == txtFoBookName.Text);
            User   user   = _context.Users.FirstOrDefault(u => u.Username == _username);
            Person person = _context.People.FirstOrDefault(u => u.Id.ToString() == _slcId);
            Order  order  = new Order()
            {
                Status      = true,
                PersonId    = Convert.ToInt32(_slcId),
                BookId      = book.id,
                UserId      = user.id,
                overdueDebt = 0,
                Date        = txtFoOrderDate.Value,
                Deadline    = txtFoDeadline.Value
            };

            _context.Orders.Add(order);
            if (book.AvaliableQuantity != 0)
            {
                book.AvaliableQuantity--;
                person.BooksHave++;
            }
            else
            {
                MessageBox.Show("Hazirda kitabxanada bu kitabdan qalmayib ");
                return;
            }

            _context.SaveChanges();
            MessageBox.Show("Sifaris ugurla yaradildi!!!");
            gvBookSrc.Rows.Clear();
            txtBookSrc.Text = "";
        }
示例#8
0
        private void btnUsUp_Click(object sender, EventArgs e)
        {
            if (gvUsUp.Rows[0] is null)
            {
                MessageBox.Show("Update etmek ucun User cedvelde yoxdur");
                return;
            }
            string mail        = gvUsUp.Rows[0].Cells[3].Value.ToString();
            User   choosenUser = _context.Users.FirstOrDefault(u => u.Email == mail);

            if (txtFullNam.Text != "")
            {
                choosenUser.Fullname = txtFullNam.Text;
                MessageBox.Show("FulName Yenilendi");
            }
            if (txtUsarNam.Text != "")
            {
                choosenUser.Username = txtUsarNam.Text;
                MessageBox.Show("UserName Yenilendi");
            }
            if (txtMail.Text != "")
            {
                choosenUser.Email = txtMail.Text;
                MessageBox.Show("Mail Yenilendi");
            }
            bool      _status = (cmbStatus.Text == "active") ? true : false;
            userLevel _level  = (cmbLaval.Text == "admin") ? userLevel.Admin : userLevel.Moderator;

            if (cmbLaval.Text != "")
            {
                choosenUser.Level = _level;
                MessageBox.Show("Level Yenilendi");
            }
            if (cmbStatus.Text != "")
            {
                choosenUser.Status = _status;
                MessageBox.Show("Status Yenilendi");
            }
            _context.SaveChanges();
        }
示例#9
0
        private void btnAddCostumer_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(txtCostumerName.Text))
            {
                MessageBox.Show("Musteri adi daxil edin");
                return;
            }
            if (string.IsNullOrEmpty(txtCostumerSName.Text))
            {
                MessageBox.Show("Musteri soyadi daxil edin");
                return;
            }
            if (string.IsNullOrEmpty(txtCostumerPhone.Text))
            {
                MessageBox.Show("Musteri nomresi daxil edin");
                return;
            }
            if (string.IsNullOrEmpty(txtCostumerMail.Text))
            {
                MessageBox.Show("Musteri elektron puctu daxil edin");
                return;
            }

            Person person = new Person()
            {
                Name        = txtCostumerName.Text,
                Surname     = txtCostumerSName.Text,
                Email       = txtCostumerMail.Text,
                PhoneNumber = txtCostumerPhone.Text,
                BooksHave   = 0
            };

            _context.People.Add(person);
            _context.SaveChanges();
            MessageBox.Show("Musteri Elave olundu");
            this.Close();
        }
        private void btnBookUp_Click(object sender, EventArgs e)
        {
            if (dgvFindCtm.Rows[0] is null || dgvFindCtm.Rows[0].Cells[0].Value is null)
            {
                MessageBox.Show("Update etmek ucun Musteri cedvelde yoxdur");
                return;
            }
            string phone       = dgvFindCtm.Rows[0].Cells[3].Value.ToString();
            Person choosenCust = _context.People.FirstOrDefault(u => u.PhoneNumber == phone);

            if (txtMail.Text != "")
            {
                choosenCust.Email = txtMail.Text;
                MessageBox.Show("Mail Yenilendi");
            }
            if (txtPhone.Text != "")
            {
                choosenCust.PhoneNumber = txtPhone.Text;
                MessageBox.Show("Mobil Nomre Yenilendi");
            }
            _context.SaveChanges();
            txtFindCust.Clear();
            dgvFindCtm.Rows.Clear();
        }