/// <summary> /// Получение содержимого таблицы /// в виде DataTable /// </summary> public ComplexValue ReadDataTable(dbTables tblname) { ComplexValue rval = new ComplexValue(); rval.dtable = dbConnector.dirCmd.GetDataTable(tblname); return(rval); }
/// <summary> /// Обновление таблицы в БД. /// </summary> /// <param name="dTable">набор данных</param> /// <param name="tblname">enum нужной таблицы</param> /// <returns></returns> public void UpdateDataTable(DataTable dTable, dbTables tblname) { if (dTable == null) { return; } var stmnt = TableSelector.GetSelectStatement(tblname); if (String.IsNullOrEmpty(stmnt)) { return; } m_sqlCmd.CommandText = stmnt; var dataAdapter = new SQLiteDataAdapter(m_sqlCmd); var commandBuilder = new SQLiteCommandBuilder(dataAdapter); dataAdapter.Update(dTable); }
public static string GetSelectStatement(dbTables tblname) { switch (tblname) { case dbTables.tblParts: return(comSelParts); case dbTables.tblContainers: return(comSelContainers); case dbTables.tblDocuments: return(comSelDocuments); case dbTables.tblParagraphs: return(comSelParagraphs); case dbTables.tblSents: return(comSelSents); case dbTables.tblPhraseContent: return(comSelPhraseContent); case dbTables.tblLemms: return(comSelLemms); case dbTables.tblGrammems: return(comSelGrammems); case dbTables.tblSyntNodes: return(comSelSyntNodes); case dbTables.tblRealWord: return(comSelRealWord); case dbTables.tblTermContent: return(comSelTermContent); case dbTables.tblUndefContent: return(comSelUndefContent); case dbTables.mBlockTypes: return(comSelmBlockTypes); case dbTables.mAttrTypes: return(comSelmAttrTypes); case dbTables.mAttributes: return(comSelmAttributes); case dbTables.mBlocks: return(comSelmBlocks); case dbTables.mFactHeap: return(comSelmFactHeap); default: return(""); } }
/// <summary> /// Чтения таблицы из БД. /// </summary> /// <param name="tblname">enum нужной таблицы</param> /// <returns>DataTable</returns> public DataTable GetDataTable(dbTables tblname) { var stmnt = TableSelector.GetSelectStatement(tblname); if (String.IsNullOrEmpty(stmnt)) { return(null); } DataTable dTable = new DataTable(); try { SQLiteDataAdapter adapter = new SQLiteDataAdapter(stmnt, m_dbConn); adapter.Fill(dTable); } catch (SQLiteException ex) { //MessageBox.Show("Error: " + ex.Message); } return(dTable); }
public dbMatching IsMatch(dbTables table, string info1, string info2) { if (isConnected) { if (Regex.IsMatch(info1, @"^[A-Za-z0-9]+$") && Regex.IsMatch(info2, @"^[A-Za-z0-9]+$")) { if (table == dbTables.login) { string commandString = "select * from login where name='" + info1 + "' and password='******' "; SQLiteCommand loginCommand = new SQLiteCommand(commandString, connection); loginCommand.ExecuteNonQuery(); SQLiteDataReader dr = loginCommand.ExecuteReader(); int count = 0; while (dr.Read()) { count++; } dr.Close(); if (count == 1) { return(dbMatching.Match); } else if (count > 1) { return(dbMatching.DuplicatesError); } else if (count == 0) { commandString = "select * from login where name='" + info2 + "' and password='******' "; loginCommand = new SQLiteCommand(commandString, connection); loginCommand.ExecuteNonQuery(); dr = loginCommand.ExecuteReader(); count = 0; while (dr.Read()) { count++; } dr.Close(); if (count == 1) { return(dbMatching.Match); } else if (count > 1) { return(dbMatching.DuplicatesError); } else if (count == 0) { return(dbMatching.NoMatch); } else { return(dbMatching.UnknownError); } } else { return(dbMatching.UnknownError); } } } return(dbMatching.NoMatch); } else { return(dbMatching.NotConnected); } }
private void cbTables_SelectedIndexChanged(object sender, EventArgs e) { ActiveAspect = (dbTables)((sender as ComboBox).SelectedIndex); }
/// <summary> /// Обновление таблицы в БД. /// </summary> /// <param name="dTable">набор данных</param> /// <param name="tblname">enum нужной таблицы</param> /// <returns></returns> public void UpdateDataTable(DataTable dTable, dbTables tblname) { dbConnector.dirCmd.UpdateDataTable(dTable, tblname); }