コード例 #1
0
 private void BtnRegister_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         if (txtConfirmPassword.Password == txtRegPassword.Password)
         {
             SingletonDb sig = SingletonDb.getInstance();
             if (sig.registerAccount(txtRegUsername.Text, txtEmail.Text, txtRegPassword.Password, (bool)chBxAdminCheckBox.IsChecked) == true)
             {
                 RegisterPanel.Visibility = Visibility.Hidden;
                 LoginPanel.Visibility    = Visibility.Visible;
                 txtNickname.Focus();
             }
             else
             {
                 MessageBox.Show("User not added!");
             }
         }
         else if (txtConfirmPassword.Password != txtRegPassword.Password)
         {
             MessageBox.Show("Passwords not equal!");
         }
     }
     catch (Exception a)
     {
         MessageBox.Show(a.ToString());
     }
 }
コード例 #2
0
        private void BtnLogin_Click_1(object sender, RoutedEventArgs e)
        {
            SingletonDb sig = SingletonDb.getInstance();

            if (sig.loginAccount(txtNickname.Text, txtPassword.Password))
            {
                this.Close();
            }
        }
コード例 #3
0
        private void BtnAddCar_Click(object sender, RoutedEventArgs e)
        {
            CarsDBEntities context = new CarsDBEntities();

            if (CarNameComboBox.SelectedItem == null || txtCarsDiscount.Text == " " || txtCarsEngineLitres.Text == " " ||
                txtCarsGazType.Text == "" || txtCarsModel.Text == "" || txtCarsPhoto1.Text == "" || txtCarsTransmission.Text == "" ||
                txtCarsTypeOfCar.Text == "" || txtCarsPhoto2.Text == "" || txtCarsPhoto3.Text == "")
            {
                MessageBox.Show("Input data is empty!");
            }
            else
            {
                SingletonDb sig = SingletonDb.getInstance();
                sig.addCarToDb(CarNameComboBox.SelectedItem.ToString(), txtCarsModel.Text, txtCarsTransmission.Text, txtCarsGazType.Text, double.Parse(txtCarsEngineLitres.Text), txtCarsTypeOfCar.Text, int.Parse(txtCarsDiscount.Text), txtCarsPhoto1.Text, double.Parse(txtCarPrice.Text), txtCarsPhoto2.Text, txtCarsPhoto3.Text);
            }
        }