示例#1
0
        private bool InsertNewRow()
        {
            string query =
                $"insert into Students (name, birth, year, class) " +
                $"values('{nameBox.Text}', '{birthPicker.Value.ToString()}', '{yearBox.SelectedIndex + 1}', {classBox.SelectedIndex + 1})";
            Exception result = DBGate.NonQuery(Properties.Settings.Default.ConnectionString, query);

            if (result != null)
            {
                MessageBox.Show(
                    $"Критическая ошибка при добавлении." + result.Message,
                    "Ошибка",
                    MessageBoxButtons.OK, MessageBoxIcon.Information); return(false);
            }
            return(true);
        }
示例#2
0
        private bool InsertNewRow()
        {
            string query =
                $"insert into Users (login, password, name, role) " +
                $"values('{loginBox.Text}', '{passwordBox.Text}', '{nameBox.Text}', {roleBox.SelectedIndex + 1})";
            Exception result = DBGate.NonQuery(Properties.Settings.Default.ConnectionString, query);

            if (result != null)
            {
                MessageBox.Show(
                    $"Критическая ошибка при добавлении. \r\nВведенное имя пользователя уже занято.",
                    "Ошибка",
                    MessageBoxButtons.OK, MessageBoxIcon.Information); return(false);
            }
            return(true);
        }