private void cmd_login_Click(object sender, EventArgs e) { try { DataClasses1DataContext db = new DataClasses1DataContext(Tool.ConnectionString); this.Text = "Connecting to database"; var list = db.sp_login(txt_username.Text, EncodeString.Encrypt(txt_password.Text)).ToList(); if (list.Count >= 1) { foreach (var i in list) { fmain.fullname = i.fullname; fmain.lbl_current_username.Text = i.fullname; fmain.UserLevel = i.Level_cn.ToString(); fmain.UserCn = i.cn.ToString(); } //if (fmain.UserLevel != "3") //{ db.sp_insertLog__("Login", fmain.fullname, "Login"); fmain.Text = Tool.Systemname; fmain.buttonSelectection(fmain.pb1); fmain.DailyTimeRecordSELECT(); fmain.Show(); //} fmain.isLogin = true; this.Close(); } else { txt_username.Clear(); txt_password.Clear(); MessageBox.Show("User does not exist", "Access Denied", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } } catch (Exception ex) { MessageBox.Show(this, string.Format("An error occured {0}", ex.Message), "Connection Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); new frm_server().ShowDialog(); } }
private void button1_Click(object sender, EventArgs e) { try { IniFile ini = new IniFile(Tool.confg); ini.IniWriteValue("SERVER", "Server", txt_Server.Text); ini.IniWriteValue("SERVER", "Database", txt_database.Text); ini.IniWriteValue("SERVER", "UID", txt_userID.Text); ini.IniWriteValue("SERVER", "Pwd", EncodeString.Encrypt(txt_Password.Text)); Tool.ConnectionString = "Data Source=" + ini.IniReadValue("SERVER", "Server") + ";Initial Catalog=" + ini.IniReadValue("SERVER", "Database") + ";Persist Security Info=True;User ID=" + ini.IniReadValue("SERVER", "UID") + ";Password="******"SERVER", "Pwd") + ";"; Application.Restart(); } catch (Exception ex) { MessageBox.Show(this, string.Format("An error occured {0}", ex.Message), "Connection Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } }
private void button5_Click(object sender, EventArgs e) { Console.Write(EncodeString.Encrypt("Sommerson26")); }