Esempio n. 1
0
        private void DataGridView1_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            MyApplication toaccept = dataGridView1.Rows[e.RowIndex].DataBoundItem as MyApplication;

            if (toaccept != null)
            {
                var          accept = new ApplicVerificationClient(toaccept);
                DialogResult res    = accept.ShowDialog();
                if (res == DialogResult.Yes)
                {
                    lombard.ApplicationsToUser.Remove(accept.work);
                    Product prod = accept.work.Prod;
                    prod.DateTime = DateTime.Now;
                    lombard.Products.Add(prod);

                    myApplicationBindingSource.DataSource = lombard.ApplicationsToUser.Where(o => o.Giver == activeUser);
                    myApplicationBindingSource.ResetBindings(false);
                    lombard.Save();
                }
                if (res == DialogResult.No)
                {
                    lombard.ApplicationsToUser.Remove(accept.work);
                    myApplicationBindingSource.DataSource = lombard.ApplicationsToUser.Where(o => o.Giver == activeUser);
                    myApplicationBindingSource.ResetBindings(false);
                    lombard.Save();
                }
            }
        }
Esempio n. 2
0
        private void ClientMain_FormClosing(object sender, FormClosingEventArgs e)
        {
            Form CustomerAutor = System.Windows.Forms.Application.OpenForms[0];

            if (!lombard.IsDirty)
            {
                CustomerAutor.Close();
                return;
            }
            var res = MessageBox.Show("Save data before exit?", "", MessageBoxButtons.YesNoCancel);

            switch (res)
            {
            case DialogResult.Cancel:
                e.Cancel = true;
                CustomerAutor.Close();

                break;

            case DialogResult.Yes:
                lombard.Save();
                CustomerAutor.Close();

                break;

            case DialogResult.No:
                CustomerAutor.Close();

                break;
            }
        }
Esempio n. 3
0
        private void AdminMain_FormClosing(object sender, FormClosingEventArgs e)
        {
            if (!lombard.IsDirty)
            {
                return;
            }
            var res = MessageBox.Show("Save data before exit?", "", MessageBoxButtons.YesNoCancel);

            switch (res)
            {
            case DialogResult.Cancel:
                e.Cancel = true;
                break;

            case DialogResult.Yes:
                lombard.Save();
                break;

            case DialogResult.No:
                break;
            }
        }
Esempio n. 4
0
        private void ButtonRegister_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrWhiteSpace(RegName.Text) || string.IsNullOrWhiteSpace(RegPassword.Text) || string.IsNullOrWhiteSpace(IDbox.Text))
            {
                if (string.IsNullOrWhiteSpace(RegName.Text))
                {
                    RegName.BackColor = Color.Red;
                }
                if (string.IsNullOrWhiteSpace(RegPassword.Text))
                {
                    RegPassword.BackColor = Color.Red;
                }
                if (string.IsNullOrWhiteSpace(IDbox.Text))
                {
                    RegPassword.BackColor = Color.Red;
                }
                MessageBox.Show("Fill in the blank space, please");
                RegName.BackColor     = Color.White;
                RegPassword.BackColor = Color.White;
                IDbox.BackColor       = Color.White;
            }
            else if (RegName.Text.Length <= 2 || RegName.Text.Length >= 10)
            {
                RegName.BackColor = Color.Red;
                MessageBox.Show("Name has inappropriate length, try again");
                RegName.BackColor = Color.White;
                RegName.Text      = string.Empty;
            }
            else if (RegPassword.Text.Length <= 4 || RegPassword.Text.Length >= 10)
            {
                RegPassword.BackColor    = Color.Red;
                RegPassReenter.BackColor = Color.Red;
                MessageBox.Show("Password has inappropriate length, try again");
                RegPassword.BackColor    = Color.White;
                RegPassword.Text         = string.Empty;
                RegPassReenter.BackColor = Color.White;
                RegPassReenter.Text      = string.Empty;
            }
            else if (RegPassReenter.Text != RegPassword.Text)
            {
                RegPassword.BackColor    = Color.Red;
                RegPassReenter.BackColor = Color.Red;
                MessageBox.Show("Passwords don't match, try again");
                RegPassword.BackColor    = Color.White;
                RegPassword.Text         = string.Empty;
                RegPassReenter.BackColor = Color.White;
                RegPassReenter.Text      = string.Empty;
            }
            else if (IDbox.Text.Length != 9)
            {
                IDbox.BackColor = Color.Red;
                MessageBox.Show("id has inappropriate length, try again");
                IDbox.BackColor = Color.White;
                IDbox.Text      = string.Empty;
            }
            //filled and long enough
            else
            {
                string login    = RegName.Text;
                string password = (RegPassword.Text);
                int    iD       = Convert.ToInt32(IDbox.Text);
                // unique users
                if (lombard.Clients.FirstOrDefault(u => u.Name.ToLower() == login.ToLower() && u.ID == iD) != null)
                {
                    MessageBox.Show("Sorry, such Client already exist...Change your login");
                    RegName.Text     = string.Empty;
                    RegPassword.Text = string.Empty;
                }
                else
                {
                    Client user = new Client(iD, login, password);
                    lombard.Clients.Add(user);
                    MessageBox.Show("We are glad to hear you joined us!");
                    lombard.Save();
                    Form main = new ClientMain(ref lombard, user);
                    main.Show();

                    this.Close();
                }
            }
        }
