RError.com

RError.com Logo RError.com Logo

RError.com Navigation

  • 主页

Mobile menu

Close
  • 主页
  • 系统&网络
    • 热门问题
    • 最新问题
    • 标签
  • Ubuntu
    • 热门问题
    • 最新问题
    • 标签
  • 帮助
主页 / user-212040

YoFi's questions

Martin Hope
YoFi
Asked: 2020-01-26 20:26:32 +0000 UTC

检查所选文件是否存在

  • 2

如何检查文件是否被选中?

private void BrowseFilesButton_Click(object sender, RoutedEventArgs e)
        {
            var ofd = new OpenFileDialog {Multiselect = true};
            ofd.ShowDialog();
            ViewModel.ChoosenFiles = ofd.FileNames;
            FileBox.Text = $"Selected {ofd.FileNames.Length} scripts";
        }

        private void ExecFilesButton_Click(object sender, RoutedEventArgs e)
        {   
            List<Script> scriptToRun = ViewModel.ChoosenFiles.Select(item => new Script(item)).ToList();

            SetProgressBar(scriptToRun.Count);
            var runner = new Runner(ViewModel.SelectedConnection);
            runner.RunQueries(scriptToRun, UpdateProgressBar());

            MessageBox.Show("ok");
        }
c#
  • 3 个回答
  • 10 Views
Martin Hope
YoFi
Asked: 2020-01-17 18:04:23 +0000 UTC

将 List<> 传递给类

  • -3

如何传值List<string> scriptsToRun给另一个类(给方法runQueries)?

从这里:

private void ExecAllSkrypty_Click(object sender, EventArgs e)
        {
            string[] dir = Directory.GetFiles(skryptyDirBox.Text);

            List<string> scriptsToRun = new List<string>();

            foreach (var item in dir)
            {
                string query = File.ReadAllText(item);
                var fileName = Path.GetFileName(item);
                scriptsToRun.Add(fileName);
            }
            GetRunner().runQueries(fileName, query);
        }

这里:

public void runQueries(string sName, string query)
        {
            using (var c = new Context(connection,true))
            {
                var scriptRunned = c.Scripts.Where(x => scriptsToRun.Contains(x.ScriptName)).Select(s => s.ScriptName).ToList();

                scriptsToRun.RemoveAll(s => scriptRunned.Contains(s));

                foreach (var sname in scriptRunned)
                {
                    //read the file sname
                    Insertquery(sname,query);
                }
            }
        }
c#
  • 1 个回答
  • 10 Views
Martin Hope
YoFi
Asked: 2020-01-12 20:12:48 +0000 UTC

插入到 schema.table PostgreSQL c#

  • 0

如何使用所需模式向数据库添加条目?求问题。如果你没有指定模式名称,那么它会写入公共,如果我指定那么我会得到一个错误。

public void insertquery(string sName)
        {
            command.CommandText = $"INSERT INTO rpsql.s_test(script_name) values ('{sName}')";
            connection.Open();
            command.ExecuteNonQuery();
            connection.Close();
        }

在此处输入图像描述

c#
  • 1 个回答
  • 10 Views
Martin Hope
YoFi
Asked: 2020-01-11 18:29:29 +0000 UTC

从 TextBox 保存到 ComboBox

  • 0

Form1 http://i12.pixs.ru/storage/0/5/2/form1jpg_4473358_24731052.jpg Form1 http://i12.pixs.ru/storage/0/7/1/form2jpg_1765146_24731071.jpg

如何将名称为 Name(TextBox) 的第二种形式的 TexBox 中输入的值保存在 ComboBox 中。以及如何在从 ComboBox 中进行选择时,将这些值传递给 connectionString?

class Connection
    {
        private string connectionString;
        protected NpgsqlCommand command;
        protected NpgsqlConnection connection;
        protected NpgsqlDataReader reader;


        public PostgreConnection()
        {
            connectionString = @"Server ="+ ServerBox.Text +
                                ";Port="+ PortBox.Text +
                                ";Database="+ DatabaseBox.Text +
                                ";User ID=" + UserIDBox.Text +
                                ";Password=" + PasswordBox.Text;

            connection = new NpgsqlConnection(connectionString);
            command = connection.CreateCommand();
        }
    }
c#
  • 1 个回答
  • 10 Views
Martin Hope
YoFi
Asked: 2020-12-23 16:55:03 +0000 UTC

FK Firebird 2.5 搜索实现

  • 0

我需要显示所有相互依赖的表的名称。有 200 个这样的表 + 从属表。例如,表 X 具有来自 Y 的 FK,Y 具有来自 Z 的 FK。即,查找 FK。是否可以从表列表和找到的表中实现 FK 查找?

这是一个查找一个表 (M_KONTRAH_GL) 名称的查询:

SELECT
   master_relation_constraints.rdb$relation_name AS reference_table
FROM
   rdb$relation_constraints detail_relation_constraints
   JOIN rdb$index_segments detail_index_segments ON detail_relation_constraints.rdb$index_name = detail_index_segments.rdb$index_name 
   JOIN rdb$ref_constraints ON detail_relation_constraints.rdb$constraint_name = rdb$ref_constraints.rdb$constraint_name 
   JOIN rdb$relation_constraints master_relation_constraints ON rdb$ref_constraints.rdb$const_name_uq = master_relation_constraints.rdb$constraint_name
WHERE
   detail_relation_constraints.rdb$constraint_type = 'FOREIGN KEY'
   AND detail_relation_constraints.rdb$relation_name = 'M_KONTRAH_GL'
