Test
parent
2470faad75
commit
fda7ac88ee
|
|
@ -1,5 +1,5 @@
|
|||
{
|
||||
"DatabseConnection": {
|
||||
"ConnectionString" : "server=192.168.200.13;userid=student;password=student;database=localhost"
|
||||
"ConnectionString" : "server=localhost;userid=root;password=root;database=bathhousemanagment"
|
||||
}
|
||||
}
|
||||
|
|
@ -8,12 +8,12 @@
|
|||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Folder Include="Models\"/>
|
||||
<AvaloniaResource Include="Assets\**"/>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Avalonia" Version="11.3.10"/>
|
||||
<PackageReference Include="Avalonia.Controls.DataGrid" Version="11.3.10" />
|
||||
<PackageReference Include="Avalonia.Desktop" Version="11.3.10"/>
|
||||
<PackageReference Include="Avalonia.Themes.Fluent" Version="11.3.10"/>
|
||||
<PackageReference Include="Avalonia.Fonts.Inter" Version="11.3.10"/>
|
||||
|
|
|
|||
|
|
@ -0,0 +1,48 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using BathHouseManagmet.Models;
|
||||
using Microsoft.Extensions.Options;
|
||||
using MySqlConnector;
|
||||
|
||||
namespace BathHouseManagmet.Database;
|
||||
|
||||
public class ClientRepository
|
||||
{
|
||||
MySqlConnection connection;
|
||||
|
||||
public ClientRepository(IOptions<DatabaseConnection> connect)
|
||||
{
|
||||
connection = new MySqlConnection(connect.Value.ConnectionString);
|
||||
}
|
||||
|
||||
public List<Client> GetClients()
|
||||
{
|
||||
List<Client> result = new();
|
||||
string sql = "select * from `client`";
|
||||
try
|
||||
{
|
||||
connection.Open();
|
||||
using(var command = new MySqlCommand(sql, connection))
|
||||
using (var reader = command.ExecuteReader())
|
||||
{
|
||||
while (reader.Read())
|
||||
{
|
||||
result.Add(new Client
|
||||
{
|
||||
Id = reader.GetInt32("id"),
|
||||
Name = reader.GetString("name"),
|
||||
Surname = reader.GetString("surname"),
|
||||
});
|
||||
}
|
||||
}
|
||||
connection.Close();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Console.WriteLine(e);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -1,6 +1,120 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using BathHouseManagmet.Models;
|
||||
using Microsoft.Extensions.Options;
|
||||
using MySqlConnector;
|
||||
|
||||
namespace BathHouseManagmet.Database;
|
||||
|
||||
public class employee
|
||||
public class EmployeeRepository
|
||||
{
|
||||
|
||||
MySqlConnection connection;
|
||||
|
||||
public EmployeeRepository(IOptions<DatabaseConnection> connect)
|
||||
{
|
||||
connection = new MySqlConnection(connect.Value.ConnectionString);
|
||||
}
|
||||
|
||||
public List<Employee> GetEmployees(Position position)
|
||||
{
|
||||
List<Employee> result = new();
|
||||
string sql = "select * from `employee` where position_id = " + position.Id;
|
||||
try
|
||||
{
|
||||
connection.Open();
|
||||
using (var command = new MySqlCommand(sql, connection))
|
||||
using (var reader = command.ExecuteReader())
|
||||
{
|
||||
while (reader.Read())
|
||||
{
|
||||
result.Add(new Employee
|
||||
{
|
||||
Id = reader.GetInt32("id"),
|
||||
Name = reader.GetString("name"),
|
||||
Surname = reader.GetString("surname"),
|
||||
OnWork = reader.GetBoolean("on_work"),
|
||||
PositionId = reader.GetInt32("position_id"),
|
||||
});
|
||||
}
|
||||
}
|
||||
connection.Close();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Console.WriteLine(e);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public bool InsertEmployee(Employee employee)
|
||||
{
|
||||
string sql =
|
||||
"insert into `employee` (`id`, `name`, `surname`, `on_work`, `position_id`) values (0, @name, @surname, @on_work, @position_id)";
|
||||
try
|
||||
{
|
||||
connection.Open();
|
||||
using (var command = new MySqlCommand(sql, connection))
|
||||
{
|
||||
command.Parameters.AddWithValue("@name", employee.Name);
|
||||
command.Parameters.AddWithValue("@surname", employee.Surname);
|
||||
command.Parameters.AddWithValue("@on_work", employee.OnWork);
|
||||
command.Parameters.AddWithValue("@position_id", employee.PositionId);
|
||||
command.ExecuteNonQuery();
|
||||
}
|
||||
connection.Close();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
connection.Close();
|
||||
return false;
|
||||
}
|
||||
connection.Close();
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool UpdateEmployee(Employee employee)
|
||||
{
|
||||
string sql = "update `employee` set name = @name, surname = @surname, on_work = @on_work, position_id = @position_id";
|
||||
try
|
||||
{
|
||||
connection.Open();
|
||||
using (var command = new MySqlCommand(sql, connection))
|
||||
{
|
||||
command.Parameters.AddWithValue("@name", employee.Name);
|
||||
command.Parameters.AddWithValue("@surname", employee.Surname);
|
||||
command.Parameters.AddWithValue("@on_work", employee.OnWork);
|
||||
command.Parameters.AddWithValue("@position_id", employee.PositionId);
|
||||
command.ExecuteNonQuery();
|
||||
}
|
||||
connection.Close();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
connection.Close();
|
||||
return false;
|
||||
}
|
||||
connection.Close();
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool DeleteEmployee(Employee employee)
|
||||
{
|
||||
string sql = "delete from `employee` where `id` = " + employee.Id;
|
||||
try
|
||||
{
|
||||
connection.Open();
|
||||
using (var command = new MySqlCommand(sql, connection))
|
||||
{
|
||||
command.ExecuteNonQuery();
|
||||
}
|
||||
connection.Close();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
connection.Close();
|
||||
return false;
|
||||
}
|
||||
connection.Close();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
@ -2,5 +2,7 @@ namespace BathHouseManagmet.Models;
|
|||
|
||||
public class Client
|
||||
{
|
||||
|
||||
public int Id { get; set; }
|
||||
public string Name { get; set; }
|
||||
public string Surname { get; set; }
|
||||
}
|
||||
|
|
@ -2,5 +2,8 @@ namespace BathHouseManagmet.Models;
|
|||
|
||||
public class Discount
|
||||
{
|
||||
|
||||
public int Id { get; set; }
|
||||
public string Name { get; set; }
|
||||
public string Description { get; set; }
|
||||
public int DescountPercent { get; set; }
|
||||
}
|
||||
|
|
@ -2,5 +2,9 @@ namespace BathHouseManagmet.Models;
|
|||
|
||||
public class Employee
|
||||
{
|
||||
|
||||
public int Id { get; set; }
|
||||
public string Name { get; set; }
|
||||
public string Surname { get; set; }
|
||||
public bool OnWork { get; set; }
|
||||
public int PositionId { get; set; }
|
||||
}
|
||||
|
|
@ -1,6 +1,15 @@
|
|||
using System;
|
||||
|
||||
namespace BathHouseManagmet.Models;
|
||||
|
||||
public class Order
|
||||
{
|
||||
|
||||
public int Id { get; set; }
|
||||
public int ClientId { get; set; }
|
||||
public int ZoneId { get; set; }
|
||||
public DateTime OrderDate { get; set; }
|
||||
public int WorkPrice { get; set; }
|
||||
public int EmployeeId { get; set; }
|
||||
public int DiscountId { get; set; }
|
||||
public int FinalPrice { get; set; }
|
||||
}
|
||||
|
|
@ -2,5 +2,6 @@ namespace BathHouseManagmet.Models;
|
|||
|
||||
public class Position
|
||||
{
|
||||
|
||||
public int Id { get; set; }
|
||||
public string Name { get; set; }
|
||||
}
|
||||
|
|
@ -2,5 +2,6 @@ namespace BathHouseManagmet.Models;
|
|||
|
||||
public class Zone
|
||||
{
|
||||
|
||||
public int Id { get; set; }
|
||||
public string Name { get; set; }
|
||||
}
|
||||
|
|
@ -2,5 +2,5 @@
|
|||
|
||||
public partial class MainWindowViewModel : ViewModelBase
|
||||
{
|
||||
public string Greeting { get; } = "Welcome to Avalonia!";
|
||||
|
||||
}
|
||||
|
|
@ -7,13 +7,6 @@
|
|||
x:Class="BathHouseManagmet.Views.MainWindow"
|
||||
x:DataType="vm:MainWindowViewModel"
|
||||
Icon="/Assets/avalonia-logo.ico"
|
||||
Title="BathHouseManagmet">
|
||||
|
||||
<Design.DataContext>
|
||||
<!-- This only sets the DataContext for the previewer in an IDE,
|
||||
to set the actual DataContext for runtime, set the DataContext property in code (look at App.axaml.cs) -->
|
||||
<vm:MainWindowViewModel/>
|
||||
</Design.DataContext>
|
||||
|
||||
|
||||
Title="BathHouseManagment">
|
||||
|
||||
</Window>
|
||||
|
|
|
|||
|
|
@ -50,6 +50,10 @@
|
|||
"target": "Package",
|
||||
"version": "[11.3.10, )"
|
||||
},
|
||||
"Avalonia.Controls.DataGrid": {
|
||||
"target": "Package",
|
||||
"version": "[11.3.10, )"
|
||||
},
|
||||
"Avalonia.Desktop": {
|
||||
"target": "Package",
|
||||
"version": "[11.3.10, )"
|
||||
|
|
|
|||
Binary file not shown.
|
|
@ -13,7 +13,7 @@ using System.Reflection;
|
|||
[assembly: System.Reflection.AssemblyCompanyAttribute("BathHouseManagmet")]
|
||||
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
|
||||
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
|
||||
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0")]
|
||||
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+9c2351b863396c43a39f9449f08dc29f85df9763")]
|
||||
[assembly: System.Reflection.AssemblyProductAttribute("BathHouseManagmet")]
|
||||
[assembly: System.Reflection.AssemblyTitleAttribute("BathHouseManagmet")]
|
||||
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
17822dc97d6951100cace6bedba90a41c6699f5f35c4dab0ea6de5260ae3b301
|
||||
4757971917ac4d5bc9219094abbbd12816220e52e18e259e295afe360fad1005
|
||||
|
|
|
|||
Binary file not shown.
Binary file not shown.
|
|
@ -124,6 +124,22 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
"Avalonia.Controls.DataGrid/11.3.10": {
|
||||
"type": "package",
|
||||
"dependencies": {
|
||||
"Avalonia": "11.3.10"
|
||||
},
|
||||
"compile": {
|
||||
"lib/net8.0/Avalonia.Controls.DataGrid.dll": {
|
||||
"related": ".xml"
|
||||
}
|
||||
},
|
||||
"runtime": {
|
||||
"lib/net8.0/Avalonia.Controls.DataGrid.dll": {
|
||||
"related": ".xml"
|
||||
}
|
||||
}
|
||||
},
|
||||
"Avalonia.Desktop/11.3.10": {
|
||||
"type": "package",
|
||||
"dependencies": {
|
||||
|
|
@ -1505,6 +1521,25 @@
|
|||
"lib/netstandard2.0/Avalonia.Controls.ColorPicker.xml"
|
||||
]
|
||||
},
|
||||
"Avalonia.Controls.DataGrid/11.3.10": {
|
||||
"sha512": "KSwme0XOL8594fFvoQ37s5rnSo9vCKutCpufCEmd0R7x/fRWOjK3g3su1Z3nukgbobryPVjQvZxi/E92DPPYpw==",
|
||||
"type": "package",
|
||||
"path": "avalonia.controls.datagrid/11.3.10",
|
||||
"files": [
|
||||
".nupkg.metadata",
|
||||
".signature.p7s",
|
||||
"Icon.png",
|
||||
"avalonia.controls.datagrid.11.3.10.nupkg.sha512",
|
||||
"avalonia.controls.datagrid.nuspec",
|
||||
"lib/net6.0/Avalonia.Controls.DataGrid.dll",
|
||||
"lib/net6.0/Avalonia.Controls.DataGrid.xml",
|
||||
"lib/net8.0/Avalonia.Controls.DataGrid.dll",
|
||||
"lib/net8.0/Avalonia.Controls.DataGrid.xml",
|
||||
"lib/netstandard2.0/Avalonia.Controls.DataGrid.dll",
|
||||
"lib/netstandard2.0/Avalonia.Controls.DataGrid.xml",
|
||||
"readme.md"
|
||||
]
|
||||
},
|
||||
"Avalonia.Desktop/11.3.10": {
|
||||
"sha512": "Enb/6GTCO3+GlSxyhyxYuMjiyBT1EGdFkOLdAPKXYTxgCcnWvqdC6lwBslD0y18P8B8pOnlYryTEmBRsBSvHjQ==",
|
||||
"type": "package",
|
||||
|
|
@ -3140,6 +3175,7 @@
|
|||
"projectFileDependencyGroups": {
|
||||
"net10.0": [
|
||||
"Avalonia >= 11.3.10",
|
||||
"Avalonia.Controls.DataGrid >= 11.3.10",
|
||||
"Avalonia.Desktop >= 11.3.10",
|
||||
"Avalonia.Diagnostics >= 11.3.10",
|
||||
"Avalonia.Fonts.Inter >= 11.3.10",
|
||||
|
|
@ -3198,6 +3234,10 @@
|
|||
"target": "Package",
|
||||
"version": "[11.3.10, )"
|
||||
},
|
||||
"Avalonia.Controls.DataGrid": {
|
||||
"target": "Package",
|
||||
"version": "[11.3.10, )"
|
||||
},
|
||||
"Avalonia.Desktop": {
|
||||
"target": "Package",
|
||||
"version": "[11.3.10, )"
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"version": 2,
|
||||
"dgSpecHash": "q5oPTWmJay4=",
|
||||
"dgSpecHash": "WewDm+VE+hc=",
|
||||
"success": true,
|
||||
"projectFilePath": "C:\\Users\\Mikhail\\RiderProjects\\BathHouseManagmet\\BathHouseManagmet.csproj",
|
||||
"expectedPackageFiles": [
|
||||
|
|
@ -8,6 +8,7 @@
|
|||
"C:\\Users\\Mikhail\\.nuget\\packages\\avalonia.angle.windows.natives\\2.1.25547.20250602\\avalonia.angle.windows.natives.2.1.25547.20250602.nupkg.sha512",
|
||||
"C:\\Users\\Mikhail\\.nuget\\packages\\avalonia.buildservices\\11.3.2\\avalonia.buildservices.11.3.2.nupkg.sha512",
|
||||
"C:\\Users\\Mikhail\\.nuget\\packages\\avalonia.controls.colorpicker\\11.3.10\\avalonia.controls.colorpicker.11.3.10.nupkg.sha512",
|
||||
"C:\\Users\\Mikhail\\.nuget\\packages\\avalonia.controls.datagrid\\11.3.10\\avalonia.controls.datagrid.11.3.10.nupkg.sha512",
|
||||
"C:\\Users\\Mikhail\\.nuget\\packages\\avalonia.desktop\\11.3.10\\avalonia.desktop.11.3.10.nupkg.sha512",
|
||||
"C:\\Users\\Mikhail\\.nuget\\packages\\avalonia.diagnostics\\11.3.10\\avalonia.diagnostics.11.3.10.nupkg.sha512",
|
||||
"C:\\Users\\Mikhail\\.nuget\\packages\\avalonia.fonts.inter\\11.3.10\\avalonia.fonts.inter.11.3.10.nupkg.sha512",
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
|
|
@ -1 +1 @@
|
|||
17775150734683214
|
||||
17780383974089094
|
||||
|
|
@ -1 +1 @@
|
|||
17775150734683214
|
||||
17780383974089094
|
||||
Loading…
Reference in New Issue