Initial commit
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data.OleDb;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace Database
|
||||
{
|
||||
class FishRations : OleDBDataGridViewHandler
|
||||
{
|
||||
static OleDbCommand SelectCommand()
|
||||
{
|
||||
string command = "SELECT [FFF].[id], [FT].[data] AS [type], [FF].[data] AS [food]" +
|
||||
"FROM [fish_types_fish_food] AS [FFF], [fish_types] AS [FT], [fish_food] AS [FF]" +
|
||||
"WHERE [type_id] = [FT].[id] AND [food_id] = [FF].[id];";
|
||||
var result = new OleDbCommand(command, OleDBHandler.Connection);
|
||||
return result;
|
||||
}
|
||||
public FishRations(DataGridView dataGridView) : base(SelectCommand(), "fish_types_fish_food", dataGridView) { }
|
||||
public void Insert(int typeId, int foodId)
|
||||
{
|
||||
string command = "SELECT COUNT(*) FROM [fish_types_fish_food]" +
|
||||
$"WHERE [type_id] = {typeId} AND [food_id] = {foodId};";
|
||||
var result = OleDBHandler.Execute(command, OleDBHandler.ExecuteType.Scalar);
|
||||
if (Convert.ToInt32(result) > 0)
|
||||
return;
|
||||
(string, object) pair1 = ("type_id", typeId);
|
||||
(string, object) pair2 = ("food_id", foodId);
|
||||
OleDBHandler.Insert(nameTable, pair1, pair2);
|
||||
RefreshView();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user