예제 #1
0
        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);
            }
        }
예제 #2
0
        public MainForm()
        {
            InitializeComponent();
            Dbo.ConnectToDatabase();
            Dbo.Execute("SET SCHEMA 'ksiegarnia_internetowa'");
            AddTablesToComboBox();

            lastPanel = firstPanel;
        }
예제 #3
0
 private void sqlButtonRun_Click(object sender, EventArgs e)
 {
     try
     {
         grid.DataSource = Dbo.GetTable(sqlTextBox.Text);
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
예제 #4
0
        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);
            }
        }
예제 #5
0
 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);
         }
     }
 }
예제 #6
0
        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);
            }
        }
예제 #7
0
 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);
 }
예제 #8
0
 private void ShowTable(string table)
 {
     grid.DataSource = Dbo.GetWholeTable(table);
     lastTableName   = table;
 }
예제 #9
0
 private void button3_Click(object sender, EventArgs e)
 {
     SelectedView();
     Dbo.Execute(SqlQueryConsts.ZAM_STATS);
     ShowTable("zamowienia_koszty");
 }
예제 #10
0
 private void wydawnictwaStats_Click(object sender, EventArgs e)
 {
     SelectedView();
     Dbo.Execute(SqlQueryConsts.WYD_STATS);
     ShowTable("wyd_stats");
 }
예제 #11
0
 private void miasta_stats_Click(object sender, EventArgs e)
 {
     SelectedView();
     Dbo.Execute(SqlQueryConsts.CITY_STATS);
     ShowTable("city_stats");
 }
예제 #12
0
 private void button2_Click(object sender, EventArgs e)
 {
     SelectedView();
     Dbo.Execute(SqlQueryConsts.BOOKS_STATS);
     ShowTable("books_stats");
 }
예제 #13
0
 private void button1_Click(object sender, EventArgs e)
 {
     SelectedView();
     Dbo.Execute(SqlQueryConsts.BOOKS_QUERY);
     ShowTable("books_query");
 }