コード例 #1
0
        private void MainForm_FormClosing(object sender, FormClosingEventArgs e)
        {
            if (!store.IsDirty)
            {
                Form CustomerAutor = Application.OpenForms[0];
                CustomerAutor.Left = this.Left;
                CustomerAutor.Top  = this.Top;
                CustomerAutor.Show();
                return;
            }
            var res = MessageBox.Show("Save data before exit?", "", MessageBoxButtons.YesNoCancel);

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

            case DialogResult.Yes:
                store.Save();
                Form CustomerAutor = Application.OpenForms[0];
                CustomerAutor.Left = this.Left;
                CustomerAutor.Top  = this.Top;
                CustomerAutor.Show();
                break;

            case DialogResult.No:
                Form Customer = Application.OpenForms[0];
                Customer.Left = this.Left;
                Customer.Top  = this.Top;
                Customer.Show();
                break;
            }
        }
コード例 #2
0
        private void Compilation_Click(object sender, EventArgs e)
        {
            if (OrdersGridView.Rows.Count > 0)
            {
                var res = MessageBox.Show("Do you want to order your best Trip ever?", "", MessageBoxButtons.OKCancel);
                switch (res)
                {
                case DialogResult.Cancel:
                    break;

                case DialogResult.OK:
                    if (Store.Orders.Count > 0)
                    {
                        foreach (Order o in Store.Orders)
                        {
                            if (Order.Client.Name == Client.Name)
                            {
                                o.IsOrdered = true;
                                Store.Save();
                            }
                        }
                    }
                    break;
                }
                ResetOrder();
            }
            else
            {
                MessageBox.Show("Sorry,there is no potion of trip(");
            }
        }
コード例 #3
0
        private void ShowTrip_Load(object sender, EventArgs e)
        {
            Store.Save();
            LocationText.Text     = Portion.Trip.Location;
            PriceText.Text        = Convert.ToString(Portion.Trip.Price);
            AddServText.Text      = Portion.Trip.AdditionalService;
            AccomodationText.Text = Portion.Trip.Accomodation;
            HostText.Text         = Portion.Trip.Host;
            HostBox.Image         = Portion.Trip.ImageOfHost;
            tripPic.Image         = Portion.Trip.Image;
            liiiikes.Text         = Convert.ToString(Portion.Trip.Counter);

            heartUnlike.Hide();
        }
コード例 #4
0
ファイル: Sign_up.cs プロジェクト: sdermann/travel-agency-app
        private void SignButt_Click(object sender, EventArgs e)
        {
            string pattern = @"^(?("")(""[^""]+?""@)|(([0-9a-z]((\.(?!\.))|[-!#\$%&'\*\+/=\?\^`\{\}\|~\w])*)(?<=[0-9a-z])@))" +
                             @"(?(\[)(\[(\d{1,3}\.){3}\d{1,3}\])|(([0-9a-z][-\w]*[0-9a-z]*\.)+[a-z0-9]{2,17}))$";

            if (string.IsNullOrWhiteSpace(ClientName.Text) || string.IsNullOrWhiteSpace(ClientPassword.Text))
            {
                if (string.IsNullOrWhiteSpace(ClientName.Text))
                {
                    ClientName.BackColor = Color.MediumSeaGreen;
                }
                if (string.IsNullOrWhiteSpace(ClientPassword.Text))
                {
                    ClientPassword.BackColor = Color.MediumSeaGreen;
                }
                MessageBox.Show("Fill in the blank space, please");
                ClientName.BackColor     = Color.White;
                ClientPassword.BackColor = Color.White;
            }
            else if (ClientName.Text.Length <= 4 || ClientName.Text.Length >= 10)
            {
                ClientName.BackColor = Color.MediumSeaGreen;
                MessageBox.Show("Name has inappropriate length, try again");
                ClientName.BackColor = Color.White;
                ClientName.Text      = string.Empty;
            }
            else if (ClientPassword.Text.Length <= 4 || ClientPassword.Text.Length >= 10)
            {
                ClientPassword.BackColor = Color.MediumSeaGreen;
                MessageBox.Show("ClientPassword has inappropriate length, try again");
                ClientPassword.BackColor = Color.White;
                ClientPassword.Text      = string.Empty;
            }
            else if (!Regex.IsMatch(ClientEmail.Text, pattern, RegexOptions.IgnoreCase))
            {
                MessageBox.Show("Email has inappropriate format, try again");
                ClientEmail.BackColor = Color.White;
                ClientEmail.Text      = string.Empty;
            }
            else
            {
                string nickname;
                int    number;
                int    password;
                string email;
                bool   isInt     = int.TryParse(ClientPassword.Text, out number);
                bool   isIntName = int.TryParse(ClientName.Text, out number);
                // Данные с полей
                if (isIntName == true || isInt == false)
                {
                    if (isIntName == true)
                    {
                        ClientName.BackColor = Color.MediumSeaGreen;
                        MessageBox.Show("Name consists only of numbers, try again");
                        ClientName.Text      = string.Empty;
                        ClientName.BackColor = Color.White;
                    }
                    else
                    {
                        nickname = ClientName.Text;
                    }
                    if (isInt == false)
                    {
                        ClientPassword.BackColor = Color.MediumSeaGreen;
                        MessageBox.Show("Password consists not only of numbers, try again");
                        ClientPassword.Text      = string.Empty;
                        ClientPassword.BackColor = Color.White;
                    }
                    else
                    {
                        password = Convert.ToInt32(ClientPassword.Text);
                    }
                }
                else
                {
                    nickname = ClientName.Text;
                    password = Convert.ToInt32(ClientPassword.Text);
                    email    = ClientEmail.Text;
                    // Проверяем, нет ли уже такого пользователя
                    if (store.Clients.FirstOrDefault(u => u.Name == nickname) != null)
                    {
                        MessageBox.Show("Sorry, such Client-name already exists in our family..");
                        ClientName.Text = string.Empty;
                    }
                    if (store.Clients.FirstOrDefault(u => u.Email == email) != null)
                    {
                        MessageBox.Show("Sorry, such  e-mail already exists in our family..");
                        ClientEmail.Text = string.Empty;
                    }
                    else
                    {
                        Client user = new Client(nickname, password, email);
                        store.Clients.Add(user);
                        MessageBox.Show("We are glad to hear you joined us!");
                        store.Save();
                        Form CustomerAutor = Application.OpenForms[0];
                        CustomerAutor.Left = this.Left;
                        CustomerAutor.Top  = this.Top;
                        CustomerAutor.Show();
                        this.Close();
                    }
                }
            }
        }
