public static string LoginApp( string host, string port, string servicename, string userdb, string pwddb, string username, string password) { string result = "Lỗi đăng nhập."; DataAccess dbA = new DataAccess(); MyApp.MSSQLConnectionString = MyApp.GetLoginMSSQL(host, servicename, userdb, pwddb); dbA.ConnectionString = MyApp.MSSQLConnectionString; string sql = "SELECT code From [User] WHERE code='" + username + "' and SDUNG = 'C'"; List <KeyValuePair <string, object> > ParaMeterCollection = new List <KeyValuePair <string, object> >(); try { DbDataReader reader = dbA.ExecuteAsDataReaderSql(sql, ParaMeterCollection); if (reader.Read()) { result = "true"; } } catch (Exception ex) { result = ex.Message; } return(result); }
/// <summary> /// Thực thi đăng nhập /// </summary> /// <param name="sSql"></param> private void btnCommit_Click(object sender, EventArgs e) { #region Kiểm tra thông tin đầu vào if (txtOLDpass.Text != UserInformation.Pass) { MessageBox.Show("Mật khẩu cũ sai", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (txtNEWpass.Text != txtNEWpasscheck.Text) { MessageBox.Show("Xác nhận mật khẩu sai", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (txtNEWpass.Text == txtOLDpass.Text) { MessageBox.Show("Mật khẩu mới không được giống mật khẩu cũ", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (txtNEWpass.Text == "") { MessageBox.Show("Mật khẩu không được trống", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } #endregion string sql = "PASS_CHANGE '" + UserInformation.Code + "' , '" + txtNEWpass.Text + "'"; int _ok = DatLoa.AddNew(sql); if (_ok >= 0) { MyApp.MSSQLConnectionString = MyApp.GetLoginMSSQL(MyApp.gHostDB, MyApp.gServiceNameDB, MyApp.gUserDB, txtNEWpass.Text); UserInformation.Pass = txtNEWpass.Text; this.DialogResult = DialogResult.OK; this.Close(); } }