Esempio n. 5
0
        private void ButtonSendAppl_Click(object sender, EventArgs e)
        {
            #region correctcheck

            if (string.IsNullOrWhiteSpace(textBoxName.Text) || string.IsNullOrWhiteSpace(textBoxPriceDesired.Text))
            {
                if (string.IsNullOrWhiteSpace(textBoxName.Text))
                {
                    textBoxName.BackColor = Color.Red;
                }
                if (string.IsNullOrWhiteSpace(textBoxPriceDesired.Text))
                {
                    textBoxPriceDesired.BackColor = Color.Red;
                }

                MessageBox.Show("Fill in the blank space, please");
                textBoxName.BackColor         = Color.White;
                textBoxPriceDesired.BackColor = Color.White;
            }
            else if (textBoxName.Text.Length <= 2)
            {
                textBoxName.BackColor = Color.Red;
                MessageBox.Show("Name/Adress has inappropriate length, try again");
                textBoxName.BackColor = Color.White;
                textBoxName.Text      = string.Empty;
            }
            else if (!int.TryParse(textBoxPriceDesired.Text, out int number))
            {
                textBoxPriceDesired.BackColor = Color.Red;
                MessageBox.Show("Price is not  number, try again");
                textBoxPriceDesired.BackColor = Color.White;
                textBoxPriceDesired.Text      = string.Empty;
            }
            else if (Convert.ToInt32(textBoxPriceDesired.Text) < 1)
            {
                textBoxPriceDesired.BackColor = Color.Red;
                MessageBox.Show("Price cannot be negative, try again");
                textBoxPriceDesired.BackColor = Color.White;
                textBoxPriceDesired.Text      = string.Empty;
            }

            #endregion correctcheck

            //filled and long enough
            else
            {
                string text        = textBoxName.Text;
                int    price       = Convert.ToInt32(textBoxPriceDesired.Text);
                string description = textBoxDescription.Text;

                Image noImage = pictureBox.Image;

                if (radioButtonItemName.Checked == true)
                {
                    Product       intake = new Item(text, price, activeuser, description, noImage);
                    MyApplication applic = new MyApplication((Product)intake, activeuser);
                    lombard.ApplicationsToAdmin.Add(applic);
                    // MessageBox.Show(intake.ToString(),"",MessageBoxButtons.OK);
                }

                if (radioButtonProperty.Checked == true)
                {
                    Product intake = new Property(text, price, activeuser, description)
                    {
                        Image = noImage
                    };
                    MyApplication applic = new MyApplication((Product)intake, activeuser);
                    lombard.ApplicationsToAdmin.Add(applic);
                    //MessageBox.Show(intake.ToString(), "", MessageBoxButtons.OK);
                }

                //MessageBox.Show((lombard.ApplicationsToAdmin[lombard.ApplicationsToAdmin.Count()-1].Prod.ToString()), "", MessageBoxButtons.OK);
                MessageBox.Show("Application added succesfully!");
                lombard.Save();
                Form CustomerMain = System.Windows.Forms.Application.OpenForms[1];
                CustomerMain.Left = this.Left;
                CustomerMain.Top  = this.Top;
                CustomerMain.Show();

                this.Close();
            }
        }