コード例 #5
0
 private void Sign_up_Click(object sender, EventArgs e)
 {
     if (string.IsNullOrWhiteSpace(NameAdmin.Text) || string.IsNullOrWhiteSpace(Password.Text))
     {
         if (string.IsNullOrWhiteSpace(NameAdmin.Text))
         {
             NameAdmin.BackColor = Color.MediumSeaGreen;
         }
         if (string.IsNullOrWhiteSpace(Password.Text))
         {
             Password.BackColor = Color.MediumSeaGreen;
         }
         MessageBox.Show("Fill in the blank space, please");
         NameAdmin.BackColor = Color.White;
         Password.BackColor  = Color.White;
     }
     else if (NameAdmin.Text.Length <= 4 || NameAdmin.Text.Length >= 10)
     {
         NameAdmin.BackColor = Color.MediumSeaGreen;
         MessageBox.Show("Name has inappropriate length, try again");
         NameAdmin.BackColor = Color.White;
         NameAdmin.Text      = string.Empty;
     }
     else if (Password.Text.Length <= 4 || Password.Text.Length >= 10)
     {
         Password.BackColor = Color.MediumSeaGreen;
         MessageBox.Show("Password has inappropriate length, try again");
         Password.BackColor = Color.White;
         Password.Text      = string.Empty;
     }
     else
     {
         string nickname;
         int    number;
         int    password;
         bool   isInt     = int.TryParse(Password.Text, out number);
         bool   isIntName = int.TryParse(NameAdmin.Text, out number);
         // Data
         if (isIntName == true || isInt == false)
         {
             if (isIntName == true)
             {
                 NameAdmin.BackColor = Color.MediumSeaGreen;
                 MessageBox.Show("Name consists only of numbers, try again");
                 NameAdmin.Text      = string.Empty;
                 NameAdmin.BackColor = Color.White;
             }
             else
             {
                 nickname = NameAdmin.Text;
             }
             if (isInt == false)
             {
                 Password.BackColor = Color.MediumSeaGreen;
                 MessageBox.Show("Password consists not only of numbers, try again");
                 Password.Text      = string.Empty;
                 Password.BackColor = Color.White;
             }
             else
             {
                 password = Convert.ToInt32(Password.Text);
             }
         }
         else
         {
             nickname = NameAdmin.Text;
             password = Convert.ToInt32(Password.Text);
             string pass = SicretCode.Text;
             // Check if user exists
             if (store.Admins.FirstOrDefault(u => u.Name == nickname) != null)
             {
                 MessageBox.Show("Sorry, such Admin-name already exists in our team..");
                 NameAdmin.Text = string.Empty;
                 Password.Text  = string.Empty;
             }
             else
             {
                 if (pass == PasswordX)
                 {
                     Admin user = new Admin(nickname, password);
                     store.Admins.Add(user);
                     MessageBox.Show("We are glad to hear you joined us!");
                     store.Save();
                     Form CustomerAutor = Application.OpenForms[0];
                     CustomerAutor.Left = this.Left;
                     CustomerAutor.Top  = this.Top;
                     CustomerAutor.Show();
                     this.Close();
                 }
                 else
                 {
                     SicretCode.BackColor = Color.MediumSeaGreen;
                     MessageBox.Show("Check your Admin password!)");
                     SicretCode.BackColor = Color.White;
                     SicretCode.Text      = string.Empty;
                 }
             }
         }
     }
 }