static void Main(string[] args) { string dbPath = string.Empty; string csvPath = string.Empty; if (args.Length > 0) { dbPath = args[0]; csvPath = args[1]; } else { dbPath = @"E:\WorkSpace\client_Manghuangji_Trunk_Android\Assets\R\Inside\database\game.bytes";//args[0]; csvPath = "../../../ExportCSV"; } Console.WriteLine("dbPath:" + dbPath); Console.WriteLine("csvPath:" + csvPath); if (!File.Exists(dbPath)) { Console.WriteLine("not found " + dbPath); Console.ReadKey(); } SQLiteDatabase db = new SQLiteDatabase(dbPath); DataTable dataTable; String query = "SELECT name FROM sqlite_master " + "WHERE type = 'table'" + "ORDER BY 1"; dataTable = db.GetDataTable(query); ArrayList dataTableList = new ArrayList(); foreach (DataRow row in dataTable.Rows) { dataTableList.Add(row.ItemArray[0].ToString()); } string exportDirName = csvPath; if (Directory.Exists(exportDirName)) { Directory.Delete(exportDirName, true); } Directory.CreateDirectory(exportDirName); for (int tableIndex = 0; tableIndex < dataTableList.Count; tableIndex++) { Console.WriteLine(string.Format("{0}/{1}:{2}", tableIndex, dataTableList.Count, dataTableList[tableIndex])); DataTable tmpDataTable = db.GetDataTable("select * from " + dataTableList[tableIndex]); ExportToCSV(exportDirName, tmpDataTable); } Console.WriteLine("ExportSqliteToCVS Finish"); Console.ReadKey(); }
public Tournoi() { String query = "select count(*) from equipe"; nbEquipes = Int32.Parse(db.ExecuteScalar(query)); query = "select * from equipe"; DataTable data = db.GetDataTable(query); foreach (DataRow row in data.Rows) { Equipe equ = new Equipe(Int32.Parse(row["id"].ToString()), row["nom"].ToString(), Int32.Parse(row["capitaine_id"].ToString())); this.Equipes[equ.id] = equ; } query = "select * from exception"; DataTable dataExc = db.GetDataTable(query); foreach (DataRow row in dataExc.Rows) { this.Equipes[Int32.Parse(row["equipe1_id"].ToString())].exceptions.Add(Int32.Parse(row["equipe2_id"].ToString())); this.Equipes[Int32.Parse(row["equipe2_id"].ToString())].exceptions.Add(Int32.Parse(row["equipe1_id"].ToString())); } query = "select * from personne where equipe_id is null and arbitre = 1"; DataTable arb = db.GetDataTable(query); foreach (DataRow row in arb.Rows) { Personne pers; if (row["equipe_id"] == System.DBNull.Value) { pers = new Personne(Int32.Parse(row["id"].ToString()), row["prenom"].ToString(), row["nom"].ToString(), 0, true); } else { pers = new Personne(Int32.Parse(row["id"].ToString()), row["prenom"].ToString(), row["nom"].ToString(), Int32.Parse(row["equipe_id"].ToString()), true); } this.Arbitres[pers.id] = pers; } query = "select * from personne where equipe_id is not null and equipe_id > 0"; DataTable players = db.GetDataTable(query); foreach (DataRow row in players.Rows) { Personne pers; pers = new Personne(Int32.Parse(row["id"].ToString()), row["prenom"].ToString(), row["nom"].ToString(), Int32.Parse(row["equipe_id"].ToString()), false); this.Joueurs[pers.id] = pers; } foreach (KeyValuePair <int, Equipe> equipe in this.Equipes) { equipe.Value.setJoueurs(this.Joueurs); } }
private EmployeeCard GetCurrentEmployee() { String query = String.Format("select * from employees where employeeID={0};", TextBoxCardID.Text.Trim()); DataTable dt = sql.GetDataTable(query); if (dt.Rows.Count > 0) { return((EmployeeCard)dt.Rows[0].ItemArray); } else { return(null); } }
public static void ListBooks() { string query = "select TITLE \"Title\", AUTHOR \"Author\", " + "PUBDATE \"Publish Date\", ISBN \"ISBN\" from Books"; DataTable books = db.GetDataTable(query); foreach (DataRow r in books.Rows) { Console.WriteLine("{0}, {1}, {2}, {3}", r["Title"].ToString(), r["Author"].ToString(), r["Publish Date"].ToString(), r["ISBN"].ToString()); } }
internal IList <Participant> GetReport() { SQLiteDatabase db = new SQLiteDatabase(); DataTable reportTable = db.GetDataTable(Constants.SqlReport); IList <Participant> report = new List <Participant>(); if (reportTable != null && reportTable.Rows.Count > 0) { Participant participant; foreach (DataRow row in reportTable.Rows) { participant = new Participant(); participant.Email = row["email"].ToString(); participant.Identification = row["identification"].ToString(); participant.Name = row["name"].ToString(); participant.Corrects = row["corrects"].ToString(); report.Add(participant); } } return(report); }
public Delete() { InitializeComponent(); try { SQLiteDatabase db = new SQLiteDatabase(); DataTable Login; String query = "select name \"Name\", lastname \"lastname\", Lid \"Lid\","; query += "name \"name\", lastname \"lastname\", Lid \"Lid\""; query += "from Login;"; Login = db.GetDataTable(query); List <string> UsersList = new List <string>(); //Or looped through for some other reason foreach (DataRow r in Login.Rows) { UsersList.Add(r["name"].ToString()); } comboBox.ItemsSource = UsersList; comboBox.SelectedIndex = 0; } catch (Exception fail) { String error = "The following error has occurred:\n\n"; error += fail.Message.ToString() + "\n\n"; MessageBox.Show(error); this.Close(); } }
public byte[] GetFile(string file) { DataTable t = _db.GetDataTable("SELECT * FROM filestorage where name = @name", new Dictionary <string, object>() { { "@name", file } }); if (t.Rows.Count == 0) { return(null); } long start = long.Parse(t.Rows[0]["start"].ToString()); long end = long.Parse(t.Rows[0]["end"].ToString()); long size = long.Parse(t.Rows[0]["size"].ToString()); byte[] buffer = new byte[size]; if (_file != string.Empty) { using (var fs = new FileStream(_file, FileMode.Open)) { fs.Seek(start, SeekOrigin.Begin); fs.Read(buffer, 0, buffer.Length); } } else { _stream.Seek(start, SeekOrigin.Begin); _stream.Read(buffer, 0, buffer.Length); } return(buffer); }
private void button_Click(object sender, RoutedEventArgs e) { listBox.Items.Clear(); try { SQLiteDatabase db = new SQLiteDatabase(); DataTable Login; String query = "select name \"Name\", lastname \"lastname\","; query += "name \"name\", lastname \"last name\""; query += "from Login;"; Login = db.GetDataTable(query); //Or looped through for some other reason foreach (DataRow r in Login.Rows) { listBox.Items.Add(r["name"].ToString() + " " + r["lastname"].ToString()); } } catch (Exception fail) { String error = "The following error has occurred:\n\n"; error += fail.Message.ToString() + "\n\n"; MessageBox.Show(error); this.Close(); } }
// Fill the listboxes from the database private void getDataFromDb(string query, ListBox lstBox) { try { lstBox.Items.Clear(); data = db.GetDataTable(query); foreach (DataRow r in data.Rows) { lstBox.Items.Add(r[0].ToString()); } } catch (Exception fail) { failure(fail); } }
public void test() { try { SQLiteDatabase db = new SQLiteDatabase(); DataTable recipe; String query = "select NAME \"Name\", DESCRIPTION \"Description\","; query += "PREP_TIME \"Prep Time\", COOKING_TIME \"Cooking Time\""; query += "from RECIPE;"; recipe = db.GetDataTable(query); // The results can be directly applied to a DataGridView control //recipeDataGrid.DataSource = recipe; /* * // Or looped through for some other reason * foreach (DataRow r in recipe.Rows) * { * MessageBox.Show(r["Name"].ToString()); * MessageBox.Show(r["Description"].ToString()); * MessageBox.Show(r["Prep Time"].ToString()); * MessageBox.Show(r["Cooking Time"].ToString()); * } * */ } catch (Exception fail) { String error = "The following error has occurred:\n\n"; error += fail.Message.ToString() + "\n\n"; MessageBox.Show(error); this.Close(); } }
private void bt_add_Click(object sender, EventArgs e) { AjoutException addIgnore = new AjoutException(); addIgnore.ShowDialog(); this.exceptions = db.GetDataTable(query); }
public itempage1() { InitializeComponent(); try { var db = new SQLiteDatabase(); DataTable recipe; String query = "select ID \"id\", NAME \"Description\","; query += "CLIP \"Text\""; query += "from CLIPBOARD;"; recipe = db.GetDataTable(query); // The/ results can be directly applied to a DataGridView control //dataGrid.DataContext = recipe; /* // Or looped through for some other reason foreach (DataRow r in recipe.Rows) { MessageBox.Show(r["Name"].ToString()); MessageBox.Show(r["Description"].ToString()); MessageBox.Show(r["Prep Time"].ToString()); MessageBox.Show(r["Cooking Time"].ToString()); } */ } catch (Exception fail) { String error = "The following error has occurred:\n\n"; error += fail.Message.ToString() + "\n\n"; MessageBox.Show(error); this.Close(); } }
public static bool EmployeeExists(string employeeID, SQLiteDatabase sql) { // notify user if card wasn't found if (sql.GetDataTable("select * from employees where employeeID=" + employeeID.Trim() + ";").Rows.Count == 1) return true; else return false; }
private static void KartInfoTest() { DataTable data = _database.GetDataTable(string.Format("SELECT Kart, RacerName, MIN(BestLap) AS BestLap, AVG(BestLap) AS AvgLap, DateTime FROM Races INNER JOIN Racers ON Races.CustId = Racers.Id GROUP BY Kart WHERE;", DateTime.Now.Subtract(TimeSpan.FromDays(7)).ToString("G"))); foreach (DataRow row in data.Rows) { Console.WriteLine("Kart - {0} || {1} || {2} || {3} || {4}", row["Kart"], row["RacerName"], row["BestLap"], row["AvgLap"], row["DateTime"]); } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { string sql = "select * from userInfo order by id desc limit 200"; SQLiteDatabase db = new SQLiteDatabase(); var datatable = db.GetDataTable(sql); rptUserInfo.DataSource = datatable; rptUserInfo.DataBind(); } }
public Form1(int selectedMail, int action) { InitializeComponent(); // action: // 0 = new mail // 1 = reply // 2 = forward // 3 = send public key string selectedSender = "unknown"; string selectedSubject = "unknown"; string selectedBody = "unknown"; if (action == 1 || action == 2) { SQLiteDatabase db = new SQLiteDatabase(); DataTable Mail; String query = "select Sender \"Sender\", Subject \"Subject\","; query += "Body \"Body\", Timestamp \"Timestamp\""; query += "from Mails "; query += "where ID = " + selectedMail + ";"; Mail = db.GetDataTable(query); foreach (DataRow r in Mail.Rows) { selectedSender = r["Sender"].ToString(); selectedSubject = r["Subject"].ToString(); selectedBody = r["Body"].ToString(); } } switch (action) { case 1: // Reply textBoxTo.Text = selectedSender; textBoxSub.Text = "RE: " + selectedSubject; break; case 2: // Forward textBoxTo.Text = ""; textBoxSub.Text = "FW: " + selectedSubject; break; case 3: textBoxSub.Text = "My public key"; textBoxBody.Text = Properties.Settings.Default.RSAPublic; textBoxPublicKey.Visible = false; label1.Visible = false; checkBoxEncrypt.Visible = false; checkBoxRSA.Visible = false; break; default: textBoxTo.Text = ""; textBoxSub.Text = ""; break; } }
static public bool EmployeeExists(string employeeID, SQLiteDatabase sql) { // notify user if card wasn't found if (sql.GetDataTable("select * from employees where employeeID=" + employeeID.Trim() + ";").Rows.Count == 1) { return(true); } else { return(false); } }
private void loadConfig() { db = new SQLiteDatabase(Setting.sqlite_dbname); _appconf = new appConfig(); DataTable dconfig = db.GetDataTable("select companyname,address,telephone,province,taxid,taxrate from configuration"); DataTable dsale = db.GetDataTable("select formtype,billlock,saleprice,costprice,gp,autopurch,docno,customer from saleconfig"); DataTable ditem = db.GetDataTable("select iscost,ismin,islowcost,ispricechange from itemconfig"); if (ditem.Rows.Count > 0) { _appconf.iscost = Convert.ToInt16(ditem.Rows[0]["iscost"]); _appconf.ismin = Convert.ToInt16(ditem.Rows[0]["ismin"]); _appconf.islowcost = Convert.ToInt16(ditem.Rows[0]["islowcost"]); _appconf.ispricechange = Convert.ToInt16(ditem.Rows[0]["ispricechange"]); } if (dsale.Rows.Count > 0) { _appconf.formtype = dsale.Rows[0]["formtype"].ToString(); _appconf.billlock = Convert.ToInt16(dsale.Rows[0]["billlock"]); _appconf.saleprice = Convert.ToInt16(dsale.Rows[0]["saleprice"]); _appconf.costprice = Convert.ToInt16(dsale.Rows[0]["costprice"]); _appconf.gp = Convert.ToInt16(dsale.Rows[0]["gp"]); _appconf.autopurch = Convert.ToInt16(dsale.Rows[0]["autopurch"]); _appconf.defdocno = dsale.Rows[0]["docno"].ToString(); _appconf.defcustomer = dsale.Rows[0]["customer"].ToString(); } if (dconfig.Rows.Count > 0) { _appconf.companyname = dconfig.Rows[0]["companyname"].ToString(); _appconf.address = dconfig.Rows[0]["address"].ToString(); _appconf.telephone = dconfig.Rows[0]["telephone"].ToString(); _appconf.province = dconfig.Rows[0]["province"].ToString(); _appconf.taxid = dconfig.Rows[0]["taxid"].ToString(); _appconf.taxrate = dconfig.Rows[0]["taxrate"].ToString(); } //vGridControl1.DataSource = dconfig; //vGridControl2.DataSource = dsale; //vGridControl3.DataSource = ditem; }
static void TestSQLite() { var table = CreateTestTable(); SQLiteDatabase db = new SQLiteDatabase("MYDB"); db.CreateTable("MYTABLE", table); var table2 = db.InspectDatabase(); var table3 = db.GetDataTable("MYTABLE"); var obj = CreateTestArray(); var table4 = ExcelFriendlyConversion.ConvertObjectArrayToDataTable("MYTABLE4", obj); PrintTableInfoToConsole(table4); db.CreateTable("MYTABLE4", table4); var table5 = db.GetDataTable("MYTABLE4"); PrintTableInfoToConsole(table5); Console.WriteLine("Database created .."); }
private static void RetrieveAndDisplayData(SQLiteDatabase db) { var results = db.GetDataTable("SELECT * From Log"); //TODO: Use generics instead. Please don't go out there kicking a cute puppy because of this code :( foreach (DataRow item in results.Rows) { Console.WriteLine("Level: {0} - Location: {1} - Date and Time: {2}", item["Level"].ToString().ToUpper(), item["Location"], item["TimeStamp"]); Console.WriteLine("Message: \n{0} \n", item["Message"]); } Console.ReadLine(); }
private int GetParticipantId(string identification) { SQLiteDatabase db = new SQLiteDatabase(); DataTable participanTable = db.GetDataTable(string.Format(Constants.SqlParticipantId, identification)); if (participanTable != null && participanTable.Rows.Count > 0) { return(int.Parse(participanTable.Rows[0]["participant_id"].ToString())); } return(0); }
private void initDataRow() { db = new SQLiteDatabase(sqlite_dbname); dconfig = db.GetDataTable("select companyname,address,telephone,province,taxid,taxrate from configuration"); dsale = db.GetDataTable("select formtype,billlock,saleprice,costprice,gp,autopurch,docno,customer from saleconfig"); ditem = db.GetDataTable("select iscost,ismin,islowcost,ispricechange from itemconfig"); if (ditem.Rows.Count > 0) { vGridControl3.Rows["editorRow6"].Properties.Value = Convert.ToInt16(ditem.Rows[0]["iscost"]) == 1 ? "เตือน" : "ไม่เตือน"; vGridControl3.Rows["editorRow7"].Properties.Value = Convert.ToInt16(ditem.Rows[0]["ismin"]) == 1? "เตือน" : "ไม่เตือน"; vGridControl3.Rows["editorRow8"].Properties.Value = Convert.ToInt16(ditem.Rows[0]["islowcost"]) == 1?"เตือน" : "ไม่เตือน"; vGridControl3.Rows["editorRow9"].Properties.Value = Convert.ToInt16(ditem.Rows[0]["ispricechange"]) == 1?"เตือน" : "ไม่เตือน"; } if (dsale.Rows.Count > 0) { vGridControl2.Rows["editorRow1"].Properties.Value = dsale.Rows[0]["formtype"].ToString(); vGridControl2.Rows["editorRow2"].Properties.Value = dsale.Rows[0]["billlock"].ToString() == "1"?"ทำงาน":"ไม่ทำงาน"; vGridControl2.Rows["editorRow3"].Properties.Value = dsale.Rows[0]["saleprice"].ToString(); vGridControl2.Rows["editorRow4"].Properties.Value = dsale.Rows[0]["costprice"].ToString(); vGridControl2.Rows["editorRow5"].Properties.Value = dsale.Rows[0]["gp"].ToString(); vGridControl2.Rows["row5"].Properties.Value = dsale.Rows[0]["autopurch"].ToString() == "1" ? "ทำงาน" : "ไม่ทำงาน"; vGridControl2.Rows["row7"].Properties.Value = dsale.Rows[0]["docno"].ToString(); vGridControl2.Rows["row8"].Properties.Value = dsale.Rows[0]["customer"].ToString(); } if (dconfig.Rows.Count > 0) { vGridControl1.Rows["row"].Properties.Value = dconfig.Rows[0]["companyname"].ToString(); vGridControl1.Rows["row1"].Properties.Value = dconfig.Rows[0]["address"].ToString(); vGridControl1.Rows["row2"].Properties.Value = dconfig.Rows[0]["telephone"].ToString(); vGridControl1.Rows["row3"].Properties.Value = dconfig.Rows[0]["province"].ToString(); vGridControl1.Rows["row4"].Properties.Value = dconfig.Rows[0]["taxid"].ToString(); vGridControl1.Rows["row6"].Properties.Value = dconfig.Rows[0]["taxrate"].ToString(); } //vGridControl1.DataSource = dconfig; //vGridControl2.DataSource = dsale; //vGridControl3.DataSource = ditem; }
/// <summary>Updates the live box score data grid.</summary> /// <param name="teamID">Name of the team.</param> /// <param name="playersList">The players list.</param> /// <param name="pbsList">The player box score list.</param> /// <param name="playersT">The players' SQLite table name.</param> /// <param name="loading"> /// if set to <c>true</c>, it is assumed that a pre-existing box score is being loaded. /// </param> private static void updateLiveBoxScoreDataGrid( int teamID, out ObservableCollection <KeyValuePair <int, string> > playersList, ref SortableBindingList <LivePlayerBoxScore> pbsList, string playersT, bool loading) { var db = new SQLiteDatabase(MainWindow.CurrentDB); var q = "select * from " + playersT + " where TeamFin = \"" + teamID + "\""; q += " ORDER BY LastName ASC"; var res = db.GetDataTable(q); playersList = new ObservableCollection <KeyValuePair <int, string> >(); if (!loading) { pbsList = new SortableBindingList <LivePlayerBoxScore>(); } foreach (DataRow r in res.Rows) { var ps = new PlayerStats(r, MainWindow.TST); playersList.Add(new KeyValuePair <int, string>(ps.ID, ps.LastName + ", " + ps.FirstName)); } for (var i = 0; i < pbsList.Count; i++) { var cur = pbsList[i]; var name = MainWindow.PST[cur.PlayerID].LastName + ", " + MainWindow.PST[cur.PlayerID].FirstName; var player = new KeyValuePair <int, string>(cur.PlayerID, name); cur.Name = name; if (!playersList.Contains(player)) { playersList.Add(player); } pbsList[i] = cur; } playersList = new ObservableCollection <KeyValuePair <int, string> >(playersList.OrderBy(item => item.Value)); if (!loading) { foreach (var p in playersList) { pbsList.Add(new LivePlayerBoxScore { PlayerID = p.Key }); } } }
public Form1(int selectedMail, int action) { InitializeComponent(); // Actions: // 0 = new mail // 1 = reply // 2 = forward string selectedSender = "unknown"; string selectedSubject = "unknown"; string selectedBody = "unknown"; if (action == 1 || action == 2) { SQLiteDatabase db = new SQLiteDatabase(); DataTable Mail; String query = "select Sender \"Sender\", Subject \"Subject\","; query += "Body \"Body\", Timestamp \"Timestamp\""; query += "from Mails "; query += "where ID = " + selectedMail + ";"; Mail = db.GetDataTable(query); foreach (DataRow r in Mail.Rows) { selectedSender = r["Sender"].ToString(); selectedSubject = r["Subject"].ToString(); selectedBody = r["Body"].ToString(); } } switch (action) { case 1: // Reply textBoxTo.Text = selectedSender; textBoxSub.Text = "RE: " + selectedSubject; break; case 2: // Forward textBoxTo.Text = ""; textBoxSub.Text = "FW: " + selectedSubject; break; default: textBoxTo.Text = ""; textBoxFrom.Text = ""; textBoxSub.Text = ""; break; } //MessageBox.Show(selectedMail.ToString() + " - " + action.ToString()); }
private void FillListView() { SQLiteDatabase db = new SQLiteDatabase(); DataTable dt = db.GetDataTable("select * from prestasi_slta"); list_prestasi.Items.Clear(); for (int i = 0; i < dt.Rows.Count; i++) { DataRow dr = dt.Rows[i]; ListViewItem listitem = new ListViewItem(dr["NAMA_KEGIATAN"].ToString()); listitem.SubItems.Add(dr["JENIS"].ToString()); listitem.SubItems.Add(dr["TINGKAT"].ToString()); listitem.SubItems.Add(dr["TAHUN"].ToString()); listitem.SubItems.Add(dr["PENCAPAIAN"].ToString()); list_prestasi.Items.Add(listitem); } }
private void LoadButton_Click(object sender, EventArgs e) { if (TextBoxCardID.Text != "") { try { if (Helper.EmployeeExists(TextBoxCardID.Text, sql)) { //Disable UIs TextBoxCardID.Enabled = false; LoadButton.Enabled = false; dt = sql.GetDataTable("select id, dayOfWeek as Day, clockIn, clockOut from avgHours where employeeId=" + TextBoxCardID.Text + " order by dayOfWeek asc;"); if (dt.Rows.Count > 0) { AvgHoursGridView.DataSource = dt; AvgHoursGridView.ClearSelection(); AvgHoursGridView.Columns[0].Visible = false; // hide id column, used to determine which entry to update/remove foreach (DataGridViewColumn column in AvgHoursGridView.Columns) { column.SortMode = DataGridViewColumnSortMode.NotSortable; } AvgHoursGridView.RowStateChanged += new System.Windows.Forms.DataGridViewRowStateChangedEventHandler(AvgHoursGridView_RowStateChanged); } else { MessageBox.Show("No entries were found for this ID,\n use the fields below to add one.", "No entries found!", MessageBoxButtons.OK, MessageBoxIcon.Information); } SetAddButton(); } else { throw new ArgumentException("The ID you entered does not exist, please make sure ID was entered correctly."); } } catch (Exception err) { MessageBox.Show(err.Message, "An Error occured!", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }
private void GererException_Load(object sender, EventArgs e) { try { db = new SQLiteDatabase(); query = "SELECT equipe1_id, equipe2_id, e1.nom as nom1, e2.nom as nom2 FROM exception" + " LEFT JOIN equipe e1 ON equipe1_id = e1.id" + " LEFT JOIN equipe e2 ON equipe2_id = e2.id"; exceptions = db.GetDataTable(query); dataGridView1.DataSource = exceptions; dataGridView1.Columns[0].Visible = false; dataGridView1.Columns[1].Visible = false; dataGridView1.Columns[2].HeaderText = "Equipe 1"; dataGridView1.Columns[3].HeaderText = "Equipe 2"; } catch (Exception ex) { MessageBox.Show(ex.Message); } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { int id = 0; if (Request["id"] != null) { int.TryParse(Request["id"], out id); if (id > 0) { string sql = "select * from usercookie where infoId=" + id + " limit 200"; SQLiteDatabase db = new SQLiteDatabase(); var datatable = db.GetDataTable(sql); rptCookieInfo.DataSource = datatable; rptCookieInfo.DataBind(); } } } }
private void ButtonRemove_Click(object sender, EventArgs e) { // vars bool found = false; dt = sql.GetDataTable("select * from employees where employeeID=" + TextBoxCardID.Text.Trim() + ";"); // check if this is the card we're looking for if (dt.Rows.Count == 1) { // mark as found found = true; // confirm deletion of card if (MessageBox.Show(this, "Are you sure you want to delete " + dt.Rows[0].ItemArray[1].ToString() + "'s card?\n(Card/Student ID: " + dt.Rows[0].ItemArray[0].ToString() + ")", "Confirm Card Deletion", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation) == DialogResult.Yes) { // write to file try { sql.Delete("employees", String.Format("employeeID = {0}", dt.Rows[0].ItemArray[0].ToString())); if (CheckBoxDelTimeLog.Checked == true) { sql.Delete("timeStamps", String.Format("employeeID = {0}", dt.Rows[0].ItemArray[0].ToString())); } } catch (Exception err) { MessageBox.Show(this, "There was an error while trying to remove the card.\n\n" + err.Message, "File Deletion Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } // notify user if card wasn't found if (!found) { MessageBox.Show(this, "The card you entered wasn't found. Are you sure you typed it in correctly?", "Card Not Found!", MessageBoxButtons.OK, MessageBoxIcon.Error); } // reset text box TextBoxCardID.Clear(); TextBoxCardID.Focus(); }
private void FillListView() { SQLiteDatabase db = new SQLiteDatabase(); DataTable dt = db.GetDataTable("select * from nilai_unas_slta"); list_unas.Items.Clear(); for (int i = 0; i < dt.Rows.Count; i++) { DataRow dr = dt.Rows[i]; ListViewItem listitem = new ListViewItem(dr["TAHUN_AJARAN"].ToString()); listitem.SubItems.Add(dr["NILAI_IPA"].ToString()); listitem.SubItems.Add(dr["JUMLAH_MAPEL_IPA"].ToString()); listitem.SubItems.Add(dr["NILAI_IPS"].ToString()); listitem.SubItems.Add(dr["JUMLAH_MAPEL_IPS"].ToString()); listitem.SubItems.Add(dr["NILAI_BAHASA"].ToString()); listitem.SubItems.Add(dr["JUMLAH_MAPEL_BAHASA"].ToString()); listitem.SubItems.Add(dr["NILAI_SMK"].ToString()); listitem.SubItems.Add(dr["JUMLAH_MAPEL_SMK"].ToString()); list_unas.Items.Add(listitem); } }
internal IList <Question> GetQuestions() { SQLiteDatabase db = new SQLiteDatabase(); DataTable questionsTable = db.GetDataTable(Constants.SqlQuestions); IList <Question> questions = new List <Question>(); if (questionsTable != null && questionsTable.Rows.Count > 0) { Question question; foreach (DataRow row in questionsTable.Rows) { question = new Question(); question.Answer = row["answer"].ToString() == "1"; question.Description = row["question"].ToString(); question.Number = int.Parse(row["number"].ToString()); question.QuestionId = int.Parse(row["question_id"].ToString()); questions.Add(question); } } return(questions); }
// Here is the deal - // User asks "what files/folders are in /test" // Using a MPTT or adjacency list will not answer that question // Those store tree data - but would require resolving ALL paths in the tree to find the folder // Obviously we could store the full path as a lookup like I do - but then what would // MPTT or AL get me? // Nothing. // Folders will also be stored as entities // so that we can just query the entities table to determine what files/folders there are // If a user requests what entities are in /test - we can easily look that up by querying directories // table then query entities with dir = directory ID // But what if a user requests a full dump of all files? // It would resolve as a GetEntities("/") then GetEntities("/test") etc // Src: https://stackoverflow.com/questions/6802539/hierarchical-tree-database-for-directories-path-in-filesystem public ICollection <FileSystemPath> GetEntities(FileSystemPath path) { DataTable dir = db.GetDataTable("SELECT * FROM directories WHERE fullpath = @path", new Dictionary <string, object>() { { "@path", path.Path } }); DataTable res = db.GetDataTable("SELECT * FROM entities WHERE dir = @dir", new Dictionary <string, object>() { { "@dir", dir.Rows[0]["id"].ToString() } }); List <FileSystemPath> files = new List <FileSystemPath>(); //files.Add(FileSystemPath.Parse("/test.txt")); foreach (DataRow r in res.Rows) { FileSystemPath p = FileSystemPath.Parse(path.Path + r["fname"].ToString()); files.Add(p); } return(files); }
/// <summary> /// Initializes a new instance of the <see cref="DualListWindow" /> class. Used to enable/disable players/teams for the season. /// </summary> /// <param name="currentDB">The current DB.</param> /// <param name="curSeason">The cur season.</param> /// <param name="maxSeason">The max season.</param> /// <param name="mode">The mode.</param> public DualListWindow(string currentDB, int curSeason, int maxSeason, Mode mode) : this() { _mode = mode; _currentDB = currentDB; _curSeason = curSeason; _maxSeason = maxSeason; txbDescription.Text = "Current Season: " + _curSeason + "/" + _maxSeason; var db = new SQLiteDatabase(_currentDB); var teamsT = "Teams"; _playersT = "Players"; if (_curSeason != _maxSeason) { var s = "S" + _curSeason; teamsT += s; _playersT += s; } if (mode == Mode.HiddenTeams) { var q = "select DisplayName, isHidden from " + teamsT + " ORDER BY DisplayName ASC"; var res = db.GetDataTable(q); foreach (DataRow r in res.Rows) { if (!ParseCell.GetBoolean(r, "isHidden")) { lstEnabled.Items.Add(ParseCell.GetString(r, "DisplayName")); } else { lstDisabled.Items.Add(ParseCell.GetString(r, "DisplayName")); } } btnLoadList.Visibility = Visibility.Hidden; } else if (mode == Mode.HiddenPlayers) { Title = "Enable/Disable Players for Season"; lblEnabled.Content = "Enabled Players"; lblDisabled.Content = "Disabled Players"; var q = "SELECT (LastName || ', ' || FirstName || ' (' || TeamFin || ')') AS Name, ID, isHidden FROM " + _playersT + " ORDER BY LastName"; var res = db.GetDataTable(q); foreach (DataRow r in res.Rows) { var s = ParseCell.GetString(r, "Name"); if (!ParseCell.GetBoolean(r, "isHidden")) { _shownPlayers.Add(new KeyValuePair <int, string>(ParseCell.GetInt32(r, "ID"), s)); } else { _hiddenPlayers.Add(new KeyValuePair <int, string>(ParseCell.GetInt32(r, "ID"), s)); } } _shownPlayers.RaiseListChangedEvents = true; lstEnabled.DisplayMemberPath = "Value"; lstEnabled.SelectedValuePath = "Key"; lstEnabled.ItemsSource = _shownPlayers; _hiddenPlayers.RaiseListChangedEvents = true; lstDisabled.DisplayMemberPath = "Value"; lstDisabled.SelectedValuePath = "Key"; lstDisabled.ItemsSource = _hiddenPlayers; btnLoadList.Visibility = Visibility.Hidden; } }
//for migration purposes only. delete. public List<TicketResource> GetAllTickets() { SQLiteDatabase db = new SQLiteDatabase(); string sql = "select * from Tickets"; DataTable result = db.GetDataTable(sql); List<TicketResource> ticketResources = new List<TicketResource>(); foreach (DataRow row in result.Rows) { //just do an insert here instead TicketResource ticketRes = ConvertDataRowToTicketResource(row); InsertNewTicket(ticketRes); ticketResources.Add(ticketRes); } return ticketResources; }
private void NouvelleEquipe_Load(object sender, EventArgs e) { db = new SQLiteDatabase(); try { db = new SQLiteDatabase(); String query = ""; if (this.id_equipe != 0) { query = "select nom from equipe where id = " + this.id_equipe; String teamName = db.ExecuteScalar(query); tb_nom.Text = teamName; query = "select capitaine_id from equipe where id = " + this.id_equipe; capitaineId = Int32.Parse(db.ExecuteScalar(query)); } query = "select * FROM personne WHERE equipe_id is null or equipe_id = 0"; if (this.id_equipe != 0) { query += " or equipe_id = " + this.id_equipe; } personnes = db.GetDataTable(query); DataColumn inTeam = new DataColumn("Selection", typeof(Boolean)); personnes.Columns.Add(inTeam); DataColumn isCap = new DataColumn("Capitaine", typeof(Boolean)); personnes.Columns.Add(isCap); foreach (DataRow r in personnes.Rows) { if (r["equipe_id"] != System.DBNull.Value) { r["Selection"] = 1; playerCount++; } else { r["Selection"] = 0; } if (Int32.Parse(r["id"].ToString()) == capitaineId) { r["Capitaine"] = 1; } else { r["Capitaine"] = 0; } } dataGridView1.DataSource = personnes; dataGridView1.Columns[0].Width = 30; dataGridView1.Columns[3].Visible = false; dataGridView1.Columns[4].Visible = false; for (int i = 0; i < 5; i++) { dataGridView1.Columns[i].ReadOnly = true; } } catch (Exception fail) { String error = "The following error has occurred:\n\n"; error += fail.Message.ToString() + "\n\n"; MessageBox.Show(error); this.Close(); } }
void LoadedEventHandler(object sender, RoutedEventArgs e) { Logger.MonitoringLogger.Debug("Login window loaded event"); LoadFromConfigurationFile(); try { Logger.MonitoringLogger.Info("Populate profile list with information from the database"); db = new SQLiteDatabase(); DataTable resultQuery; String query = "select * FROM profileList;"; resultQuery = db.GetDataTable(query); // Loop over all data foreach (DataRow r in resultQuery.Rows) { ServerProfile serverProfile = new ServerProfile(r["profilName"].ToString(), r["hostname"].ToString(), Int32.Parse(r["port"].ToString()), r["password"].ToString(), Boolean.Parse(r["autoReconnect"].ToString())); loginDataView.ServersProfiles.Add(serverProfile); Logger.MonitoringLogger.Info(r.ToString()); } } catch (Exception databaseException) { MessageDialog.ShowAsync( "Erreur de lecture de la base de donnée", "Erreur de lecture de la base de donnée ! Informations de debug :\n" + databaseException.ToString(), MessageBoxButton.OK, MessageDialogType.Light, this); } NotifyBox.Show( (DrawingImage)this.FindResource("SearchDrawingImage"), "Astuce", "Un clic droit permet d'ouvrir le menu application !", false); Logger.MonitoringLogger.Debug(WINDOW_NAME + " loaded function ended"); }
static void DumpSqlite(string filename) { Serializer s = new Serializer(); try { var db = new SQLiteDatabase(filename); List <String> tableList = db.GetTables(); List<SerializableDictionary<string, string>> dictList = new List<SerializableDictionary<string, string>>(); foreach (string table in tableList) { String query = string.Format("select * from {0};", table); DataTable recipe = db.GetDataTable(query); foreach (DataRow r in recipe.Rows) { SerializableDictionary<string, string> item = new SerializableDictionary<string, string>(); foreach (DataColumn c in recipe.Columns) { item[c.ToString()] = r[c.ToString()].ToString(); } dictList.Add(item); } s.Serialize(string.Format("{0}.xml", table), dictList, table); dictList.Clear(); } } catch (Exception fail) { String error = "The following error has occurred:\n\n"; error += fail.Message + "\n\n"; } }
public void Run() { string[] arguments = Environment.GetCommandLineArgs(); string key; SettingsData data; if (File.Exists("settings.xml")) { data = SettingsFile.Read("settings.xml"); } else { Console.WriteLine("Can't find settings.xml file - attempting to generate one"); data = GenerateSettings(); SettingsFile.Write(data, "settings.xml"); } if (arguments.Length > 1 && arguments[1] == "fuse") { try { Fuse.LazyUnmount(arguments[2]); key = AESWrapper.GenerateKeyString(ConsoleEx.Password("Key: "), data.salt, data.iterations, data.keySize); using (var mount = Fuse.Mount(arguments[2], new DeDupeFuseFileSystem(key, data))) { Task t = mount.WaitForUnmountAsync(); t.Wait(); } } catch (FuseException fe) { Console.WriteLine($"Fuse throw an exception: {fe}"); Console.WriteLine("Try unmounting the file system by executing:"); Console.WriteLine($"fuser -kM {arguments[2]}"); Console.WriteLine($"sudo umount -f {arguments[2]}"); } } else { string input = ""; FileSystemPath currentDirectory = FileSystemPath.Parse("/"); string[] Scopes = { DriveService.Scope.Drive, DriveService.Scope.DriveFile }; if (arguments.Length > 1) { key = AESWrapper.GenerateKeyString(arguments[1], data.salt, data.iterations, data.keySize); } else { key = AESWrapper.GenerateKeyString(ConsoleEx.Password("Key: "), data.salt, data.iterations, data.keySize); } using (EncryptedTempFile dbfile = new EncryptedTempFile("data.sqlite.enc", key)) { SQLiteDatabase db = new SQLiteDatabase(dbfile.Path); var res = db.GetDataTable("PRAGMA table_info(settings)"); if (res.Rows.Count == 0) { this.setUpDatabase(db); } this.runMigrations(db); dbfile.Flush(); //GDriveFileSystem gdrive = new GDriveFileSystem(Scopes, "DistrubtedDeDupe", dbfile.Path); Log.Instance.Write("log.txt"); DeDupeFileSystem fs = new DeDupeFileSystem(dbfile.Path, key); foreach (KeyValuePair <string, string> kv in data.locations) { fs.AddFileSystem(new DeDupeLocalFileSystem(kv.Value, kv.Key)); } //fs.AddFileSystem(gdrive); string fileName; byte[] fileData; do { if (currentDirectory.Path == "/") { Console.Write($"#:{currentDirectory.Path}> "); } else { Console.Write($"#:{currentDirectory.Path.TrimEnd('/')}> "); } if (arguments.Length > 1) { input = arguments[2]; } else { input = Console.ReadLine(); } switch (input.Split(" ")[0]) { case "stats": long entitySpaceUsed = long.Parse(db.ExecuteScalar("SELECT SUM(size) FROM entities")); long blockSpaceUsed = long.Parse(db.ExecuteScalar("SELECT SUM(size) FROM blocks")); long chunks = long.Parse(db.ExecuteScalar("SELECT count(id) from blocks")); long diffSpace = entitySpaceUsed - blockSpaceUsed; Console.WriteLine($"Space used for entites => {entitySpaceUsed.GetBytesReadable()}"); Console.WriteLine($"Space used for blocks => {blockSpaceUsed.GetBytesReadable()}"); Console.WriteLine($"Space saved => {diffSpace.GetBytesReadable()}"); Console.WriteLine($"Blocks used => {chunks}"); break; case "addstorage": string location = input.Split(" ")[1].Trim(); string name = input.Split(" ")[2].Trim(); data.locations[name] = Path.GetFullPath(location); fs.AddFileSystem(new DeDupeLocalFileSystem(Path.GetFullPath(location), name)); SettingsFile.Write(data, "settings.xml"); break; case "decryptdb": fileName = input.Split(" ")[1].Trim(); //byte[] plain = AESWrapper.DecryptToByte(System.IO.File.ReadAllBytes(dbfile.Path), key); System.IO.File.WriteAllBytes(fileName, System.IO.File.ReadAllBytes(dbfile.Path)); break; case "help": ShowHelp(); break; case "changekey": key = AESWrapper.GenerateKeyString(ConsoleEx.Password("Key: "), data.salt, data.iterations, data.keySize); fs.UpdateKey(key); break; case "generate": data = GenerateSettings(); if (data != null) { SettingsFile.Write(data, "settings.xml"); key = AESWrapper.GenerateKeyString(ConsoleEx.Password("Key: "), data.salt, data.iterations, data.keySize); fs.UpdateKey(key); } break; case "showsettings": Console.WriteLine($"Iterations = {data.iterations}"); Console.WriteLine($"Salt = {data.salt}"); Console.WriteLine($"Key size = {data.keySize}"); foreach (var kv in data.locations) { Console.WriteLine($"{kv.Key} = {kv.Value}"); } break; case "ls": Console.WriteLine( VirtualDirectoryListing.List(fs.GetExtendedEntities(currentDirectory))); break; case "ll": Console.WriteLine( VirtualDirectoryListing.ListWithHash(fs.GetExtendedEntities(currentDirectory))); break; case "put": if (data.locations.Count == 0) { Console.WriteLine("[Error]: No file locations setup"); break; } fileName = input.Split(" ")[1].Trim(); byte[] fileDataPut = System.IO.File.ReadAllBytes(fileName); //string encFile = AESWrapper.EncryptToString(fileData, key); Stopwatch watch1 = new Stopwatch(); watch1.Start(); using (Stream f = fs.CreateFile(FileSystemPath.Parse(currentDirectory.Path + fileName))) { f.Write(fileDataPut, 0, fileDataPut.Length); } fs.FlushTempFile(); dbfile.Flush(); watch1.Stop(); Console.WriteLine($"Elapsed time: {watch1.Elapsed.ToString("g")}"); break; case "localcat": if (data.locations.Count == 0) { Console.WriteLine("[Error]: No file locations setup"); break; } fileName = input.Split(" ")[1].Trim(); fileData = System.IO.File.ReadAllBytes(fileName); Console.WriteLine(AESWrapper.DecryptToString(fileData, key)); break; case "remotecat": if (data.locations.Count == 0) { Console.WriteLine("[Error]: No file locations setup"); break; } fileName = input.Split(" ")[1].Trim(); try { using (Stream f = fs.OpenFile( FileSystemPath.Parse(currentDirectory.Path + fileName), FileAccess.Read)) { Console.WriteLine(f.ReadAllText()); } } catch (Exception e) { Console.WriteLine("[Error]: " + e.ToString()); } break; case "get": if (data.locations.Count == 0) { Console.WriteLine("[Error]: No file locations setup"); break; } fileName = input.Split(" ")[1].Trim(); string dstFileName = input.Split(" ")[2].Trim(); Stopwatch watch2 = new Stopwatch(); watch2.Start(); using (Stream f = fs.OpenFile(FileSystemPath.Parse(currentDirectory.Path + fileName), FileAccess.Read)) { byte[] test = f.ReadAllBytes(); System.IO.File.WriteAllBytes(dstFileName, test); } watch2.Stop(); Console.WriteLine($"Elapsed time: {watch2.Elapsed.ToString("g")}"); break; case "mkdir": string newDir = input.Split(" ")[1].Trim(); fs.CreateDirectory(currentDirectory.AppendDirectory(newDir)); dbfile.Flush(); break; case "cd": string dirtmpStr; //dirtmp = currentDirectory.AppendDirectory(input.Split(" ")[1]); dirtmpStr = ParseDotDot(currentDirectory.Path, input.Split(" ")[1]); FileSystemPath dirtmp; if (dirtmpStr == "/") { dirtmp = FileSystemPath.Parse(dirtmpStr); } else { dirtmp = FileSystemPath.Parse(dirtmpStr + "/"); } if (fs.Exists(dirtmp)) { //currentDirectory = currentDirectory.AppendDirectory(input.Split(" ")[1]); currentDirectory = dirtmp; } else { Console.WriteLine("No such directory exists"); } break; } if (arguments.Length > 1) { break; } } while (input != "exit" && input != "quit"); dbfile.Flush(); } } }
static void Main(string[] args) { string tmpdbpath = args[0]; string tmpluapath = args[1]; if (File.Exists(tmpdbpath) == false) { Console.WriteLine("not found " + tmpdbpath); Console.ReadKey(); } SQLiteDatabase db = new SQLiteDatabase(tmpdbpath); DataTable recipe; String query = "SELECT name FROM sqlite_master " + "WHERE type = 'table'" + "ORDER BY 1"; recipe = db.GetDataTable(query); ArrayList list = new ArrayList(); foreach (DataRow row in recipe.Rows) { list.Add(row.ItemArray[0].ToString()); } string tmpExportLuaDirName = tmpluapath; if (Directory.Exists(tmpExportLuaDirName) == false) { Directory.CreateDirectory(tmpExportLuaDirName); } //foreach (var item in list) for (int tableIndex = 0; tableIndex < list.Count; tableIndex++) { Console.WriteLine(tableIndex + "/" + list.Count + " : " + list[tableIndex]); DataTable tmpDataTable = db.GetDataTable("select * from " + list[tableIndex]); StreamWriter tmpStreamWrite = new StreamWriter(tmpExportLuaDirName + "/" + tmpDataTable.TableName + ".lua"); tmpStreamWrite.WriteLine(tmpDataTable.TableName + "="); tmpStreamWrite.WriteLine("{"); foreach (var tableRow in tmpDataTable.Rows) { string tmpOneTableStr = " {"; DataRow tmpRow = tableRow as DataRow; for (int i = 0; i < tmpRow.ItemArray.Length; i++) { if (i != 0) { tmpOneTableStr = tmpOneTableStr + ","; } if (tmpDataTable.Columns[i].DataType.Name == "String") { tmpOneTableStr = tmpOneTableStr + tmpDataTable.Columns[i].ColumnName + "=\"" + tmpRow.ItemArray[i] + "\""; } else { tmpOneTableStr = tmpOneTableStr + tmpDataTable.Columns[i].ColumnName + "=" + tmpRow.ItemArray[i]; } } tmpOneTableStr = tmpOneTableStr + "},"; tmpStreamWrite.WriteLine(tmpOneTableStr); } tmpStreamWrite.WriteLine("}"); tmpStreamWrite.WriteLine("return " + tmpDataTable.TableName); tmpStreamWrite.Flush(); tmpStreamWrite.Close(); } Console.WriteLine("Finish"); Console.ReadKey(); }
/// <summary> /// Confirm identity of logging in user /// </summary> /// <param name="n"></param> /// <param name="e"></param> protected void loginconf(Network n, Irc.IrcEventArgs e) { if (IsMatch("^everify (?<nonce>.*?)$", e.Data.Message.Substring(BOT_CONTROL_SEQ.Length))) { string[] temp = Matches["nonce"].Value.Split(':'); string name = temp[0]; SQLiteDatabase db = new SQLiteDatabase(); System.Data.DataTable accounts; String query = "SELECT id \"ID\", name \"NAME\", email \"EMAIL\", gpgkey \"key\", verify \"VERIFY\" FROM accounts;"; accounts = db.GetDataTable(query); bool registered = false; int id = 0; foreach (DataRow account in accounts.Rows) { id++; if (account["NAME"] as string == name) { Answer(n, e, "Name from verify string: " + name); Answer(n, e, "Verify string from db: " + account["VERIFY"].ToString()); Answer(n, e, "Verify string from irc: " + Matches["nonce"].Value); if (account["VERIFY"].ToString().ToLower() == Matches["nonce"].Value.ToLower() + "\n") { User u = new User(); u.nick = e.Data.Nick; u.user = name; u.kid = account["key"] as string; loggedin.Add(u); //LOGIN THE USER AT THE BOT LEVEL SO OTHER PLUGINS CAN SEE Bot.LoginUser(u); //JUST ANOTHER WAY TO REPLY TO THE USER Answer(n, e, e.Data.Nick + ": You are now logged in."); registered = true; } else { Answer(n, e, e.Data.Nick + ": Invalid login."); } } } if (!registered) { Answer(n, e, e.Data.Nick + ": Your not registered."); } } }
private void btnOK_Click(object sender, RoutedEventArgs e) { if (_mode == Mode.HiddenTeams) { var db = new SQLiteDatabase(_currentDB); var teamsT = "Teams"; var plTeamsT = "PlayoffTeams"; var oppT = "Opponents"; var plOppT = "PlayoffOpponents"; if (_curSeason != _maxSeason) { var s = "S" + _curSeason; teamsT += s; plTeamsT += s; oppT += s; plOppT += s; } foreach (string name in lstEnabled.Items) { var dict = new Dictionary <string, string> { { "isHidden", "False" } }; db.Update(teamsT, dict, "DisplayName LIKE \"" + name + "\""); db.Update(plTeamsT, dict, "DisplayName LIKE \"" + name + "\""); db.Update(oppT, dict, "DisplayName LIKE \"" + name + "\""); db.Update(plOppT, dict, "DisplayName LIKE \"" + name + "\""); } foreach (string name in lstDisabled.Items) { var q = "select * from GameResults where SeasonNum = " + _curSeason + " AND (Team1ID = " + getTeamIDFromDisplayName(name) + " OR Team2ID = " + getTeamIDFromDisplayName(name) + ")"; var res = db.GetDataTable(q); if (res.Rows.Count > 0) { var r = MessageBox.Show( name + " have box scores this season. Are you sure you want to disable this team?", "NBA Stats Tracker", MessageBoxButton.YesNo, MessageBoxImage.Question); if (r == MessageBoxResult.No) { continue; } } var dict = new Dictionary <string, string> { { "isHidden", "True" } }; db.Update(teamsT, dict, "DisplayName LIKE \"" + name + "\""); db.Update(plTeamsT, dict, "DisplayName LIKE \"" + name + "\""); db.Update(oppT, dict, "DisplayName LIKE \"" + name + "\""); db.Update(plOppT, dict, "DisplayName LIKE \"" + name + "\""); } MainWindow.AddInfo = "$$TEAMSENABLED"; Close(); } else if (_mode == Mode.HiddenPlayers) { var db = new SQLiteDatabase(_currentDB); var dataList = new List <Dictionary <string, string> >(); var whereList = new List <string>(); foreach (KeyValuePair <int, string> item in lstEnabled.Items) { var dict = new Dictionary <string, string> { { "isHidden", "False" } }; dataList.Add(dict); whereList.Add("ID = " + item.Key); } db.UpdateManyTransaction(_playersT, dataList, whereList); dataList = new List <Dictionary <string, string> >(); whereList = new List <string>(); foreach (KeyValuePair <int, string> item in lstDisabled.Items) { var q = "select * from PlayerResults INNER JOIN GameResults ON GameResults.GameID = PlayerResults.GameID where SeasonNum = " + _curSeason + " AND PlayerID = " + item.Key; var res = db.GetDataTable(q, true); if (res.Rows.Count > 0) { var r = MessageBox.Show( item.Value + " has box scores this season. Are you sure you want to disable them?", "NBA Stats Tracker", MessageBoxButton.YesNo, MessageBoxImage.Question); if (r == MessageBoxResult.No) { continue; } } var dict = new Dictionary <string, string> { { "isHidden", "True" }, { "isActive", "False" }, { "TeamFin", "" } }; dataList.Add(dict); whereList.Add("ID = " + item.Key); } db.UpdateManyTransaction(_playersT, dataList, whereList); MainWindow.AddInfo = "$$PLAYERSENABLED"; Close(); } else if (_mode == Mode.REDitor) { if (lstEnabled.Items.Count != 30) { MessageBox.Show( "You can't have less or more than 30 teams enabled. You currently have " + lstEnabled.Items.Count + "."); return; } //MainWindow.selectedTeams = new List<Dictionary<string, string>>(_activeTeams); MainWindow.SelectedTeams = new List <Dictionary <string, string> >(); foreach (string team in lstEnabled.Items) { var teamName = team.Split(new[] { " (ID: " }, StringSplitOptions.None)[0]; MainWindow.SelectedTeams.Add( _validTeams.Find( delegate(Dictionary <string, string> t) { if (t["Name"] == teamName) { return(true); } return(false); })); } MainWindow.SelectedTeamsChanged = _changed; DialogResult = true; Close(); } else if (_mode == Mode.TradePlayers) { foreach (var pair in _rosters) { var newTeam = pair.Key; foreach (var pID in pair.Value) { var oldTeam = MainWindow.PST[pID].TeamF; var oldTeamS = MainWindow.PST[pID].TeamS; if (newTeam != oldTeam) { if (oldTeamS == -1) { MainWindow.PST[pID].TeamS = MainWindow.PST[pID].TeamF; } MainWindow.PST[pID].TeamF = newTeam; MainWindow.PST[pID].IsSigned = newTeam != -1; } } } DialogResult = true; Close(); } }