private async void BtnCreateCat_Click(object sender, EventArgs e)
        {
            try
            {
                if (CheckInput())
                {
                    string name = txtCategory.Text.Trim();
                    if (!db.Categories.Any(gt => gt.Category_Name == name))
                    {
                        db.Categories.Add(new Category {
                            Category_Name = name
                        });
                        await db.SaveChangesAsync();

                        cmbCategoryForm.Items.Clear();
                        txtCategory.Text = "";
                        CMBFill();
                        MessageBox.Show("Adding", "Succesfull", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                    else
                    {
                        MessageBox.Show($"{name} Alredy exist", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                }
            }
            catch
            {
                CmbAndTextboxRefresh();
            }
        }
        private async void BtnClientCreate_Click(object sender, EventArgs e)
        {
            string name     = txtClientName.Text;
            string surname  = txtClientSurname.Text;
            string tel      = txtClientTel.Text;
            string identify = txtIdentifyNumber.Text;

            if (CheckInputs(name, surname, tel, identify))
            {
                settingClient = new Client()
                {
                    Client_Name = name, Client_Surname = surname, Client_Tel = tel, Identify_Card = identify
                };
            }

            db.Clients.Add(settingClient);
            await db.SaveChangesAsync();

            UpdateDGV();
        }
        private async void BtnBookCreate_Click(object sender, EventArgs e)
        {
            int     count  = int.Parse(txtBookCount.Text.Trim());
            decimal price  = decimal.Parse(txtBookPrice.Text.Trim());
            string  name   = txtBookName.Text;
            string  author = txtAuthor.Text;

            int category_Id = (cmbBook.SelectedItem as CategoryGen).Id;

            if (CheckInputs(name, price, count, author))
            {
                settingBook = new Book {
                    Book_Name = name, Author = author, Count = count, Price = price, CategoriesId = category_Id
                };
            }
            db.Books.Add(settingBook);
            await db.SaveChangesAsync();

            UpdateDGV();

            MessageBox.Show("Succesful", "Congrulations", MessageBoxButtons.OK, MessageBoxIcon.Information);
        }
예제 #4
0
        private async void BtnRegisterF_Click(object sender, EventArgs e)
        {
            try
            {
                string name       = txtRegName.Text.Trim();
                string surname    = txtRegSurname.Text.Trim();
                string email      = txtRegEmail.Text.Trim();
                string password   = txtRegPassword.Text.Trim();
                string repassword = txtRegRepeat.Text.Trim();

                if (CheckUserInfo(name, surname, email, password, repassword))
                {
                    string security_password = Helpers.HashPassword(password);

                    User user = new User
                    {
                        Name     = name,
                        Surname  = surname,
                        Email    = email,
                        Password = security_password
                    };
                    db.Users.Add(user);
                    await db.SaveChangesAsync();

                    MessageBox.Show("Congrulations you are Registered. Olease wait Admin confirm", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            catch
            {
                DialogResult result = MessageBox.Show("You want try again ?", "Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Information);
                if (result == DialogResult.Yes)
                {
                    txtRegName.Text     = "";
                    txtRegSurname.Text  = "";
                    txtRegEmail.Text    = "";
                    txtRegPassword.Text = "";
                    txtRegRepeat.Text   = "";
                }
                else
                {
                    this.Close();
                }
            }
        }
        private async void BtnConfirm_Click(object sender, EventArgs e)
        {
            try
            {
                DateTime givenDay = new DateTime(DateTime.Today.Year, DateTime.Today.Month, DateTime.Today.Day);
                DateTime retunDay = new DateTime(2019, 10, 06);
                decimal  total    = decimal.Parse(lblTotal.Text);
                Order    order    = new Order()
                {
                    Total         = total,
                    BookCount     = countSaledBooks,
                    Order_Time    = givenDay,
                    Rerturn_Time  = retunDay,
                    Returned_Time = null,
                    UsersId       = _user.Id,
                    ClientId      = (cmbClientChoose.SelectedItem as ConverCl).Id,
                    Deleted       = false
                };

                foreach (ListClass book in listboxSale.Items)
                {
                    order.OrderBooks.Add(new OrderBook {
                        BookId = book.Id, OrdersId = order.Id, Count = book.Count,
                    });
                }
                db.Orders.Add(order);
                await db.SaveChangesAsync();

                MessageBox.Show("Succesfully Added order", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);

                foreach (ListClass book in listboxSale.Items)
                {
                    DecBoobCount(book);
                }
                dgvUserControl.DataSource = null;
                CmbAndDgvREfresh();
            }
            catch
            {
                MessageBox.Show("You can Saled only real order", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                CmbAndDgvREfresh();
            }
        }
예제 #6
0
        private async void DgvControlPanel_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            int          id     = (int)dgvControlPanel.Rows[e.RowIndex].Cells[0].Value;
            Order        order  = db.Orders.Find(id);
            DialogResult result = MessageBox.Show("Are you want confirm this User", "Information", MessageBoxButtons.YesNo, MessageBoxIcon.Information);

            if (result == DialogResult.Yes)
            {
                order.Deleted = true;
            }
            else
            {
                order.Status = true;
            }
            await db.SaveChangesAsync();

            CountNewUsers();
            RefreshDGV();
        }