private void grid_UserDeletingRow(object sender, DataGridViewRowCancelEventArgs e) { e.Cancel = true; List <Conditional> conditionals = new List <Conditional>(); int currentColumn = 0; foreach (DataGridViewCell cell in e.Row.Cells) { string columnName = grid.Columns[currentColumn++].Name; string value = cell.Value.ToString(); if (String.IsNullOrEmpty(value)) { conditionals.Add(new Conditional(columnName, "IS NULL", string.Empty)); continue; } else if (cell.ValueType.ToString() == "System.String" || cell.ValueType.ToString() == "System.DateTime") { value = "\'" + value + "\'"; } conditionals.Add(new Conditional(columnName, "=", value)); } try { Dbo.DeleteValues(lastTableName, conditionals); ShowTable(lastTableName); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
public MainForm() { InitializeComponent(); Dbo.ConnectToDatabase(); Dbo.Execute("SET SCHEMA 'ksiegarnia_internetowa'"); AddTablesToComboBox(); lastPanel = firstPanel; }
private void sqlButtonRun_Click(object sender, EventArgs e) { try { grid.DataSource = Dbo.GetTable(sqlTextBox.Text); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
public void AddTablesToComboBox() { foreach (DataRow table in Dbo.GetTablesFromSchema().Rows) { TreeNode node = new TreeNode(table.ItemArray[0].ToString()); foreach (DataColumn column in Dbo.GetWholeTable(table.ItemArray[0].ToString()).Columns) { node.Nodes.Add(column.ColumnName); } tablesTreeView.Nodes.Add(node); } }
private void similarBookTextBox_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Enter) { string title = "\'" + similarBookTextBox.Text + "\'"; try { grid.DataSource = Dbo.GetTable(String.Format("SELECT * from find_similar(" + title + ")")); } catch (Exception ex) { MessageBox.Show(ex.Message); } } }
private void addNewButton_Click(object sender, EventArgs e) { List <String> columnValues = new List <String>(); foreach (Control c in addNewPanel.Controls) { if (c is TextBox) { TextBox textBox = (TextBox)c; columnValues.Add(!String.IsNullOrWhiteSpace(textBox.Text) ? textBox.Text : "NULL"); } } try { Dbo.InsertValues(lastTableName, columnValues.ToArray()); ShowTable(lastTableName); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void ShowNodeTable() { if (lastIsView) { lastTable = Dbo.GetTable(lastTableName, GetAllConditionals()); grid.DataSource = lastTable; } else if (lastSelectedNode.Parent == null) { lastTableName = lastSelectedNode.Text; lastTable = Dbo.GetTable(lastSelectedNode.Text, GetAllConditionals()); grid.DataSource = lastTable; SetEditable(false); } else { lastTableName = lastSelectedNode.Parent.Text; lastTable = Dbo.GetTable(lastSelectedNode.Parent.Text, GetAllConditionals()); grid.DataSource = Dbo.GetTable(lastSelectedNode.Parent.Text, GetAllConditionals(), lastSelectedNode.Text); SetEditable(false); } ShowAddNewRow(lastTable); }
private void ShowTable(string table) { grid.DataSource = Dbo.GetWholeTable(table); lastTableName = table; }
private void button3_Click(object sender, EventArgs e) { SelectedView(); Dbo.Execute(SqlQueryConsts.ZAM_STATS); ShowTable("zamowienia_koszty"); }
private void wydawnictwaStats_Click(object sender, EventArgs e) { SelectedView(); Dbo.Execute(SqlQueryConsts.WYD_STATS); ShowTable("wyd_stats"); }
private void miasta_stats_Click(object sender, EventArgs e) { SelectedView(); Dbo.Execute(SqlQueryConsts.CITY_STATS); ShowTable("city_stats"); }
private void button2_Click(object sender, EventArgs e) { SelectedView(); Dbo.Execute(SqlQueryConsts.BOOKS_STATS); ShowTable("books_stats"); }
private void button1_Click(object sender, EventArgs e) { SelectedView(); Dbo.Execute(SqlQueryConsts.BOOKS_QUERY); ShowTable("books_query"); }