Example #1
0
 public ClientForm(AuthorizationsForm f1)
 {
     InitializeComponent();
     client = new DataBase.DataBaseClient();
     parser = new CodeParser();
     _f1 = f1;
 }
 private void registrationButton_Click(object sender, EventArgs e)
 {
     DataBase.DataBaseClient client = new DataBase.DataBaseClient();
     client.Open();
     string username = usernameBox.Text;
     string password = passwordBox.Text;
     int tmpUserId = client.Registration(username, password);
     switch (tmpUserId)
     {
         case -1:
             MessageBox.Show("Error of datatable querty");
             break;
         case -2:
             MessageBox.Show("Error in secon query");
             break;
         case -10:
             MessageBox.Show("Username already exist");
             break;
         case -20:
             MessageBox.Show("Registration will failed");
             break;
         default:
             MessageBox.Show("Succesfull registration");
             break;
     }
     passwordBox.Text = "";
     usernameBox.Text = "";
     client.Close();
 }
 private void logInButton_Click(object sender, EventArgs e)
 {
     DataBase.DataBaseClient client = new DataBase.DataBaseClient();
     client.Open();
     string username = usernameBox.Text;
     string password = passwordBox.Text;
     tmpUserId = client.Authorizate(username, password);
     switch (tmpUserId)
     {
         case -1:
             {
                 usernameBox.Text = "";
                 passwordBox.Text = "";
                 Bitmap fail = new Bitmap(@"..\..\images\fail1.png");
                 nameCheckBox.SizeMode = PictureBoxSizeMode.StretchImage;
                 passwordCheckBox.SizeMode = PictureBoxSizeMode.StretchImage;
                 nameCheckBox.Image = fail;
                 passwordCheckBox.Image = fail;
                 client.Close();
                 break;
             }
         case -2:
             {
                 passwordBox.Text = "";
                 Bitmap suceed = new Bitmap(@"..\..\images\suceed.jpg");
                 Bitmap fail = new Bitmap(@"..\..\images\fail1.png");
                 nameCheckBox.SizeMode = PictureBoxSizeMode.StretchImage;
                 passwordCheckBox.SizeMode = PictureBoxSizeMode.StretchImage;
                 nameCheckBox.Image = suceed;
                 passwordCheckBox.Image = fail;
                 client.Close();
                 break;
             }
         default:
             ClientForm InClient = new ClientForm(this);
             this.Hide();
             InClient.Show();
             // this.Close();
             break;
     }
 }
 public AuthorizationsForm()
 {
     InitializeComponent();
     client = new DataBase.DataBaseClient();
 }
Example #5
0
        private void registration_Click(object sender, EventArgs e)
        {
            bool flag = true;
            string username = LoginBox.Text ?? String.Empty;
            string firstName = FstNmBox.Text ?? String.Empty;
            string secondName = SndNmBox.Text ?? String.Empty;
            string password = PassBox.Text ?? String.Empty;
            string confirmPassword = ConfPassBox.Text ?? String.Empty;
            string language = comboBox1.Text;
            string message = "";

            if (username == String.Empty)
            {
                message += "Enter username\n";
                flag = false;
            }

            if(firstName == String.Empty)
            {
                message += "Enter you'r first name\n";
                flag = false;
            }

            if(secondName == String.Empty)
            {
                message += "Enter you'r second name\n";
                flag = false;
            }

            if(password == String.Empty)
            {
                message += "Enter you'r password\n";
                flag = false;
            }
            else
            {
                if( confirmPassword == String.Empty)
                {
                    message += "Enter confirm password\n";
                    flag = false;
                }
                else
                {
                    if(password != confirmPassword)
                    {
                        message += "Confirm password will failed\n";
                        flag = false;
                    }
                }
            }

            if(flag == true)
            {
                DataBase.DataBaseClient client = new DataBase.DataBaseClient();
                try
                {
                    int tmpId = client.Registration(username, password, firstName, secondName, language);
                    switch (tmpId)
                    {
                        case (-10):
                            {
                                MessageBox.Show("Пользователь с таким именем уже существует");
                                break;
                            }
                        case (-20):
                            {
                                MessageBox.Show("Ошибка базы данных, регистрация не была оконченна");
                                break;
                            }
                    }
                }
                catch(Exception exception)
                {
                    MessageBox.Show(exception.ToString());
                }
                this.Close();
            }
            else
            {
                MessageBox.Show(message);
            }
        }
Example #6
0
 public RegForm(AuthorizationsForm f1)
 {
     InitializeComponent();
     client = new DataBase.DataBaseClient();
     _f1 = f1;
 }
Example #7
0
 public RegForm()
 {
     InitializeComponent();
     client = new DataBase.DataBaseClient();
 }