sql
  • 1 个回答
  • 10 Views
Martin Hope
YoFi
Asked: 2020-08-10 16:56:17 +0000 UTC

如何解决 FileSystemWatcher 中的更改事件重复?

  • 11

文件监控。出于某种原因,当对文件进行更改时,Change. 如何解决?

这是代码:

public void monitoring(string path)
{
    this.sPath = path;
    string first = Path.GetDirectoryName(path);
    string second = Path.GetFileName(path);
    FileSystemWatcher fsw = new FileSystemWatcher(first, second);
    fsw.Changed += new FileSystemEventHandler(watcher_Changed);
    fsw.EnableRaisingEvents = true;
}

public void watcher_Changed(object sender, FileSystemEventArgs e)
{
    MessageBox.Show("Be happy :3");
    SplitAndQuery(this.sPath);
}
c#
  • 4 个回答
  • 10 Views
Martin Hope
YoFi
Asked: 2020-08-08 21:36:52 +0000 UTC

跳过空行

  • 1

如何在行之间和行后忽略 TextFile 中的空行? 文本文件格式:
错误

2016-01-01 20:23;Work;5;чистка;5000.00  
2016-01-03 00:40;Custom;1;2;6;3

2016-01-03 00:41;Custom;1;1;10;1  

第 48 行if (element[1] == "Card")

这是代码本身:

public void SplitAndQuery(string path)
{
    char[] separatorLines = { '\n' };
    char[] separatorWords = { ';' };
    string[] lines = File.ReadAllText(path, Encoding.Default).Split(separatorLines, StringSplitOptions.RemoveEmptyEntries);
    for (int i = 0; i <= lines.Length - 1; i++)
    {
      string[] element = lines[i].Split(separatorWords, StringSplitOptions.RemoveEmptyEntries);

        if (element[1] == "Card")
        {
            if (checkCard(element[2]) == false)
            {
                insertCard(element[2], element[3], element[4], element[5], element[6], element[7], element[8]);

                if (checkDiscount(element[2]) == "-1")
                {
                    connection.Close();
                    MessageBox.Show("ups");
                }
                else
                {
                    insertDiscount(element[0],element[9]);
                }
            }
            else if (checkCard(element[2]) == true)
            {
                updateCard(element[3], element[4], element[5], element[6], element[7], element[8], element[2]);
                if (checkDiscount(element[2]) == "-1")
                {
                    connection.Close();
                    MessageBox.Show("ups");
                }
                else
                {
                    insertDiscount(element[0],element[9]);
                    connection.Close();
                }
            }
        }
c#
  • 3 个回答
  • 10 Views

Sidebar

Stats

  • 问题 10021
  • Answers 30001
  • 最佳答案 8000
  • 用户 6900
  • 常问
  • 回答
  • Marko Smith

    我看不懂措辞

    • 1 个回答
  • Marko Smith

    请求的模块“del”不提供名为“default”的导出

    • 3 个回答
  • Marko Smith

    "!+tab" 在 HTML 的 vs 代码中不起作用

    • 5 个回答
  • Marko Smith

    我正在尝试解决“猜词”的问题。Python

    • 2 个回答
  • Marko Smith

    可以使用哪些命令将当前指针移动到指定的提交而不更改工作目录中的文件?

    • 1 个回答
  • Marko Smith

    Python解析野莓

    • 1 个回答
  • Marko Smith

    问题:“警告:检查最新版本的 pip 时出错。”

    • 2 个回答
  • Marko Smith

    帮助编写一个用值填充变量的循环。解决这个问题

    • 2 个回答
  • Marko Smith

    尽管依赖数组为空,但在渲染上调用了 2 次 useEffect

    • 2 个回答
  • Marko Smith

    数据不通过 Telegram.WebApp.sendData 发送

    • 1 个回答
  • Martin Hope
    Alexandr_TT 2020年新年大赛! 2020-12-20 18:20:21 +0000 UTC
  • Martin Hope
    Alexandr_TT 圣诞树动画 2020-12-23 00:38:08 +0000 UTC
  • Martin Hope
    Air 究竟是什么标识了网站访问者? 2020-11-03 15:49:20 +0000 UTC
  • Martin Hope
    Qwertiy 号码显示 9223372036854775807 2020-07-11 18:16:49 +0000 UTC
  • Martin Hope
    user216109 如何为黑客设下陷阱,或充分击退攻击? 2020-05-10 02:22:52 +0000 UTC
  • Martin Hope
    Qwertiy 并变成3个无穷大 2020-11-06 07:15:57 +0000 UTC
  • Martin Hope
    koks_rs 什么是样板代码? 2020-10-27 15:43:19 +0000 UTC
  • Martin Hope
    Sirop4ik 向 git 提交发布的正确方法是什么? 2020-10-05 00:02:00 +0000 UTC
  • Martin Hope
    faoxis 为什么在这么多示例中函数都称为 foo? 2020-08-15 04:42:49 +0000 UTC
  • Martin Hope
    Pavel Mayorov 如何从事件或回调函数中返回值?或者至少等他们完成。 2020-08-11 16:49:28 +0000 UTC

热门标签

javascript python java php c# c++ html android jquery mysql

Explore

  • 主页
  • 问题
    • 热门问题
    • 最新问题
  • 标签
  • 帮助

Footer

RError.com

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

帮助

© 2023 RError.com All Rights Reserve   沪ICP备12040472号-5