示例#1
0
        public Admin()
        {
            InitializeComponent();
            db = new BookStoreEntities();

            cmbBox_Years.Items.Add("2017");
            cmbBox_Years.Items.Add("2018");
            cmbBox_Years.Items.Add("2019");

            cmbBox_Years.SelectedIndexChanged += CmbBox_Years_SelectedIndexChanged;

            dataGridView_Sales.DataSource = db.Sales.ToList();

            month = new List <string>()
            {
                "Jan",
                "Feb",
                "Mar",
                "Apr",
                "May",
                "Jun",
                "Jul",
                "Aug",
                "Sep",
                "Oct",
                "Nov",
                "Dec"
            };



            chart1.ChartAreas[0].AxisX.Interval = 1;

            dataGridView_Books.DataSource = db.Books.ToList();
        }
示例#2
0
 public SignIn()
 {
     InitializeComponent();
     txtBox_password.PasswordChar = '*';
     this.FormClosed += SignIn_FormClosed;
     db = new BookStoreEntities();
     this.MaximumSize = new System.Drawing.Size(255, 383);
     this.MinimumSize = new System.Drawing.Size(255, 383);
 }
        public EditForm(Book editObj)
        {
            InitializeComponent();
            db = new BookStoreEntities();

            editBook = editObj;

            txtBox_Fio.Text         = editBook.Fio;
            txtBox_PublishName.Text = editBook.PublishName;
            txtBox_BookName.Text    = editBook.NameBook;
            txtBox_Price.Text       = editBook.Price.ToString();
            txtBox_Pages.Text       = editBook.Pages.ToString();
            txtBox_SalePrice.Text   = editBook.SalePrice.ToString();
            dateTimePicker.Value    = editBook.DateOfPublishing;
        }
示例#4
0
        public Main()
        {
            InitializeComponent();

            this.MinimumSize = new System.Drawing.Size(938, 597);;
            this.MaximumSize = new System.Drawing.Size(938, 597);;

            db = new BookStoreEntities();

            SignIn signInForm = new SignIn();

            if (signInForm.ShowDialog() == DialogResult.OK)
            {
                currUser             = signInForm.currentUser;
                linkLable_login.Text = currUser.Login;
            }
            else
            {
                return;
            }
            dataGridView_Books.DataSource = db.Books.ToList();

            dataGridView_Cart.DataSource = (from item in db.Books
                                            join item2 in db.Carts on item.ID_BOOK equals item2.Book_ID
                                            where item2.User_Login == currUser.Login
                                            select item).ToList();

            dataGridView_Cart.Columns["ID_BOOK"].Visible          = false;
            dataGridView_Cart.Columns["Fio"].Visible              = false;
            dataGridView_Cart.Columns["PublishName"].Visible      = false;
            dataGridView_Cart.Columns["Price"].Visible            = false;
            dataGridView_Cart.Columns["Pages"].Visible            = false;
            dataGridView_Cart.Columns["DateOfPublishing"].Visible = false;
            dataGridView_Cart.Columns["SalePrice"].Visible        = false;

            cmbBox_SortBy.SelectedIndexChanged += CmbBox_SortBy_SelectedIndexChanged;
            cmbBox_SortBy.Items.Add("Old");
            cmbBox_SortBy.Items.Add("New");
            cmbBox_SortBy.Items.Add("Name");
            cmbBox_SortBy.Items.Add("From lowest");
            cmbBox_SortBy.Items.Add("From highest");
        }
示例#5
0
        private void Btn_SignIn_Click(object sender, EventArgs e)
        {
            Regex regex = new Regex("^[a-zA-Z0-9]+([._]?[a-zA-Z0-9]+){5}$");

            string input_login    = txtBox_login.Text;
            string input_password = txtBox_password.Text;

            if (regex.Match(input_login).Success&& regex.Match(input_password).Success)
            {
                txtBox_password.BackColor = Color.White;
                txtBox_login.BackColor    = Color.White;

                if (signInForm) //SIGN IN
                {
                    //ADMIN
                    if (input_login == admin_login && input_password == admin_pass)
                    {
                        Admin adminForm = new Admin();

                        this.Hide();
                        if (adminForm.ShowDialog() == DialogResult.OK)
                        {
                            this.Show();
                        }
                        else
                        {
                            Application.Exit();
                        }
                    }
                    else
                    {
                        int corect_login = db.Users.Where(user => user.Login == input_login).Count();

                        if (corect_login == 1)
                        {
                            var corect_password = db.Users.Where(user => user.Login == input_login).Where(user => user.Password == input_password.ToString()).Count();

                            if (corect_password == 1)
                            {
                                this.DialogResult = DialogResult.OK;
                                currentUser       = new User()
                                {
                                    Login = input_login, Password = password
                                };
                            }
                            else
                            {
                                txtBox_password.BackColor = Color.PaleVioletRed;
                                MessageBox.Show("Incorrect password");
                            }
                        }
                        else
                        {
                            txtBox_login.BackColor = Color.PaleVioletRed;
                            MessageBox.Show("Incorrect username");
                        }
                    } //END
                }     //END

                else  //Create Acount
                {
                    using (BookStoreEntities db = new BookStoreEntities())
                    {
                        User newUser = new User()
                        {
                            Login = txtBox_login.Text, Password = txtBox_password.Text
                        };
                        db.Users.Add(newUser);
                        db.SaveChanges();
                        MessageBox.Show("Created new user");
                    }
                }//End
            }
            else
            {
                if (!regex.Match(input_password).Success)
                {
                    txtBox_password.BackColor = Color.PaleVioletRed;
                }
                if (!regex.Match(input_login).Success)
                {
                    txtBox_login.BackColor = Color.PaleVioletRed;
                }
            }
        }
示例#6
0
 public AddForm()
 {
     InitializeComponent();
     db = new BookStoreEntities();
 }