private void btn_Settings_Click(object sender, EventArgs e) { f_Settings fs = new f_Settings { sqlc = Sqlc, sqlc2 = Sqlc2, prof = Login_profile }; fs.ShowDialog(); foreach (profile p in c_DBHandler.getProfiles(Sqlc)) { if (p.name == Login_profile.name) { Login_profile = p; } } dg_DataTable.colors = new Color[] { Color.FromArgb(Convert.ToInt32(Login_profile.color_1)), Color.FromArgb(Convert.ToInt32(Login_profile.color_2)), Color.FromArgb(Convert.ToInt32(Login_profile.color_3)) }; if (fs.OK) { fillMainList(); } GC.Collect(); }
//Queries from main database /// <summary> /// Get list of user profiles /// </summary> /// <param name="sqlc">Current open SQLite Connection</param> /// <returns>List of profile objects</returns> public static List <profile> getProfiles(SQLiteConnection sqlc) { List <profile> proflist = new List <profile>(); SQLiteCommand sqlk = new SQLiteCommand( @" SELECT id, COALESCE(profil_name ,'') AS profil_name, COALESCE(last_login ,'') AS last_login, COALESCE(font_family ,'') AS font_family, COALESCE(font_size ,'') AS font_size, COALESCE(font_style ,'') AS font_style , COALESCE(font_color ,'') AS font_color , COALESCE(color_1 ,'') AS color_1, COALESCE(color_2 ,'') AS color_2, COALESCE(color_3 ,'') AS color_3 FROM profilok" , sqlc); SQLiteDataReader r = sqlk.ExecuteReader(); while (r.Read()) { try { if (r.GetString(r.GetOrdinal("profil_name")) == "") { continue; } profile p = new profile(); p.name = r.GetString(r.GetOrdinal("profil_name")); p.fontStyle = r.GetString(r.GetOrdinal("font_style")); p.fontSize = r.GetString(r.GetOrdinal("font_size")); p.fontFamily = r.GetString(r.GetOrdinal("font_family")); p.fontColor = r.GetString(r.GetOrdinal("font_color")); p.color_1 = r.GetString(r.GetOrdinal("color_1")); p.color_2 = r.GetString(r.GetOrdinal("color_2")); p.color_3 = r.GetString(r.GetOrdinal("color_3")); p.last_login = r.GetString(r.GetOrdinal("last_login")); proflist.Add(p); } catch (Exception ex) { Console.WriteLine(ex.ToString()); //System.Media.SystemSounds.Asterisk.Play(); } } return(proflist); }
private void btn_EditProfile_Click(object sender, EventArgs e) { f_EditProfile fedp = new f_EditProfile(); fedp.prof = prof; fedp.edit = true; fedp.sqlc = sqlc; fedp.ShowDialog(); foreach (profile p in c_DBHandler.getProfiles(sqlc)) { if (p.name == prof.name) { prof = p; } } }
private void btn_Save_Click(object sender, EventArgs e) { fontColor = p_FontColor.BackColor.ToArgb().ToString(); color_1 = p_Color1.BackColor.ToArgb().ToString(); color_2 = p_Color2.BackColor.ToArgb().ToString(); color_3 = p_Color3.BackColor.ToArgb().ToString(); profile p = new profile(); p.name = tb_ProfileName.Text; p.fontFamily = fontFamily; p.fontSize = fontSize; p.fontStyle = fontStyle; p.fontColor = fontColor; p.color_1 = color_1; p.color_2 = color_2; p.color_3 = color_3; string ret = c_DBHandler.editProfile(sqlc, p, edit); if (!ret.Contains("ERROR")) { this.Close(); } else { ret = ret.Substring(ret.IndexOf(":") + 1); if (ret == "0") { MessageBox.Show($"Már létezik profil ezzel a névvel\r\n[ {p.name} ]", "Hiba!", MessageBoxButtons.OK, MessageBoxIcon.Error); } else if (ret == "-1") { MessageBox.Show($"Hiba az adatbáziskapcsolattal!\r\nNem tudtam létrehozni a profilt.", "Hiba!", MessageBoxButtons.OK, MessageBoxIcon.Error); } else if (ret == "NONAME") { MessageBox.Show($"A név mező kitöltése kötelező!", "Hiba!", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { MessageBox.Show($"Ismeretlen hiba!\r\nHibaüzenet: [ {ret} ]", "Hiba!", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }
public void login() { if (cb_UserProfile.SelectedIndex < 0) { MessageBox.Show("Jelenleg nincs profil kiválasztva.\r\nKérjük válasszon ki egy profilt a belépéshez.\r\nHa nincs profilja, hozzon létre egyet.", "Válasszon ki egy profilt!", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } profile p = new profile(); foreach (profile pp in _profs) { if (cb_UserProfile.Text == pp.name) { p = pp; break; } } //TODO: handle profile if (c_DBHandler.login(_sqlc, tb_Password.Text, p)) { Form1 f = new Form1(); f.Login_profile = p; f.Sqlc = _sqlc; f.Sqlc2 = _sqlc2; this.Hide(); f.ShowDialog(); this.Show(); fillProfiles(); tb_Password.Text = ""; cb_UserProfile.SelectedIndex = -1; lbl_BadPass.Visible = false; } else { lbl_BadPass.Visible = true; } }