private void Login(string strUsername, string strPassword) { try { clsEncryption oEncryption = new clsEncryption(); using (clsConnection oconn = new clsConnection()) { NpgsqlCommand ocmd = new NpgsqlCommand(); oconn.Open(); ocmd.Connection = oconn.Conn; ocmd = new NpgsqlCommand(); ocmd.Connection = oconn.Conn; bool isActive = true; string strsql = @"select userid, username, fullname,email, groupusers from tbm_users where username=@username and password=@password and dlt='0' and active='1'"; ocmd.Parameters.Add("@username", NpgsqlTypes.NpgsqlDbType.Varchar).Value = oEncryption.Encrypt(strUsername.ToString().ToUpper()); ocmd.Parameters.Add("@password", NpgsqlTypes.NpgsqlDbType.Varchar).Value = oEncryption.Encrypt(strPassword.ToString()); ocmd.CommandText = strsql; NpgsqlDataReader dr; dr = ocmd.ExecuteReader(); if (dr.Read()) { clsRegKey oRegKey = new clsRegKey(); oRegKey.RegistryPathCurrentUser = clsGlobal.s_FullRegKey; oRegKey = null; clsGlobal.strUserName = oEncryption.Decrypt(dr["username"].ToString()); clsGlobal.strUserID = dr["userid"].ToString(); clsGlobal.strHakAkses = dr["groupusers"].ToString(); clsGlobal.strNamaPetugas = dr["fullname"].ToString(); clsGlobal.strUserPassword = txtPassword.Text; clsGlobal.strGroupUser = dr["groupusers"].ToString(); } else { XtraMessageBox.Show("Invalid username or password .!", clsGlobal.str_ApplicationName, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); strPassword = ""; oconn.Close(); ocmd = null; oEncryption = null; return; } oconn.Close(); ocmd = null; } oEncryption = null; this.DialogResult = System.Windows.Forms.DialogResult.OK; } catch (Exception ex) { XtraMessageBox.Show("Unable connect to database server, please configure the database connection first", clsGlobal.str_ApplicationName, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); frmServerInitialize frm = new frmServerInitialize(); frm.ShowDialog(this); } }
private void btnConnect_Click(object sender, EventArgs e) { try { oconn.Server = txtServer.Text; oconn.User = txtUsername.Text; oconn.Password = txtpassword.Text; oconn.Database = cboDatabase.Text; oconn.Port = txtPort.Text; oconn.OpenTesting(); XtraMessageBox.Show("Congratulation\n You have been connected to server : " + txtServer.Text, clsGlobal.str_ApplicationName, MessageBoxButtons.OK, MessageBoxIcon.Information); oReg.SaveSetting("Server", txtServer.Text); oReg.SaveSetting("User", oEncryption.Encrypt(txtUsername.Text)); oReg.SaveSetting("Password", oEncryption.Encrypt(txtpassword.Text)); oReg.SaveSetting("Database", cboDatabase.Text); oReg.SaveSetting("Port", txtPort.Text); oconn.Server = oReg.getSetting("Server"); oconn.User = oReg.getSetting("User"); oconn.Password = oReg.getSetting("Password"); oconn.Database = oReg.getSetting("Database"); oconn.Port = oReg.getSetting("Port"); clsGlobal.str_Server = oconn.Server; clsGlobal.str_User = txtUsername.Text; clsGlobal.str_Password = txtpassword.Text; clsGlobal.str_Database = oconn.Database; clsGlobal.str_Port = oconn.Port; oconn.Close(); this.Dispose(); } catch (Exception ee) { XtraMessageBox.Show("Could not connect to the server .!\nCall Your System Administrator\n", clsGlobal.str_ApplicationName, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } }
public frmMain() { try { formSplash = new frmLogin(); formSplash.ShowDialog(this); if (formSplash.DialogResult == DialogResult.OK) { clsGlobal.xpatchDatabase(); loadDialog = new WaitDialogForm("Loading Components...", "Processing...Please Wait...", new Size(420, 78)); InitializeComponent(); if (clsGlobal.bolevaluationversion) { clsGlobal.pstrAppName = "EVALUATION VERSION - Mobilo Rental"; this.Text = "EVALUATION VERSION - Mobilo Rental"; } else { clsGlobal.pstrAppName = "MobiloRental"; this.Text = "Mobilo Rental"; } oReg.RegistryPathCurrentUser = clsGlobal.s_FullRegKey; using (clsConnection oconn = new clsConnection()) { oconn.Open(); lblWelcome.Text = "WELCOME : " + clsGlobal.strUserName.ToUpper(); lblPosition.Text = "POSITION : " + clsGlobal.strGroupUser.ToUpper(); oconn.Close(); } setUserPrivillage(); nbiVisibility(); } } catch { } finally { setLoadDialog(false, ""); } try { if (clsGlobal.isusebackgroundimage) { if (System.IO.File.Exists(Application.StartupPath.ToString() + "\\bg\\mainbg.jpg")) { panelHome.Visible = true; panelHome.BackgroundImage = Image.FromFile(Application.StartupPath.ToString() + "\\bg\\mainbg.jpg"); panelHome.BackgroundImageLayout = ImageLayout.Stretch; } } } catch (Exception ex) { } }