private void btnSignIn_Click(object sender, EventArgs e) { if (String.IsNullOrEmpty(txtUsernameSingIn.Text) || String.IsNullOrEmpty(txtPasswordSingIn.Text)) { MessageBox.Show("Vui lòng nhập đầy đủ thông tin"); return; } String query = String.Format( "SELECT * FROM Users WHERE Username='******' AND Password='******'", txtUsernameSingIn.Text, txtPasswordSingIn.Text ); var queryResult = new SqlCommand(query, resourceTransporter.GetConnection()).ExecuteScalar(); if (queryResult == null) { MessageBox.Show("Sai tên tài khoản hoặc mật khẩu"); txtPasswordSingIn.Text = ""; return; } SimpleMedia media = new SimpleMedia(); // media.setUser(txtUsernameSingIn.Text); media.Show(); this.Hide(); }
private void SimpleMedia_FormClosed(object sender, FormClosedEventArgs e) { string deletePlaylistQuery = String.Format("DELETE FROM PlaylistItems WHERE username='******'", username); string deleteResourceQuery = String.Format("DELETE FROM Resources WHERE username='******'", username); new SqlCommand(deletePlaylistQuery, resourceTransporter.GetConnection()).ExecuteScalar(); new SqlCommand(deleteResourceQuery, resourceTransporter.GetConnection()).ExecuteScalar(); this.savePlayListMusic(); this.saveFavoriteMusic(); this.savePlayListVideo(); this.saveFavoriteVideo(); this.saveHistoryDownloaded(); }
private void btnSingUp_Click(object sender, EventArgs e) { if (String.IsNullOrEmpty(txtUsername.Text) || String.IsNullOrEmpty(txtPassword.Text) || String.IsNullOrEmpty(txtPasswordAgain.Text) || String.IsNullOrEmpty(txtName.Text)) { MessageBox.Show("Vui lòng nhập đầy đủ thông tin"); return; } if (!String.Equals(txtPassword.Text, txtPasswordAgain.Text)) { MessageBox.Show("Pass work không khớp, vui lòng nhập lại"); this.txtPassword.Text = ""; this.txtPasswordAgain.Text = ""; return; } SqlCommand checkExistUserCommand = new SqlCommand(String.Format("SELECT * FROM Users WHERE Username='******'", txtUsername.Text), resourceTransporter.GetConnection()); if (checkExistUserCommand.ExecuteScalar() != null) { MessageBox.Show("User đã tồn tại"); this.resetFrom(); return; } SqlCommand insertCommand = new SqlCommand(String.Format("INSERT INTO Users VALUES ('{0}', '{1}', '{2}')", txtUsername.Text, txtPassword.Text, txtName.Text), resourceTransporter.GetConnection()); insertCommand.ExecuteNonQuery(); SignIn signInForm = new SignIn(); signInForm.setUpUser(txtUsername.Text, txtPassword.Text); signInForm.Show(); this.Close(); }