Exemplo n.º 1
0
        public void sql_build_Change(string sql, TextBox ID, string text_ID, CheckBox [] array_check, string[] t_box_name, string[] query_input_name, Grid Grid_Change)
        {
            for (int i = 0; i < array_check.Length; i++)
            {
                if (array_check[i].IsChecked == true)
                {
                    TextBox text_Box = (TextBox)Grid_Change.FindName(t_box_name[i]);
                    if (text_Box == null)
                    {
                        MessageBox.Show("Поле не были созданы и не были заполнены", "Уведомление");
                        break;
                    }
                    if (text_Box.Text.Trim() == string.Empty)
                    {
                        MessageBox.Show("Поле было пустое", "Уведомление");
                    }
                    else
                    {
                        sql += query_input_name[i] + "=" + string.Format("\'{0}\'", text_Box.Text) + ",";
                    }
                }
            }
            if (sql.EndsWith(","))
            {
                sql = sql.Remove(sql.Length - 1);
            }
            sql += text_ID + ID.Text + ";";
            Query_input Query = new Query_input();

            Query.input(sql);
        }
Exemplo n.º 2
0
        private void Button_Click_3(object sender, RoutedEventArgs e)
        {
            string sql     = "UPDATE dbo.[Services provided to the client] SET ";
            string text_ID = " WHERE ID_Client = ";

            CheckBox[] array_check = new CheckBox[] { Check_ID_Cliet, Check_ID_Serv, Check_Costs };
            for (int i = 0; i < array_check.Length; i++)
            {
                if (array_check[i].IsChecked == true)
                {
                    TextBox text_Box = (TextBox)Grid_Change.FindName(t_box_name[i]);
                    if (text_Box == null)
                    {
                        MessageBox.Show("Поле не были созданы и не были заполнены", "Уведомление");
                        break;
                    }
                    if (text_Box.Text.Trim() == string.Empty)
                    {
                    }
                    else
                    {
                        sql += query_input_name[i] + "=" + string.Format("\'{0}\'", text_Box.Text) + ",";
                    }
                }
            }
            if (sql.EndsWith(","))
            {
                sql = sql.Remove(sql.Length - 1);
            }
            sql += text_ID + Services_ID.Text + " and ";
            sql += "ID_Services = " + Client_ID.Text + ";";
            Query_input Query = new Query_input();

            Query.input(sql);
        }
Exemplo n.º 3
0
        public void sql_build_input(string sql, string [] query_input_name, string[] text_Box_input)
        {
            Query_input Query = new Query_input();

            for (int i = 0; i < query_input_name.Length; i++)
            {
                sql += query_input_name[i] + ",";
            }
            if (sql.EndsWith(","))
            {
                sql = sql.Remove(sql.Length - 1);
            }
            sql += ") values (";
            for (int i = 0; i < text_Box_input.Length; i++)
            {
                if (text_Box_input[i].Trim() == string.Empty)
                {
                }
                else
                {
                    sql += string.Format("\'{0}\'", text_Box_input[i]) + ",";
                }
            }
            if (sql.EndsWith(","))
            {
                sql = sql.Remove(sql.Length - 1);
            }
            sql += ")";
            Query.input(sql);
        }
Exemplo n.º 4
0
 public void delete(string sql, TextBox Delet, string db)
 {
     if (Delet.Text.Trim() == string.Empty)
     {
         MessageBox.Show("Поле удаление пустое", "Уведомление");
     }
     else
     {
         Query_input Query = new Query_input();
         Query.input(sql);
     }
 }
Exemplo n.º 5
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            string sql_query = SQL.Text;
            string db        = "";
            string dbo       = "";

            string[] exp      = sql_query.ToLower().Split(' ');
            string[] array_db = new string[] { "Staff", "Positionen", "Client", "Rooms", "Services", "Services provided to the client",
                                               "staff", "positionen", "client", "rooms", "services", "services provided to the client" };
            string[] array_dbo = new string[] { "dbo.[Staff]", "dbo.[Positionen]", "dbo.[Client]", "dbo.[Rooms]", "dbo.[Services]", "dbo.[Services provided to the client]",
                                                "dbo.[staff]", "dbo.[positionen]", "dbo.[client]", "dbo.[rooms]", "dbo.[services]", "dbo.[services provided to the client]" };
            for (int i = 0; i < array_db.Length; i++)
            {
                if (sql_query.Contains(array_db[i]))
                {
                    db += array_db[i];
                }
                if (sql_query.Contains(array_dbo[i]))
                {
                    dbo += array_db[i];
                }
            }
            foreach (string i in exp)
            {
                if (i == "GRANT SELECT")
                {
                    sql_query = SQL.Text;
                    Query_input Query = new Query_input();
                    Query.input(sql_query);
                    break;
                }
                if (i == "select")
                {
                    sql_query = SQL.Text;
                    Query_output Query = new Query_output();
                    Query.Output(sql_query, db, table);
                    break;
                }
                if (i == "select*from")
                {
                    sql_query = SQL.Text;
                    Query_output Query = new Query_output();
                    Query.Output(sql_query, db, table);
                    break;
                }
                if (i == "alter")
                {
                    sql_query = SQL.Text;
                    Query_input Query = new Query_input();
                    Query.input(sql_query);
                    break;
                }
                if (i == "insert")
                {
                    sql_query = SQL.Text;
                    Query_input Query = new Query_input();
                    Query.input(sql_query);
                    break;
                }
                if (i == "drop")
                {
                    sql_query = SQL.Text;
                    Query_input Query = new Query_input();
                    Query.input(sql_query);
                    break;
                }
                if (i == "update")
                {
                    sql_query = SQL.Text;
                    Query_input Query = new Query_input();
                    Query.input(sql_query);
                    break;
                }
                if (i == "delete")
                {
                    sql_query = SQL.Text;
                    Query_input Query = new Query_input();
                    Query.input(sql_query);
                    break;
                }
                if (i == "exec")
                {
                    sql_query = SQL.Text;
                    Query_output Query = new Query_output();
                    Query.Output(sql_query, db, table);
                    break;
                }
                if (i == "create")
                {
                    sql_query = SQL.Text;
                    Query_input Query = new Query_input();
                    Query.input(sql_query);
                    break;
                }
                if (i == "execute")
                {
                    sql_query = SQL.Text;
                    Query_input Query = new Query_input();
                    Query.input(sql_query);
                    break;
                }
                else
                {
                    MessageBox.Show("Запрос задан не верно или данная команда не используется в интерфейсе", "Уведомление");
                    break;
                }
            }
        }