School Commit Init
This commit is contained in:
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -0,0 +1,470 @@
|
||||
{
|
||||
"cells": [
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "b8210b19",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"## A.I. Assignment 5\n",
|
||||
"\n",
|
||||
"## Learning Goals\n",
|
||||
"\n",
|
||||
"By the end of this lab, you should be able to:\n",
|
||||
"* Get more familiar with tensors in pytorch \n",
|
||||
"* Create a simple multilayer perceptron model with pytorch\n",
|
||||
"* Visualise the parameters\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"### Task\n",
|
||||
"\n",
|
||||
"Build a fully connected feed forward network that adds two bits. Determine the a propper achitecture for this network (what database you use for this problem? how many layers? how many neurons on each layer? what is the activation function? what is the loss function? etc)\n",
|
||||
"\n",
|
||||
"Create at least 3 such networks and compare their performance (how accurate they are?, how farst they are trained to get at 1 accuracy?)\n",
|
||||
"\n",
|
||||
"Display for the best one the weights for each layer.\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 55,
|
||||
"id": "e3614e5f",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"import torch\n",
|
||||
"import torch.nn as nn\n",
|
||||
"from collections import OrderedDict\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "eaf778c4",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"### 1st Model"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 56,
|
||||
"id": "5ee7e7d7",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"# your code here\n",
|
||||
"model = nn.Sequential(OrderedDict([\n",
|
||||
" ('hidden', nn.Linear(2,3)),\n",
|
||||
" ('sigmoid1', nn.Sigmoid()),\n",
|
||||
" ('output', nn.Linear(3,2)),\n",
|
||||
"]))"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 57,
|
||||
"id": "665ae958",
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"Sequential(\n",
|
||||
" (hidden): Linear(in_features=2, out_features=3, bias=True)\n",
|
||||
" (sigmoid1): Sigmoid()\n",
|
||||
" (output): Linear(in_features=3, out_features=2, bias=True)\n",
|
||||
")\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"print(model)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 58,
|
||||
"id": "e26f0d3e",
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"tensor([[0., 0.],\n",
|
||||
" [0., 1.],\n",
|
||||
" [1., 0.],\n",
|
||||
" [1., 1.]])\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"# your code here\n",
|
||||
"data_in = torch.tensor([[0.,0.],[0.,1.],[1.,0.],[1.,1.]])\n",
|
||||
"print(data_in)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 59,
|
||||
"id": "4fb16bbc",
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"tensor([[0., 0.],\n",
|
||||
" [0., 1.],\n",
|
||||
" [0., 1.],\n",
|
||||
" [1., 0.]])\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"# your code here\n",
|
||||
"data_target = torch.tensor([[0.,0.],[0.,1.],[0.,1.],[1.,0.]])\n",
|
||||
"print(data_target)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 60,
|
||||
"id": "69d920ed",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"# your code here\n",
|
||||
"criterion = nn.L1Loss()\n",
|
||||
"optimizer = torch.optim.SGD(model.parameters(), lr=0.1)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 61,
|
||||
"id": "cde91f6f",
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"Epoch 1: Loss = 0.41974443197250366\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"Epoch 1001: Loss = 0.3748631477355957\n",
|
||||
"Epoch 2001: Loss = 0.37467941641807556\n",
|
||||
"Epoch 3001: Loss = 0.37417155504226685\n",
|
||||
"Epoch 4001: Loss = 0.37154191732406616\n",
|
||||
"Epoch 5001: Loss = 0.3255583643913269\n",
|
||||
"Epoch 6001: Loss = 0.19477465748786926\n",
|
||||
"tensor([[-0., 0.],\n",
|
||||
" [-0., 1.],\n",
|
||||
" [-0., 1.],\n",
|
||||
" [1., 0.]], grad_fn=<RoundBackward0>)\n",
|
||||
"Model reached 100% accuracy at epoch 6449\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"# your code here\n",
|
||||
"# Train the model\n",
|
||||
"for epoch in range(10000):\n",
|
||||
" # reset the gradients to zero before each forward and backward pass\n",
|
||||
" optimizer.zero_grad() \n",
|
||||
" # forward pass\n",
|
||||
" outputs = model(data_in) \n",
|
||||
" \n",
|
||||
" # accuracy\n",
|
||||
" predicted = (outputs.round() == data_target)\n",
|
||||
" accuracy = predicted.sum().item() / (data_target == data_target).sum().item()\n",
|
||||
" if accuracy == 1:\n",
|
||||
" print(outputs.round())\n",
|
||||
" print(f\"Model reached 100% accuracy at epoch {epoch+1}\")\n",
|
||||
" break\n",
|
||||
" # calculate loss\n",
|
||||
" \n",
|
||||
" loss1 = criterion(outputs, data_target)\n",
|
||||
" if epoch % 1000 == 0:\n",
|
||||
" print(f'Epoch {epoch+1}: Loss = {loss1}')\n",
|
||||
" # backward pass\n",
|
||||
" loss1.backward() \n",
|
||||
" # update weights\n",
|
||||
" optimizer.step() "
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 62,
|
||||
"id": "dff3ec1a",
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"accuracy: 100.0%\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"# your code here\n",
|
||||
"# visualize the resuts\n",
|
||||
"outputs = model(data_in)\n",
|
||||
"predicted = (outputs.round() == data_target)\n",
|
||||
"accuracy = predicted.sum().item() / (data_target == data_target).sum().item()\n",
|
||||
"print(f\"accuracy: {accuracy*100}%\")\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 63,
|
||||
"id": "c1a7518b",
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"hidden.weight tensor([[ 3.6313, -3.4167],\n",
|
||||
" [ 1.3280, -0.5874],\n",
|
||||
" [ 0.3637, -2.2525]])\n",
|
||||
"hidden.bias tensor([ 2.5554, -0.1830, 0.7138])\n",
|
||||
"output.weight tensor([[ 1.7310, -0.1016, -2.1195],\n",
|
||||
" [-2.4398, 1.7537, 0.6634]])\n",
|
||||
"output.bias tensor([-0.1873, 1.1474])\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"# your code here\n",
|
||||
"# print model wights\n",
|
||||
"for name, param in model.named_parameters():\n",
|
||||
" print(name, param.data)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "5b569b90",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"### 2nd Model"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 66,
|
||||
"id": "4cdf09ba",
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"Sequential(\n",
|
||||
" (hidden1): Linear(in_features=2, out_features=3, bias=True)\n",
|
||||
" (sigmoid1): Sigmoid()\n",
|
||||
" (hidden2): Linear(in_features=3, out_features=4, bias=True)\n",
|
||||
" (sigmoid2): Sigmoid()\n",
|
||||
" (output1): Linear(in_features=4, out_features=2, bias=True)\n",
|
||||
" (relu): ReLU()\n",
|
||||
")\n",
|
||||
"tensor([[0., 0.],\n",
|
||||
" [0., 1.],\n",
|
||||
" [1., 0.],\n",
|
||||
" [1., 1.]])\n",
|
||||
"tensor([[0., 0.],\n",
|
||||
" [0., 1.],\n",
|
||||
" [0., 1.],\n",
|
||||
" [1., 0.]])\n",
|
||||
"tensor([[0.0000, 0.0000],\n",
|
||||
" [0.0000, 1.0630],\n",
|
||||
" [0.0000, 1.0580],\n",
|
||||
" [0.0000, 0.0000]], grad_fn=<ReluBackward0>)\n",
|
||||
"accuracy: 87.5%\n",
|
||||
"hidden1.weight tensor([[3.7943, 3.9107],\n",
|
||||
" [1.3786, 1.1741],\n",
|
||||
" [0.5741, 0.9622]])\n",
|
||||
"hidden1.bias tensor([-0.3776, -1.5335, -0.2704])\n",
|
||||
"hidden2.weight tensor([[-2.0642, 1.3785, 0.4542],\n",
|
||||
" [ 2.6336, -1.9812, -1.4470],\n",
|
||||
" [-0.2936, -0.5167, 0.0780],\n",
|
||||
" [-1.2268, 1.2764, 0.6379]])\n",
|
||||
"hidden2.bias tensor([ 0.4410, -0.3201, -0.1641, -0.3203])\n",
|
||||
"output1.weight tensor([[ 0.0149, 0.3398, -0.2382, 0.0658],\n",
|
||||
" [-2.4774, 3.5136, 0.1576, -1.6128]])\n",
|
||||
"output1.bias tensor([-0.2175, 0.2636])\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"model = nn.Sequential(OrderedDict([\n",
|
||||
" ('hidden1', nn.Linear(2,3)),\n",
|
||||
" ('sigmoid1', nn.Sigmoid()),\n",
|
||||
" ('hidden2', nn.Linear(3,4)),\n",
|
||||
" ('sigmoid2', nn.Sigmoid()),\n",
|
||||
" ('output1', nn.Linear(4,2)),\n",
|
||||
" ('relu', nn.ReLU()),\n",
|
||||
"]))\n",
|
||||
"print(model)\n",
|
||||
"data_in = torch.tensor([[0.,0.],[0.,1.],[1.,0.],[1.,1.]])\n",
|
||||
"print(data_in)\n",
|
||||
"data_target = torch.tensor([[0.,0.],[0.,1.],[0.,1.],[1.,0.]])\n",
|
||||
"print(data_target)\n",
|
||||
"criterion = nn.L1Loss()\n",
|
||||
"optimizer = torch.optim.SGD(model.parameters(), lr=0.1)\n",
|
||||
"for epoch in range(10000):\n",
|
||||
" # reset the gradients to zero before each forward and backward pass\n",
|
||||
" optimizer.zero_grad() \n",
|
||||
" # forward pass\n",
|
||||
" outputs = model(data_in) \n",
|
||||
" \n",
|
||||
" # accuracy\n",
|
||||
" predicted = (outputs.round() == data_target)\n",
|
||||
" accuracy = predicted.sum().item() / (data_target == data_target).sum().item()\n",
|
||||
" if accuracy == 1:\n",
|
||||
" print(f\"Model 1 reached 100% accuracy at epoch {epoch+1}\")\n",
|
||||
" break\n",
|
||||
" # calculate loss\n",
|
||||
" loss1 = criterion(outputs, data_target)\n",
|
||||
" # backward pass\n",
|
||||
" loss1.backward() \n",
|
||||
" # update weights\n",
|
||||
" optimizer.step() \n",
|
||||
"outputs = model(data_in)\n",
|
||||
"print(outputs)\n",
|
||||
"predicted = (outputs.round() == data_target)\n",
|
||||
"accuracy = predicted.sum().item() / (data_target == data_target).sum().item()\n",
|
||||
"print(f\"accuracy: {accuracy*100}%\")\n",
|
||||
"for name, param in model.named_parameters():\n",
|
||||
" print(name, param.data)\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "7d95ac7a",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"### 3th Model"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 69,
|
||||
"id": "d0bea66c",
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"Sequential(\n",
|
||||
" (hidden1): Linear(in_features=2, out_features=3, bias=True)\n",
|
||||
" (relu1): ReLU()\n",
|
||||
" (output1): Linear(in_features=3, out_features=2, bias=True)\n",
|
||||
")\n",
|
||||
"tensor([[0., 0.],\n",
|
||||
" [0., 1.],\n",
|
||||
" [1., 0.],\n",
|
||||
" [1., 1.]])\n",
|
||||
"tensor([[0., 0.],\n",
|
||||
" [0., 1.],\n",
|
||||
" [0., 1.],\n",
|
||||
" [1., 0.]])\n",
|
||||
"Epoch 1: Loss = 0.3959614038467407\n",
|
||||
"Epoch 101: Loss = 0.11625192314386368\n",
|
||||
"Epoch 201: Loss = 0.08679977804422379\n",
|
||||
"Epoch 301: Loss = 0.06458555907011032\n",
|
||||
"Epoch 401: Loss = 0.06256230920553207\n",
|
||||
"Epoch 501: Loss = 0.06250278651714325\n",
|
||||
"Epoch 601: Loss = 0.06250019371509552\n",
|
||||
"Epoch 701: Loss = 0.0625000074505806\n",
|
||||
"Epoch 801: Loss = 0.0625\n",
|
||||
"Epoch 901: Loss = 0.0625\n",
|
||||
"accuracy: 87.5%\n",
|
||||
"hidden1.weight tensor([[-0.0102, 0.3543],\n",
|
||||
" [ 0.3771, 1.0492],\n",
|
||||
" [-0.8659, 0.8689]])\n",
|
||||
"hidden1.bias tensor([-0.5027, -0.3777, -0.0030])\n",
|
||||
"output1.weight tensor([[-0.5325, 0.9537, -0.7395],\n",
|
||||
" [ 0.1828, -0.4768, 0.9471]])\n",
|
||||
"output1.bias tensor([-2.4464e-07, 5.0000e-01])\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"model = nn.Sequential(OrderedDict([\n",
|
||||
" ('hidden1', nn.Linear(2,3)),\n",
|
||||
" ('relu1', nn.ReLU()),\n",
|
||||
" ('output1', nn.Linear(3,2)),\n",
|
||||
"]))\n",
|
||||
"print(model)\n",
|
||||
"data_in = torch.tensor([[0.,0.],[0.,1.],[1.,0.],[1.,1.]])\n",
|
||||
"print(data_in)\n",
|
||||
"data_target = torch.tensor([[0.,0.],[0.,1.],[0.,1.],[1.,0.]])\n",
|
||||
"print(data_target)\n",
|
||||
"criterion = nn.MSELoss()\n",
|
||||
"optimizer = torch.optim.SGD(model.parameters(), lr=0.1)\n",
|
||||
"for epoch in range(1000):\n",
|
||||
" # reset the gradients to zero before each forward and backward pass\n",
|
||||
" optimizer.zero_grad() \n",
|
||||
" # forward pass\n",
|
||||
" outputs = model(data_in) \n",
|
||||
" \n",
|
||||
" # accuracy\n",
|
||||
" predicted = (outputs.round() == data_target)\n",
|
||||
" accuracy = predicted.sum().item() / (data_target == data_target).sum().item()\n",
|
||||
" if accuracy == 1:\n",
|
||||
" print(f\"Model 1 reached 100% accuracy at epoch {epoch+1}\")\n",
|
||||
" break\n",
|
||||
" # calculate loss\n",
|
||||
" loss1 = criterion(outputs, data_target)\n",
|
||||
" if epoch % 100 == 0:\n",
|
||||
" print(f'Epoch {epoch+1}: Loss = {loss1}')\n",
|
||||
" # backward pass\n",
|
||||
" loss1.backward() \n",
|
||||
" # update weights\n",
|
||||
" optimizer.step() \n",
|
||||
"outputs = model(data_in)\n",
|
||||
"predicted = (outputs.round() == data_target)\n",
|
||||
"accuracy = predicted.sum().item() / (data_target == data_target).sum().item()\n",
|
||||
"print(f\"accuracy: {accuracy*100}%\")\n",
|
||||
"for name, param in model.named_parameters():\n",
|
||||
" print(name, param.data)\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "e29c65a2",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": []
|
||||
}
|
||||
],
|
||||
"metadata": {
|
||||
"kernelspec": {
|
||||
"display_name": "Python 3 (ipykernel)",
|
||||
"language": "python",
|
||||
"name": "python3"
|
||||
},
|
||||
"language_info": {
|
||||
"codemirror_mode": {
|
||||
"name": "ipython",
|
||||
"version": 3
|
||||
},
|
||||
"file_extension": ".py",
|
||||
"mimetype": "text/x-python",
|
||||
"name": "python",
|
||||
"nbconvert_exporter": "python",
|
||||
"pygments_lexer": "ipython3",
|
||||
"version": "3.12.2"
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
"nbformat_minor": 5
|
||||
}
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -0,0 +1,635 @@
|
||||
{
|
||||
"cells": [
|
||||
{
|
||||
"attachments": {},
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"# Lab 8: Evolutionary computation\n",
|
||||
"\n",
|
||||
"### Consider the following example:\n",
|
||||
"\n",
|
||||
"Determine the minimum of the function $f(x)= x_1^2+...+x_n^2$ with $x_i \\in [-5.12, 5.12]$, $i \\in \\overline{(1, n)}$\n",
|
||||
"\n",
|
||||
"We have an example of steady state genetic algorithm with: representation an array of real numbers; 100 individuals; crossover $$child = \\alpha \\cdot (parent1 - parent2) + parent2 ;$$ mutation - reinitialise on a random position the individual's value."
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 29,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"Result: The detected minimum point after 10000 iterations is f(-0.00 -0.00) = 0.00\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"\n",
|
||||
"\n",
|
||||
"from random import randint, random\n",
|
||||
"from operator import add\n",
|
||||
"from math import cos, pi\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"def individual(length, vmin, vmax):\n",
|
||||
" '''\n",
|
||||
" Create a member of the population - an individual\n",
|
||||
"\n",
|
||||
" length: the number of genes (components)\n",
|
||||
" vmin: the minimum possible value \n",
|
||||
" vmax: the maximum possible value \n",
|
||||
" '''\n",
|
||||
" return [ (random()*(vmax-vmin)+vmin) for x in range(length) ]\n",
|
||||
" \n",
|
||||
"def population(count, length, vmin, vmax):\n",
|
||||
" \"\"\"\n",
|
||||
" Create a number of individuals (i.e. a population).\n",
|
||||
"\n",
|
||||
" count: the number of individuals in the population\n",
|
||||
" length: the number of values per individual\n",
|
||||
" vmin: the minimum possible value \n",
|
||||
" vmax: the maximum possible value \n",
|
||||
" \"\"\"\n",
|
||||
" return [ individual(length, vmin, vmax) for x in range(count) ]\n",
|
||||
"\n",
|
||||
"def fitness(individual):\n",
|
||||
" \"\"\"\n",
|
||||
" Determine the fitness of an individual. Lower is better.(min problem)\n",
|
||||
" For this problem we have the Rastrigin function\n",
|
||||
" \n",
|
||||
" individual: the individual to evaluate\n",
|
||||
" \"\"\"\n",
|
||||
" n=len(individual)\n",
|
||||
" f=0;\n",
|
||||
" for i in range(n):\n",
|
||||
" f=f+individual[i]*individual[i]\n",
|
||||
" return f\n",
|
||||
" \n",
|
||||
"def mutate(individual, pM, vmin, vmax): \n",
|
||||
" '''\n",
|
||||
" Performs a mutation on an individual with the probability of pM.\n",
|
||||
" If the event will take place, at a random position a new value will be\n",
|
||||
" generated in the interval [vmin, vmax]\n",
|
||||
"\n",
|
||||
" individual:the individual to be mutated\n",
|
||||
" pM: the probability the mutation to occure\n",
|
||||
" vmin: the minimum possible value \n",
|
||||
" vmax: the maximum possible value\n",
|
||||
" '''\n",
|
||||
" if pM > random():\n",
|
||||
" p = randint(0, len(individual)-1)\n",
|
||||
" individual[p] = random()*(vmax-vmin)+vmin\n",
|
||||
" return individual\n",
|
||||
" \n",
|
||||
"def crossover(parent1, parent2):\n",
|
||||
" '''\n",
|
||||
" crossover between 2 parents\n",
|
||||
" '''\n",
|
||||
" child=[]\n",
|
||||
" alpha=random()\n",
|
||||
" for x in range(len(parent1)):\n",
|
||||
" child.append(alpha*(parent1[x]-parent2[x])+parent2[x])\n",
|
||||
" return child\n",
|
||||
"\n",
|
||||
"def iteration(pop, pM, vmin, vmax):\n",
|
||||
" '''\n",
|
||||
" an iteration\n",
|
||||
"\n",
|
||||
" pop: the current population\n",
|
||||
" pM: the probability the mutation to occure\n",
|
||||
" vmin: the minimum possible value \n",
|
||||
" vmax: the maximum possible value\n",
|
||||
" '''\n",
|
||||
" i1=randint(0,len(pop)-1)\n",
|
||||
" i2=randint(0,len(pop)-1)\n",
|
||||
" if (i1!=i2):\n",
|
||||
" c=crossover(pop[i1],pop[i2])\n",
|
||||
" c=mutate(c, pM, vmin, vmax)\n",
|
||||
" f1=fitness(pop[i1])\n",
|
||||
" f2=fitness(pop[i2])\n",
|
||||
" '''\n",
|
||||
" the repeated evaluation of the parents can be avoided\n",
|
||||
" if next to the values stored in the individuals we \n",
|
||||
" keep also their fitnesses \n",
|
||||
" '''\n",
|
||||
" fc=fitness(c)\n",
|
||||
" if(f1>f2) and (f1>fc):\n",
|
||||
" pop[i1]=c\n",
|
||||
" if(f2>f1) and (f2>fc):\n",
|
||||
" pop[i2]=c\n",
|
||||
" return pop\n",
|
||||
"\n",
|
||||
"def main(noIteratii=10000):\n",
|
||||
" #PARAMETERS:\n",
|
||||
" \n",
|
||||
" #population size\n",
|
||||
" dimPopulation = 100\n",
|
||||
" #individual size\n",
|
||||
" dimIndividual = 2\n",
|
||||
" #the boundries of the search interval\n",
|
||||
" vmin = -5.12\n",
|
||||
" vmax = 5.12\n",
|
||||
" #the mutation probability\n",
|
||||
" pM=0.01\n",
|
||||
" \n",
|
||||
" P = population(dimPopulation, dimIndividual, vmin, vmax)\n",
|
||||
" for i in range(noIteratii):\n",
|
||||
" P = iteration(P, pM, vmin, vmax)\n",
|
||||
"\n",
|
||||
" #print the best individual\n",
|
||||
" graded = [ (fitness(x), x) for x in P]\n",
|
||||
" graded = sorted(graded)\n",
|
||||
" result=graded[0]\n",
|
||||
" fitnessOptim=result[0]\n",
|
||||
" individualOptim=result[1]\n",
|
||||
" print('Result: The detected minimum point after %d iterations is f(%3.2f %3.2f) = %3.2f'% \\\n",
|
||||
" (noIteratii,individualOptim[0],individualOptim[1], fitnessOptim) )\n",
|
||||
" \n",
|
||||
"main()"
|
||||
]
|
||||
},
|
||||
{
|
||||
"attachments": {},
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"Exercise 1: Construct a similar algorithm to the one provided as an example for the Bukin function N.6 (search the internet for this function).\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 25,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"Result: The detected minimum point after 10000 iterations is f(-9.81 0.96) = 0.00\n",
|
||||
"0.0\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"# your code here\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"from random import randint, random\n",
|
||||
"from operator import add\n",
|
||||
"from math import cos, pi\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"def individual():\n",
|
||||
" return [ (random()*(-5+15)-15), (random()*(3+3)-3)]\n",
|
||||
" \n",
|
||||
"def population(count):\n",
|
||||
" return [ individual() for x in range(count) ]\n",
|
||||
"\n",
|
||||
"def fitness(individual):\n",
|
||||
" return (100 *((abs(individual[1] - 0.01*(individual[0]**2)))**(1/2))) + (0.01 * abs(individual[0] + 10))\n",
|
||||
" \n",
|
||||
"def mutate(individual, pM): \n",
|
||||
" if pM > random():\n",
|
||||
" p = randint(0, 1)\n",
|
||||
" if p == 0:\n",
|
||||
" individual[0] = random()*(-5+15)-15\n",
|
||||
" else:\n",
|
||||
" individual[1] = random()*(3+3)-3\n",
|
||||
" return individual\n",
|
||||
" \n",
|
||||
"def crossover(parent1, parent2):\n",
|
||||
" child=[]\n",
|
||||
" alpha=random()\n",
|
||||
" for x in range(len(parent1)):\n",
|
||||
" child.append(alpha*(parent1[x]-parent2[x])+parent2[x])\n",
|
||||
" return child\n",
|
||||
"\n",
|
||||
"def iteration(pop, pM):\n",
|
||||
" i1=randint(0,len(pop)-1)\n",
|
||||
" i2=randint(0,len(pop)-1)\n",
|
||||
" if (i1!=i2):\n",
|
||||
" c=crossover(pop[i1],pop[i2])\n",
|
||||
" c=mutate(c, pM)\n",
|
||||
" f1=fitness(pop[i1])\n",
|
||||
" f2=fitness(pop[i2])\n",
|
||||
" fc=fitness(c)\n",
|
||||
" if(f1>f2) and (f1>fc):\n",
|
||||
" pop[i1]=c\n",
|
||||
" if(f2>f1) and (f2>fc):\n",
|
||||
" pop[i2]=c\n",
|
||||
" return pop\n",
|
||||
"\n",
|
||||
"def main(noIteratii=10000):\n",
|
||||
" #PARAMETERS:\n",
|
||||
" \n",
|
||||
" #population size\n",
|
||||
" dimPopulation = 100\n",
|
||||
" #the mutation probability\n",
|
||||
" pM=0.01\n",
|
||||
" \n",
|
||||
" P = population(dimPopulation)\n",
|
||||
" for i in range(noIteratii):\n",
|
||||
" P = iteration(P, pM)\n",
|
||||
"\n",
|
||||
" #print the best individual\n",
|
||||
" graded = [ (fitness(x), x) for x in P]\n",
|
||||
" graded = sorted(graded)\n",
|
||||
" result=graded[0]\n",
|
||||
" fitnessOptim=result[0]\n",
|
||||
" individualOptim=result[1]\n",
|
||||
" print('Result: The detected minimum point after %d iterations is f(%3.2f %3.2f) = %3.2f'% \\\n",
|
||||
" (noIteratii,individualOptim[0],individualOptim[1], fitnessOptim) )\n",
|
||||
" print(fitness((-10,1)))\n",
|
||||
"main()"
|
||||
]
|
||||
},
|
||||
{
|
||||
"attachments": {},
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"Consider the knapsack problem:\n",
|
||||
"\n",
|
||||
"Consider a Knapsack with a total volum equal with $V_{max}$.\n",
|
||||
"\n",
|
||||
"There are $n$ objects, with values $(p_i)_{n}$ and volumes $(v_i)_n$.\n",
|
||||
"\n",
|
||||
"Solve this problem using a generationist Genetic Algorithm, with a binary representation.\n",
|
||||
"\n",
|
||||
"Exercise 2: Initialization\n",
|
||||
"Objective: Implement the initialization step of a genetic algorithm."
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 34,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"[[0 1 0 0 1 1 1 0]\n",
|
||||
" [0 1 0 1 0 1 0 0]\n",
|
||||
" [0 1 0 1 0 1 0 1]\n",
|
||||
" [1 0 0 0 0 0 0 1]\n",
|
||||
" [0 1 0 1 0 1 1 1]\n",
|
||||
" [0 1 0 1 0 1 1 1]\n",
|
||||
" [1 1 0 0 1 1 0 0]\n",
|
||||
" [1 0 0 0 0 0 1 0]\n",
|
||||
" [1 0 0 1 0 0 1 0]\n",
|
||||
" [1 1 1 1 0 0 0 0]]\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"import random\n",
|
||||
"import numpy as np\n",
|
||||
"\n",
|
||||
"def individual(chromosome_length):\n",
|
||||
" return np.array([randint(0,1) for _ in range(chromosome_length)])\n",
|
||||
"\n",
|
||||
"def initialize_population(population_size, chromosome_length):\n",
|
||||
" # generate random a population with population_size number of individuals\n",
|
||||
" # each individual with the size chromosome_length\n",
|
||||
" # IN: population_size, chromosome_length\n",
|
||||
" # OUT: population\n",
|
||||
" return np.array([individual(chromosome_length) for _ in range(population_size)])\n",
|
||||
" # your code here\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"# Test the initialization step\n",
|
||||
"population_size = 10\n",
|
||||
"chromosome_length = 8\n",
|
||||
"weights = np.array([1, 4, 5, 7, 3, 2, 4 ,1])\n",
|
||||
"values = np.array([2, 3, 1, 4, 2, 3, 4, 5])\n",
|
||||
"limit = 14\n",
|
||||
"population = initialize_population(population_size, chromosome_length)\n",
|
||||
"print(population)\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"attachments": {},
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"Exercise 3: Fitness Evaluation\n",
|
||||
"\n",
|
||||
"Objective: Implement the fitness evaluation step of a genetic algorithm."
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 35,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"[12 10 15 7 0 0 10 6 10 0]\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"def evaluate_fitness(population):\n",
|
||||
" # evaluate the fitness of each individual in the population\n",
|
||||
" # IN: population\n",
|
||||
" # OUT: fitness_scores\n",
|
||||
" # your code here\n",
|
||||
" total_weights = (weights * population).sum(axis=1)\n",
|
||||
" scores = (values * population).sum(axis=1)\n",
|
||||
" scores[total_weights > limit] = 0\n",
|
||||
" return scores\n",
|
||||
" \n",
|
||||
"# Test the fitness evaluation step\n",
|
||||
"fitness_scores = evaluate_fitness(population)\n",
|
||||
"print(fitness_scores)\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"attachments": {},
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"Exercise 4: Selection\n",
|
||||
"\n",
|
||||
"Objective: Implement the selection step of a genetic algorithm."
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 36,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"[[0 1 0 1 0 1 0 0]\n",
|
||||
" [0 1 0 1 0 1 0 1]]\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"def select_parents(population, fitness_scores):\n",
|
||||
" # select two parents from the population based on the fitness - \n",
|
||||
" # the better the fitness, the higher the chance to be selected\n",
|
||||
" # IN: population, fitness_scores\n",
|
||||
" # OUT: selected_parents\n",
|
||||
" # your code here\n",
|
||||
" probs = ((fitness_scores + 1) / (fitness_scores + 1).sum())\n",
|
||||
" indexes = np.random.choice(population.shape[0], size = 2, replace=False, p=probs)\n",
|
||||
" return population[indexes]\n",
|
||||
" \n",
|
||||
"# Test the selection step\n",
|
||||
"parents = select_parents(population, fitness_scores)\n",
|
||||
"print(parents)\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"attachments": {},
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"Exercise 5: Crossover\n",
|
||||
"\n",
|
||||
"Objective: Implement the crossover step of a genetic algorithm."
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 39,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"[0. 1. 0. 1. 0. 1. 0. 1.]\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"def crossover(parents):\n",
|
||||
" # create new offspring by combining the parents\n",
|
||||
" # IN: parents\n",
|
||||
" # OUT: offspring\n",
|
||||
"\n",
|
||||
" # your code here\n",
|
||||
" offspring = np.zeros((parents.shape[1],))\n",
|
||||
" for i in range(parents.shape[1]):\n",
|
||||
" if parents[0][i] == parents[1][i]:\n",
|
||||
" offspring[i] = parents[0][i]\n",
|
||||
" else:\n",
|
||||
" offspring[i] = random.randint(0, 1)\n",
|
||||
" return offspring\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"# Test the crossover step\n",
|
||||
"offspring = crossover(parents)\n",
|
||||
"print(offspring)\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"attachments": {},
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"Exercise 6: Mutation\n",
|
||||
"\n",
|
||||
"Objective: Implement the mutation step of a genetic algorithm."
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 40,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"[0.0, 1.0, 0.0, 1.0, 0.0, 1.0, 0.0, 1.0]\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"def mutate(chromosome, mutation_rate):\n",
|
||||
" # mutate the chromosome by randomly flipping bits\n",
|
||||
" # IN: chromosome, mutation_rate\n",
|
||||
" # OUT: mutated_chromosome\n",
|
||||
"\n",
|
||||
" # your code here\n",
|
||||
" if random.random() <= mutation_rate:\n",
|
||||
" for i in range(len(chromosome)):\n",
|
||||
" chromosome[i] = random.randint(0, 1)\n",
|
||||
" return chromosome\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"# Test the mutation step\n",
|
||||
"mutation_rate = 0.1\n",
|
||||
"mutated_offspring = [mutate(child, mutation_rate) for child in offspring]\n",
|
||||
"print(mutated_offspring)\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"attachments": {},
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"Exercise 7: Complete Genetic Algorithm\n",
|
||||
"\n",
|
||||
"Objective: Combine all the steps of a genetic algorithm to solve a specific problem."
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 56,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"[[1 1 0 0 0 1 1 1]\n",
|
||||
" [1 1 0 0 0 1 1 1]\n",
|
||||
" [1 1 0 0 0 1 1 1]\n",
|
||||
" [1 1 0 0 0 1 1 1]\n",
|
||||
" [1 1 0 0 0 1 1 1]\n",
|
||||
" [1 1 0 0 0 1 1 1]\n",
|
||||
" [1 1 0 0 0 1 1 1]\n",
|
||||
" [1 1 0 0 0 1 1 1]\n",
|
||||
" [1 1 0 0 0 1 1 1]\n",
|
||||
" [1 1 0 0 0 1 1 1]]\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"def genetic_algorithm(population_size, chromosome_length, generations, mutation_rate):\n",
|
||||
" \n",
|
||||
" # complete genetic algorithm\n",
|
||||
" # IN: population_size, chromosome_length, generations, mutation_rate\n",
|
||||
" # OUT: population\n",
|
||||
"\n",
|
||||
"\n",
|
||||
" # initialize the population\n",
|
||||
" population = initialize_population(population_size, chromosome_length)\n",
|
||||
" # your code here\n",
|
||||
" \n",
|
||||
"\n",
|
||||
" for _ in range(generations):\n",
|
||||
" # Fitness evaluation\n",
|
||||
" # your code here\n",
|
||||
" fitnesses = evaluate_fitness(population)\n",
|
||||
" \n",
|
||||
" # Selection\n",
|
||||
" \n",
|
||||
" # your code here\n",
|
||||
" parents = select_parents(population, fitnesses)\n",
|
||||
"\n",
|
||||
" # Crossover\n",
|
||||
"\n",
|
||||
" # your code here\n",
|
||||
" child = crossover(parents)\n",
|
||||
"\n",
|
||||
" # Mutation\n",
|
||||
" \n",
|
||||
" # your code here\n",
|
||||
" mutated_child = mutate(child, mutation_rate)\n",
|
||||
"\n",
|
||||
" # Replace the population with the new generation\n",
|
||||
" \n",
|
||||
" # your code here\n",
|
||||
" minimum = fitnesses.min()\n",
|
||||
" for i in range(fitnesses.shape[0]):\n",
|
||||
" if minimum == fitnesses[i]:\n",
|
||||
" population[i] = mutated_child\n",
|
||||
" break\n",
|
||||
"\n",
|
||||
" return population\n",
|
||||
"\n",
|
||||
"# Test the complete genetic algorithm\n",
|
||||
"population_size = 10\n",
|
||||
"chromosome_length = 8\n",
|
||||
"generations = 100\n",
|
||||
"mutation_rate = 0.1\n",
|
||||
"\n",
|
||||
"final_population = genetic_algorithm(population_size, chromosome_length, generations, mutation_rate)\n",
|
||||
"print(final_population)\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"attachments": {},
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"Exercise 8: Extract the result from the final population\n",
|
||||
"\n",
|
||||
"Objective: Get the best individual from the final population.\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 57,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"Maximum is 17\n",
|
||||
"Chosen values [2 3 0 0 0 3 4 5] with weights [1 4 0 0 0 2 4 1]\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"# determine the best individual from the final population and print it out\n",
|
||||
"\n",
|
||||
"# your code here\n",
|
||||
"\n",
|
||||
"fitnesses = evaluate_fitness(final_population)\n",
|
||||
"maximum = fitnesses.max()\n",
|
||||
"print(f\"Maximum is {maximum}\")\n",
|
||||
"for i in range(0, fitnesses.shape[0]):\n",
|
||||
" if fitnesses[i] == maximum:\n",
|
||||
" print(f\"Chosen values {final_population[i] * values} with weights {final_population[i] * weights}\")\n",
|
||||
" break"
|
||||
]
|
||||
}
|
||||
],
|
||||
"metadata": {
|
||||
"kernel_info": {
|
||||
"name": "python"
|
||||
},
|
||||
"kernelspec": {
|
||||
"display_name": "Python 3",
|
||||
"language": "python",
|
||||
"name": "python3"
|
||||
},
|
||||
"language_info": {
|
||||
"codemirror_mode": {
|
||||
"name": "ipython",
|
||||
"version": 3
|
||||
},
|
||||
"file_extension": ".py",
|
||||
"mimetype": "text/x-python",
|
||||
"name": "python",
|
||||
"nbconvert_exporter": "python",
|
||||
"pygments_lexer": "ipython3",
|
||||
"version": "3.12.2"
|
||||
},
|
||||
"nteract": {
|
||||
"version": "nteract-front-end@1.0.0"
|
||||
},
|
||||
"orig_nbformat": 4
|
||||
},
|
||||
"nbformat": 4,
|
||||
"nbformat_minor": 2
|
||||
}
|
||||
@@ -0,0 +1,198 @@
|
||||
{
|
||||
"cells": [
|
||||
{
|
||||
"attachments": {},
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"## Lab. 12\n",
|
||||
"\n",
|
||||
"### Solve the following problem using Genetic Algorithms:\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"Problem: Weighted N-Queen Problem\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"You are given an N×N chessboard, and each cell of the board has an associated weight. Your task is to find a valid placement of N queens such that the total weight of the queens is maximized, and no two queens threaten each other.\n",
|
||||
"\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"attachments": {},
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"\n",
|
||||
"\n",
|
||||
"In the traditional N-Queen Problem, the goal is to place N queens on an N×N chessboard in such a way that no two queens threaten each other. In this variation, we introduce weights to the queens and aim to find a placement that maximizes the total weight of the queens while satisfying the constraint of non-threatening positions.\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"Constraints:\n",
|
||||
"\n",
|
||||
"1. There should be exactly one queen in each row and each column.\n",
|
||||
"2. No two queens should be placed in the same diagonal, i.e., they should not threaten each other.\n",
|
||||
"3. The placement should maximize the total weight of the queens.\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"Representation:\n",
|
||||
"\n",
|
||||
"Use a permutation-based representation. Each permutation represents the column position of the queen for each row. \n",
|
||||
"\n",
|
||||
"For example, if N=4, a valid permutation [2, 4, 1, 3] indicates that the queen in the first row is placed in column 2, the queen in the second row is placed in column 4, and so on.\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"Genetic Algorithm Steps:\n",
|
||||
"\n",
|
||||
"1. *Initialization*: Generate an initial population of permutations randomly.\n",
|
||||
"\n",
|
||||
"2. *Fitness Evaluation*: Evaluate the fitness of each permutation by calculating the total weight of the queens while considering the non-threatening positions.\n",
|
||||
"\n",
|
||||
"3. *Selection*: Select a subset of permutations from the population based on their fitness, using selection techniques like tournament selection or roulette wheel selection.\n",
|
||||
"\n",
|
||||
"4. *Crossover*: Perform crossover (recombination) on the selected permutations to create new offspring permutations.\n",
|
||||
"\n",
|
||||
"5. *Mutation*: Introduce random changes (mutations) in the offspring permutations to maintain diversity in the population.\n",
|
||||
"\n",
|
||||
"6. *Fitness Evaluation for the new individuals*: Evaluate the fitness of the new population.\n",
|
||||
"\n",
|
||||
"7. *Form the new population*: Select the surviving individuals based on scores, with chances direct proportional with their performance.\n",
|
||||
"\n",
|
||||
"8. Repeat steps 3-7 for a certain number of generations or until a termination condition is met (e.g., a maximum number of iterations or a satisfactory solution is found).\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"9. *Termination*: Return the best-performing individual (permutation) found as the solution to the problem.\n",
|
||||
"\n",
|
||||
"Note: The fitness function used in this problem should calculate the total weight of the queens based on the positions specified by the permutation. Additionally, the fitness function should penalize solutions that violate the non-threatening constraint by assigning a lower fitness score to such permutations."
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 223,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"[[0 1 2 3]\n",
|
||||
" [1 0 4 5]\n",
|
||||
" [2 4 0 6]\n",
|
||||
" [3 5 6 0]]\n",
|
||||
"[[3 0 1 2]\n",
|
||||
" [3 1 2 0]\n",
|
||||
" [3 1 2 0]\n",
|
||||
" [0 1 2 3]\n",
|
||||
" [2 0 1 3]]\n",
|
||||
"[2 0 3 1]\n",
|
||||
"14\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"import numpy as np\n",
|
||||
"import random\n",
|
||||
"\n",
|
||||
"np.random.seed(40)\n",
|
||||
"\n",
|
||||
"n = 4\n",
|
||||
"weights = np.array([[0, 1, 2, 3], [1, 0, 4, 5], [2, 4, 0, 6], [3, 5, 6, 0]])\n",
|
||||
"\n",
|
||||
"print(weights)\n",
|
||||
"\n",
|
||||
"def initialization(chromosome_size: int, population_size: int) -> np.ndarray:\n",
|
||||
" return np.array([np.random.permutation(chromosome_size) for _ in range(population_size)])\n",
|
||||
"\n",
|
||||
"def fitness(chromosome: np.ndarray, weights: np.ndarray) -> int:\n",
|
||||
" score = 0\n",
|
||||
" for i in range(len(chromosome)):\n",
|
||||
" if not is_attacked(chromosome, [i, chromosome[i]]):\n",
|
||||
" score += weights[i, chromosome[i]]\n",
|
||||
" return score\n",
|
||||
"\n",
|
||||
"def is_attacked(chromosome: np.ndarray, queen: list) -> bool:\n",
|
||||
" for i in range(len(chromosome)):\n",
|
||||
" if i == queen[0]:\n",
|
||||
" continue\n",
|
||||
" if abs(i - queen[0]) == abs(chromosome[i] - queen[1]):\n",
|
||||
" return True\n",
|
||||
" return False\n",
|
||||
"\n",
|
||||
"def selection(population: np.ndarray, weights: np.ndarray) -> np.ndarray:\n",
|
||||
" return random.choices(population, weights=[fitness(chromosome, weights)+1 for chromosome in population], k=2)\n",
|
||||
"\n",
|
||||
"def crossover(parent1: np.ndarray, parent2: np.ndarray) -> np.ndarray:\n",
|
||||
" point1, point2 = sorted(np.random.choice(len(parent1)+1, 2, replace=False))\n",
|
||||
" offspring = np.full_like(parent1, -1)\n",
|
||||
" offspring[point1:point2] = parent1[point1:point2]\n",
|
||||
"\n",
|
||||
" idx = 0\n",
|
||||
" while idx != len(offspring) and offspring[idx] != -1:\n",
|
||||
" idx += 1\n",
|
||||
" for gene in parent2:\n",
|
||||
" if gene not in offspring:\n",
|
||||
" offspring[idx] = gene\n",
|
||||
" while idx != len(offspring) and offspring[idx] != -1:\n",
|
||||
" idx += 1\n",
|
||||
" return offspring\n",
|
||||
"\n",
|
||||
"def mutation(chromosome: np.ndarray, probability: np.float32) -> np.ndarray:\n",
|
||||
" if random.random() < probability:\n",
|
||||
" point1, point2 = np.random.choice(len(chromosome), 2, replace=False)\n",
|
||||
" chromosome[point1], chromosome[point2] = chromosome[point2], chromosome[point1]\n",
|
||||
" return chromosome\n",
|
||||
"\n",
|
||||
"def genetic_algorithm(n: int, weights: np.ndarray, population_size: int, generations: int, mutation_probability: np.float32) -> np.ndarray:\n",
|
||||
" population = initialization(n, population_size)\n",
|
||||
" print(population)\n",
|
||||
" for _ in range(generations):\n",
|
||||
" parent1, parent2 = selection(population, weights)\n",
|
||||
" offspring = crossover(parent1, parent2)\n",
|
||||
" offspring = mutation(offspring, mutation_probability)\n",
|
||||
" if fitness(offspring, weights) > fitness(parent1, weights):\n",
|
||||
" population[np.where((population == parent1).all(axis=1))[0][0]] = offspring\n",
|
||||
" elif fitness(offspring, weights) > fitness(parent2, weights):\n",
|
||||
" population[np.where((population == parent2).all(axis=1))[0][0]] = offspring\n",
|
||||
" return max(population, key=lambda x: fitness(x, weights))\n",
|
||||
" \n",
|
||||
"\n",
|
||||
"# print(initialization(n, 5))\n",
|
||||
"# print(fitness(np.array([2, 0, 3, 1]), weights))\n",
|
||||
"# print(crossover(np.array([1, 3, 0, 2]), np.array([1, 3, 0, 2])))\n",
|
||||
"\n",
|
||||
"champion = genetic_algorithm(n, weights, 5, 100, 0.6)\n",
|
||||
"print(champion)\n",
|
||||
"print(fitness(champion, weights))\n",
|
||||
"\n",
|
||||
"\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"metadata": {
|
||||
"kernel_info": {
|
||||
"name": "python"
|
||||
},
|
||||
"kernelspec": {
|
||||
"display_name": "Python 3",
|
||||
"language": "python",
|
||||
"name": "python3"
|
||||
},
|
||||
"language_info": {
|
||||
"codemirror_mode": {
|
||||
"name": "ipython",
|
||||
"version": 3
|
||||
},
|
||||
"file_extension": ".py",
|
||||
"mimetype": "text/x-python",
|
||||
"name": "python",
|
||||
"nbconvert_exporter": "python",
|
||||
"pygments_lexer": "ipython3",
|
||||
"version": "3.12.2"
|
||||
},
|
||||
"nteract": {
|
||||
"version": "nteract-front-end@1.0.0"
|
||||
},
|
||||
"orig_nbformat": 4
|
||||
},
|
||||
"nbformat": 4,
|
||||
"nbformat_minor": 2
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
,YearsExperience,Salary
|
||||
0,1.2000000000000002,39344.0
|
||||
1,1.4000000000000001,46206.0
|
||||
2,1.6,37732.0
|
||||
3,2.1,43526.0
|
||||
4,2.3000000000000003,39892.0
|
||||
5,3.0,56643.0
|
||||
6,3.1,60151.0
|
||||
7,3.3000000000000003,54446.0
|
||||
8,3.3000000000000003,64446.0
|
||||
9,3.8000000000000003,57190.0
|
||||
10,4.0,63219.0
|
||||
11,4.1,55795.0
|
||||
12,4.1,56958.0
|
||||
13,4.199999999999999,57082.0
|
||||
14,4.6,61112.0
|
||||
15,5.0,67939.0
|
||||
16,5.199999999999999,66030.0
|
||||
17,5.3999999999999995,83089.0
|
||||
18,6.0,81364.0
|
||||
19,6.1,93941.0
|
||||
20,6.8999999999999995,91739.0
|
||||
21,7.199999999999999,98274.0
|
||||
22,8.0,101303.0
|
||||
23,8.299999999999999,113813.0
|
||||
24,8.799999999999999,109432.0
|
||||
25,9.1,105583.0
|
||||
26,9.6,116970.0
|
||||
27,9.7,112636.0
|
||||
28,10.4,122392.0
|
||||
29,10.6,121873.0
|
||||
|
File diff suppressed because it is too large
Load Diff
Binary file not shown.
|
After Width: | Height: | Size: 141 KiB |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,154 @@
|
||||
sepal length (cm),sepal width (cm),petal length (cm),petal width (cm),iris_name
|
||||
5.1,3.5,1.4,0.2,setosa
|
||||
4.9,3,1.4,0.2,setosa
|
||||
4.7,3.2,1.3,0.2,setosa
|
||||
4.6,3.1,1.5,0.2,setosa
|
||||
5,3.6,1.4,0.2,setosa
|
||||
5.4,3.9,1.7,0.4,setosa
|
||||
4.6,3.4,1.4,0.3,setosa
|
||||
5,3.4,1.5,0.2,setosa
|
||||
4.4,2.9,1.4,0.2,setosa
|
||||
4.9,3.1,1.5,0.1,setosa
|
||||
5.4,3.7,1.5,0.2,setosa
|
||||
4.8,3.4,1.6,0.2,setosa
|
||||
4.8,3,1.4,0.1,setosa
|
||||
4.3,3,1.1,0.1,setosa
|
||||
5.8,4,1.2,0.2,setosa
|
||||
5.7,4.4,1.5,0.4,setosa
|
||||
5.4,3.9,1.3,0.4,setosa
|
||||
5.1,3.5,1.4,0.3,setosa
|
||||
5.7,3.8,1.7,0.3,setosa
|
||||
5.1,3.8,1.5,0.3,setosa
|
||||
5.4,3.4,1.7,0.2,setosa
|
||||
5.1,3.7,1.5,0.4,setosa
|
||||
4.6,3.6,1,0.2,setosa
|
||||
4.6,3.6,1,,setosa
|
||||
5.1,3.3,1.7,0.5,setosa
|
||||
4.8,3.4,1.9,0.2,setosa
|
||||
5,3,1.6,0.2,setosa
|
||||
5,3.4,1.6,0.4,setosa
|
||||
5.2,3.5,1.5,0.2,setosa
|
||||
5.2,3.4,1.4,0.2,setosa
|
||||
4.7,3.2,1.6,0.2,setosa
|
||||
4.8,3.1,1.6,0.2,setosa
|
||||
5.4,3.4,1.5,0.4,setosa
|
||||
5.2,4.1,1.5,0.1,setosa
|
||||
5.5,4.2,1.4,0.2,setosa
|
||||
4.9,3.1,1.5,0.2,setosa
|
||||
5,3.2,1.2,0.2,setosa
|
||||
5.5,3.5,1.3,0.2,setosa
|
||||
4.9,3.6,1.4,0.1,setosa
|
||||
4.4,3,1.3,0.2,setosa
|
||||
5.1,3.4,1.5,0.2,setosa
|
||||
,3,1.3,0.2,
|
||||
5,3.5,1.3,0.3,setosa
|
||||
4.5,2.3,1.3,0.3,setosa
|
||||
4.4,3.2,1.3,0.2,setosa
|
||||
5,3.5,1.6,0.6,setosa
|
||||
5.1,3.8,1.9,0.4,setosa
|
||||
4.8,3,1.4,0.3,setosa
|
||||
5.1,3.8,1.6,0.2,setosa
|
||||
4.6,3.2,1.4,0.2,setosa
|
||||
5.3,3.7,1.5,0.2,setosa
|
||||
5,3.3,1.4,0.2,setosa
|
||||
7,3.2,4.7,1.4,versicolor
|
||||
6.4,3.2,4.5,1.5,versicolor
|
||||
6.4,,4.5,1.5,versicolor
|
||||
6.9,3.1,4.9,1.5,versicolor
|
||||
5.5,2.3,4,1.3,versicolor
|
||||
6.5,2.8,4.6,1.5,versicolor
|
||||
5.7,2.8,4.5,1.3,versicolor
|
||||
6.3,3.3,4.7,1.6,versicolor
|
||||
4.9,2.4,3.3,1,versicolor
|
||||
6.6,2.9,4.6,1.3,versicolor
|
||||
5.2,2.7,3.9,1.4,versicolor
|
||||
5,2,3.5,1,versicolor
|
||||
5.9,3,4.2,1.5,versicolor
|
||||
6,2.2,4,1,versicolor
|
||||
6.1,2.9,4.7,1.4,versicolor
|
||||
5.6,2.9,3.6,1.3,versicolor
|
||||
6.7,3.1,4.4,1.4,versicolor
|
||||
5.6,3,4.5,1.5,versicolor
|
||||
5.8,2.7,4.1,1,versicolor
|
||||
6.2,2.2,4.5,1.5,versicolor
|
||||
5.6,2.5,3.9,1.1,versicolor
|
||||
5.9,3.2,4.8,1.8,versicolor
|
||||
6.1,2.8,4,1.3,versicolor
|
||||
6.3,2.5,4.9,1.5,versicolor
|
||||
6.1,2.8,4.7,1.2,versicolor
|
||||
6.4,2.9,4.3,1.3,versicolor
|
||||
6.6,3,4.4,1.4,versicolor
|
||||
6.8,2.8,4.8,1.4,versicolor
|
||||
6.7,3,5,1.7,versicolor
|
||||
6,2.9,4.5,1.5,versicolor
|
||||
5.7,2.6,3.5,1,versicolor
|
||||
5.5,2.4,3.8,1.1,versicolor
|
||||
5.5,2.4,3.7,1,versicolor
|
||||
5.8,2.7,3.9,1.2,versicolor
|
||||
6,2.7,5.1,1.6,versicolor
|
||||
5.4,3,4.5,1.5,versicolor
|
||||
6,3.4,4.5,1.6,versicolor
|
||||
6.7,3.1,4.7,1.5,versicolor
|
||||
6.3,2.3,4.4,1.3,versicolor
|
||||
5.6,3,4.1,1.3,versicolor
|
||||
5.5,2.5,4,1.3,versicolor
|
||||
5.5,2.6,4.4,1.2,versicolor
|
||||
6.1,3,4.6,1.4,versicolor
|
||||
5.8,2.6,4,1.2,versicolor
|
||||
5,2.3,3.3,1,versicolor
|
||||
5.6,2.7,4.2,1.3,versicolor
|
||||
5.7,3,4.2,1.2,versicolor
|
||||
5.7,2.9,4.2,1.3,versicolor
|
||||
6.2,2.9,4.3,1.3,versicolor
|
||||
5.1,2.5,3,1.1,versicolor
|
||||
5.7,2.8,4.1,1.3,versicolor
|
||||
6.3,3.3,6,2.5,virginica
|
||||
5.8,2.7,5.1,1.9,virginica
|
||||
7.1,3,5.9,2.1,virginica
|
||||
6.3,2.9,5.6,1.8,virginica
|
||||
6.5,3,5.8,2.2,virginica
|
||||
7.6,3,6.6,2.1,virginica
|
||||
4.9,2.5,4.5,1.7,virginica
|
||||
7.3,2.9,6.3,1.8,virginica
|
||||
6.7,2.5,5.8,1.8,virginica
|
||||
7.2,3.6,6.1,2.5,virginica
|
||||
6.5,3.2,5.1,2,virginica
|
||||
6.4,2.7,5.3,1.9,virginica
|
||||
6.8,3,5.5,2.1,virginica
|
||||
5.7,2.5,5,2,virginica
|
||||
5.8,2.8,5.1,2.4,virginica
|
||||
6.4,3.2,5.3,2.3,virginica
|
||||
6.5,3,5.5,1.8,virginica
|
||||
7.7,3.8,6.7,2.2,virginica
|
||||
7.7,2.6,6.9,2.3,virginica
|
||||
6,2.2,5,1.5,virginica
|
||||
6.9,3.2,5.7,2.3,virginica
|
||||
5.6,2.8,4.9,2,virginica
|
||||
7.7,2.8,6.7,2,virginica
|
||||
6.3,2.7,4.9,1.8,virginica
|
||||
6.7,3.3,5.7,2.1,virginica
|
||||
7.2,3.2,6,1.8,virginica
|
||||
6.2,2.8,4.8,1.8,virginica
|
||||
6.1,3,4.9,1.8,virginica
|
||||
6.4,2.8,5.6,2.1,virginica
|
||||
7.2,3,5.8,1.6,virginica
|
||||
7.4,2.8,6.1,1.9,virginica
|
||||
7.9,3.8,6.4,2,virginica
|
||||
6.4,2.8,5.6,2.2,virginica
|
||||
6.3,2.8,5.1,1.5,virginica
|
||||
6.1,2.6,5.6,1.4,virginica
|
||||
7.7,3,6.1,2.3,virginica
|
||||
6.3,3.4,5.6,2.4,virginica
|
||||
6.4,3.1,5.5,1.8,virginica
|
||||
6,3,4.8,1.8,virginica
|
||||
6.9,3.1,5.4,2.1,virginica
|
||||
6.7,3.1,5.6,2.4,virginica
|
||||
6.9,3.1,5.1,2.3,virginica
|
||||
5.8,2.7,5.1,1.9,virginica
|
||||
6.8,3.2,5.9,2.3,virginica
|
||||
6.7,3.3,5.7,2.5,virginica
|
||||
6.7,3,5.2,2.3,virginica
|
||||
6.3,2.5,5,1.9,virginica
|
||||
6.5,3,5.2,2,virginica
|
||||
6.2,3.4,5.4,2.3,virginica
|
||||
5.9,3,5.1,1.8,virginica
|
||||
|
Binary file not shown.
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,26 @@
|
||||
Hours,Scores
|
||||
2.5,21
|
||||
5.1,47
|
||||
3.2,27
|
||||
8.5,75
|
||||
3.5,30
|
||||
1.5,20
|
||||
9.2,88
|
||||
5.5,60
|
||||
8.3,81
|
||||
2.7,25
|
||||
7.7,85
|
||||
5.9,62
|
||||
4.5,41
|
||||
3.3,42
|
||||
1.1,17
|
||||
8.9,95
|
||||
2.5,30
|
||||
1.9,24
|
||||
6.1,67
|
||||
7.4,69
|
||||
2.7,30
|
||||
4.8,54
|
||||
3.8,35
|
||||
6.9,76
|
||||
7.8,86
|
||||
|
@@ -0,0 +1,98 @@
|
||||
Hours,Scores
|
||||
2.5,21
|
||||
5.1,47
|
||||
3.2,27
|
||||
8.5,75
|
||||
3.5,30
|
||||
1.5,20
|
||||
9.2,88
|
||||
5.5,60
|
||||
8.3,81
|
||||
2.7,25
|
||||
7.7,85
|
||||
5.9,62
|
||||
4.5,41
|
||||
3.3,42
|
||||
1.1,17
|
||||
8.9,95
|
||||
2.5,30
|
||||
1.9,24
|
||||
6.1,67
|
||||
7.4,69
|
||||
2.7,30
|
||||
4.8,54
|
||||
3.8,35
|
||||
6.9,76
|
||||
7.8,86
|
||||
4.2,49
|
||||
9.5,90
|
||||
5.8,63
|
||||
2.3,23
|
||||
4.7,50
|
||||
1.6,19
|
||||
9.0,92
|
||||
6.2,68
|
||||
8.1,82
|
||||
3.9,38
|
||||
2.2,22
|
||||
7.1,73
|
||||
6.3,66
|
||||
5.3,56
|
||||
4.4,45
|
||||
1.8,21
|
||||
9.4,93
|
||||
6.7,71
|
||||
3.7,37
|
||||
7.3,77
|
||||
4.1,44
|
||||
8.0,79
|
||||
3.1,28
|
||||
1.3,16
|
||||
5.7,59
|
||||
2.8,29
|
||||
7.9,80
|
||||
6.6,72
|
||||
3.6,36
|
||||
2.4,26
|
||||
4.6,48
|
||||
8.4,84
|
||||
1.7,18
|
||||
5.2,53
|
||||
6.4,64
|
||||
7.6,78
|
||||
9.3,94
|
||||
3.4,33
|
||||
2.1,20
|
||||
5.4,55
|
||||
8.2,83
|
||||
1.4,15
|
||||
9.6,98
|
||||
6.8,74
|
||||
7.5,70
|
||||
4.3,43
|
||||
6.5,65
|
||||
8.7,87
|
||||
3.0,27
|
||||
2.9,31
|
||||
1.2,14
|
||||
9.7,96
|
||||
4.9,51
|
||||
5.6,57
|
||||
8.6,89
|
||||
2.6,32
|
||||
7.2,72
|
||||
1.0,12
|
||||
6.0,61
|
||||
4.0,40
|
||||
5.0,52
|
||||
6.8,67
|
||||
2.0,18
|
||||
3.0,34
|
||||
7.0,73
|
||||
9.8,99
|
||||
5.8,60
|
||||
4.4,44
|
||||
6.1,63
|
||||
3.7,37
|
||||
8.0,84
|
||||
|
||||
|
@@ -0,0 +1,49 @@
|
||||
import torch
|
||||
from torch import nn
|
||||
import numpy as np
|
||||
import matplotlib.pyplot as plt
|
||||
|
||||
def plot_decision_boundary(model: torch.nn.Module, X: torch.Tensor, y: torch.Tensor) -> None:
|
||||
"""Plots decision boundaries of a given PyTorch model, in comparison to the ground truth.
|
||||
|
||||
Args:
|
||||
model (torch.nn.Module): The PyTorch model to visualize.
|
||||
X (torch.Tensor): The input tensor for the model.
|
||||
y (torch.Tensor): The ground truth tensor.
|
||||
|
||||
Returns:
|
||||
None.
|
||||
|
||||
"""
|
||||
# Transfer the model and data to CPU
|
||||
device = torch.device("cpu")
|
||||
model.to(device)
|
||||
X, y = X.to(device), y.to(device)
|
||||
|
||||
# Create a grid of prediction boundaries
|
||||
x_min, x_max = X[:, 0].min() - 0.1, X[:, 0].max() + 0.1
|
||||
y_min, y_max = X[:, 1].min() - 0.1, X[:, 1].max() + 0.1
|
||||
xx, yy = np.meshgrid(np.linspace(x_min, x_max, 101), np.linspace(y_min, y_max, 101))
|
||||
|
||||
# Convert the grid to a PyTorch tensor
|
||||
X_to_pred_on = torch.from_numpy(np.column_stack((xx.ravel(), yy.ravel()))).float().to(device)
|
||||
|
||||
# Make predictions using the model
|
||||
model.eval()
|
||||
with torch.no_grad():
|
||||
y_logits = model(X_to_pred_on)
|
||||
|
||||
# Determine if this is a binary or multi-class classification problem
|
||||
if len(torch.unique(y)) > 2:
|
||||
y_pred = torch.softmax(y_logits, dim=1).argmax(dim=1) # multi-class
|
||||
else:
|
||||
y_pred = torch.round(torch.sigmoid(y_logits)) # binary
|
||||
|
||||
# Reshape the prediction tensor and plot the decision boundary
|
||||
y_pred = y_pred.reshape(xx.shape).detach().numpy()
|
||||
plt.contourf(xx, yy, y_pred, cmap=plt.cm.RdYlBu, alpha=0.7)
|
||||
|
||||
# Plot the original data points
|
||||
plt.scatter(X[:, 0], X[:, 1], c=y, s=40, cmap=plt.cm.RdYlBu)
|
||||
plt.xlim(xx.min(), xx.max())
|
||||
plt.ylim(yy.min(), yy.max())
|
||||
@@ -0,0 +1,25 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 17
|
||||
VisualStudioVersion = 17.9.34622.214
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DbmsLab1", "DbmsLab1\DbmsLab1.csproj", "{384EB98E-CE0A-4480-B73A-D043CCEBAE1D}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{384EB98E-CE0A-4480-B73A-D043CCEBAE1D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{384EB98E-CE0A-4480-B73A-D043CCEBAE1D}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{384EB98E-CE0A-4480-B73A-D043CCEBAE1D}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{384EB98E-CE0A-4480-B73A-D043CCEBAE1D}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {3BA95047-F50B-4CC2-B40B-C4FB6F0F3673}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
@@ -0,0 +1,13 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<configuration>
|
||||
<configSections>
|
||||
</configSections>
|
||||
<connectionStrings>
|
||||
<add name="DbmsLab1.Properties.Settings.masterConnectionString"
|
||||
connectionString="Data Source=DANIELCUJBA\SQLEXPRESS;Initial Catalog=master;Integrated Security=True;TrustServerCertificate=True"
|
||||
providerName="System.Data.SqlClient" />
|
||||
</connectionStrings>
|
||||
<startup>
|
||||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8" />
|
||||
</startup>
|
||||
</configuration>
|
||||
@@ -0,0 +1,83 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{384EB98E-CE0A-4480-B73A-D043CCEBAE1D}</ProjectGuid>
|
||||
<OutputType>WinExe</OutputType>
|
||||
<RootNamespace>WindowsFormsApp1</RootNamespace>
|
||||
<AssemblyName>WindowsFormsApp1</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
|
||||
<Deterministic>true</Deterministic>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Deployment" />
|
||||
<Reference Include="System.Drawing" />
|
||||
<Reference Include="System.Net.Http" />
|
||||
<Reference Include="System.Windows.Forms" />
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Form1.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Form1.Designer.cs">
|
||||
<DependentUpon>Form1.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Program.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<EmbeddedResource Include="Form1.resx">
|
||||
<DependentUpon>Form1.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="Properties\Resources.resx">
|
||||
<Generator>ResXFileCodeGenerator</Generator>
|
||||
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
|
||||
<SubType>Designer</SubType>
|
||||
</EmbeddedResource>
|
||||
<Compile Include="Properties\Resources.Designer.cs">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DependentUpon>Resources.resx</DependentUpon>
|
||||
</Compile>
|
||||
<None Include="Properties\Settings.settings">
|
||||
<Generator>SettingsSingleFileGenerator</Generator>
|
||||
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
|
||||
</None>
|
||||
<Compile Include="Properties\Settings.Designer.cs">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DependentUpon>Settings.settings</DependentUpon>
|
||||
<DesignTimeSharedInput>True</DesignTimeSharedInput>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="App.config" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
||||
@@ -0,0 +1,38 @@
|
||||
using System.Windows.Forms;
|
||||
using System.Data;
|
||||
using System.Data.SqlClient;
|
||||
|
||||
namespace DbmsLab1
|
||||
{
|
||||
partial class Form1
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
private DataSet ds;
|
||||
private DataGridView dataGridView1;
|
||||
private DataGridView dataGridView2;
|
||||
private DataSet ds2;
|
||||
private Button UpdateBtn;
|
||||
private SqlDataAdapter adapter;
|
||||
private SqlDataAdapter adapter2;
|
||||
private Button DeleteBtn;
|
||||
private int SelectedChildId = -1;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,161 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using System.Data.SqlClient;
|
||||
|
||||
namespace DbmsLab1
|
||||
{
|
||||
public partial class Form1 : Form
|
||||
{
|
||||
public SqlConnection sqlconnection = new SqlConnection("Data Source=DANIELCUJBA\\SQLEXPRESS;Initial Catalog=master;Integrated Security=True;");
|
||||
public Form1()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.ds = new System.Data.DataSet();
|
||||
this.dataGridView1 = new System.Windows.Forms.DataGridView();
|
||||
this.dataGridView2 = new System.Windows.Forms.DataGridView();
|
||||
this.ds2 = new System.Data.DataSet();
|
||||
this.UpdateBtn = new System.Windows.Forms.Button();
|
||||
this.DeleteBtn = new System.Windows.Forms.Button();
|
||||
((System.ComponentModel.ISupportInitialize)(this.ds)).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.dataGridView2)).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.ds2)).BeginInit();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// ds
|
||||
//
|
||||
this.ds.DataSetName = "NewDataSet";
|
||||
//
|
||||
// dataGridView1
|
||||
//
|
||||
this.dataGridView1.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||
this.dataGridView1.Location = new System.Drawing.Point(79, 12);
|
||||
this.dataGridView1.Name = "dataGridView1";
|
||||
this.dataGridView1.Size = new System.Drawing.Size(745, 150);
|
||||
this.dataGridView1.TabIndex = 0;
|
||||
this.dataGridView1.CellClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.dataGridView1_CellClick);
|
||||
//
|
||||
// dataGridView2
|
||||
//
|
||||
this.dataGridView2.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||
this.dataGridView2.Location = new System.Drawing.Point(79, 196);
|
||||
this.dataGridView2.Name = "dataGridView2";
|
||||
this.dataGridView2.Size = new System.Drawing.Size(745, 150);
|
||||
this.dataGridView2.TabIndex = 1;
|
||||
this.dataGridView2.CellClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.dataGridView2_CellContentClick);
|
||||
//
|
||||
// ds2
|
||||
//
|
||||
this.ds2.DataSetName = "NewDataSet";
|
||||
//
|
||||
// UpdateBtn
|
||||
//
|
||||
this.UpdateBtn.Location = new System.Drawing.Point(364, 389);
|
||||
this.UpdateBtn.Name = "UpdateBtn";
|
||||
this.UpdateBtn.Size = new System.Drawing.Size(138, 46);
|
||||
this.UpdateBtn.TabIndex = 2;
|
||||
this.UpdateBtn.Text = "Save Changes to DB";
|
||||
this.UpdateBtn.UseVisualStyleBackColor = true;
|
||||
this.UpdateBtn.Click += new System.EventHandler(this.UpdateBtn_Click);
|
||||
//
|
||||
// DeleteBtn
|
||||
//
|
||||
this.DeleteBtn.Location = new System.Drawing.Point(624, 389);
|
||||
this.DeleteBtn.Name = "DeleteBtn";
|
||||
this.DeleteBtn.Size = new System.Drawing.Size(108, 45);
|
||||
this.DeleteBtn.TabIndex = 3;
|
||||
this.DeleteBtn.Text = "Delete";
|
||||
this.DeleteBtn.UseVisualStyleBackColor = true;
|
||||
this.DeleteBtn.Click += new System.EventHandler(this.DeleteBtn_Click);
|
||||
//
|
||||
// Form1
|
||||
//
|
||||
this.ClientSize = new System.Drawing.Size(890, 473);
|
||||
this.Controls.Add(this.DeleteBtn);
|
||||
this.Controls.Add(this.UpdateBtn);
|
||||
this.Controls.Add(this.dataGridView2);
|
||||
this.Controls.Add(this.dataGridView1);
|
||||
this.Name = "Form1";
|
||||
this.Load += new System.EventHandler(this.Form1_Load);
|
||||
((System.ComponentModel.ISupportInitialize)(this.ds)).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.dataGridView2)).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.ds2)).EndInit();
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
|
||||
private void Form1_Load(object sender, EventArgs e)
|
||||
{
|
||||
var command = new SqlCommand("SELECT * FROM CardSet", sqlconnection);
|
||||
this.adapter = new SqlDataAdapter(command);
|
||||
|
||||
|
||||
|
||||
this.ds = new DataSet("CardSet");
|
||||
this.adapter.Fill(ds, "CardSet");
|
||||
dataGridView1.DataSource= this.ds.Tables["CardSet"];
|
||||
|
||||
|
||||
}
|
||||
|
||||
private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
|
||||
{
|
||||
var id = dataGridView1.Rows[e.RowIndex].Cells[0].Value;
|
||||
var command = new SqlCommand(string.Format("SELECT * FROM Cards WHERE cardset = {0}",id), sqlconnection);
|
||||
this.adapter2 = new SqlDataAdapter(command);
|
||||
|
||||
|
||||
this.ds2 = new DataSet("Cards");
|
||||
this.adapter2.Fill(ds2, "Cards");
|
||||
dataGridView2.DataSource = this.ds2.Tables["Cards"];
|
||||
}
|
||||
|
||||
private void UpdateBtn_Click(object sender, EventArgs e)
|
||||
{
|
||||
var builder = new SqlCommandBuilder(adapter2);
|
||||
adapter2.UpdateCommand = builder.GetUpdateCommand();
|
||||
try
|
||||
{
|
||||
this.adapter2.Update((DataTable)this.dataGridView2.DataSource);
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message);
|
||||
}
|
||||
}
|
||||
|
||||
private void DeleteBtn_Click(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
var builder = new SqlCommandBuilder(adapter2);
|
||||
adapter2.UpdateCommand = builder.GetUpdateCommand();
|
||||
dataGridView2.Rows.RemoveAt(this.SelectedChildId);
|
||||
this.adapter2.Update((DataTable)this.dataGridView2.DataSource);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void dataGridView2_CellContentClick(object sender, DataGridViewCellEventArgs e)
|
||||
{
|
||||
this.SelectedChildId = e.RowIndex;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,129 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<metadata name="ds.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>17, 17</value>
|
||||
</metadata>
|
||||
<metadata name="ds2.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>83, 17</value>
|
||||
</metadata>
|
||||
<metadata name="$this.TrayHeight" type="System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>106</value>
|
||||
</metadata>
|
||||
</root>
|
||||
@@ -0,0 +1,22 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace DbmsLab1
|
||||
{
|
||||
internal static class Program
|
||||
{
|
||||
/// <summary>
|
||||
/// The main entry point for the application.
|
||||
/// </summary>
|
||||
[STAThread]
|
||||
static void Main()
|
||||
{
|
||||
Application.EnableVisualStyles();
|
||||
Application.SetCompatibleTextRenderingDefault(false);
|
||||
Application.Run(new Form1());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyTitle("DbmsLab1")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("DbmsLab1")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2024")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// Setting ComVisible to false makes the types in this assembly not visible
|
||||
// to COM components. If you need to access a type in this assembly from
|
||||
// COM, set the ComVisible attribute to true on that type.
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||
[assembly: Guid("384eb98e-ce0a-4480-b73a-d043ccebae1d")]
|
||||
|
||||
// Version information for an assembly consists of the following four values:
|
||||
//
|
||||
// Major Version
|
||||
// Minor Version
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||
@@ -0,0 +1,71 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
// Runtime Version:4.0.30319.42000
|
||||
//
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace DbmsLab1.Properties
|
||||
{
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// A strongly-typed resource class, for looking up localized strings, etc.
|
||||
/// </summary>
|
||||
// This class was auto-generated by the StronglyTypedResourceBuilder
|
||||
// class via a tool like ResGen or Visual Studio.
|
||||
// To add or remove a member, edit your .ResX file then rerun ResGen
|
||||
// with the /str option, or rebuild your VS project.
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||
internal class Resources
|
||||
{
|
||||
|
||||
private static global::System.Resources.ResourceManager resourceMan;
|
||||
|
||||
private static global::System.Globalization.CultureInfo resourceCulture;
|
||||
|
||||
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
|
||||
internal Resources()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the cached ResourceManager instance used by this class.
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
internal static global::System.Resources.ResourceManager ResourceManager
|
||||
{
|
||||
get
|
||||
{
|
||||
if ((resourceMan == null))
|
||||
{
|
||||
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("DbmsLab1.Properties.Resources", typeof(Resources).Assembly);
|
||||
resourceMan = temp;
|
||||
}
|
||||
return resourceMan;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Overrides the current thread's CurrentUICulture property for all
|
||||
/// resource lookups using this strongly typed resource class.
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
internal static global::System.Globalization.CultureInfo Culture
|
||||
{
|
||||
get
|
||||
{
|
||||
return resourceCulture;
|
||||
}
|
||||
set
|
||||
{
|
||||
resourceCulture = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,117 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
||||
@@ -0,0 +1,37 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
// Runtime Version:4.0.30319.42000
|
||||
//
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace DbmsLab1.Properties {
|
||||
|
||||
|
||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "17.9.0.0")]
|
||||
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
|
||||
|
||||
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
|
||||
|
||||
public static Settings Default {
|
||||
get {
|
||||
return defaultInstance;
|
||||
}
|
||||
}
|
||||
|
||||
[global::System.Configuration.ApplicationScopedSettingAttribute()]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Configuration.SpecialSettingAttribute(global::System.Configuration.SpecialSetting.ConnectionString)]
|
||||
[global::System.Configuration.DefaultSettingValueAttribute("Data Source=DANIELCUJBA\\SQLEXPRESS;Initial Catalog=master;Integrated Security=Tru" +
|
||||
"e;TrustServerCertificate=True")]
|
||||
public string masterConnectionString {
|
||||
get {
|
||||
return ((string)(this["masterConnectionString"]));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)" GeneratedClassNamespace="DbmsLab1.Properties" GeneratedClassName="Settings">
|
||||
<Profiles />
|
||||
<Settings>
|
||||
<Setting Name="masterConnectionString" Type="(Connection string)" Scope="Application">
|
||||
<DesignTimeValue Profile="(Default)"><?xml version="1.0" encoding="utf-16"?>
|
||||
<SerializableConnectionString xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||
<ConnectionString>Data Source=DANIELCUJBA\SQLEXPRESS;Initial Catalog=master;Integrated Security=True;TrustServerCertificate=True</ConnectionString>
|
||||
<ProviderName>System.Data.SqlClient</ProviderName>
|
||||
</SerializableConnectionString></DesignTimeValue>
|
||||
<Value Profile="(Default)">Data Source=DANIELCUJBA\SQLEXPRESS;Initial Catalog=master;Integrated Security=True;TrustServerCertificate=True</Value>
|
||||
</Setting>
|
||||
</Settings>
|
||||
</SettingsFile>
|
||||
@@ -0,0 +1,25 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 17
|
||||
VisualStudioVersion = 17.9.34622.214
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DbmsLab2", "DbmsLab2\DbmsLab2.csproj", "{384EB98E-CE0A-4480-B73A-D043CCEBAE1D}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{384EB98E-CE0A-4480-B73A-D043CCEBAE1D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{384EB98E-CE0A-4480-B73A-D043CCEBAE1D}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{384EB98E-CE0A-4480-B73A-D043CCEBAE1D}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{384EB98E-CE0A-4480-B73A-D043CCEBAE1D}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {3BA95047-F50B-4CC2-B40B-C4FB6F0F3673}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
@@ -0,0 +1,21 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<configuration>
|
||||
<configSections>
|
||||
</configSections>
|
||||
<connectionStrings>
|
||||
<add name="DbmsLab2.Properties.Settings.masterConnectionString"
|
||||
connectionString="Data Source=DANIELCUJBA\SQLEXPRESS;Initial Catalog=master;Integrated Security=True;TrustServerCertificate=True"
|
||||
providerName="System.Data.SqlClient" />
|
||||
</connectionStrings>
|
||||
<startup>
|
||||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8" />
|
||||
</startup>
|
||||
<appSettings>
|
||||
<add key="MasterTable" value="CardSet"/>
|
||||
<add key="ChildTable" value="Cards"/>
|
||||
<add key="FK" value="cardset"/>
|
||||
<!--<add key="mastertable" value="Factions"/>
|
||||
<add key="childtable" value="Cards"/>
|
||||
<add key="fk" value="faction"/>-->
|
||||
</appSettings>
|
||||
</configuration>
|
||||
@@ -0,0 +1,84 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{384EB98E-CE0A-4480-B73A-D043CCEBAE1D}</ProjectGuid>
|
||||
<OutputType>WinExe</OutputType>
|
||||
<RootNamespace>WindowsFormsApp1</RootNamespace>
|
||||
<AssemblyName>WindowsFormsApp1</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
|
||||
<Deterministic>true</Deterministic>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Configuration" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Deployment" />
|
||||
<Reference Include="System.Drawing" />
|
||||
<Reference Include="System.Net.Http" />
|
||||
<Reference Include="System.Windows.Forms" />
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Form1.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Form1.Designer.cs">
|
||||
<DependentUpon>Form1.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Program.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<EmbeddedResource Include="Form1.resx">
|
||||
<DependentUpon>Form1.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="Properties\Resources.resx">
|
||||
<Generator>ResXFileCodeGenerator</Generator>
|
||||
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
|
||||
<SubType>Designer</SubType>
|
||||
</EmbeddedResource>
|
||||
<Compile Include="Properties\Resources.Designer.cs">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DependentUpon>Resources.resx</DependentUpon>
|
||||
</Compile>
|
||||
<None Include="Properties\Settings.settings">
|
||||
<Generator>SettingsSingleFileGenerator</Generator>
|
||||
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
|
||||
</None>
|
||||
<Compile Include="Properties\Settings.Designer.cs">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DependentUpon>Settings.settings</DependentUpon>
|
||||
<DesignTimeSharedInput>True</DesignTimeSharedInput>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="App.config" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
||||
@@ -0,0 +1,38 @@
|
||||
using System.Windows.Forms;
|
||||
using System.Data;
|
||||
using System.Data.SqlClient;
|
||||
|
||||
namespace DbmsLab2
|
||||
{
|
||||
partial class Form1
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
private DataSet ds;
|
||||
private DataGridView dataGridView1;
|
||||
private DataGridView dataGridView2;
|
||||
private DataSet ds2;
|
||||
private Button UpdateBtn;
|
||||
private SqlDataAdapter adapter;
|
||||
private SqlDataAdapter adapter2;
|
||||
private Button DeleteBtn;
|
||||
private int SelectedChildId = -1;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,162 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using System.Data.SqlClient;
|
||||
using System.Configuration;
|
||||
|
||||
namespace DbmsLab2
|
||||
{
|
||||
public partial class Form1 : Form
|
||||
{
|
||||
public SqlConnection sqlconnection = new SqlConnection("Data Source=DANIELCUJBA\\SQLEXPRESS;Initial Catalog=master;Integrated Security=True;");
|
||||
public Form1()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.ds = new System.Data.DataSet();
|
||||
this.dataGridView1 = new System.Windows.Forms.DataGridView();
|
||||
this.dataGridView2 = new System.Windows.Forms.DataGridView();
|
||||
this.ds2 = new System.Data.DataSet();
|
||||
this.UpdateBtn = new System.Windows.Forms.Button();
|
||||
this.DeleteBtn = new System.Windows.Forms.Button();
|
||||
((System.ComponentModel.ISupportInitialize)(this.ds)).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.dataGridView2)).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.ds2)).BeginInit();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// ds
|
||||
//
|
||||
this.ds.DataSetName = "NewDataSet";
|
||||
//
|
||||
// dataGridView1
|
||||
//
|
||||
this.dataGridView1.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||
this.dataGridView1.Location = new System.Drawing.Point(79, 12);
|
||||
this.dataGridView1.Name = "dataGridView1";
|
||||
this.dataGridView1.Size = new System.Drawing.Size(745, 150);
|
||||
this.dataGridView1.TabIndex = 0;
|
||||
this.dataGridView1.CellClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.dataGridView1_CellClick);
|
||||
//
|
||||
// dataGridView2
|
||||
//
|
||||
this.dataGridView2.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||
this.dataGridView2.Location = new System.Drawing.Point(79, 196);
|
||||
this.dataGridView2.Name = "dataGridView2";
|
||||
this.dataGridView2.Size = new System.Drawing.Size(745, 150);
|
||||
this.dataGridView2.TabIndex = 1;
|
||||
this.dataGridView2.CellClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.dataGridView2_CellContentClick);
|
||||
//
|
||||
// ds2
|
||||
//
|
||||
this.ds2.DataSetName = "NewDataSet";
|
||||
//
|
||||
// UpdateBtn
|
||||
//
|
||||
this.UpdateBtn.Location = new System.Drawing.Point(364, 389);
|
||||
this.UpdateBtn.Name = "UpdateBtn";
|
||||
this.UpdateBtn.Size = new System.Drawing.Size(138, 46);
|
||||
this.UpdateBtn.TabIndex = 2;
|
||||
this.UpdateBtn.Text = "Save Changes to DB";
|
||||
this.UpdateBtn.UseVisualStyleBackColor = true;
|
||||
this.UpdateBtn.Click += new System.EventHandler(this.UpdateBtn_Click);
|
||||
//
|
||||
// DeleteBtn
|
||||
//
|
||||
this.DeleteBtn.Location = new System.Drawing.Point(624, 389);
|
||||
this.DeleteBtn.Name = "DeleteBtn";
|
||||
this.DeleteBtn.Size = new System.Drawing.Size(108, 45);
|
||||
this.DeleteBtn.TabIndex = 3;
|
||||
this.DeleteBtn.Text = "Delete";
|
||||
this.DeleteBtn.UseVisualStyleBackColor = true;
|
||||
this.DeleteBtn.Click += new System.EventHandler(this.DeleteBtn_Click);
|
||||
//
|
||||
// Form1
|
||||
//
|
||||
this.ClientSize = new System.Drawing.Size(890, 473);
|
||||
this.Controls.Add(this.DeleteBtn);
|
||||
this.Controls.Add(this.UpdateBtn);
|
||||
this.Controls.Add(this.dataGridView2);
|
||||
this.Controls.Add(this.dataGridView1);
|
||||
this.Name = "Form1";
|
||||
this.Load += new System.EventHandler(this.Form1_Load);
|
||||
((System.ComponentModel.ISupportInitialize)(this.ds)).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.dataGridView2)).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.ds2)).EndInit();
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
|
||||
private void Form1_Load(object sender, EventArgs e)
|
||||
{
|
||||
var command = new SqlCommand($"SELECT * FROM {ConfigurationManager.AppSettings["MasterTable"]}", sqlconnection);
|
||||
this.adapter = new SqlDataAdapter(command);
|
||||
|
||||
|
||||
|
||||
this.ds = new DataSet(ConfigurationManager.AppSettings["MasterTable"]);
|
||||
this.adapter.Fill(ds, ConfigurationManager.AppSettings["MasterTable"]);
|
||||
dataGridView1.DataSource= this.ds.Tables[ConfigurationManager.AppSettings["MasterTable"]];
|
||||
|
||||
|
||||
}
|
||||
|
||||
private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
|
||||
{
|
||||
var id = dataGridView1.Rows[e.RowIndex].Cells[0].Value;
|
||||
var command = new SqlCommand($"SELECT * FROM {ConfigurationManager.AppSettings["ChildTable"]} WHERE {ConfigurationManager.AppSettings["FK"]} = {id}", sqlconnection);
|
||||
this.adapter2 = new SqlDataAdapter(command);
|
||||
|
||||
|
||||
this.ds2 = new DataSet(ConfigurationManager.AppSettings["ChildTable"]);
|
||||
this.adapter2.Fill(ds2, ConfigurationManager.AppSettings["ChildTable"]);
|
||||
dataGridView2.DataSource = this.ds2.Tables[ConfigurationManager.AppSettings["ChildTable"]];
|
||||
}
|
||||
|
||||
private void UpdateBtn_Click(object sender, EventArgs e)
|
||||
{
|
||||
var builder = new SqlCommandBuilder(adapter2);
|
||||
adapter2.UpdateCommand = builder.GetUpdateCommand();
|
||||
try
|
||||
{
|
||||
this.adapter2.Update((DataTable)this.dataGridView2.DataSource);
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message);
|
||||
}
|
||||
}
|
||||
|
||||
private void DeleteBtn_Click(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
var builder = new SqlCommandBuilder(adapter2);
|
||||
adapter2.UpdateCommand = builder.GetUpdateCommand();
|
||||
dataGridView2.Rows.RemoveAt(this.SelectedChildId);
|
||||
this.adapter2.Update((DataTable)this.dataGridView2.DataSource);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void dataGridView2_CellContentClick(object sender, DataGridViewCellEventArgs e)
|
||||
{
|
||||
this.SelectedChildId = e.RowIndex;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,129 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<metadata name="ds.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>17, 17</value>
|
||||
</metadata>
|
||||
<metadata name="ds2.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>83, 17</value>
|
||||
</metadata>
|
||||
<metadata name="$this.TrayHeight" type="System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>106</value>
|
||||
</metadata>
|
||||
</root>
|
||||
@@ -0,0 +1,22 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace DbmsLab2
|
||||
{
|
||||
internal static class Program
|
||||
{
|
||||
/// <summary>
|
||||
/// The main entry point for the application.
|
||||
/// </summary>
|
||||
[STAThread]
|
||||
static void Main()
|
||||
{
|
||||
Application.EnableVisualStyles();
|
||||
Application.SetCompatibleTextRenderingDefault(false);
|
||||
Application.Run(new Form1());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyTitle("DbmsLab2")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("DbmsLab2")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2024")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// Setting ComVisible to false makes the types in this assembly not visible
|
||||
// to COM components. If you need to access a type in this assembly from
|
||||
// COM, set the ComVisible attribute to true on that type.
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||
[assembly: Guid("384eb98e-ce0a-4480-b73a-d043ccebae1d")]
|
||||
|
||||
// Version information for an assembly consists of the following four values:
|
||||
//
|
||||
// Major Version
|
||||
// Minor Version
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||
@@ -0,0 +1,71 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
// Runtime Version:4.0.30319.42000
|
||||
//
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace DbmsLab2.Properties
|
||||
{
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// A strongly-typed resource class, for looking up localized strings, etc.
|
||||
/// </summary>
|
||||
// This class was auto-generated by the StronglyTypedResourceBuilder
|
||||
// class via a tool like ResGen or Visual Studio.
|
||||
// To add or remove a member, edit your .ResX file then rerun ResGen
|
||||
// with the /str option, or rebuild your VS project.
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||
internal class Resources
|
||||
{
|
||||
|
||||
private static global::System.Resources.ResourceManager resourceMan;
|
||||
|
||||
private static global::System.Globalization.CultureInfo resourceCulture;
|
||||
|
||||
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
|
||||
internal Resources()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the cached ResourceManager instance used by this class.
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
internal static global::System.Resources.ResourceManager ResourceManager
|
||||
{
|
||||
get
|
||||
{
|
||||
if ((resourceMan == null))
|
||||
{
|
||||
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("DbmsLab2.Properties.Resources", typeof(Resources).Assembly);
|
||||
resourceMan = temp;
|
||||
}
|
||||
return resourceMan;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Overrides the current thread's CurrentUICulture property for all
|
||||
/// resource lookups using this strongly typed resource class.
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
internal static global::System.Globalization.CultureInfo Culture
|
||||
{
|
||||
get
|
||||
{
|
||||
return resourceCulture;
|
||||
}
|
||||
set
|
||||
{
|
||||
resourceCulture = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,117 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
||||
@@ -0,0 +1,37 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
// Runtime Version:4.0.30319.42000
|
||||
//
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace DbmsLab2.Properties {
|
||||
|
||||
|
||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "17.9.0.0")]
|
||||
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
|
||||
|
||||
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
|
||||
|
||||
public static Settings Default {
|
||||
get {
|
||||
return defaultInstance;
|
||||
}
|
||||
}
|
||||
|
||||
[global::System.Configuration.ApplicationScopedSettingAttribute()]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Configuration.SpecialSettingAttribute(global::System.Configuration.SpecialSetting.ConnectionString)]
|
||||
[global::System.Configuration.DefaultSettingValueAttribute("Data Source=DANIELCUJBA\\SQLEXPRESS;Initial Catalog=master;Integrated Security=Tru" +
|
||||
"e;TrustServerCertificate=True")]
|
||||
public string masterConnectionString {
|
||||
get {
|
||||
return ((string)(this["masterConnectionString"]));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)" GeneratedClassNamespace="DbmsLab2.Properties" GeneratedClassName="Settings">
|
||||
<Profiles />
|
||||
<Settings>
|
||||
<Setting Name="masterConnectionString" Type="(Connection string)" Scope="Application">
|
||||
<DesignTimeValue Profile="(Default)"><?xml version="1.0" encoding="utf-16"?>
|
||||
<SerializableConnectionString xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||
<ConnectionString>Data Source=DANIELCUJBA\SQLEXPRESS;Initial Catalog=master;Integrated Security=True;TrustServerCertificate=True</ConnectionString>
|
||||
<ProviderName>System.Data.SqlClient</ProviderName>
|
||||
</SerializableConnectionString></DesignTimeValue>
|
||||
<Value Profile="(Default)">Data Source=DANIELCUJBA\SQLEXPRESS;Initial Catalog=master;Integrated Security=True;TrustServerCertificate=True</Value>
|
||||
</Setting>
|
||||
</Settings>
|
||||
</SettingsFile>
|
||||
@@ -0,0 +1,15 @@
|
||||
begin tran
|
||||
update Cards set name = 'CardTest3' where hmy=1260
|
||||
waitfor delay '00:00:05'
|
||||
update Cards set name = 'CardTest4' where hmy=1261
|
||||
commit
|
||||
|
||||
set tran isolation level serializable
|
||||
|
||||
insert into Cards(name, faction, description, action, image, cost, type, power, color, cardset) values ('CardTest1',1,'Test card 1','Test action 1','Test image 1',1,'Unit',1,'Bronze',1);
|
||||
insert into Cards(name, faction, description, action, image, cost, type, power, color, cardset) values ('CardTest2',2,'Test card 2','Test action 2','Test image 2',2,'special',2,'gold',2);
|
||||
select * from Cards where name like 'CardTest%';
|
||||
|
||||
delete from Cards where name like 'CardTest%';
|
||||
update Cards set name = 'CardTest1' where hmy=1248
|
||||
update Cards set name = 'CardTest2' where hmy=1249
|
||||
@@ -0,0 +1,5 @@
|
||||
begin tran
|
||||
update Cards set name = 'CardTest4' where hmy=1261
|
||||
waitfor delay '00:00:05'
|
||||
update Cards set name = 'CardTest3' where hmy=1260
|
||||
commit
|
||||
@@ -0,0 +1,26 @@
|
||||
create or alter procedure write_and_rollback
|
||||
as
|
||||
begin
|
||||
begin tran
|
||||
update Cards set name = 'Test Dirty Reads' where hmy = 1
|
||||
waitfor delay '00:00:05'
|
||||
rollback tran
|
||||
end
|
||||
go
|
||||
|
||||
create or alter procedure read_multiple_times
|
||||
as
|
||||
begin
|
||||
begin tran
|
||||
select * from Cards where hmy = 1
|
||||
waitfor delay '00:00:05'
|
||||
select * from Cards where hmy = 1
|
||||
waitfor delay '00:00:05'
|
||||
select * from Cards where hmy = 1
|
||||
commit tran
|
||||
end
|
||||
go
|
||||
|
||||
set transaction isolation level read uncommitted
|
||||
|
||||
exec read_multiple_times
|
||||
@@ -0,0 +1 @@
|
||||
exec write_and_rollback
|
||||
@@ -0,0 +1,142 @@
|
||||
|
||||
-- This script creates a stored procedure that inserts data into the Players, Cards and Decks tables.
|
||||
-- The procedure is wrapped in a transaction and uses a try-catch block to ensure that all inserts are successful or none are.
|
||||
-- If an error occurs, the transaction is rolled back and no data is inserted.
|
||||
|
||||
create or alter procedure all_or_nothing_insert
|
||||
as
|
||||
begin
|
||||
set nocount on
|
||||
declare @player1 int, @player2 int, @card1 int, @card2 int
|
||||
begin transaction
|
||||
begin try
|
||||
insert into Players(name, totalMatches, totalWins, totalLosses, totalDraws, reward_points, scraps, ores, meteorite_powder, rank) values ('PlayerTest1',10,5,3,2,100,100,100,100,1);
|
||||
insert into Players(name, totalMatches, totalWins, totalLosses, totalDraws, reward_points, scraps, ores, meteorite_powder, rank) values ('PlayerTest2',20,10,6,4,200,200,200,200,2);
|
||||
|
||||
insert into Cards(name, faction, description, action, image, cost, type, power, color, cardset) values ('CardTest1',1,'Test card 1','Test action 1','Test image 1',1,'Unit',1,'Bronze',1);
|
||||
insert into Cards(name, faction, description, action, image, cost, type, power, color, cardset) values ('CardTest2',2,'Test card 2','Test action 2','Test image 2',2,'special',2,'gold',2);
|
||||
|
||||
set @player1 = (select hmy from Players where name = 'PlayerTest1');
|
||||
set @player2 = (select hmy from Players where name = 'PlayerTest2');
|
||||
set @card1 = (select hmy from Cards where name = 'CardTest1');
|
||||
set @card2 = (select hmy from Cards where name = 'CardTest2');
|
||||
|
||||
insert into CardsOwnership(hPlayer, hCard, nrOfCards, nrOfPremiumCards) values (@player1, @card1, 1, 1);
|
||||
insert into CardsOwnership(hPlayer, hCard, nrOfCards, nrOfPremiumCards) values (@player2, @card2, 1, 1);
|
||||
|
||||
|
||||
commit transaction
|
||||
print 'All inserts succeeded'
|
||||
end try
|
||||
begin catch
|
||||
rollback transaction
|
||||
end catch
|
||||
end
|
||||
go
|
||||
exec all_or_nothing_insert
|
||||
go
|
||||
|
||||
-- This script creates a stored procedure that inserts data into the Players, Cards and Decks tables.
|
||||
-- The procedure is wrapped in a transaction and uses savepoints to ensure that if an error occurs, only the failed insert is rolled back.
|
||||
-- The procedure also uses a try-catch block to handle errors and print messages to the console.
|
||||
|
||||
create or alter procedure partial_insert
|
||||
as
|
||||
begin
|
||||
set nocount on
|
||||
declare @player1 int, @player2 int, @card1 int, @card2 int, @savepoint1 int, @savepoint2 int
|
||||
set @savepoint1 = 1
|
||||
set @savepoint2 = 1
|
||||
|
||||
begin transaction
|
||||
begin try
|
||||
insert into Players(name, totalMatches, totalWins, totalLosses, totalDraws, reward_points, scraps, ores, meteorite_powder, rank) values ('PlayerTest1',10,5,3,2,100,100,100,100,1);
|
||||
insert into Players(name, totalMatches, totalWins, totalLosses, totalDraws, reward_points, scraps, ores, meteorite_powder, rank) values ('PlayerTest2',20,10,6,4,200,200,200,200,2);
|
||||
save transaction InsertPlayers
|
||||
set @savepoint1 = 0
|
||||
|
||||
insert into Cards(name, faction, description, action, image, cost, type, power, color, cardset) values ('CardTest1',1,'Test card 1','Test action 1','Test image 1',1,'Unit',1,'Bronze',1);
|
||||
insert into Cards(name, faction, description, action, image, cost, type, power, color, cardset) values ('CardTest2',2,'Test card 2','Test action 2','Test image 2',2,'special',2,'gold',2);
|
||||
save transaction InsertCards
|
||||
set @savepoint2 = 0
|
||||
|
||||
set @player1 = (select hmy from Players where name = 'PlayerTest1');
|
||||
set @player2 = (select hmy from Players where name = 'PlayerTest2');
|
||||
set @card1 = (select hmy from Cards where name = 'CardTest1');
|
||||
set @card2 = (select hmy from Cards where name = 'CardTest2');
|
||||
|
||||
insert into CardsOwnership(hPlayer, hCard, nrOfCards, nrOfPremiumCards) values (@player1, @card1, 1, 1);
|
||||
insert into CardsOwnership(hPlayer, hCard, nrOfCards, nrOfPremiumCards) values (@player2, @card2, 1, 1);
|
||||
|
||||
commit transaction
|
||||
print 'All inserts succeeded'
|
||||
end try
|
||||
begin catch
|
||||
if @@TRANCOUNT > 0
|
||||
begin
|
||||
if @savepoint1 = 1
|
||||
begin
|
||||
print 'Players insert failed'
|
||||
rollback tran
|
||||
print error_message()
|
||||
end
|
||||
else if @savepoint2 = 1
|
||||
begin
|
||||
print 'Cards insert failed'
|
||||
rollback tran InsertPlayers
|
||||
print error_message()
|
||||
commit tran
|
||||
end
|
||||
else
|
||||
begin
|
||||
print 'CardsOwnership insert failed'
|
||||
print error_message()
|
||||
rollback tran InsertCards
|
||||
commit tran
|
||||
end
|
||||
end
|
||||
else
|
||||
print error_message()
|
||||
end catch
|
||||
end
|
||||
go
|
||||
exec partial_insert
|
||||
|
||||
-- This script deletes all the inserted data from the Players, Cards and Decks tables.
|
||||
|
||||
go
|
||||
create or alter proc delete_added
|
||||
as
|
||||
begin
|
||||
begin try
|
||||
declare @player1 int, @player2 int, @card1 int, @card2 int, @cardOwnership1 int, @cardOwnership2 int
|
||||
set @player1 = (select hmy from Players where name = 'PlayerTest1');
|
||||
set @player2 = (select hmy from Players where name = 'PlayerTest2');
|
||||
set @card1 = (select hmy from Cards where name = 'CardTest1');
|
||||
set @card2 = (select hmy from Cards where name = 'CardTest2');
|
||||
if @player1 is not null and @player2 is not null and @card1 is not null and @card2 is not null
|
||||
begin
|
||||
delete from CardsOwnership where hCard = @card1 and hPlayer = @player1
|
||||
delete from CardsOwnership where hCard = @card2 and hPlayer = @player2
|
||||
end
|
||||
if @card1 is not null and @card2 is not null
|
||||
begin
|
||||
delete from Cards where hmy = @card1
|
||||
delete from Cards where hmy = @card2
|
||||
end
|
||||
if @player1 is not null and @player2 is not null
|
||||
begin
|
||||
delete from Players where hmy = @player1
|
||||
delete from Players where hmy = @player2
|
||||
end
|
||||
end try
|
||||
begin catch
|
||||
print error_message()
|
||||
delete from Cards where name = 'CardTest1'
|
||||
delete from Cards where name = 'CardTest2'
|
||||
delete from Players where name = 'PlayerTest1'
|
||||
delete from Players where name = 'PlayerTest2'
|
||||
end catch
|
||||
end
|
||||
go
|
||||
exec delete_added
|
||||
@@ -0,0 +1,8 @@
|
||||
begin tran
|
||||
select * from Cards where name like 'CardTest%'
|
||||
waitfor delay '00:00:03'
|
||||
select * from Cards where name like 'CardTest%'
|
||||
commit tran
|
||||
|
||||
|
||||
set transaction isolation level repeatable read
|
||||
@@ -0,0 +1,11 @@
|
||||
begin tran
|
||||
insert into Cards(name, faction, description, action, image, cost, type, power, color, cardset) values ('CardTest2',2,'Test card 2','Test action 2','Test image 2',2,'special',2,'gold',2);
|
||||
waitfor delay '00:00:05'
|
||||
commit tran
|
||||
|
||||
insert into Cards(name, faction, description, action, image, cost, type, power, color, cardset) values ('CardTest1',1,'Test card 1','Test action 1','Test image 1',1,'Unit',1,'Bronze',1);
|
||||
insert into Cards(name, faction, description, action, image, cost, type, power, color, cardset) values ('CardTest2',2,'Test card 2','Test action 2','Test image 2',2,'special',2,'gold',2);
|
||||
|
||||
delete from Cards where name = 'CardTest2';
|
||||
|
||||
delete from Cards where name like 'CardTest%';
|
||||
@@ -0,0 +1,7 @@
|
||||
begin tran
|
||||
select * from Cards where hmy = 1
|
||||
waitfor delay '00:00:03'
|
||||
select * from Cards where hmy = 1
|
||||
commit tran
|
||||
|
||||
set transaction isolation level read committed
|
||||
@@ -0,0 +1,4 @@
|
||||
begin tran
|
||||
update Cards set name = 'Test unrepetable reads' where hmy = 1
|
||||
waitfor delay '00:00:05'
|
||||
commit tran
|
||||
@@ -0,0 +1,25 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 17
|
||||
VisualStudioVersion = 17.9.34728.123
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Practic", "Practic\Practic.csproj", "{1E1F18BC-F95C-41B1-A472-6E928149DC0A}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{1E1F18BC-F95C-41B1-A472-6E928149DC0A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{1E1F18BC-F95C-41B1-A472-6E928149DC0A}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{1E1F18BC-F95C-41B1-A472-6E928149DC0A}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{1E1F18BC-F95C-41B1-A472-6E928149DC0A}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {893F237B-72BB-4745-BD59-72F8EB1C6821}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
@@ -0,0 +1,13 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<configuration>
|
||||
<configSections>
|
||||
</configSections>
|
||||
<connectionStrings>
|
||||
<add name="Practic.Properties.Settings.HotelConnectionString"
|
||||
connectionString="Data Source=DANIELCUJBA\SQLEXPRESS;Initial Catalog=Hotel;Integrated Security=True;TrustServerCertificate=True"
|
||||
providerName="System.Data.SqlClient" />
|
||||
</connectionStrings>
|
||||
<startup>
|
||||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
|
||||
</startup>
|
||||
</configuration>
|
||||
@@ -0,0 +1,235 @@
|
||||
using System.Data;
|
||||
using System.Data.SqlClient;
|
||||
|
||||
namespace Practic
|
||||
{
|
||||
partial class Form1
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.components = new System.ComponentModel.Container();
|
||||
this.dgvGuest = new System.Windows.Forms.DataGridView();
|
||||
this.idDataGridViewTextBoxColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
|
||||
this.nameDataGridViewTextBoxColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
|
||||
this.emailDataGridViewTextBoxColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
|
||||
this.phoneDataGridViewTextBoxColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
|
||||
this.guestBindingSource = new System.Windows.Forms.BindingSource(this.components);
|
||||
this.hotelDataSet = new Practic.HotelDataSet();
|
||||
this.guestTableAdapter = new Practic.HotelDataSetTableAdapters.GuestTableAdapter();
|
||||
this.dgvReservations = new System.Windows.Forms.DataGridView();
|
||||
this.idDataGridViewTextBoxColumn1 = new System.Windows.Forms.DataGridViewTextBoxColumn();
|
||||
this.guestIdDataGridViewTextBoxColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
|
||||
this.roomIdDataGridViewTextBoxColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
|
||||
this.checkInDataGridViewTextBoxColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
|
||||
this.checkOutDataGridViewTextBoxColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
|
||||
this.paidDataGridViewCheckBoxColumn = new System.Windows.Forms.DataGridViewCheckBoxColumn();
|
||||
this.reservationBindingSource = new System.Windows.Forms.BindingSource(this.components);
|
||||
this.reservationTableAdapter = new Practic.HotelDataSetTableAdapters.ReservationTableAdapter();
|
||||
this.saveBtn = new System.Windows.Forms.Button();
|
||||
((System.ComponentModel.ISupportInitialize)(this.dgvGuest)).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.guestBindingSource)).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.hotelDataSet)).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.dgvReservations)).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.reservationBindingSource)).BeginInit();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// dgvGuest
|
||||
//
|
||||
this.dgvGuest.AutoGenerateColumns = false;
|
||||
this.dgvGuest.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||
this.dgvGuest.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
|
||||
this.idDataGridViewTextBoxColumn,
|
||||
this.nameDataGridViewTextBoxColumn,
|
||||
this.emailDataGridViewTextBoxColumn,
|
||||
this.phoneDataGridViewTextBoxColumn});
|
||||
this.dgvGuest.DataSource = this.guestBindingSource;
|
||||
this.dgvGuest.Location = new System.Drawing.Point(149, 23);
|
||||
this.dgvGuest.Name = "dgvGuest";
|
||||
this.dgvGuest.Size = new System.Drawing.Size(444, 150);
|
||||
this.dgvGuest.TabIndex = 0;
|
||||
this.dgvGuest.CellContentClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.dgvGuest_CellContentClick);
|
||||
//
|
||||
// idDataGridViewTextBoxColumn
|
||||
//
|
||||
this.idDataGridViewTextBoxColumn.DataPropertyName = "Id";
|
||||
this.idDataGridViewTextBoxColumn.HeaderText = "Id";
|
||||
this.idDataGridViewTextBoxColumn.Name = "idDataGridViewTextBoxColumn";
|
||||
this.idDataGridViewTextBoxColumn.ReadOnly = true;
|
||||
//
|
||||
// nameDataGridViewTextBoxColumn
|
||||
//
|
||||
this.nameDataGridViewTextBoxColumn.DataPropertyName = "name";
|
||||
this.nameDataGridViewTextBoxColumn.HeaderText = "name";
|
||||
this.nameDataGridViewTextBoxColumn.Name = "nameDataGridViewTextBoxColumn";
|
||||
//
|
||||
// emailDataGridViewTextBoxColumn
|
||||
//
|
||||
this.emailDataGridViewTextBoxColumn.DataPropertyName = "email";
|
||||
this.emailDataGridViewTextBoxColumn.HeaderText = "email";
|
||||
this.emailDataGridViewTextBoxColumn.Name = "emailDataGridViewTextBoxColumn";
|
||||
//
|
||||
// phoneDataGridViewTextBoxColumn
|
||||
//
|
||||
this.phoneDataGridViewTextBoxColumn.DataPropertyName = "phone";
|
||||
this.phoneDataGridViewTextBoxColumn.HeaderText = "phone";
|
||||
this.phoneDataGridViewTextBoxColumn.Name = "phoneDataGridViewTextBoxColumn";
|
||||
//
|
||||
// guestBindingSource
|
||||
//
|
||||
this.guestBindingSource.DataMember = "Guest";
|
||||
this.guestBindingSource.DataSource = this.hotelDataSet;
|
||||
//
|
||||
// hotelDataSet
|
||||
//
|
||||
this.hotelDataSet.DataSetName = "HotelDataSet";
|
||||
this.hotelDataSet.SchemaSerializationMode = System.Data.SchemaSerializationMode.IncludeSchema;
|
||||
//
|
||||
// guestTableAdapter
|
||||
//
|
||||
this.guestTableAdapter.ClearBeforeFill = true;
|
||||
//
|
||||
// dgvReservations
|
||||
//
|
||||
this.dgvReservations.AutoGenerateColumns = false;
|
||||
this.dgvReservations.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||
this.dgvReservations.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
|
||||
this.idDataGridViewTextBoxColumn1,
|
||||
this.guestIdDataGridViewTextBoxColumn,
|
||||
this.roomIdDataGridViewTextBoxColumn,
|
||||
this.checkInDataGridViewTextBoxColumn,
|
||||
this.checkOutDataGridViewTextBoxColumn,
|
||||
this.paidDataGridViewCheckBoxColumn});
|
||||
this.dgvReservations.DataSource = this.reservationBindingSource;
|
||||
this.dgvReservations.Location = new System.Drawing.Point(77, 195);
|
||||
this.dgvReservations.Name = "dgvReservations";
|
||||
this.dgvReservations.Size = new System.Drawing.Size(645, 150);
|
||||
this.dgvReservations.TabIndex = 1;
|
||||
//
|
||||
// idDataGridViewTextBoxColumn1
|
||||
//
|
||||
this.idDataGridViewTextBoxColumn1.DataPropertyName = "Id";
|
||||
this.idDataGridViewTextBoxColumn1.HeaderText = "Id";
|
||||
this.idDataGridViewTextBoxColumn1.Name = "idDataGridViewTextBoxColumn1";
|
||||
this.idDataGridViewTextBoxColumn1.ReadOnly = true;
|
||||
//
|
||||
// guestIdDataGridViewTextBoxColumn
|
||||
//
|
||||
this.guestIdDataGridViewTextBoxColumn.DataPropertyName = "guestId";
|
||||
this.guestIdDataGridViewTextBoxColumn.HeaderText = "guestId";
|
||||
this.guestIdDataGridViewTextBoxColumn.Name = "guestIdDataGridViewTextBoxColumn";
|
||||
//
|
||||
// roomIdDataGridViewTextBoxColumn
|
||||
//
|
||||
this.roomIdDataGridViewTextBoxColumn.DataPropertyName = "roomId";
|
||||
this.roomIdDataGridViewTextBoxColumn.HeaderText = "roomId";
|
||||
this.roomIdDataGridViewTextBoxColumn.Name = "roomIdDataGridViewTextBoxColumn";
|
||||
//
|
||||
// checkInDataGridViewTextBoxColumn
|
||||
//
|
||||
this.checkInDataGridViewTextBoxColumn.DataPropertyName = "checkIn";
|
||||
this.checkInDataGridViewTextBoxColumn.HeaderText = "checkIn";
|
||||
this.checkInDataGridViewTextBoxColumn.Name = "checkInDataGridViewTextBoxColumn";
|
||||
//
|
||||
// checkOutDataGridViewTextBoxColumn
|
||||
//
|
||||
this.checkOutDataGridViewTextBoxColumn.DataPropertyName = "checkOut";
|
||||
this.checkOutDataGridViewTextBoxColumn.HeaderText = "checkOut";
|
||||
this.checkOutDataGridViewTextBoxColumn.Name = "checkOutDataGridViewTextBoxColumn";
|
||||
//
|
||||
// paidDataGridViewCheckBoxColumn
|
||||
//
|
||||
this.paidDataGridViewCheckBoxColumn.DataPropertyName = "paid";
|
||||
this.paidDataGridViewCheckBoxColumn.HeaderText = "paid";
|
||||
this.paidDataGridViewCheckBoxColumn.Name = "paidDataGridViewCheckBoxColumn";
|
||||
//
|
||||
// reservationBindingSource
|
||||
//
|
||||
this.reservationBindingSource.DataMember = "Reservation";
|
||||
this.reservationBindingSource.DataSource = this.hotelDataSet;
|
||||
//
|
||||
// reservationTableAdapter
|
||||
//
|
||||
this.reservationTableAdapter.ClearBeforeFill = true;
|
||||
//
|
||||
// saveBtn
|
||||
//
|
||||
this.saveBtn.Location = new System.Drawing.Point(343, 437);
|
||||
this.saveBtn.Name = "saveBtn";
|
||||
this.saveBtn.Size = new System.Drawing.Size(75, 23);
|
||||
this.saveBtn.TabIndex = 2;
|
||||
this.saveBtn.Text = "Save";
|
||||
this.saveBtn.UseVisualStyleBackColor = true;
|
||||
this.saveBtn.Click += new System.EventHandler(this.saveBtn_Click);
|
||||
//
|
||||
// Form1
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(800, 594);
|
||||
this.Controls.Add(this.saveBtn);
|
||||
this.Controls.Add(this.dgvReservations);
|
||||
this.Controls.Add(this.dgvGuest);
|
||||
this.Name = "Form1";
|
||||
this.Text = "Form1";
|
||||
this.Load += new System.EventHandler(this.Form1_Load);
|
||||
((System.ComponentModel.ISupportInitialize)(this.dgvGuest)).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.guestBindingSource)).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.hotelDataSet)).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.dgvReservations)).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.reservationBindingSource)).EndInit();
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.DataGridView dgvGuest;
|
||||
private HotelDataSet hotelDataSet;
|
||||
private System.Windows.Forms.BindingSource guestBindingSource;
|
||||
private HotelDataSetTableAdapters.GuestTableAdapter guestTableAdapter;
|
||||
private System.Windows.Forms.DataGridViewTextBoxColumn idDataGridViewTextBoxColumn;
|
||||
private System.Windows.Forms.DataGridViewTextBoxColumn nameDataGridViewTextBoxColumn;
|
||||
private System.Windows.Forms.DataGridViewTextBoxColumn emailDataGridViewTextBoxColumn;
|
||||
private System.Windows.Forms.DataGridViewTextBoxColumn phoneDataGridViewTextBoxColumn;
|
||||
private System.Windows.Forms.DataGridView dgvReservations;
|
||||
private System.Windows.Forms.BindingSource reservationBindingSource;
|
||||
private HotelDataSetTableAdapters.ReservationTableAdapter reservationTableAdapter;
|
||||
private System.Windows.Forms.DataGridViewTextBoxColumn idDataGridViewTextBoxColumn1;
|
||||
private System.Windows.Forms.DataGridViewTextBoxColumn guestIdDataGridViewTextBoxColumn;
|
||||
private System.Windows.Forms.DataGridViewTextBoxColumn roomIdDataGridViewTextBoxColumn;
|
||||
private System.Windows.Forms.DataGridViewTextBoxColumn checkInDataGridViewTextBoxColumn;
|
||||
private System.Windows.Forms.DataGridViewTextBoxColumn checkOutDataGridViewTextBoxColumn;
|
||||
private System.Windows.Forms.DataGridViewCheckBoxColumn paidDataGridViewCheckBoxColumn;
|
||||
private System.Windows.Forms.Button saveBtn;
|
||||
|
||||
private SqlDataAdapter adapter1;
|
||||
private SqlDataAdapter adapter2;
|
||||
private DataSet ds1;
|
||||
private DataSet ds2;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,55 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Data.SqlClient;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace Practic
|
||||
{
|
||||
public partial class Form1 : Form
|
||||
{
|
||||
public SqlConnection connection = new SqlConnection("Data Source=DANIELCUJBA\\SQLEXPRESS;Initial Catalog=Hotel;Integrated Security=True;");
|
||||
public Form1()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private void Form1_Load(object sender, EventArgs e)
|
||||
{
|
||||
var command = new SqlCommand("SELECT * FROM Guest", connection);
|
||||
this.adapter1 = new SqlDataAdapter(command);
|
||||
this.ds1 = new DataSet("Guest");
|
||||
this.adapter1.Fill(ds1, "Guest");
|
||||
this.dgvGuest.DataSource = ds1.Tables["Guest"];
|
||||
}
|
||||
|
||||
private void dgvGuest_CellContentClick(object sender, DataGridViewCellEventArgs e)
|
||||
{
|
||||
var id = dgvGuest.Rows[e.RowIndex].Cells[0].Value;
|
||||
var command = new SqlCommand($"SELECT * FROM Reservation WHERE guestId = ${id}", connection);
|
||||
this.adapter2 = new SqlDataAdapter(command);
|
||||
this.ds2 = new DataSet("Reservation");
|
||||
this.adapter2.Fill(ds2, "Reservation");
|
||||
this.dgvReservations.DataSource = ds2.Tables["Reservation"];
|
||||
}
|
||||
|
||||
private void saveBtn_Click(object sender, EventArgs e)
|
||||
{
|
||||
var builder = new SqlCommandBuilder(adapter2);
|
||||
adapter2.UpdateCommand = builder.GetUpdateCommand();
|
||||
try
|
||||
{
|
||||
this.adapter2.Update((DataTable)this.dgvReservations.DataSource);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,135 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<metadata name="guestBindingSource.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>138, 17</value>
|
||||
</metadata>
|
||||
<metadata name="hotelDataSet.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>17, 17</value>
|
||||
</metadata>
|
||||
<metadata name="guestTableAdapter.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>298, 17</value>
|
||||
</metadata>
|
||||
<metadata name="reservationBindingSource.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>450, 17</value>
|
||||
</metadata>
|
||||
<metadata name="reservationTableAdapter.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>639, 17</value>
|
||||
</metadata>
|
||||
</root>
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1 @@
|
||||
|
||||
@@ -0,0 +1,432 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<xs:schema id="HotelDataSet" targetNamespace="http://tempuri.org/HotelDataSet.xsd" xmlns:mstns="http://tempuri.org/HotelDataSet.xsd" xmlns="http://tempuri.org/HotelDataSet.xsd" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" xmlns:msprop="urn:schemas-microsoft-com:xml-msprop" attributeFormDefault="qualified" elementFormDefault="qualified">
|
||||
<xs:annotation>
|
||||
<xs:appinfo source="urn:schemas-microsoft-com:xml-msdatasource">
|
||||
<DataSource DefaultConnectionIndex="0" FunctionsComponentName="QueriesTableAdapter" Modifier="AutoLayout, AnsiClass, Class, Public" SchemaSerializationMode="IncludeSchema" xmlns="urn:schemas-microsoft-com:xml-msdatasource">
|
||||
<Connections>
|
||||
<Connection AppSettingsObjectName="Settings" AppSettingsPropertyName="HotelConnectionString" ConnectionStringObject="" IsAppSettingsProperty="true" Modifier="Assembly" Name="HotelConnectionString (Settings)" ParameterPrefix="@" PropertyReference="ApplicationSettings.Practic.Properties.Settings.GlobalReference.Default.HotelConnectionString" Provider="System.Data.SqlClient" />
|
||||
</Connections>
|
||||
<Tables>
|
||||
<TableAdapter BaseClass="System.ComponentModel.Component" DataAccessorModifier="AutoLayout, AnsiClass, Class, Public" DataAccessorName="GuestTableAdapter" GeneratorDataComponentClassName="GuestTableAdapter" Name="Guest" UserDataComponentName="GuestTableAdapter">
|
||||
<MainSource>
|
||||
<DbSource ConnectionRef="HotelConnectionString (Settings)" DbObjectName="Hotel.dbo.Guest" DbObjectType="Table" FillMethodModifier="Public" FillMethodName="Fill" GenerateMethods="Both" GenerateShortCommands="true" GeneratorGetMethodName="GetData" GeneratorSourceName="Fill" GetMethodModifier="Public" GetMethodName="GetData" QueryType="Rowset" ScalarCallRetval="System.Object, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" UseOptimisticConcurrency="true" UserGetMethodName="GetData" UserSourceName="Fill">
|
||||
<DeleteCommand>
|
||||
<DbCommand CommandType="Text" ModifiedByUser="false">
|
||||
<CommandText>DELETE FROM [dbo].[Guest] WHERE (([Id] = @Original_Id) AND ([name] = @Original_name) AND ([email] = @Original_email) AND ([phone] = @Original_phone))</CommandText>
|
||||
<Parameters>
|
||||
<Parameter AllowDbNull="false" AutogeneratedName="" DataSourceName="" DbType="Int32" Direction="Input" ParameterName="@Original_Id" Precision="0" ProviderType="Int" Scale="0" Size="0" SourceColumn="Id" SourceColumnNullMapping="false" SourceVersion="Original" />
|
||||
<Parameter AllowDbNull="false" AutogeneratedName="" DataSourceName="" DbType="AnsiString" Direction="Input" ParameterName="@Original_name" Precision="0" ProviderType="VarChar" Scale="0" Size="0" SourceColumn="name" SourceColumnNullMapping="false" SourceVersion="Original" />
|
||||
<Parameter AllowDbNull="false" AutogeneratedName="" DataSourceName="" DbType="AnsiString" Direction="Input" ParameterName="@Original_email" Precision="0" ProviderType="VarChar" Scale="0" Size="0" SourceColumn="email" SourceColumnNullMapping="false" SourceVersion="Original" />
|
||||
<Parameter AllowDbNull="false" AutogeneratedName="" DataSourceName="" DbType="AnsiString" Direction="Input" ParameterName="@Original_phone" Precision="0" ProviderType="VarChar" Scale="0" Size="0" SourceColumn="phone" SourceColumnNullMapping="false" SourceVersion="Original" />
|
||||
</Parameters>
|
||||
</DbCommand>
|
||||
</DeleteCommand>
|
||||
<InsertCommand>
|
||||
<DbCommand CommandType="Text" ModifiedByUser="false">
|
||||
<CommandText>INSERT INTO [dbo].[Guest] ([name], [email], [phone]) VALUES (@name, @email, @phone);
|
||||
SELECT Id, name, email, phone FROM Guest WHERE (Id = SCOPE_IDENTITY())</CommandText>
|
||||
<Parameters>
|
||||
<Parameter AllowDbNull="false" AutogeneratedName="" DataSourceName="" DbType="AnsiString" Direction="Input" ParameterName="@name" Precision="0" ProviderType="VarChar" Scale="0" Size="0" SourceColumn="name" SourceColumnNullMapping="false" SourceVersion="Current" />
|
||||
<Parameter AllowDbNull="false" AutogeneratedName="" DataSourceName="" DbType="AnsiString" Direction="Input" ParameterName="@email" Precision="0" ProviderType="VarChar" Scale="0" Size="0" SourceColumn="email" SourceColumnNullMapping="false" SourceVersion="Current" />
|
||||
<Parameter AllowDbNull="false" AutogeneratedName="" DataSourceName="" DbType="AnsiString" Direction="Input" ParameterName="@phone" Precision="0" ProviderType="VarChar" Scale="0" Size="0" SourceColumn="phone" SourceColumnNullMapping="false" SourceVersion="Current" />
|
||||
</Parameters>
|
||||
</DbCommand>
|
||||
</InsertCommand>
|
||||
<SelectCommand>
|
||||
<DbCommand CommandType="Text" ModifiedByUser="false">
|
||||
<CommandText>SELECT Id, name, email, phone FROM dbo.Guest</CommandText>
|
||||
<Parameters />
|
||||
</DbCommand>
|
||||
</SelectCommand>
|
||||
<UpdateCommand>
|
||||
<DbCommand CommandType="Text" ModifiedByUser="false">
|
||||
<CommandText>UPDATE [dbo].[Guest] SET [name] = @name, [email] = @email, [phone] = @phone WHERE (([Id] = @Original_Id) AND ([name] = @Original_name) AND ([email] = @Original_email) AND ([phone] = @Original_phone));
|
||||
SELECT Id, name, email, phone FROM Guest WHERE (Id = @Id)</CommandText>
|
||||
<Parameters>
|
||||
<Parameter AllowDbNull="false" AutogeneratedName="" DataSourceName="" DbType="AnsiString" Direction="Input" ParameterName="@name" Precision="0" ProviderType="VarChar" Scale="0" Size="0" SourceColumn="name" SourceColumnNullMapping="false" SourceVersion="Current" />
|
||||
<Parameter AllowDbNull="false" AutogeneratedName="" DataSourceName="" DbType="AnsiString" Direction="Input" ParameterName="@email" Precision="0" ProviderType="VarChar" Scale="0" Size="0" SourceColumn="email" SourceColumnNullMapping="false" SourceVersion="Current" />
|
||||
<Parameter AllowDbNull="false" AutogeneratedName="" DataSourceName="" DbType="AnsiString" Direction="Input" ParameterName="@phone" Precision="0" ProviderType="VarChar" Scale="0" Size="0" SourceColumn="phone" SourceColumnNullMapping="false" SourceVersion="Current" />
|
||||
<Parameter AllowDbNull="false" AutogeneratedName="" DataSourceName="" DbType="Int32" Direction="Input" ParameterName="@Original_Id" Precision="0" ProviderType="Int" Scale="0" Size="0" SourceColumn="Id" SourceColumnNullMapping="false" SourceVersion="Original" />
|
||||
<Parameter AllowDbNull="false" AutogeneratedName="" DataSourceName="" DbType="AnsiString" Direction="Input" ParameterName="@Original_name" Precision="0" ProviderType="VarChar" Scale="0" Size="0" SourceColumn="name" SourceColumnNullMapping="false" SourceVersion="Original" />
|
||||
<Parameter AllowDbNull="false" AutogeneratedName="" DataSourceName="" DbType="AnsiString" Direction="Input" ParameterName="@Original_email" Precision="0" ProviderType="VarChar" Scale="0" Size="0" SourceColumn="email" SourceColumnNullMapping="false" SourceVersion="Original" />
|
||||
<Parameter AllowDbNull="false" AutogeneratedName="" DataSourceName="" DbType="AnsiString" Direction="Input" ParameterName="@Original_phone" Precision="0" ProviderType="VarChar" Scale="0" Size="0" SourceColumn="phone" SourceColumnNullMapping="false" SourceVersion="Original" />
|
||||
<Parameter AllowDbNull="false" AutogeneratedName="Id" ColumnName="Id" DataSourceName="Hotel.dbo.Guest" DataTypeServer="int" DbType="Int32" Direction="Input" ParameterName="@Id" Precision="0" ProviderType="Int" Scale="0" Size="4" SourceColumn="Id" SourceColumnNullMapping="false" SourceVersion="Current" />
|
||||
</Parameters>
|
||||
</DbCommand>
|
||||
</UpdateCommand>
|
||||
</DbSource>
|
||||
</MainSource>
|
||||
<Mappings>
|
||||
<Mapping SourceColumn="Id" DataSetColumn="Id" />
|
||||
<Mapping SourceColumn="name" DataSetColumn="name" />
|
||||
<Mapping SourceColumn="email" DataSetColumn="email" />
|
||||
<Mapping SourceColumn="phone" DataSetColumn="phone" />
|
||||
</Mappings>
|
||||
<Sources />
|
||||
</TableAdapter>
|
||||
<TableAdapter BaseClass="System.ComponentModel.Component" DataAccessorModifier="AutoLayout, AnsiClass, Class, Public" DataAccessorName="PaymentTableAdapter" GeneratorDataComponentClassName="PaymentTableAdapter" Name="Payment" UserDataComponentName="PaymentTableAdapter">
|
||||
<MainSource>
|
||||
<DbSource ConnectionRef="HotelConnectionString (Settings)" DbObjectName="Hotel.dbo.Payment" DbObjectType="Table" FillMethodModifier="Public" FillMethodName="Fill" GenerateMethods="Both" GenerateShortCommands="true" GeneratorGetMethodName="GetData" GeneratorSourceName="Fill" GetMethodModifier="Public" GetMethodName="GetData" QueryType="Rowset" ScalarCallRetval="System.Object, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" UseOptimisticConcurrency="true" UserGetMethodName="GetData" UserSourceName="Fill">
|
||||
<DeleteCommand>
|
||||
<DbCommand CommandType="Text" ModifiedByUser="false">
|
||||
<CommandText>DELETE FROM [dbo].[Payment] WHERE (([Id] = @Original_Id) AND ([reservationId] = @Original_reservationId) AND ([amount] = @Original_amount) AND ([serviceId] = @Original_serviceId))</CommandText>
|
||||
<Parameters>
|
||||
<Parameter AllowDbNull="false" AutogeneratedName="" DataSourceName="" DbType="Int32" Direction="Input" ParameterName="@Original_Id" Precision="0" ProviderType="Int" Scale="0" Size="0" SourceColumn="Id" SourceColumnNullMapping="false" SourceVersion="Original" />
|
||||
<Parameter AllowDbNull="false" AutogeneratedName="" DataSourceName="" DbType="Int32" Direction="Input" ParameterName="@Original_reservationId" Precision="0" ProviderType="Int" Scale="0" Size="0" SourceColumn="reservationId" SourceColumnNullMapping="false" SourceVersion="Original" />
|
||||
<Parameter AllowDbNull="false" AutogeneratedName="" DataSourceName="" DbType="Int32" Direction="Input" ParameterName="@Original_amount" Precision="0" ProviderType="Int" Scale="0" Size="0" SourceColumn="amount" SourceColumnNullMapping="false" SourceVersion="Original" />
|
||||
<Parameter AllowDbNull="false" AutogeneratedName="" DataSourceName="" DbType="Int32" Direction="Input" ParameterName="@Original_serviceId" Precision="0" ProviderType="Int" Scale="0" Size="0" SourceColumn="serviceId" SourceColumnNullMapping="false" SourceVersion="Original" />
|
||||
</Parameters>
|
||||
</DbCommand>
|
||||
</DeleteCommand>
|
||||
<InsertCommand>
|
||||
<DbCommand CommandType="Text" ModifiedByUser="false">
|
||||
<CommandText>INSERT INTO [dbo].[Payment] ([reservationId], [amount], [serviceId]) VALUES (@reservationId, @amount, @serviceId);
|
||||
SELECT Id, reservationId, amount, serviceId FROM Payment WHERE (Id = SCOPE_IDENTITY())</CommandText>
|
||||
<Parameters>
|
||||
<Parameter AllowDbNull="false" AutogeneratedName="" DataSourceName="" DbType="Int32" Direction="Input" ParameterName="@reservationId" Precision="0" ProviderType="Int" Scale="0" Size="0" SourceColumn="reservationId" SourceColumnNullMapping="false" SourceVersion="Current" />
|
||||
<Parameter AllowDbNull="false" AutogeneratedName="" DataSourceName="" DbType="Int32" Direction="Input" ParameterName="@amount" Precision="0" ProviderType="Int" Scale="0" Size="0" SourceColumn="amount" SourceColumnNullMapping="false" SourceVersion="Current" />
|
||||
<Parameter AllowDbNull="false" AutogeneratedName="" DataSourceName="" DbType="Int32" Direction="Input" ParameterName="@serviceId" Precision="0" ProviderType="Int" Scale="0" Size="0" SourceColumn="serviceId" SourceColumnNullMapping="false" SourceVersion="Current" />
|
||||
</Parameters>
|
||||
</DbCommand>
|
||||
</InsertCommand>
|
||||
<SelectCommand>
|
||||
<DbCommand CommandType="Text" ModifiedByUser="false">
|
||||
<CommandText>SELECT Id, reservationId, amount, serviceId FROM dbo.Payment</CommandText>
|
||||
<Parameters />
|
||||
</DbCommand>
|
||||
</SelectCommand>
|
||||
<UpdateCommand>
|
||||
<DbCommand CommandType="Text" ModifiedByUser="false">
|
||||
<CommandText>UPDATE [dbo].[Payment] SET [reservationId] = @reservationId, [amount] = @amount, [serviceId] = @serviceId WHERE (([Id] = @Original_Id) AND ([reservationId] = @Original_reservationId) AND ([amount] = @Original_amount) AND ([serviceId] = @Original_serviceId));
|
||||
SELECT Id, reservationId, amount, serviceId FROM Payment WHERE (Id = @Id)</CommandText>
|
||||
<Parameters>
|
||||
<Parameter AllowDbNull="false" AutogeneratedName="" DataSourceName="" DbType="Int32" Direction="Input" ParameterName="@reservationId" Precision="0" ProviderType="Int" Scale="0" Size="0" SourceColumn="reservationId" SourceColumnNullMapping="false" SourceVersion="Current" />
|
||||
<Parameter AllowDbNull="false" AutogeneratedName="" DataSourceName="" DbType="Int32" Direction="Input" ParameterName="@amount" Precision="0" ProviderType="Int" Scale="0" Size="0" SourceColumn="amount" SourceColumnNullMapping="false" SourceVersion="Current" />
|
||||
<Parameter AllowDbNull="false" AutogeneratedName="" DataSourceName="" DbType="Int32" Direction="Input" ParameterName="@serviceId" Precision="0" ProviderType="Int" Scale="0" Size="0" SourceColumn="serviceId" SourceColumnNullMapping="false" SourceVersion="Current" />
|
||||
<Parameter AllowDbNull="false" AutogeneratedName="" DataSourceName="" DbType="Int32" Direction="Input" ParameterName="@Original_Id" Precision="0" ProviderType="Int" Scale="0" Size="0" SourceColumn="Id" SourceColumnNullMapping="false" SourceVersion="Original" />
|
||||
<Parameter AllowDbNull="false" AutogeneratedName="" DataSourceName="" DbType="Int32" Direction="Input" ParameterName="@Original_reservationId" Precision="0" ProviderType="Int" Scale="0" Size="0" SourceColumn="reservationId" SourceColumnNullMapping="false" SourceVersion="Original" />
|
||||
<Parameter AllowDbNull="false" AutogeneratedName="" DataSourceName="" DbType="Int32" Direction="Input" ParameterName="@Original_amount" Precision="0" ProviderType="Int" Scale="0" Size="0" SourceColumn="amount" SourceColumnNullMapping="false" SourceVersion="Original" />
|
||||
<Parameter AllowDbNull="false" AutogeneratedName="" DataSourceName="" DbType="Int32" Direction="Input" ParameterName="@Original_serviceId" Precision="0" ProviderType="Int" Scale="0" Size="0" SourceColumn="serviceId" SourceColumnNullMapping="false" SourceVersion="Original" />
|
||||
<Parameter AllowDbNull="false" AutogeneratedName="Id" ColumnName="Id" DataSourceName="Hotel.dbo.Payment" DataTypeServer="int" DbType="Int32" Direction="Input" ParameterName="@Id" Precision="0" ProviderType="Int" Scale="0" Size="4" SourceColumn="Id" SourceColumnNullMapping="false" SourceVersion="Current" />
|
||||
</Parameters>
|
||||
</DbCommand>
|
||||
</UpdateCommand>
|
||||
</DbSource>
|
||||
</MainSource>
|
||||
<Mappings>
|
||||
<Mapping SourceColumn="Id" DataSetColumn="Id" />
|
||||
<Mapping SourceColumn="reservationId" DataSetColumn="reservationId" />
|
||||
<Mapping SourceColumn="amount" DataSetColumn="amount" />
|
||||
<Mapping SourceColumn="serviceId" DataSetColumn="serviceId" />
|
||||
</Mappings>
|
||||
<Sources />
|
||||
</TableAdapter>
|
||||
<TableAdapter BaseClass="System.ComponentModel.Component" DataAccessorModifier="AutoLayout, AnsiClass, Class, Public" DataAccessorName="ReservationTableAdapter" GeneratorDataComponentClassName="ReservationTableAdapter" Name="Reservation" UserDataComponentName="ReservationTableAdapter">
|
||||
<MainSource>
|
||||
<DbSource ConnectionRef="HotelConnectionString (Settings)" DbObjectName="Hotel.dbo.Reservation" DbObjectType="Table" FillMethodModifier="Public" FillMethodName="Fill" GenerateMethods="Both" GenerateShortCommands="true" GeneratorGetMethodName="GetData" GeneratorSourceName="Fill" GetMethodModifier="Public" GetMethodName="GetData" QueryType="Rowset" ScalarCallRetval="System.Object, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" UseOptimisticConcurrency="true" UserGetMethodName="GetData" UserSourceName="Fill">
|
||||
<DeleteCommand>
|
||||
<DbCommand CommandType="Text" ModifiedByUser="false">
|
||||
<CommandText>DELETE FROM [dbo].[Reservation] WHERE (([Id] = @Original_Id) AND ([guestId] = @Original_guestId) AND ([roomId] = @Original_roomId) AND ([checkIn] = @Original_checkIn) AND ([checkOut] = @Original_checkOut) AND ([paid] = @Original_paid))</CommandText>
|
||||
<Parameters>
|
||||
<Parameter AllowDbNull="false" AutogeneratedName="" DataSourceName="" DbType="Int32" Direction="Input" ParameterName="@Original_Id" Precision="0" ProviderType="Int" Scale="0" Size="0" SourceColumn="Id" SourceColumnNullMapping="false" SourceVersion="Original" />
|
||||
<Parameter AllowDbNull="false" AutogeneratedName="" DataSourceName="" DbType="Int32" Direction="Input" ParameterName="@Original_guestId" Precision="0" ProviderType="Int" Scale="0" Size="0" SourceColumn="guestId" SourceColumnNullMapping="false" SourceVersion="Original" />
|
||||
<Parameter AllowDbNull="false" AutogeneratedName="" DataSourceName="" DbType="Int32" Direction="Input" ParameterName="@Original_roomId" Precision="0" ProviderType="Int" Scale="0" Size="0" SourceColumn="roomId" SourceColumnNullMapping="false" SourceVersion="Original" />
|
||||
<Parameter AllowDbNull="false" AutogeneratedName="" DataSourceName="" DbType="Date" Direction="Input" ParameterName="@Original_checkIn" Precision="0" ProviderType="Date" Scale="0" Size="0" SourceColumn="checkIn" SourceColumnNullMapping="false" SourceVersion="Original" />
|
||||
<Parameter AllowDbNull="false" AutogeneratedName="" DataSourceName="" DbType="Date" Direction="Input" ParameterName="@Original_checkOut" Precision="0" ProviderType="Date" Scale="0" Size="0" SourceColumn="checkOut" SourceColumnNullMapping="false" SourceVersion="Original" />
|
||||
<Parameter AllowDbNull="false" AutogeneratedName="" DataSourceName="" DbType="Boolean" Direction="Input" ParameterName="@Original_paid" Precision="0" ProviderType="Bit" Scale="0" Size="0" SourceColumn="paid" SourceColumnNullMapping="false" SourceVersion="Original" />
|
||||
</Parameters>
|
||||
</DbCommand>
|
||||
</DeleteCommand>
|
||||
<InsertCommand>
|
||||
<DbCommand CommandType="Text" ModifiedByUser="false">
|
||||
<CommandText>INSERT INTO [dbo].[Reservation] ([guestId], [roomId], [checkIn], [checkOut], [paid]) VALUES (@guestId, @roomId, @checkIn, @checkOut, @paid);
|
||||
SELECT Id, guestId, roomId, checkIn, checkOut, paid FROM Reservation WHERE (Id = SCOPE_IDENTITY())</CommandText>
|
||||
<Parameters>
|
||||
<Parameter AllowDbNull="false" AutogeneratedName="" DataSourceName="" DbType="Int32" Direction="Input" ParameterName="@guestId" Precision="0" ProviderType="Int" Scale="0" Size="0" SourceColumn="guestId" SourceColumnNullMapping="false" SourceVersion="Current" />
|
||||
<Parameter AllowDbNull="false" AutogeneratedName="" DataSourceName="" DbType="Int32" Direction="Input" ParameterName="@roomId" Precision="0" ProviderType="Int" Scale="0" Size="0" SourceColumn="roomId" SourceColumnNullMapping="false" SourceVersion="Current" />
|
||||
<Parameter AllowDbNull="false" AutogeneratedName="" DataSourceName="" DbType="Date" Direction="Input" ParameterName="@checkIn" Precision="0" ProviderType="Date" Scale="0" Size="0" SourceColumn="checkIn" SourceColumnNullMapping="false" SourceVersion="Current" />
|
||||
<Parameter AllowDbNull="false" AutogeneratedName="" DataSourceName="" DbType="Date" Direction="Input" ParameterName="@checkOut" Precision="0" ProviderType="Date" Scale="0" Size="0" SourceColumn="checkOut" SourceColumnNullMapping="false" SourceVersion="Current" />
|
||||
<Parameter AllowDbNull="false" AutogeneratedName="" DataSourceName="" DbType="Boolean" Direction="Input" ParameterName="@paid" Precision="0" ProviderType="Bit" Scale="0" Size="0" SourceColumn="paid" SourceColumnNullMapping="false" SourceVersion="Current" />
|
||||
</Parameters>
|
||||
</DbCommand>
|
||||
</InsertCommand>
|
||||
<SelectCommand>
|
||||
<DbCommand CommandType="Text" ModifiedByUser="false">
|
||||
<CommandText>SELECT Id, guestId, roomId, checkIn, checkOut, paid FROM dbo.Reservation</CommandText>
|
||||
<Parameters />
|
||||
</DbCommand>
|
||||
</SelectCommand>
|
||||
<UpdateCommand>
|
||||
<DbCommand CommandType="Text" ModifiedByUser="false">
|
||||
<CommandText>UPDATE [dbo].[Reservation] SET [guestId] = @guestId, [roomId] = @roomId, [checkIn] = @checkIn, [checkOut] = @checkOut, [paid] = @paid WHERE (([Id] = @Original_Id) AND ([guestId] = @Original_guestId) AND ([roomId] = @Original_roomId) AND ([checkIn] = @Original_checkIn) AND ([checkOut] = @Original_checkOut) AND ([paid] = @Original_paid));
|
||||
SELECT Id, guestId, roomId, checkIn, checkOut, paid FROM Reservation WHERE (Id = @Id)</CommandText>
|
||||
<Parameters>
|
||||
<Parameter AllowDbNull="false" AutogeneratedName="" DataSourceName="" DbType="Int32" Direction="Input" ParameterName="@guestId" Precision="0" ProviderType="Int" Scale="0" Size="0" SourceColumn="guestId" SourceColumnNullMapping="false" SourceVersion="Current" />
|
||||
<Parameter AllowDbNull="false" AutogeneratedName="" DataSourceName="" DbType="Int32" Direction="Input" ParameterName="@roomId" Precision="0" ProviderType="Int" Scale="0" Size="0" SourceColumn="roomId" SourceColumnNullMapping="false" SourceVersion="Current" />
|
||||
<Parameter AllowDbNull="false" AutogeneratedName="" DataSourceName="" DbType="Date" Direction="Input" ParameterName="@checkIn" Precision="0" ProviderType="Date" Scale="0" Size="0" SourceColumn="checkIn" SourceColumnNullMapping="false" SourceVersion="Current" />
|
||||
<Parameter AllowDbNull="false" AutogeneratedName="" DataSourceName="" DbType="Date" Direction="Input" ParameterName="@checkOut" Precision="0" ProviderType="Date" Scale="0" Size="0" SourceColumn="checkOut" SourceColumnNullMapping="false" SourceVersion="Current" />
|
||||
<Parameter AllowDbNull="false" AutogeneratedName="" DataSourceName="" DbType="Boolean" Direction="Input" ParameterName="@paid" Precision="0" ProviderType="Bit" Scale="0" Size="0" SourceColumn="paid" SourceColumnNullMapping="false" SourceVersion="Current" />
|
||||
<Parameter AllowDbNull="false" AutogeneratedName="" DataSourceName="" DbType="Int32" Direction="Input" ParameterName="@Original_Id" Precision="0" ProviderType="Int" Scale="0" Size="0" SourceColumn="Id" SourceColumnNullMapping="false" SourceVersion="Original" />
|
||||
<Parameter AllowDbNull="false" AutogeneratedName="" DataSourceName="" DbType="Int32" Direction="Input" ParameterName="@Original_guestId" Precision="0" ProviderType="Int" Scale="0" Size="0" SourceColumn="guestId" SourceColumnNullMapping="false" SourceVersion="Original" />
|
||||
<Parameter AllowDbNull="false" AutogeneratedName="" DataSourceName="" DbType="Int32" Direction="Input" ParameterName="@Original_roomId" Precision="0" ProviderType="Int" Scale="0" Size="0" SourceColumn="roomId" SourceColumnNullMapping="false" SourceVersion="Original" />
|
||||
<Parameter AllowDbNull="false" AutogeneratedName="" DataSourceName="" DbType="Date" Direction="Input" ParameterName="@Original_checkIn" Precision="0" ProviderType="Date" Scale="0" Size="0" SourceColumn="checkIn" SourceColumnNullMapping="false" SourceVersion="Original" />
|
||||
<Parameter AllowDbNull="false" AutogeneratedName="" DataSourceName="" DbType="Date" Direction="Input" ParameterName="@Original_checkOut" Precision="0" ProviderType="Date" Scale="0" Size="0" SourceColumn="checkOut" SourceColumnNullMapping="false" SourceVersion="Original" />
|
||||
<Parameter AllowDbNull="false" AutogeneratedName="" DataSourceName="" DbType="Boolean" Direction="Input" ParameterName="@Original_paid" Precision="0" ProviderType="Bit" Scale="0" Size="0" SourceColumn="paid" SourceColumnNullMapping="false" SourceVersion="Original" />
|
||||
<Parameter AllowDbNull="false" AutogeneratedName="Id" ColumnName="Id" DataSourceName="Hotel.dbo.Reservation" DataTypeServer="int" DbType="Int32" Direction="Input" ParameterName="@Id" Precision="0" ProviderType="Int" Scale="0" Size="4" SourceColumn="Id" SourceColumnNullMapping="false" SourceVersion="Current" />
|
||||
</Parameters>
|
||||
</DbCommand>
|
||||
</UpdateCommand>
|
||||
</DbSource>
|
||||
</MainSource>
|
||||
<Mappings>
|
||||
<Mapping SourceColumn="Id" DataSetColumn="Id" />
|
||||
<Mapping SourceColumn="guestId" DataSetColumn="guestId" />
|
||||
<Mapping SourceColumn="roomId" DataSetColumn="roomId" />
|
||||
<Mapping SourceColumn="checkIn" DataSetColumn="checkIn" />
|
||||
<Mapping SourceColumn="checkOut" DataSetColumn="checkOut" />
|
||||
<Mapping SourceColumn="paid" DataSetColumn="paid" />
|
||||
</Mappings>
|
||||
<Sources />
|
||||
</TableAdapter>
|
||||
<TableAdapter BaseClass="System.ComponentModel.Component" DataAccessorModifier="AutoLayout, AnsiClass, Class, Public" DataAccessorName="RoomTableAdapter" GeneratorDataComponentClassName="RoomTableAdapter" Name="Room" UserDataComponentName="RoomTableAdapter">
|
||||
<MainSource>
|
||||
<DbSource ConnectionRef="HotelConnectionString (Settings)" DbObjectName="Hotel.dbo.Room" DbObjectType="Table" FillMethodModifier="Public" FillMethodName="Fill" GenerateMethods="Both" GenerateShortCommands="true" GeneratorGetMethodName="GetData" GeneratorSourceName="Fill" GetMethodModifier="Public" GetMethodName="GetData" QueryType="Rowset" ScalarCallRetval="System.Object, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" UseOptimisticConcurrency="true" UserGetMethodName="GetData" UserSourceName="Fill">
|
||||
<DeleteCommand>
|
||||
<DbCommand CommandType="Text" ModifiedByUser="false">
|
||||
<CommandText>DELETE FROM [dbo].[Room] WHERE (([Id] = @Original_Id) AND ([type] = @Original_type) AND ([capacity] = @Original_capacity) AND ([price] = @Original_price))</CommandText>
|
||||
<Parameters>
|
||||
<Parameter AllowDbNull="false" AutogeneratedName="" DataSourceName="" DbType="Int32" Direction="Input" ParameterName="@Original_Id" Precision="0" ProviderType="Int" Scale="0" Size="0" SourceColumn="Id" SourceColumnNullMapping="false" SourceVersion="Original" />
|
||||
<Parameter AllowDbNull="false" AutogeneratedName="" DataSourceName="" DbType="AnsiString" Direction="Input" ParameterName="@Original_type" Precision="0" ProviderType="VarChar" Scale="0" Size="0" SourceColumn="type" SourceColumnNullMapping="false" SourceVersion="Original" />
|
||||
<Parameter AllowDbNull="false" AutogeneratedName="" DataSourceName="" DbType="Int32" Direction="Input" ParameterName="@Original_capacity" Precision="0" ProviderType="Int" Scale="0" Size="0" SourceColumn="capacity" SourceColumnNullMapping="false" SourceVersion="Original" />
|
||||
<Parameter AllowDbNull="false" AutogeneratedName="" DataSourceName="" DbType="Int32" Direction="Input" ParameterName="@Original_price" Precision="0" ProviderType="Int" Scale="0" Size="0" SourceColumn="price" SourceColumnNullMapping="false" SourceVersion="Original" />
|
||||
</Parameters>
|
||||
</DbCommand>
|
||||
</DeleteCommand>
|
||||
<InsertCommand>
|
||||
<DbCommand CommandType="Text" ModifiedByUser="false">
|
||||
<CommandText>INSERT INTO [dbo].[Room] ([type], [capacity], [price]) VALUES (@type, @capacity, @price);
|
||||
SELECT Id, type, capacity, price FROM Room WHERE (Id = SCOPE_IDENTITY())</CommandText>
|
||||
<Parameters>
|
||||
<Parameter AllowDbNull="false" AutogeneratedName="" DataSourceName="" DbType="AnsiString" Direction="Input" ParameterName="@type" Precision="0" ProviderType="VarChar" Scale="0" Size="0" SourceColumn="type" SourceColumnNullMapping="false" SourceVersion="Current" />
|
||||
<Parameter AllowDbNull="false" AutogeneratedName="" DataSourceName="" DbType="Int32" Direction="Input" ParameterName="@capacity" Precision="0" ProviderType="Int" Scale="0" Size="0" SourceColumn="capacity" SourceColumnNullMapping="false" SourceVersion="Current" />
|
||||
<Parameter AllowDbNull="false" AutogeneratedName="" DataSourceName="" DbType="Int32" Direction="Input" ParameterName="@price" Precision="0" ProviderType="Int" Scale="0" Size="0" SourceColumn="price" SourceColumnNullMapping="false" SourceVersion="Current" />
|
||||
</Parameters>
|
||||
</DbCommand>
|
||||
</InsertCommand>
|
||||
<SelectCommand>
|
||||
<DbCommand CommandType="Text" ModifiedByUser="false">
|
||||
<CommandText>SELECT Id, type, capacity, price FROM dbo.Room</CommandText>
|
||||
<Parameters />
|
||||
</DbCommand>
|
||||
</SelectCommand>
|
||||
<UpdateCommand>
|
||||
<DbCommand CommandType="Text" ModifiedByUser="false">
|
||||
<CommandText>UPDATE [dbo].[Room] SET [type] = @type, [capacity] = @capacity, [price] = @price WHERE (([Id] = @Original_Id) AND ([type] = @Original_type) AND ([capacity] = @Original_capacity) AND ([price] = @Original_price));
|
||||
SELECT Id, type, capacity, price FROM Room WHERE (Id = @Id)</CommandText>
|
||||
<Parameters>
|
||||
<Parameter AllowDbNull="false" AutogeneratedName="" DataSourceName="" DbType="AnsiString" Direction="Input" ParameterName="@type" Precision="0" ProviderType="VarChar" Scale="0" Size="0" SourceColumn="type" SourceColumnNullMapping="false" SourceVersion="Current" />
|
||||
<Parameter AllowDbNull="false" AutogeneratedName="" DataSourceName="" DbType="Int32" Direction="Input" ParameterName="@capacity" Precision="0" ProviderType="Int" Scale="0" Size="0" SourceColumn="capacity" SourceColumnNullMapping="false" SourceVersion="Current" />
|
||||
<Parameter AllowDbNull="false" AutogeneratedName="" DataSourceName="" DbType="Int32" Direction="Input" ParameterName="@price" Precision="0" ProviderType="Int" Scale="0" Size="0" SourceColumn="price" SourceColumnNullMapping="false" SourceVersion="Current" />
|
||||
<Parameter AllowDbNull="false" AutogeneratedName="" DataSourceName="" DbType="Int32" Direction="Input" ParameterName="@Original_Id" Precision="0" ProviderType="Int" Scale="0" Size="0" SourceColumn="Id" SourceColumnNullMapping="false" SourceVersion="Original" />
|
||||
<Parameter AllowDbNull="false" AutogeneratedName="" DataSourceName="" DbType="AnsiString" Direction="Input" ParameterName="@Original_type" Precision="0" ProviderType="VarChar" Scale="0" Size="0" SourceColumn="type" SourceColumnNullMapping="false" SourceVersion="Original" />
|
||||
<Parameter AllowDbNull="false" AutogeneratedName="" DataSourceName="" DbType="Int32" Direction="Input" ParameterName="@Original_capacity" Precision="0" ProviderType="Int" Scale="0" Size="0" SourceColumn="capacity" SourceColumnNullMapping="false" SourceVersion="Original" />
|
||||
<Parameter AllowDbNull="false" AutogeneratedName="" DataSourceName="" DbType="Int32" Direction="Input" ParameterName="@Original_price" Precision="0" ProviderType="Int" Scale="0" Size="0" SourceColumn="price" SourceColumnNullMapping="false" SourceVersion="Original" />
|
||||
<Parameter AllowDbNull="false" AutogeneratedName="Id" ColumnName="Id" DataSourceName="Hotel.dbo.Room" DataTypeServer="int" DbType="Int32" Direction="Input" ParameterName="@Id" Precision="0" ProviderType="Int" Scale="0" Size="4" SourceColumn="Id" SourceColumnNullMapping="false" SourceVersion="Current" />
|
||||
</Parameters>
|
||||
</DbCommand>
|
||||
</UpdateCommand>
|
||||
</DbSource>
|
||||
</MainSource>
|
||||
<Mappings>
|
||||
<Mapping SourceColumn="Id" DataSetColumn="Id" />
|
||||
<Mapping SourceColumn="type" DataSetColumn="type" />
|
||||
<Mapping SourceColumn="capacity" DataSetColumn="capacity" />
|
||||
<Mapping SourceColumn="price" DataSetColumn="price" />
|
||||
</Mappings>
|
||||
<Sources />
|
||||
</TableAdapter>
|
||||
<TableAdapter BaseClass="System.ComponentModel.Component" DataAccessorModifier="AutoLayout, AnsiClass, Class, Public" DataAccessorName="ServiceTableAdapter" GeneratorDataComponentClassName="ServiceTableAdapter" Name="Service" UserDataComponentName="ServiceTableAdapter">
|
||||
<MainSource>
|
||||
<DbSource ConnectionRef="HotelConnectionString (Settings)" DbObjectName="Hotel.dbo.Service" DbObjectType="Table" FillMethodModifier="Public" FillMethodName="Fill" GenerateMethods="Both" GenerateShortCommands="true" GeneratorGetMethodName="GetData" GeneratorSourceName="Fill" GetMethodModifier="Public" GetMethodName="GetData" QueryType="Rowset" ScalarCallRetval="System.Object, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" UseOptimisticConcurrency="true" UserGetMethodName="GetData" UserSourceName="Fill">
|
||||
<DeleteCommand>
|
||||
<DbCommand CommandType="Text" ModifiedByUser="false">
|
||||
<CommandText>DELETE FROM [dbo].[Service] WHERE (([Id] = @Original_Id) AND ([name] = @Original_name) AND ([description] = @Original_description) AND ([price] = @Original_price))</CommandText>
|
||||
<Parameters>
|
||||
<Parameter AllowDbNull="false" AutogeneratedName="" DataSourceName="" DbType="Int32" Direction="Input" ParameterName="@Original_Id" Precision="0" ProviderType="Int" Scale="0" Size="0" SourceColumn="Id" SourceColumnNullMapping="false" SourceVersion="Original" />
|
||||
<Parameter AllowDbNull="false" AutogeneratedName="" DataSourceName="" DbType="AnsiString" Direction="Input" ParameterName="@Original_name" Precision="0" ProviderType="VarChar" Scale="0" Size="0" SourceColumn="name" SourceColumnNullMapping="false" SourceVersion="Original" />
|
||||
<Parameter AllowDbNull="false" AutogeneratedName="" DataSourceName="" DbType="AnsiString" Direction="Input" ParameterName="@Original_description" Precision="0" ProviderType="VarChar" Scale="0" Size="0" SourceColumn="description" SourceColumnNullMapping="false" SourceVersion="Original" />
|
||||
<Parameter AllowDbNull="false" AutogeneratedName="" DataSourceName="" DbType="Int32" Direction="Input" ParameterName="@Original_price" Precision="0" ProviderType="Int" Scale="0" Size="0" SourceColumn="price" SourceColumnNullMapping="false" SourceVersion="Original" />
|
||||
</Parameters>
|
||||
</DbCommand>
|
||||
</DeleteCommand>
|
||||
<InsertCommand>
|
||||
<DbCommand CommandType="Text" ModifiedByUser="false">
|
||||
<CommandText>INSERT INTO [dbo].[Service] ([name], [description], [price]) VALUES (@name, @description, @price);
|
||||
SELECT Id, name, description, price FROM Service WHERE (Id = SCOPE_IDENTITY())</CommandText>
|
||||
<Parameters>
|
||||
<Parameter AllowDbNull="false" AutogeneratedName="" DataSourceName="" DbType="AnsiString" Direction="Input" ParameterName="@name" Precision="0" ProviderType="VarChar" Scale="0" Size="0" SourceColumn="name" SourceColumnNullMapping="false" SourceVersion="Current" />
|
||||
<Parameter AllowDbNull="false" AutogeneratedName="" DataSourceName="" DbType="AnsiString" Direction="Input" ParameterName="@description" Precision="0" ProviderType="VarChar" Scale="0" Size="0" SourceColumn="description" SourceColumnNullMapping="false" SourceVersion="Current" />
|
||||
<Parameter AllowDbNull="false" AutogeneratedName="" DataSourceName="" DbType="Int32" Direction="Input" ParameterName="@price" Precision="0" ProviderType="Int" Scale="0" Size="0" SourceColumn="price" SourceColumnNullMapping="false" SourceVersion="Current" />
|
||||
</Parameters>
|
||||
</DbCommand>
|
||||
</InsertCommand>
|
||||
<SelectCommand>
|
||||
<DbCommand CommandType="Text" ModifiedByUser="false">
|
||||
<CommandText>SELECT Id, name, description, price FROM dbo.Service</CommandText>
|
||||
<Parameters />
|
||||
</DbCommand>
|
||||
</SelectCommand>
|
||||
<UpdateCommand>
|
||||
<DbCommand CommandType="Text" ModifiedByUser="false">
|
||||
<CommandText>UPDATE [dbo].[Service] SET [name] = @name, [description] = @description, [price] = @price WHERE (([Id] = @Original_Id) AND ([name] = @Original_name) AND ([description] = @Original_description) AND ([price] = @Original_price));
|
||||
SELECT Id, name, description, price FROM Service WHERE (Id = @Id)</CommandText>
|
||||
<Parameters>
|
||||
<Parameter AllowDbNull="false" AutogeneratedName="" DataSourceName="" DbType="AnsiString" Direction="Input" ParameterName="@name" Precision="0" ProviderType="VarChar" Scale="0" Size="0" SourceColumn="name" SourceColumnNullMapping="false" SourceVersion="Current" />
|
||||
<Parameter AllowDbNull="false" AutogeneratedName="" DataSourceName="" DbType="AnsiString" Direction="Input" ParameterName="@description" Precision="0" ProviderType="VarChar" Scale="0" Size="0" SourceColumn="description" SourceColumnNullMapping="false" SourceVersion="Current" />
|
||||
<Parameter AllowDbNull="false" AutogeneratedName="" DataSourceName="" DbType="Int32" Direction="Input" ParameterName="@price" Precision="0" ProviderType="Int" Scale="0" Size="0" SourceColumn="price" SourceColumnNullMapping="false" SourceVersion="Current" />
|
||||
<Parameter AllowDbNull="false" AutogeneratedName="" DataSourceName="" DbType="Int32" Direction="Input" ParameterName="@Original_Id" Precision="0" ProviderType="Int" Scale="0" Size="0" SourceColumn="Id" SourceColumnNullMapping="false" SourceVersion="Original" />
|
||||
<Parameter AllowDbNull="false" AutogeneratedName="" DataSourceName="" DbType="AnsiString" Direction="Input" ParameterName="@Original_name" Precision="0" ProviderType="VarChar" Scale="0" Size="0" SourceColumn="name" SourceColumnNullMapping="false" SourceVersion="Original" />
|
||||
<Parameter AllowDbNull="false" AutogeneratedName="" DataSourceName="" DbType="AnsiString" Direction="Input" ParameterName="@Original_description" Precision="0" ProviderType="VarChar" Scale="0" Size="0" SourceColumn="description" SourceColumnNullMapping="false" SourceVersion="Original" />
|
||||
<Parameter AllowDbNull="false" AutogeneratedName="" DataSourceName="" DbType="Int32" Direction="Input" ParameterName="@Original_price" Precision="0" ProviderType="Int" Scale="0" Size="0" SourceColumn="price" SourceColumnNullMapping="false" SourceVersion="Original" />
|
||||
<Parameter AllowDbNull="false" AutogeneratedName="Id" ColumnName="Id" DataSourceName="Hotel.dbo.Service" DataTypeServer="int" DbType="Int32" Direction="Input" ParameterName="@Id" Precision="0" ProviderType="Int" Scale="0" Size="4" SourceColumn="Id" SourceColumnNullMapping="false" SourceVersion="Current" />
|
||||
</Parameters>
|
||||
</DbCommand>
|
||||
</UpdateCommand>
|
||||
</DbSource>
|
||||
</MainSource>
|
||||
<Mappings>
|
||||
<Mapping SourceColumn="Id" DataSetColumn="Id" />
|
||||
<Mapping SourceColumn="name" DataSetColumn="name" />
|
||||
<Mapping SourceColumn="description" DataSetColumn="description" />
|
||||
<Mapping SourceColumn="price" DataSetColumn="price" />
|
||||
</Mappings>
|
||||
<Sources />
|
||||
</TableAdapter>
|
||||
</Tables>
|
||||
<Sources />
|
||||
</DataSource>
|
||||
</xs:appinfo>
|
||||
</xs:annotation>
|
||||
<xs:element name="HotelDataSet" msdata:IsDataSet="true" msdata:UseCurrentLocale="true" msprop:EnableTableAdapterManager="True" msprop:Generator_UserDSName="HotelDataSet" msprop:Generator_DataSetName="HotelDataSet">
|
||||
<xs:complexType>
|
||||
<xs:choice minOccurs="0" maxOccurs="unbounded">
|
||||
<xs:element name="Guest" msprop:Generator_RowEvHandlerName="GuestRowChangeEventHandler" msprop:Generator_RowDeletedName="GuestRowDeleted" msprop:Generator_RowDeletingName="GuestRowDeleting" msprop:Generator_RowEvArgName="GuestRowChangeEvent" msprop:Generator_TablePropName="Guest" msprop:Generator_RowChangedName="GuestRowChanged" msprop:Generator_RowChangingName="GuestRowChanging" msprop:Generator_TableClassName="GuestDataTable" msprop:Generator_RowClassName="GuestRow" msprop:Generator_TableVarName="tableGuest" msprop:Generator_UserTableName="Guest">
|
||||
<xs:complexType>
|
||||
<xs:sequence>
|
||||
<xs:element name="Id" msdata:ReadOnly="true" msdata:AutoIncrement="true" msdata:AutoIncrementSeed="-1" msdata:AutoIncrementStep="-1" msprop:Generator_ColumnPropNameInRow="Id" msprop:Generator_ColumnPropNameInTable="IdColumn" msprop:Generator_ColumnVarNameInTable="columnId" msprop:Generator_UserColumnName="Id" type="xs:int" />
|
||||
<xs:element name="name" msprop:Generator_ColumnPropNameInRow="name" msprop:Generator_ColumnPropNameInTable="nameColumn" msprop:Generator_ColumnVarNameInTable="columnname" msprop:Generator_UserColumnName="name">
|
||||
<xs:simpleType>
|
||||
<xs:restriction base="xs:string">
|
||||
<xs:maxLength value="255" />
|
||||
</xs:restriction>
|
||||
</xs:simpleType>
|
||||
</xs:element>
|
||||
<xs:element name="email" msprop:Generator_ColumnPropNameInRow="email" msprop:Generator_ColumnPropNameInTable="emailColumn" msprop:Generator_ColumnVarNameInTable="columnemail" msprop:Generator_UserColumnName="email">
|
||||
<xs:simpleType>
|
||||
<xs:restriction base="xs:string">
|
||||
<xs:maxLength value="255" />
|
||||
</xs:restriction>
|
||||
</xs:simpleType>
|
||||
</xs:element>
|
||||
<xs:element name="phone" msprop:Generator_ColumnPropNameInRow="phone" msprop:Generator_ColumnPropNameInTable="phoneColumn" msprop:Generator_ColumnVarNameInTable="columnphone" msprop:Generator_UserColumnName="phone">
|
||||
<xs:simpleType>
|
||||
<xs:restriction base="xs:string">
|
||||
<xs:maxLength value="255" />
|
||||
</xs:restriction>
|
||||
</xs:simpleType>
|
||||
</xs:element>
|
||||
</xs:sequence>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
<xs:element name="Payment" msprop:Generator_RowEvHandlerName="PaymentRowChangeEventHandler" msprop:Generator_RowDeletedName="PaymentRowDeleted" msprop:Generator_RowDeletingName="PaymentRowDeleting" msprop:Generator_RowEvArgName="PaymentRowChangeEvent" msprop:Generator_TablePropName="Payment" msprop:Generator_RowChangedName="PaymentRowChanged" msprop:Generator_RowChangingName="PaymentRowChanging" msprop:Generator_TableClassName="PaymentDataTable" msprop:Generator_RowClassName="PaymentRow" msprop:Generator_TableVarName="tablePayment" msprop:Generator_UserTableName="Payment">
|
||||
<xs:complexType>
|
||||
<xs:sequence>
|
||||
<xs:element name="Id" msdata:ReadOnly="true" msdata:AutoIncrement="true" msdata:AutoIncrementSeed="-1" msdata:AutoIncrementStep="-1" msprop:Generator_ColumnPropNameInRow="Id" msprop:Generator_ColumnPropNameInTable="IdColumn" msprop:Generator_ColumnVarNameInTable="columnId" msprop:Generator_UserColumnName="Id" type="xs:int" />
|
||||
<xs:element name="reservationId" msprop:Generator_ColumnPropNameInRow="reservationId" msprop:Generator_ColumnPropNameInTable="reservationIdColumn" msprop:Generator_ColumnVarNameInTable="columnreservationId" msprop:Generator_UserColumnName="reservationId" type="xs:int" />
|
||||
<xs:element name="amount" msprop:Generator_ColumnPropNameInRow="amount" msprop:Generator_ColumnPropNameInTable="amountColumn" msprop:Generator_ColumnVarNameInTable="columnamount" msprop:Generator_UserColumnName="amount" type="xs:int" />
|
||||
<xs:element name="serviceId" msprop:Generator_ColumnPropNameInRow="serviceId" msprop:Generator_ColumnPropNameInTable="serviceIdColumn" msprop:Generator_ColumnVarNameInTable="columnserviceId" msprop:Generator_UserColumnName="serviceId" type="xs:int" />
|
||||
</xs:sequence>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
<xs:element name="Reservation" msprop:Generator_RowEvHandlerName="ReservationRowChangeEventHandler" msprop:Generator_RowDeletedName="ReservationRowDeleted" msprop:Generator_RowDeletingName="ReservationRowDeleting" msprop:Generator_RowEvArgName="ReservationRowChangeEvent" msprop:Generator_TablePropName="Reservation" msprop:Generator_RowChangedName="ReservationRowChanged" msprop:Generator_RowChangingName="ReservationRowChanging" msprop:Generator_TableClassName="ReservationDataTable" msprop:Generator_RowClassName="ReservationRow" msprop:Generator_TableVarName="tableReservation" msprop:Generator_UserTableName="Reservation">
|
||||
<xs:complexType>
|
||||
<xs:sequence>
|
||||
<xs:element name="Id" msdata:ReadOnly="true" msdata:AutoIncrement="true" msdata:AutoIncrementSeed="-1" msdata:AutoIncrementStep="-1" msprop:Generator_ColumnPropNameInRow="Id" msprop:Generator_ColumnPropNameInTable="IdColumn" msprop:Generator_ColumnVarNameInTable="columnId" msprop:Generator_UserColumnName="Id" type="xs:int" />
|
||||
<xs:element name="guestId" msprop:Generator_ColumnPropNameInRow="guestId" msprop:Generator_ColumnPropNameInTable="guestIdColumn" msprop:Generator_ColumnVarNameInTable="columnguestId" msprop:Generator_UserColumnName="guestId" type="xs:int" />
|
||||
<xs:element name="roomId" msprop:Generator_ColumnPropNameInRow="roomId" msprop:Generator_ColumnPropNameInTable="roomIdColumn" msprop:Generator_ColumnVarNameInTable="columnroomId" msprop:Generator_UserColumnName="roomId" type="xs:int" />
|
||||
<xs:element name="checkIn" msprop:Generator_ColumnPropNameInRow="checkIn" msprop:Generator_ColumnPropNameInTable="checkInColumn" msprop:Generator_ColumnVarNameInTable="columncheckIn" msprop:Generator_UserColumnName="checkIn" type="xs:dateTime" />
|
||||
<xs:element name="checkOut" msprop:Generator_ColumnPropNameInRow="checkOut" msprop:Generator_ColumnPropNameInTable="checkOutColumn" msprop:Generator_ColumnVarNameInTable="columncheckOut" msprop:Generator_UserColumnName="checkOut" type="xs:dateTime" />
|
||||
<xs:element name="paid" msprop:Generator_ColumnPropNameInRow="paid" msprop:Generator_ColumnPropNameInTable="paidColumn" msprop:Generator_ColumnVarNameInTable="columnpaid" msprop:Generator_UserColumnName="paid" type="xs:boolean" />
|
||||
</xs:sequence>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
<xs:element name="Room" msprop:Generator_RowEvHandlerName="RoomRowChangeEventHandler" msprop:Generator_RowDeletedName="RoomRowDeleted" msprop:Generator_RowDeletingName="RoomRowDeleting" msprop:Generator_RowEvArgName="RoomRowChangeEvent" msprop:Generator_TablePropName="Room" msprop:Generator_RowChangedName="RoomRowChanged" msprop:Generator_RowChangingName="RoomRowChanging" msprop:Generator_TableClassName="RoomDataTable" msprop:Generator_RowClassName="RoomRow" msprop:Generator_TableVarName="tableRoom" msprop:Generator_UserTableName="Room">
|
||||
<xs:complexType>
|
||||
<xs:sequence>
|
||||
<xs:element name="Id" msdata:ReadOnly="true" msdata:AutoIncrement="true" msdata:AutoIncrementSeed="-1" msdata:AutoIncrementStep="-1" msprop:Generator_ColumnPropNameInRow="Id" msprop:Generator_ColumnPropNameInTable="IdColumn" msprop:Generator_ColumnVarNameInTable="columnId" msprop:Generator_UserColumnName="Id" type="xs:int" />
|
||||
<xs:element name="type" msprop:Generator_ColumnPropNameInRow="type" msprop:Generator_ColumnPropNameInTable="typeColumn" msprop:Generator_ColumnVarNameInTable="columntype" msprop:Generator_UserColumnName="type">
|
||||
<xs:simpleType>
|
||||
<xs:restriction base="xs:string">
|
||||
<xs:maxLength value="255" />
|
||||
</xs:restriction>
|
||||
</xs:simpleType>
|
||||
</xs:element>
|
||||
<xs:element name="capacity" msprop:Generator_ColumnPropNameInRow="capacity" msprop:Generator_ColumnPropNameInTable="capacityColumn" msprop:Generator_ColumnVarNameInTable="columncapacity" msprop:Generator_UserColumnName="capacity" type="xs:int" />
|
||||
<xs:element name="price" msprop:Generator_ColumnPropNameInRow="price" msprop:Generator_ColumnPropNameInTable="priceColumn" msprop:Generator_ColumnVarNameInTable="columnprice" msprop:Generator_UserColumnName="price" type="xs:int" />
|
||||
</xs:sequence>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
<xs:element name="Service" msprop:Generator_RowEvHandlerName="ServiceRowChangeEventHandler" msprop:Generator_RowDeletedName="ServiceRowDeleted" msprop:Generator_RowDeletingName="ServiceRowDeleting" msprop:Generator_RowEvArgName="ServiceRowChangeEvent" msprop:Generator_TablePropName="Service" msprop:Generator_RowChangedName="ServiceRowChanged" msprop:Generator_RowChangingName="ServiceRowChanging" msprop:Generator_TableClassName="ServiceDataTable" msprop:Generator_RowClassName="ServiceRow" msprop:Generator_TableVarName="tableService" msprop:Generator_UserTableName="Service">
|
||||
<xs:complexType>
|
||||
<xs:sequence>
|
||||
<xs:element name="Id" msdata:ReadOnly="true" msdata:AutoIncrement="true" msdata:AutoIncrementSeed="-1" msdata:AutoIncrementStep="-1" msprop:Generator_ColumnPropNameInRow="Id" msprop:Generator_ColumnPropNameInTable="IdColumn" msprop:Generator_ColumnVarNameInTable="columnId" msprop:Generator_UserColumnName="Id" type="xs:int" />
|
||||
<xs:element name="name" msprop:Generator_ColumnPropNameInRow="name" msprop:Generator_ColumnPropNameInTable="nameColumn" msprop:Generator_ColumnVarNameInTable="columnname" msprop:Generator_UserColumnName="name">
|
||||
<xs:simpleType>
|
||||
<xs:restriction base="xs:string">
|
||||
<xs:maxLength value="255" />
|
||||
</xs:restriction>
|
||||
</xs:simpleType>
|
||||
</xs:element>
|
||||
<xs:element name="description" msprop:Generator_ColumnPropNameInRow="description" msprop:Generator_ColumnPropNameInTable="descriptionColumn" msprop:Generator_ColumnVarNameInTable="columndescription" msprop:Generator_UserColumnName="description">
|
||||
<xs:simpleType>
|
||||
<xs:restriction base="xs:string">
|
||||
<xs:maxLength value="255" />
|
||||
</xs:restriction>
|
||||
</xs:simpleType>
|
||||
</xs:element>
|
||||
<xs:element name="price" msprop:Generator_ColumnPropNameInRow="price" msprop:Generator_ColumnPropNameInTable="priceColumn" msprop:Generator_ColumnVarNameInTable="columnprice" msprop:Generator_UserColumnName="price" type="xs:int" />
|
||||
</xs:sequence>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
</xs:choice>
|
||||
</xs:complexType>
|
||||
<xs:unique name="Constraint1" msdata:PrimaryKey="true">
|
||||
<xs:selector xpath=".//mstns:Guest" />
|
||||
<xs:field xpath="mstns:Id" />
|
||||
</xs:unique>
|
||||
<xs:unique name="Payment_Constraint1" msdata:ConstraintName="Constraint1" msdata:PrimaryKey="true">
|
||||
<xs:selector xpath=".//mstns:Payment" />
|
||||
<xs:field xpath="mstns:Id" />
|
||||
</xs:unique>
|
||||
<xs:unique name="Reservation_Constraint1" msdata:ConstraintName="Constraint1" msdata:PrimaryKey="true">
|
||||
<xs:selector xpath=".//mstns:Reservation" />
|
||||
<xs:field xpath="mstns:Id" />
|
||||
</xs:unique>
|
||||
<xs:unique name="Room_Constraint1" msdata:ConstraintName="Constraint1" msdata:PrimaryKey="true">
|
||||
<xs:selector xpath=".//mstns:Room" />
|
||||
<xs:field xpath="mstns:Id" />
|
||||
</xs:unique>
|
||||
<xs:unique name="Service_Constraint1" msdata:ConstraintName="Constraint1" msdata:PrimaryKey="true">
|
||||
<xs:selector xpath=".//mstns:Service" />
|
||||
<xs:field xpath="mstns:Id" />
|
||||
</xs:unique>
|
||||
</xs:element>
|
||||
<xs:annotation>
|
||||
<xs:appinfo>
|
||||
<msdata:Relationship name="FK__Payment__reserva__5629CD9C" msdata:parent="Reservation" msdata:child="Payment" msdata:parentkey="Id" msdata:childkey="reservationId" msprop:Generator_UserParentTable="Reservation" msprop:Generator_UserChildTable="Payment" msprop:Generator_RelationVarName="relationFK__Payment__reserva__5629CD9C" msprop:Generator_UserRelationName="FK__Payment__reserva__5629CD9C" msprop:Generator_ChildPropName="GetPaymentRows" msprop:Generator_ParentPropName="ReservationRow" />
|
||||
<msdata:Relationship name="FK__Payment__service__571DF1D5" msdata:parent="Service" msdata:child="Payment" msdata:parentkey="Id" msdata:childkey="serviceId" msprop:Generator_UserParentTable="Service" msprop:Generator_UserChildTable="Payment" msprop:Generator_RelationVarName="relationFK__Payment__service__571DF1D5" msprop:Generator_UserRelationName="FK__Payment__service__571DF1D5" msprop:Generator_ChildPropName="GetPaymentRows" msprop:Generator_ParentPropName="ServiceRow" />
|
||||
<msdata:Relationship name="FK__Reservati__guest__5070F446" msdata:parent="Guest" msdata:child="Reservation" msdata:parentkey="Id" msdata:childkey="guestId" msprop:Generator_UserParentTable="Guest" msprop:Generator_UserChildTable="Reservation" msprop:Generator_RelationVarName="relationFK__Reservati__guest__5070F446" msprop:Generator_ChildPropName="GetReservationRows" msprop:Generator_ParentPropName="GuestRow" msprop:Generator_UserRelationName="FK__Reservati__guest__5070F446" />
|
||||
<msdata:Relationship name="FK__Reservati__roomI__5165187F" msdata:parent="Room" msdata:child="Reservation" msdata:parentkey="Id" msdata:childkey="roomId" msprop:Generator_UserParentTable="Room" msprop:Generator_UserChildTable="Reservation" msprop:Generator_RelationVarName="relationFK__Reservati__roomI__5165187F" msprop:Generator_UserRelationName="FK__Reservati__roomI__5165187F" msprop:Generator_ChildPropName="GetReservationRows" msprop:Generator_ParentPropName="RoomRow" />
|
||||
</xs:appinfo>
|
||||
</xs:annotation>
|
||||
</xs:schema>
|
||||
@@ -0,0 +1 @@
|
||||
|
||||
@@ -0,0 +1,99 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{1E1F18BC-F95C-41B1-A472-6E928149DC0A}</ProjectGuid>
|
||||
<OutputType>WinExe</OutputType>
|
||||
<RootNamespace>Practic</RootNamespace>
|
||||
<AssemblyName>Practic</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
|
||||
<Deterministic>true</Deterministic>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Deployment" />
|
||||
<Reference Include="System.Drawing" />
|
||||
<Reference Include="System.Net.Http" />
|
||||
<Reference Include="System.Windows.Forms" />
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Form1.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Form1.Designer.cs">
|
||||
<DependentUpon>Form1.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="HotelDataSet.Designer.cs">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DesignTime>True</DesignTime>
|
||||
<DependentUpon>HotelDataSet.xsd</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Program.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<EmbeddedResource Include="Form1.resx">
|
||||
<DependentUpon>Form1.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="Properties\Resources.resx">
|
||||
<Generator>ResXFileCodeGenerator</Generator>
|
||||
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
|
||||
<SubType>Designer</SubType>
|
||||
</EmbeddedResource>
|
||||
<Compile Include="Properties\Resources.Designer.cs">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DependentUpon>Resources.resx</DependentUpon>
|
||||
</Compile>
|
||||
<None Include="HotelDataSet.xsc">
|
||||
<DependentUpon>HotelDataSet.xsd</DependentUpon>
|
||||
</None>
|
||||
<None Include="HotelDataSet.xsd">
|
||||
<Generator>MSDataSetGenerator</Generator>
|
||||
<LastGenOutput>HotelDataSet.Designer.cs</LastGenOutput>
|
||||
<SubType>Designer</SubType>
|
||||
</None>
|
||||
<None Include="HotelDataSet.xss">
|
||||
<DependentUpon>HotelDataSet.xsd</DependentUpon>
|
||||
</None>
|
||||
<None Include="Properties\Settings.settings">
|
||||
<Generator>SettingsSingleFileGenerator</Generator>
|
||||
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
|
||||
</None>
|
||||
<Compile Include="Properties\Settings.Designer.cs">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DependentUpon>Settings.settings</DependentUpon>
|
||||
<DesignTimeSharedInput>True</DesignTimeSharedInput>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="App.config" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
||||
@@ -0,0 +1,22 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace Practic
|
||||
{
|
||||
internal static class Program
|
||||
{
|
||||
/// <summary>
|
||||
/// The main entry point for the application.
|
||||
/// </summary>
|
||||
[STAThread]
|
||||
static void Main()
|
||||
{
|
||||
Application.EnableVisualStyles();
|
||||
Application.SetCompatibleTextRenderingDefault(false);
|
||||
Application.Run(new Form1());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyTitle("Practic")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("Practic")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2024")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// Setting ComVisible to false makes the types in this assembly not visible
|
||||
// to COM components. If you need to access a type in this assembly from
|
||||
// COM, set the ComVisible attribute to true on that type.
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||
[assembly: Guid("1e1f18bc-f95c-41b1-a472-6e928149dc0a")]
|
||||
|
||||
// Version information for an assembly consists of the following four values:
|
||||
//
|
||||
// Major Version
|
||||
// Minor Version
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||
@@ -0,0 +1,71 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
// Runtime Version:4.0.30319.42000
|
||||
//
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace Practic.Properties
|
||||
{
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// A strongly-typed resource class, for looking up localized strings, etc.
|
||||
/// </summary>
|
||||
// This class was auto-generated by the StronglyTypedResourceBuilder
|
||||
// class via a tool like ResGen or Visual Studio.
|
||||
// To add or remove a member, edit your .ResX file then rerun ResGen
|
||||
// with the /str option, or rebuild your VS project.
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||
internal class Resources
|
||||
{
|
||||
|
||||
private static global::System.Resources.ResourceManager resourceMan;
|
||||
|
||||
private static global::System.Globalization.CultureInfo resourceCulture;
|
||||
|
||||
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
|
||||
internal Resources()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the cached ResourceManager instance used by this class.
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
internal static global::System.Resources.ResourceManager ResourceManager
|
||||
{
|
||||
get
|
||||
{
|
||||
if ((resourceMan == null))
|
||||
{
|
||||
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Practic.Properties.Resources", typeof(Resources).Assembly);
|
||||
resourceMan = temp;
|
||||
}
|
||||
return resourceMan;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Overrides the current thread's CurrentUICulture property for all
|
||||
/// resource lookups using this strongly typed resource class.
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
internal static global::System.Globalization.CultureInfo Culture
|
||||
{
|
||||
get
|
||||
{
|
||||
return resourceCulture;
|
||||
}
|
||||
set
|
||||
{
|
||||
resourceCulture = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,117 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
||||
@@ -0,0 +1,37 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
// Runtime Version:4.0.30319.42000
|
||||
//
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace Practic.Properties {
|
||||
|
||||
|
||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "17.9.0.0")]
|
||||
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
|
||||
|
||||
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
|
||||
|
||||
public static Settings Default {
|
||||
get {
|
||||
return defaultInstance;
|
||||
}
|
||||
}
|
||||
|
||||
[global::System.Configuration.ApplicationScopedSettingAttribute()]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Configuration.SpecialSettingAttribute(global::System.Configuration.SpecialSetting.ConnectionString)]
|
||||
[global::System.Configuration.DefaultSettingValueAttribute("Data Source=DANIELCUJBA\\SQLEXPRESS;Initial Catalog=Hotel;Integrated Security=True" +
|
||||
";TrustServerCertificate=True")]
|
||||
public string HotelConnectionString {
|
||||
get {
|
||||
return ((string)(this["HotelConnectionString"]));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)" GeneratedClassNamespace="Practic.Properties" GeneratedClassName="Settings">
|
||||
<Profiles />
|
||||
<Settings>
|
||||
<Setting Name="HotelConnectionString" Type="(Connection string)" Scope="Application">
|
||||
<DesignTimeValue Profile="(Default)"><?xml version="1.0" encoding="utf-16"?>
|
||||
<SerializableConnectionString xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||
<ConnectionString>Data Source=DANIELCUJBA\SQLEXPRESS;Initial Catalog=Hotel;Integrated Security=True;TrustServerCertificate=True</ConnectionString>
|
||||
<ProviderName>System.Data.SqlClient</ProviderName>
|
||||
</SerializableConnectionString></DesignTimeValue>
|
||||
<Value Profile="(Default)">Data Source=DANIELCUJBA\SQLEXPRESS;Initial Catalog=Hotel;Integrated Security=True;TrustServerCertificate=True</Value>
|
||||
</Setting>
|
||||
</Settings>
|
||||
</SettingsFile>
|
||||
@@ -0,0 +1,25 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 17
|
||||
VisualStudioVersion = 17.9.34622.214
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Lab1", "Lab1\Lab1.csproj", "{5DDE8D84-CE84-4F12-A8DD-38B99E1BBAAF}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{5DDE8D84-CE84-4F12-A8DD-38B99E1BBAAF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{5DDE8D84-CE84-4F12-A8DD-38B99E1BBAAF}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{5DDE8D84-CE84-4F12-A8DD-38B99E1BBAAF}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{5DDE8D84-CE84-4F12-A8DD-38B99E1BBAAF}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {5D743BF4-E6DC-4DFA-B47E-523157CEBD69}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
@@ -0,0 +1,10 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
||||
@@ -0,0 +1,34 @@
|
||||
using System;
|
||||
namespace Lab1
|
||||
{
|
||||
public class Program
|
||||
{
|
||||
private static System.Timers.Timer? aTimer;
|
||||
|
||||
public static void Main(string[] args)
|
||||
{
|
||||
aTimer = new System.Timers.Timer
|
||||
{
|
||||
Interval = 1000
|
||||
};
|
||||
aTimer.Elapsed += OnTimedEvent;
|
||||
aTimer.Start();
|
||||
Console.Read();
|
||||
return;
|
||||
}
|
||||
|
||||
public static void OnTimedEvent(object? source, System.Timers.ElapsedEventArgs e)
|
||||
{
|
||||
var now = DateTime.UtcNow;
|
||||
Console.Clear();
|
||||
Console.WriteLine("Date:");
|
||||
Console.WriteLine($"Decimal: {now.Day:D2}/{now.Month:D2}/{now.Year:D4}");
|
||||
Console.WriteLine($"Hexa: {now.Day:X2}/{now.Month:X2}/{now.Year:X4}");
|
||||
Console.WriteLine($"Binary: {now.Day:b5}/{now.Month:b4}/{now.Year:b16}");
|
||||
Console.WriteLine("Time:");
|
||||
Console.WriteLine($"Decimal: {now.Hour:D2}:{now.Minute:D2}:{now.Second:D2}");
|
||||
Console.WriteLine($"Hexa: {now.Hour:X2}:{now.Minute:X2}:{now.Second:X2}");
|
||||
Console.WriteLine($"Binary: {now.Hour:b6}:{now.Minute:b6}:{now.Second:b6}");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
||||
@@ -0,0 +1,122 @@
|
||||
using Timer = System.Timers.Timer;
|
||||
|
||||
namespace CacheModule{
|
||||
|
||||
public class CacheService
|
||||
{
|
||||
private readonly Dictionary<string, Dictionary<string, CachedObject>> _cache = new Dictionary<string, Dictionary<string, CachedObject>>();
|
||||
|
||||
private static object _lock = new object();
|
||||
|
||||
private readonly Timer _timer = new Timer();
|
||||
|
||||
private static CacheService? _instance;
|
||||
|
||||
private CacheService(){
|
||||
_timer.Interval = 3600 * 1000;
|
||||
_timer.Elapsed += (sender, e) => ClearExpired();
|
||||
_timer.Start();
|
||||
}
|
||||
public static CacheService Instance
|
||||
{
|
||||
get
|
||||
{
|
||||
lock (_lock)
|
||||
{
|
||||
if (_instance == null)
|
||||
{
|
||||
_instance = new CacheService();
|
||||
}
|
||||
return _instance;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void Add(string functionName, string functionParams, object value, Duration duration)
|
||||
{
|
||||
Add(functionName, functionParams, value, (int)duration);
|
||||
}
|
||||
|
||||
public void Add(string functionName, string functionParams, object value, int duration)
|
||||
{
|
||||
if (!_cache.ContainsKey(functionName))
|
||||
{
|
||||
_cache[functionName] = new Dictionary<string, CachedObject>();
|
||||
}
|
||||
|
||||
_cache[functionName][functionParams] = new CachedObject(){
|
||||
Value = value,
|
||||
Timestamp = DateTime.Now,
|
||||
Duration = duration
|
||||
};
|
||||
}
|
||||
|
||||
public object? Get(string functionName, string functionParams)
|
||||
{
|
||||
if (!_cache.ContainsKey(functionName))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
if (!_cache[functionName].ContainsKey(functionParams))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
var cachedObject = _cache[functionName][functionParams];
|
||||
if (cachedObject.IsExpired())
|
||||
{
|
||||
_cache[functionName].Remove(functionParams);
|
||||
return null;
|
||||
}
|
||||
return cachedObject.Value;
|
||||
}
|
||||
|
||||
public void Clear()
|
||||
{
|
||||
_cache.Clear();
|
||||
}
|
||||
|
||||
public void Clear(string functionName)
|
||||
{
|
||||
if (_cache.ContainsKey(functionName))
|
||||
{
|
||||
_cache.Remove(functionName);
|
||||
}
|
||||
}
|
||||
|
||||
public void Clear(string functionName, string functionParams)
|
||||
{
|
||||
if (_cache.ContainsKey(functionName))
|
||||
{
|
||||
if (_cache[functionName].ContainsKey(functionParams))
|
||||
{
|
||||
_cache[functionName].Remove(functionParams);
|
||||
if (_cache[functionName].Count == 0)
|
||||
{
|
||||
_cache.Remove(functionName);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void ClearExpired()
|
||||
{
|
||||
foreach (var functionName in _cache.Keys)
|
||||
{
|
||||
foreach (var functionParams in _cache[functionName].Keys)
|
||||
{
|
||||
if (_cache[functionName][functionParams].IsExpired())
|
||||
{
|
||||
_cache[functionName].Remove(functionParams);
|
||||
if (_cache[functionName].Count == 0)
|
||||
{
|
||||
_cache.Remove(functionName);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
using System;
|
||||
|
||||
namespace CacheModule{
|
||||
|
||||
public class CachedObject
|
||||
{
|
||||
public object? Value { get; set; }
|
||||
public DateTime Timestamp {get; set; }
|
||||
public int Duration { get; set; }
|
||||
|
||||
public bool IsExpired()
|
||||
{
|
||||
return DateTime.Now > Timestamp.AddSeconds(Duration);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
namespace CacheModule{
|
||||
public enum Duration
|
||||
{
|
||||
OneSecond = 1,
|
||||
OneMinute = 60,
|
||||
OneHour = 3600,
|
||||
OneDay = 86400,
|
||||
OneWeek = 604800,
|
||||
OneMonth = 2592000,
|
||||
OneYear = 31536000,
|
||||
FiveSeconds = 5,
|
||||
ThirtySeconds = 30,
|
||||
ThirtyMinutes = 1800,
|
||||
SixHours = 21600,
|
||||
TwelveHours = 43200,
|
||||
TwoDays = 172800,
|
||||
ThreeDays = 259200,
|
||||
TwoWeeks = 1209600,
|
||||
ThreeMonths = 7776000,
|
||||
SixMonths = 15552000
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
|
||||
<IsPackable>false</IsPackable>
|
||||
<IsTestProject>true</IsTestProject>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.6.0" />
|
||||
<PackageReference Include="xunit" Version="2.4.2" />
|
||||
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5">
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="coverlet.collector" Version="6.0.0">
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
</PackageReference>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\CacheModule\CacheModule.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
@@ -0,0 +1,134 @@
|
||||
using Xunit;
|
||||
using CacheModule;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace CacheModuleTest{
|
||||
public class CacheServiceIntegratedTest
|
||||
{
|
||||
private class MockIntegration{
|
||||
private CacheService _cacheService;
|
||||
public Dictionary<string, List<int>> keyValuePairs = new Dictionary<string, List<int>>(){
|
||||
{"first", new List<int>(){1,2,3}},
|
||||
{"second", new List<int>(){4,5,6}},
|
||||
{"third", new List<int>(){7,8,9}}
|
||||
};
|
||||
public MockIntegration(){
|
||||
_cacheService = CacheService.Instance;
|
||||
}
|
||||
|
||||
public int Get(string key, int index){
|
||||
return keyValuePairs[key][index];
|
||||
}
|
||||
public int GetSum(string key){
|
||||
return keyValuePairs[key].Sum();
|
||||
}
|
||||
|
||||
public int CachedGet(string key, int index){
|
||||
var json = JsonConvert.SerializeObject(new List<object>(){key, index}) ?? string.Empty;
|
||||
var cachedObject = _cacheService.Get(nameof(Get), json);
|
||||
if(cachedObject != null){
|
||||
return (int)cachedObject;
|
||||
}
|
||||
var result = Get(key, index);
|
||||
_cacheService.Add(nameof(Get), json, result, Duration.OneMinute);
|
||||
return result;
|
||||
}
|
||||
|
||||
public int CachedGetSum(string key){
|
||||
var json = JsonConvert.SerializeObject(new List<object>(){key}) ?? string.Empty;
|
||||
var cachedObject = _cacheService.Get(nameof(GetSum), json);
|
||||
if(cachedObject != null){
|
||||
return (int)cachedObject;
|
||||
}
|
||||
var result = GetSum(key);
|
||||
_cacheService.Add(nameof(GetSum), json, result, Duration.OneMinute);
|
||||
return result;
|
||||
}
|
||||
|
||||
public void Clear(){
|
||||
_cacheService.Clear();
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void CachedGet_WhenCalledWithinDuration_ReturnsCachedValue()
|
||||
{
|
||||
// Arrange
|
||||
var mockIntegration = new MockIntegration();
|
||||
mockIntegration.Clear();
|
||||
var key = "first";
|
||||
var index = 1;
|
||||
var expected = mockIntegration.Get(key, index);
|
||||
var cachedExpected = mockIntegration.CachedGet(key, index);
|
||||
mockIntegration.keyValuePairs[key][index] = 100;
|
||||
|
||||
// Act
|
||||
var cachedResult = mockIntegration.CachedGet(key, index);
|
||||
|
||||
// Assert
|
||||
Assert.Equal(expected, cachedResult);
|
||||
Assert.Equal(cachedExpected, cachedResult);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void CachedGet_WhenCalledAfterDuration_ReturnsNewValue()
|
||||
{
|
||||
// Arrange
|
||||
var mockIntegration = new MockIntegration();
|
||||
mockIntegration.Clear();
|
||||
var key = "first";
|
||||
var index = 1;
|
||||
var expected = mockIntegration.Get(key, index);
|
||||
var cachedExpected = mockIntegration.CachedGet(key, index);
|
||||
mockIntegration.keyValuePairs[key][index] = 100;
|
||||
|
||||
// Act
|
||||
System.Threading.Thread.Sleep(61000);
|
||||
var cachedResult = mockIntegration.CachedGet(key, index);
|
||||
|
||||
// Assert
|
||||
Assert.Equal(100, cachedResult);
|
||||
Assert.NotEqual(cachedExpected, cachedResult);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void CachedGetSum_WhenCalledWithinDuration_ReturnsCachedValue()
|
||||
{
|
||||
// Arrange
|
||||
var mockIntegration = new MockIntegration();
|
||||
mockIntegration.Clear();
|
||||
var key = "first";
|
||||
var expected = mockIntegration.GetSum(key);
|
||||
var cachedExpected = mockIntegration.CachedGetSum(key);
|
||||
mockIntegration.keyValuePairs[key] = new List<int>(){100, 100, 100};
|
||||
|
||||
// Act
|
||||
var cachedResult = mockIntegration.CachedGetSum(key);
|
||||
|
||||
// Assert
|
||||
Assert.Equal(expected, cachedResult);
|
||||
Assert.Equal(cachedExpected, cachedResult);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void CachedGetSum_WhenCalledAfterDuration_ReturnsNewValue()
|
||||
{
|
||||
// Arrange
|
||||
var mockIntegration = new MockIntegration();
|
||||
mockIntegration.Clear();
|
||||
var key = "first";
|
||||
var expected = mockIntegration.GetSum(key);
|
||||
var cachedExpected = mockIntegration.CachedGetSum(key);
|
||||
mockIntegration.keyValuePairs[key] = new List<int>(){100, 100, 100};
|
||||
|
||||
// Act
|
||||
System.Threading.Thread.Sleep(61000);
|
||||
var cachedResult = mockIntegration.CachedGetSum(key);
|
||||
|
||||
// Assert
|
||||
Assert.Equal(300, cachedResult);
|
||||
Assert.NotEqual(cachedExpected, cachedResult);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,190 @@
|
||||
using Xunit;
|
||||
using CacheModule;
|
||||
|
||||
namespace CacheModuleTest{
|
||||
public class CacheServiceUnitTest
|
||||
{
|
||||
[Fact]
|
||||
public void Instance_WhenCalled_ReturnsSameInstance()
|
||||
{
|
||||
// Arrange
|
||||
var cacheService1 = CacheService.Instance;
|
||||
var cacheService2 = CacheService.Instance;
|
||||
|
||||
// Act
|
||||
|
||||
// Assert
|
||||
Assert.Same(cacheService1, cacheService2);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Add_WhenCalledWithinDuration_AddsToCache()
|
||||
{
|
||||
// Arrange
|
||||
var cacheService = CacheService.Instance;
|
||||
cacheService.Clear();
|
||||
var functionName = "functionName";
|
||||
var functionParams = "functionParams";
|
||||
var value = new object();
|
||||
|
||||
// Act
|
||||
cacheService.Add(functionName, functionParams, value, Duration.OneMinute);
|
||||
|
||||
// Assert
|
||||
Assert.Equal(value, cacheService.Get(functionName, functionParams));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Add_WhenCalledAfterDuration_RemovesFromCache()
|
||||
{
|
||||
// Arrange
|
||||
var cacheService = CacheService.Instance;
|
||||
cacheService.Clear();
|
||||
var functionName = "functionName";
|
||||
var functionParams = "functionParams";
|
||||
var value = new object();
|
||||
|
||||
// Act
|
||||
cacheService.Add(functionName, functionParams, value, Duration.OneSecond);
|
||||
Thread.Sleep(2000);
|
||||
|
||||
// Assert
|
||||
Assert.Null(cacheService.Get(functionName, functionParams));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Add_WhenCalledWithSameFunctionNameAndFunctionParams_OverwritesCache()
|
||||
{
|
||||
// Arrange
|
||||
var cacheService = CacheService.Instance;
|
||||
cacheService.Clear();
|
||||
var functionName = "functionName";
|
||||
var functionParams = "functionParams";
|
||||
var value1 = new object();
|
||||
var value2 = new object();
|
||||
|
||||
// Act
|
||||
cacheService.Add(functionName, functionParams, value1, Duration.OneMinute);
|
||||
cacheService.Add(functionName, functionParams, value2, Duration.OneMinute);
|
||||
|
||||
// Assert
|
||||
Assert.Equal(value2, cacheService.Get(functionName, functionParams));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Get_WhenCalledWithNonExistingFunctionName_ReturnsNull()
|
||||
{
|
||||
// Arrange
|
||||
var cacheService = CacheService.Instance;
|
||||
cacheService.Clear();
|
||||
var functionName = "functionName";
|
||||
var functionParams = "functionParams";
|
||||
|
||||
// Act
|
||||
|
||||
// Assert
|
||||
Assert.Null(cacheService.Get(functionName, functionParams));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Get_WhenCalledWithNonExistingFunctionParams_ReturnsNull()
|
||||
{
|
||||
// Arrange
|
||||
var cacheService = CacheService.Instance;
|
||||
cacheService.Clear();
|
||||
var functionName = "functionName";
|
||||
var functionParams = "functionParams";
|
||||
var value = new object();
|
||||
|
||||
// Act
|
||||
cacheService.Add(functionName, functionParams, value, Duration.OneMinute);
|
||||
|
||||
// Assert
|
||||
Assert.Null(cacheService.Get(functionName, "nonExistingFunctionParams"));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Clear_WhenCalledWithParams_ClearsCache()
|
||||
{
|
||||
// Arrange
|
||||
var cacheService = CacheService.Instance;
|
||||
var functionName = "functionName";
|
||||
var functionParams = "functionParams";
|
||||
var value = new object();
|
||||
cacheService.Add(functionName, functionParams, value, Duration.OneMinute);
|
||||
|
||||
// Act
|
||||
cacheService.Clear();
|
||||
|
||||
// Assert
|
||||
Assert.Null(cacheService.Get(functionName, functionParams));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Clear_WhenCalledWithFunctionName_ClearsCache()
|
||||
{
|
||||
// Arrange
|
||||
var cacheService = CacheService.Instance;
|
||||
var functionName = "functionName";
|
||||
var functionParams = "functionParams";
|
||||
var functionName2 = "functionName2";
|
||||
var functionParams2 = "functionParams2";
|
||||
var value = new object();
|
||||
var value2 = new object();
|
||||
cacheService.Add(functionName, functionParams, value, Duration.OneMinute);
|
||||
cacheService.Add(functionName2, functionParams2, value2, Duration.OneMinute);
|
||||
|
||||
// Act
|
||||
cacheService.Clear(functionName);
|
||||
|
||||
// Assert
|
||||
Assert.Null(cacheService.Get(functionName, functionParams));
|
||||
Assert.Equal(value2, cacheService.Get(functionName2, functionParams2));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Clear_WhenCalledWithFunctionNameAndFunctionParams_ClearsCache()
|
||||
{
|
||||
// Arrange
|
||||
var cacheService = CacheService.Instance;
|
||||
var functionName = "functionName";
|
||||
var functionParams = "functionParams";
|
||||
var functionParams2 = "functionParams2";
|
||||
var value = new object();
|
||||
var value2 = new object();
|
||||
cacheService.Add(functionName, functionParams, value, Duration.OneMinute);
|
||||
cacheService.Add(functionName, functionParams2, value2, Duration.OneMinute);
|
||||
|
||||
// Act
|
||||
cacheService.Clear(functionName, functionParams);
|
||||
|
||||
// Assert
|
||||
Assert.Null(cacheService.Get(functionName, functionParams));
|
||||
Assert.Equal(value2, cacheService.Get(functionName, functionParams2));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ClearExpired_WhenCalled_ClearsExpiredCache()
|
||||
{
|
||||
// Arrange
|
||||
var cacheService = CacheService.Instance;
|
||||
var functionName = "functionName";
|
||||
var functionParams = "functionParams";
|
||||
var functionName2 = "functionName2";
|
||||
var functionParams2 = "functionParams2";
|
||||
var value = new object();
|
||||
cacheService.Add(functionName, functionParams, value, Duration.OneSecond);
|
||||
cacheService.Add(functionName2, functionParams2, value, Duration.OneMinute);
|
||||
Thread.Sleep(2000);
|
||||
|
||||
// Act
|
||||
cacheService.ClearExpired();
|
||||
|
||||
// Assert
|
||||
Assert.Null(cacheService.Get(functionName, functionParams));
|
||||
Assert.Equal(value, cacheService.Get(functionName2, functionParams2));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 17
|
||||
VisualStudioVersion = 17.0.31903.59
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CacheModule", "CacheModule\CacheModule.csproj", "{523A7A27-26EE-4F61-B316-8116D19CBC7E}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CacheModuleTest", "CacheModuleTest\CacheModuleTest.csproj", "{B2120B94-F9E9-437C-A4D2-EC1643434A21}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{523A7A27-26EE-4F61-B316-8116D19CBC7E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{523A7A27-26EE-4F61-B316-8116D19CBC7E}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{523A7A27-26EE-4F61-B316-8116D19CBC7E}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{523A7A27-26EE-4F61-B316-8116D19CBC7E}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{B2120B94-F9E9-437C-A4D2-EC1643434A21}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{B2120B94-F9E9-437C-A4D2-EC1643434A21}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{B2120B94-F9E9-437C-A4D2-EC1643434A21}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{B2120B94-F9E9-437C-A4D2-EC1643434A21}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
File diff suppressed because it is too large
Load Diff
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
After Width: | Height: | Size: 710 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 160 KiB |
@@ -0,0 +1,377 @@
|
||||
## Ignore Visual Studio temporary files, build results, and
|
||||
## files generated by popular Visual Studio add-ons.
|
||||
##
|
||||
## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
|
||||
.nuspec/
|
||||
.buildtasks/
|
||||
templatesTest/
|
||||
|
||||
# User-specific files
|
||||
*.rsuser
|
||||
*.suo
|
||||
*.user
|
||||
*.userosscache
|
||||
*.sln.docstates
|
||||
|
||||
# User-specific files (MonoDevelop/Xamarin Studio)
|
||||
*.userprefs
|
||||
|
||||
# Mono auto generated files
|
||||
mono_crash.*
|
||||
|
||||
# Build results
|
||||
[Dd]ebug/
|
||||
[Dd]ebugPublic/
|
||||
[Rr]elease/
|
||||
[Rr]eleases/
|
||||
x64/
|
||||
x86/
|
||||
[Ww][Ii][Nn]32/
|
||||
[Aa][Rr][Mm]/
|
||||
[Aa][Rr][Mm]64/
|
||||
bld/
|
||||
[Bb]in/
|
||||
[Oo]bj/
|
||||
[Ll]og/
|
||||
[Ll]ogs/
|
||||
|
||||
# Visual Studio 2015/2017 cache/options directory
|
||||
.vs/
|
||||
# Uncomment if you have tasks that create the project's static files in wwwroot
|
||||
#wwwroot/
|
||||
|
||||
# Visual Studio 2017 auto generated files
|
||||
Generated\ Files/
|
||||
|
||||
# MSTest test Results
|
||||
[Tt]est[Rr]esult*/
|
||||
[Bb]uild[Ll]og.*
|
||||
|
||||
# NUnit
|
||||
*.VisualState.xml
|
||||
TestResult.xml
|
||||
nunit-*.xml
|
||||
|
||||
# Build Results of an ATL Project
|
||||
[Dd]ebugPS/
|
||||
[Rr]eleasePS/
|
||||
dlldata.c
|
||||
|
||||
# Benchmark Results
|
||||
BenchmarkDotNet.Artifacts/
|
||||
|
||||
# .NET Core
|
||||
project.lock.json
|
||||
project.fragment.lock.json
|
||||
artifacts/
|
||||
|
||||
# ASP.NET Scaffolding
|
||||
ScaffoldingReadMe.txt
|
||||
|
||||
# StyleCop
|
||||
StyleCopReport.xml
|
||||
|
||||
# Files built by Visual Studio
|
||||
*_i.c
|
||||
*_p.c
|
||||
*_h.h
|
||||
*.ilk
|
||||
*.meta
|
||||
*.obj
|
||||
*.iobj
|
||||
*.pch
|
||||
*.pdb
|
||||
*.ipdb
|
||||
*.pgc
|
||||
*.pgd
|
||||
*.rsp
|
||||
*.sbr
|
||||
*.tlb
|
||||
*.tli
|
||||
*.tlh
|
||||
*.tmp
|
||||
*.tmp_proj
|
||||
*_wpftmp.csproj
|
||||
*.log
|
||||
*.vspscc
|
||||
*.vssscc
|
||||
.builds
|
||||
*.pidb
|
||||
*.svclog
|
||||
*.scc
|
||||
|
||||
# Chutzpah Test files
|
||||
_Chutzpah*
|
||||
|
||||
# Visual C++ cache files
|
||||
ipch/
|
||||
*.aps
|
||||
*.ncb
|
||||
*.opendb
|
||||
*.opensdf
|
||||
*.sdf
|
||||
*.cachefile
|
||||
*.VC.db
|
||||
*.VC.VC.opendb
|
||||
|
||||
# Visual Studio profiler
|
||||
*.psess
|
||||
*.vsp
|
||||
*.vspx
|
||||
*.sap
|
||||
|
||||
# Visual Studio Trace Files
|
||||
*.e2e
|
||||
|
||||
# TFS 2012 Local Workspace
|
||||
$tf/
|
||||
|
||||
# Guidance Automation Toolkit
|
||||
*.gpState
|
||||
|
||||
# ReSharper is a .NET coding add-in
|
||||
_ReSharper*/
|
||||
*.[Rr]e[Ss]harper
|
||||
*.DotSettings.user
|
||||
|
||||
# TeamCity is a build add-in
|
||||
_TeamCity*
|
||||
|
||||
# DotCover is a Code Coverage Tool
|
||||
*.dotCover
|
||||
|
||||
# AxoCover is a Code Coverage Tool
|
||||
.axoCover/*
|
||||
!.axoCover/settings.json
|
||||
|
||||
# Coverlet is a free, cross platform Code Coverage Tool
|
||||
coverage*.json
|
||||
coverage*.xml
|
||||
coverage*.info
|
||||
|
||||
# Visual Studio code coverage results
|
||||
*.coverage
|
||||
*.coveragexml
|
||||
|
||||
# NCrunch
|
||||
_NCrunch_*
|
||||
.*crunch*.local.xml
|
||||
nCrunchTemp_*
|
||||
|
||||
# MightyMoose
|
||||
*.mm.*
|
||||
AutoTest.Net/
|
||||
|
||||
# Web workbench (sass)
|
||||
.sass-cache/
|
||||
|
||||
# Installshield output folder
|
||||
[Ee]xpress/
|
||||
|
||||
# DocProject is a documentation generator add-in
|
||||
DocProject/buildhelp/
|
||||
DocProject/Help/*.HxT
|
||||
DocProject/Help/*.HxC
|
||||
DocProject/Help/*.hhc
|
||||
DocProject/Help/*.hhk
|
||||
DocProject/Help/*.hhp
|
||||
DocProject/Help/Html2
|
||||
DocProject/Help/html
|
||||
|
||||
# Click-Once directory
|
||||
publish/
|
||||
|
||||
# Publish Web Output
|
||||
*.[Pp]ublish.xml
|
||||
*.azurePubxml
|
||||
# Note: Comment the next line if you want to checkin your web deploy settings,
|
||||
# but database connection strings (with potential passwords) will be unencrypted
|
||||
*.pubxml
|
||||
*.publishproj
|
||||
|
||||
# Microsoft Azure Web App publish settings. Comment the next line if you want to
|
||||
# checkin your Azure Web App publish settings, but sensitive information contained
|
||||
# in these scripts will be unencrypted
|
||||
PublishScripts/
|
||||
|
||||
# NuGet Packages
|
||||
*.nupkg
|
||||
# NuGet Symbol Packages
|
||||
*.snupkg
|
||||
# The packages folder can be ignored because of Package Restore
|
||||
**/[Pp]ackages/*
|
||||
# except build/, which is used as an MSBuild target.
|
||||
!**/[Pp]ackages/build/
|
||||
# Uncomment if necessary however generally it will be regenerated when needed
|
||||
#!**/[Pp]ackages/repositories.config
|
||||
# NuGet v3's project.json files produces more ignorable files
|
||||
*.nuget.props
|
||||
*.nuget.targets
|
||||
|
||||
# Microsoft Azure Build Output
|
||||
csx/
|
||||
*.build.csdef
|
||||
|
||||
# Microsoft Azure Emulator
|
||||
ecf/
|
||||
rcf/
|
||||
|
||||
# Windows Store app package directories and files
|
||||
AppPackages/
|
||||
BundleArtifacts/
|
||||
Package.StoreAssociation.xml
|
||||
_pkginfo.txt
|
||||
*.appx
|
||||
*.appxbundle
|
||||
*.appxupload
|
||||
|
||||
# Visual Studio cache files
|
||||
# files ending in .cache can be ignored
|
||||
*.[Cc]ache
|
||||
# but keep track of directories ending in .cache
|
||||
!?*.[Cc]ache/
|
||||
|
||||
# Others
|
||||
ClientBin/
|
||||
~$*
|
||||
*~
|
||||
*.dbmdl
|
||||
*.dbproj.schemaview
|
||||
*.jfm
|
||||
*.pfx
|
||||
*.publishsettings
|
||||
orleans.codegen.cs
|
||||
|
||||
# Including strong name files can present a security risk
|
||||
# (https://github.com/github/gitignore/pull/2483#issue-259490424)
|
||||
#*.snk
|
||||
|
||||
# Since there are multiple workflows, uncomment next line to ignore bower_components
|
||||
# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
|
||||
#bower_components/
|
||||
|
||||
# RIA/Silverlight projects
|
||||
Generated_Code/
|
||||
|
||||
# Backup & report files from converting an old project file
|
||||
# to a newer Visual Studio version. Backup files are not needed,
|
||||
# because we have git ;-)
|
||||
_UpgradeReport_Files/
|
||||
Backup*/
|
||||
UpgradeLog*.XML
|
||||
UpgradeLog*.htm
|
||||
ServiceFabricBackup/
|
||||
*.rptproj.bak
|
||||
|
||||
# SQL Server files
|
||||
*.mdf
|
||||
*.ldf
|
||||
*.ndf
|
||||
|
||||
# Business Intelligence projects
|
||||
*.rdl.data
|
||||
*.bim.layout
|
||||
*.bim_*.settings
|
||||
*.rptproj.rsuser
|
||||
*- [Bb]ackup.rdl
|
||||
*- [Bb]ackup ([0-9]).rdl
|
||||
*- [Bb]ackup ([0-9][0-9]).rdl
|
||||
|
||||
# Microsoft Fakes
|
||||
FakesAssemblies/
|
||||
|
||||
# GhostDoc plugin setting file
|
||||
*.GhostDoc.xml
|
||||
|
||||
# Node.js Tools for Visual Studio
|
||||
.ntvs_analysis.dat
|
||||
node_modules/
|
||||
|
||||
# Visual Studio 6 build log
|
||||
*.plg
|
||||
|
||||
# Visual Studio 6 workspace options file
|
||||
*.opt
|
||||
|
||||
# Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
|
||||
*.vbw
|
||||
|
||||
# Visual Studio LightSwitch build output
|
||||
**/*.HTMLClient/GeneratedArtifacts
|
||||
**/*.DesktopClient/GeneratedArtifacts
|
||||
**/*.DesktopClient/ModelManifest.xml
|
||||
**/*.Server/GeneratedArtifacts
|
||||
**/*.Server/ModelManifest.xml
|
||||
_Pvt_Extensions
|
||||
|
||||
# Paket dependency manager
|
||||
.paket/paket.exe
|
||||
paket-files/
|
||||
|
||||
# FAKE - F# Make
|
||||
.fake/
|
||||
|
||||
# CodeRush personal settings
|
||||
.cr/personal
|
||||
|
||||
# Python Tools for Visual Studio (PTVS)
|
||||
__pycache__/
|
||||
*.pyc
|
||||
|
||||
# Cake - Uncomment if you are using it
|
||||
tools/**
|
||||
!tools/packages.config
|
||||
|
||||
# Tabs Studio
|
||||
*.tss
|
||||
|
||||
# Telerik's JustMock configuration file
|
||||
*.jmconfig
|
||||
|
||||
# BizTalk build output
|
||||
*.btp.cs
|
||||
*.btm.cs
|
||||
*.odx.cs
|
||||
*.xsd.cs
|
||||
|
||||
# OpenCover UI analysis results
|
||||
OpenCover/
|
||||
|
||||
# Azure Stream Analytics local run output
|
||||
ASALocalRun/
|
||||
|
||||
# MSBuild Binary and Structured Log
|
||||
*.binlog
|
||||
|
||||
# NVidia Nsight GPU debugger configuration file
|
||||
*.nvuser
|
||||
|
||||
# MFractors (Xamarin productivity tool) working folder
|
||||
.mfractor/
|
||||
|
||||
# Local History for Visual Studio
|
||||
.localhistory/
|
||||
|
||||
# BeatPulse healthcheck temp database
|
||||
healthchecksdb
|
||||
|
||||
# Backup folder for Package Reference Convert tool in Visual Studio 2017
|
||||
MigrationBackup/
|
||||
|
||||
# Ionide (cross platform F# VS Code tools) working folder
|
||||
.ionide/
|
||||
|
||||
# Fody - auto-generated XML schema
|
||||
FodyWeavers.xsd
|
||||
.DS_Store
|
||||
|
||||
# Android Studio
|
||||
.gradle/
|
||||
.idea/
|
||||
local.properties
|
||||
|
||||
# Directory Build overrides for local setups
|
||||
Directory.Build.Override.props
|
||||
|
||||
# Only the "snapshots" directory should be added to Git, not the "snapshots-diff" directory
|
||||
snapshots-diff/
|
||||
@@ -0,0 +1,31 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 17
|
||||
VisualStudioVersion = 17.9.34723.18
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TechTitans", "TechTitans\TechTitans.csproj", "{29F15AA2-793A-43C6-B33B-D32F76EE30DC}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Android Emulator|Any CPU = Android Emulator|Any CPU
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{29F15AA2-793A-43C6-B33B-D32F76EE30DC}.Android Emulator|Any CPU.ActiveCfg = Android Emulator|Any CPU
|
||||
{29F15AA2-793A-43C6-B33B-D32F76EE30DC}.Android Emulator|Any CPU.Build.0 = Android Emulator|Any CPU
|
||||
{29F15AA2-793A-43C6-B33B-D32F76EE30DC}.Android Emulator|Any CPU.Deploy.0 = Android Emulator|Any CPU
|
||||
{29F15AA2-793A-43C6-B33B-D32F76EE30DC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{29F15AA2-793A-43C6-B33B-D32F76EE30DC}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{29F15AA2-793A-43C6-B33B-D32F76EE30DC}.Debug|Any CPU.Deploy.0 = Debug|Any CPU
|
||||
{29F15AA2-793A-43C6-B33B-D32F76EE30DC}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{29F15AA2-793A-43C6-B33B-D32F76EE30DC}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{29F15AA2-793A-43C6-B33B-D32F76EE30DC}.Release|Any CPU.Deploy.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {C9BAC62F-2D93-42E0-9570-F6FC08EBCAB7}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
@@ -0,0 +1,14 @@
|
||||
<?xml version = "1.0" encoding = "UTF-8" ?>
|
||||
<Application xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
|
||||
xmlns:local="clr-namespace:TechTitans"
|
||||
x:Class="TechTitans.App">
|
||||
<Application.Resources>
|
||||
<ResourceDictionary>
|
||||
<ResourceDictionary.MergedDictionaries>
|
||||
<ResourceDictionary Source="Resources/Styles/Colors.xaml" />
|
||||
<ResourceDictionary Source="Resources/Styles/Styles.xaml" />
|
||||
</ResourceDictionary.MergedDictionaries>
|
||||
</ResourceDictionary>
|
||||
</Application.Resources>
|
||||
</Application>
|
||||
@@ -0,0 +1,12 @@
|
||||
namespace TechTitans
|
||||
{
|
||||
public partial class App : Application
|
||||
{
|
||||
public App()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
MainPage = new AppShell();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<Shell
|
||||
x:Class="TechTitans.AppShell"
|
||||
xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
|
||||
xmlns:local="clr-namespace:TechTitans"
|
||||
Shell.FlyoutBehavior="Disabled"
|
||||
Title="TechTitans">
|
||||
|
||||
<ShellContent
|
||||
Title="Home"
|
||||
ContentTemplate="{DataTemplate local:Views.MainPage}"
|
||||
Route="MainPage" />
|
||||
|
||||
</Shell>
|
||||
@@ -0,0 +1,10 @@
|
||||
namespace TechTitans
|
||||
{
|
||||
public partial class AppShell : Shell
|
||||
{
|
||||
public AppShell()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
namespace TechTitans.Enums
|
||||
{
|
||||
/// <summary>
|
||||
/// 1. Has listened to a lot of songs
|
||||
/// 2. Has listened to a lot of new genres
|
||||
/// 3. Has not listened to very few songs
|
||||
/// 4. None of the above
|
||||
/// </summary>
|
||||
public enum ListenerPersonality
|
||||
{
|
||||
Melophile,
|
||||
Explorer,
|
||||
Casual,
|
||||
Vanilla,
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
namespace TechTitans.Enums
|
||||
{
|
||||
public enum PlaybackEventType
|
||||
{
|
||||
like = 1,
|
||||
start_play = 2,
|
||||
end_play = 3,
|
||||
dislike = 4,
|
||||
skip = 5
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using TechTitans.Repositories;
|
||||
using System.Reflection;
|
||||
using CommunityToolkit.Maui;
|
||||
|
||||
namespace TechTitans
|
||||
{
|
||||
public static class MauiProgram
|
||||
{
|
||||
public static IConfiguration Configuration { get; private set; }
|
||||
public static MauiApp CreateMauiApp()
|
||||
{
|
||||
var builder = MauiApp.CreateBuilder();
|
||||
builder.Services.AddScoped(typeof(IRepository<>), typeof(Repository<>));
|
||||
builder
|
||||
.UseMauiApp<App>()
|
||||
.UseMauiCommunityToolkit()
|
||||
.ConfigureFonts(fonts =>
|
||||
{
|
||||
fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular");
|
||||
fonts.AddFont("OpenSans-Semibold.ttf", "OpenSansSemibold");
|
||||
});
|
||||
|
||||
#if DEBUG
|
||||
builder.Logging.AddDebug();
|
||||
#endif
|
||||
using var stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("TechTitans.appsettings.json");
|
||||
builder.Configuration.AddJsonStream(stream).Build();
|
||||
var app = builder.Build();
|
||||
Configuration = app.Services.GetService<IConfiguration>();
|
||||
return app;
|
||||
}
|
||||
}
|
||||
}
|
||||
+34
@@ -0,0 +1,34 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace TechTitans.Models
|
||||
{
|
||||
[Table("AdDistributionData")]
|
||||
public class AdDistributionData
|
||||
{
|
||||
[Key]
|
||||
[Column("song_id")]
|
||||
public int Song_Id { get; set; }
|
||||
|
||||
[Key]
|
||||
[Column("ad_campaign")]
|
||||
public int Ad_Campaign { get; set; }
|
||||
|
||||
[Column("genre")]
|
||||
public string Genre { get; set; }
|
||||
|
||||
[Column("language")]
|
||||
public string Language { get; set; }
|
||||
|
||||
[Column("month")]
|
||||
public int Month { get; set; }
|
||||
|
||||
[Column("year")]
|
||||
public int Year { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace TechTitans.Models
|
||||
{
|
||||
[Table("AuthorDetails")]
|
||||
public class AuthorDetails
|
||||
{
|
||||
[Key]
|
||||
[Column("artist_id")]
|
||||
public int Artist_Id { get; set; } = 0;
|
||||
|
||||
[Column("name")]
|
||||
public string Name { get; set; } = "DefaultName";
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user