Initial commit
This commit is contained in:
@@ -0,0 +1,181 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Data.OleDb;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace Database
|
||||
{
|
||||
public partial class MainForm : Form
|
||||
{
|
||||
|
||||
private Fishes fishes;
|
||||
private Plants plants;
|
||||
private FishFood fishFood;
|
||||
private Locations locations;
|
||||
private FishTypes fishTypes;
|
||||
private PlantTypes plantTypes;
|
||||
private FishRations fishRations;
|
||||
|
||||
public MainForm()
|
||||
{
|
||||
InitializeComponent();
|
||||
ConfigureWidgets();
|
||||
ConfigureText();
|
||||
}
|
||||
private void ConfigureWidgets() {
|
||||
fishes = new Fishes(fishesDataGridView);
|
||||
plants = new Plants(plantsDataGridView);
|
||||
fishFood = new FishFood(fishFoodDataGridView);
|
||||
locations = new Locations(locationsDataGridView);
|
||||
fishTypes = new FishTypes(fishTypesDataGridView);
|
||||
plantTypes = new PlantTypes(plantTypesDataGridView);
|
||||
fishRations = new FishRations(fishRationsDataGridView);
|
||||
|
||||
var initializerList = new (ComboBox, DataGridView)[6] {
|
||||
(fishTypeFishesComboBox, fishTypesDataGridView),
|
||||
(locationFishComboBox, locationsDataGridView),
|
||||
(fishTypeRationsComboBox, fishTypesDataGridView),
|
||||
(fishFoodRationsComboBox, fishFoodDataGridView),
|
||||
(plantTypePlantsComboBox, plantTypesDataGridView),
|
||||
(locationPlantsComboBox, locationsDataGridView)
|
||||
};
|
||||
foreach (var pair in initializerList) {
|
||||
pair.Item1.DataSource = pair.Item2.DataSource;
|
||||
pair.Item1.DropDownStyle = ComboBoxStyle.DropDownList;
|
||||
pair.Item1.DisplayMember = "data";
|
||||
pair.Item1.ValueMember = "id";
|
||||
}
|
||||
}
|
||||
private void ConfigureText() {
|
||||
var initializerList = new DataGridView[7] {
|
||||
fishesDataGridView,
|
||||
plantsDataGridView,
|
||||
fishFoodDataGridView,
|
||||
locationsDataGridView,
|
||||
fishTypesDataGridView,
|
||||
plantTypesDataGridView,
|
||||
fishRationsDataGridView
|
||||
};
|
||||
foreach (var dataGridView in initializerList)
|
||||
dataGridView.Columns["id"].HeaderText = "Identifier";
|
||||
fishesDataGridView.Columns["id"].Visible = false;
|
||||
plantsDataGridView.Columns["id"].Visible = false;
|
||||
fishesDataGridView.Columns["type"].HeaderText = "Type of fish";
|
||||
fishesDataGridView.Columns["location"].HeaderText = "Place of residence";
|
||||
fishesDataGridView.Columns["number"].HeaderText = "Population";
|
||||
plantsDataGridView.Columns["type"].HeaderText = "Type of plant";
|
||||
plantsDataGridView.Columns["location"].HeaderText = "Plant location";
|
||||
plantsDataGridView.Columns["number"].HeaderText = "Number of plants";
|
||||
fishFoodDataGridView.Columns["data"].HeaderText = "Fish nutrition";
|
||||
locationsDataGridView.Columns["data"].HeaderText = "Place of residence";
|
||||
fishTypesDataGridView.Columns["data"].HeaderText = "Type of fish";
|
||||
plantTypesDataGridView.Columns["data"].HeaderText = "Type of plant";
|
||||
fishRationsDataGridView.Columns["type"].HeaderText = "Type of fish";
|
||||
fishRationsDataGridView.Columns["food"].HeaderText = "What does it eat";
|
||||
}
|
||||
private void addLocation_Click(object sender, EventArgs e) {
|
||||
string data = locationTextBox.Text.Trim();
|
||||
if (data.Length < 1)
|
||||
return;
|
||||
locations.Insert(data);
|
||||
}
|
||||
private void updateLocation_Click(object sender, EventArgs e) {
|
||||
string data = locationTextBox.Text.Trim();
|
||||
if (data.Length < 1)
|
||||
return;
|
||||
locations.Update(data);
|
||||
}
|
||||
private void deleteLocation_Click(object sender, EventArgs e) {
|
||||
locations.Delete();
|
||||
}
|
||||
private void addFishType_Click(object sender, EventArgs e) {
|
||||
string data = fishTypeTextBox.Text.Trim();
|
||||
if (data.Length < 1)
|
||||
return;
|
||||
fishTypes.Insert(data);
|
||||
}
|
||||
private void updateFishType_Click(object sender, EventArgs e) {
|
||||
string data = fishTypeTextBox.Text.Trim();
|
||||
if (data.Length < 1)
|
||||
return;
|
||||
fishTypes.Update(data);
|
||||
}
|
||||
private void deleteFishType_Click(object sender, EventArgs e) {
|
||||
fishTypes.Delete();
|
||||
}
|
||||
private void addFishFood_Click(object sender, EventArgs e) {
|
||||
string data = fishFoodTextBox.Text.Trim();
|
||||
if (data.Length < 1)
|
||||
return;
|
||||
fishFood.Insert(data);
|
||||
}
|
||||
private void updateFishFood_Click(object sender, EventArgs e) {
|
||||
string data = fishFoodTextBox.Text.Trim();
|
||||
if (data.Length < 1)
|
||||
return;
|
||||
fishFood.Update(data);
|
||||
}
|
||||
private void deleteFishFood_Click(object sender, EventArgs e) {
|
||||
fishFood.Delete();
|
||||
}
|
||||
private void addPlantType_Click(object sender, EventArgs e) {
|
||||
string data = plantTypeTextBox.Text.Trim();
|
||||
if (data.Length < 1)
|
||||
return;
|
||||
plantTypes.Insert(data);
|
||||
}
|
||||
private void updatePlantType_Click(object sender, EventArgs e) {
|
||||
string data = plantTypeTextBox.Text.Trim();
|
||||
if (data.Length < 1)
|
||||
return;
|
||||
plantTypes.Update(data);
|
||||
}
|
||||
private void deletePlantType_Click(object sender, EventArgs e) {
|
||||
plantTypes.Delete();
|
||||
}
|
||||
private void addFish_Click(object sender, EventArgs e) {
|
||||
int number = Convert.ToInt32(numberFishNumericUpDown.Value);
|
||||
int typeId = Convert.ToInt32(fishTypeFishesComboBox.SelectedValue);
|
||||
int locationId = Convert.ToInt32(locationFishComboBox.SelectedValue);
|
||||
fishes.Insert(number, typeId, locationId);
|
||||
}
|
||||
private void updateFish_Click(object sender, EventArgs e) {
|
||||
int number = Convert.ToInt32(numberFishNumericUpDown.Value);
|
||||
int typeId = Convert.ToInt32(fishTypeFishesComboBox.SelectedValue);
|
||||
int locationId = Convert.ToInt32(locationFishComboBox.SelectedValue);
|
||||
fishes.Update(number, typeId, locationId);
|
||||
}
|
||||
private void deleteFish_Click(object sender, EventArgs e) {
|
||||
fishes.Delete();
|
||||
}
|
||||
private void addPlant_Click(object sender, EventArgs e) {
|
||||
int number = Convert.ToInt32(numberPlantsNumericUpDown.Value);
|
||||
int typeId = Convert.ToInt32(plantTypePlantsComboBox.SelectedValue);
|
||||
int locationId = Convert.ToInt32(locationPlantsComboBox.SelectedValue);
|
||||
plants.Insert(number, typeId, locationId);
|
||||
}
|
||||
private void updatePlant_Click(object sender, EventArgs e) {
|
||||
int number = Convert.ToInt32(numberPlantsNumericUpDown.Value);
|
||||
int typeId = Convert.ToInt32(plantTypePlantsComboBox.SelectedValue);
|
||||
int locationId = Convert.ToInt32(locationPlantsComboBox.SelectedValue);
|
||||
plants.Update(number, typeId, locationId);
|
||||
}
|
||||
private void deletePlant_Click(object sender, EventArgs e) {
|
||||
plants.Delete();
|
||||
}
|
||||
private void addFishRation_Click(object sender, EventArgs e) {
|
||||
int typeId = Convert.ToInt32(fishTypeFishesComboBox.SelectedValue);
|
||||
int foodId = Convert.ToInt32(fishFoodRationsComboBox.SelectedValue);
|
||||
fishRations.Insert(typeId, foodId);
|
||||
}
|
||||
private void deleteFishRation_Click(object sender, EventArgs e) {
|
||||
fishRations.Delete();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user