половина лабы, без форм

This commit is contained in:
cyxaruk 2024-11-12 20:11:03 +04:00
parent 13e90c4e85
commit 970ea7af86
20 changed files with 367 additions and 20 deletions

View File

@ -6,27 +6,24 @@ using System.Threading.Tasks;
namespace ProjectPeopleTransportation.Entities; namespace ProjectPeopleTransportation.Entities;
internal class Bus public class Bus
{ {
public int ID { get; private set; } public int ID { get; private set; }
public string Model { get; private set; } = string.Empty; public string BusName { get; private set; } = string.Empty;
public string Brand { get; private set; } = string.Empty; public int LicensePlate { get; private set; }
public int BusNum { get; private set; } public int Capacity { get; private set; }
public int YearOfCreation { get; private set; } public static Bus CreateEntity(int id, string busName, int licensePlate, int capacity)
public static Bus CreateEntity(int id, string model, int busNum, string brand, int yearOfCreation)
{ {
return new Bus return new Bus
{ {
ID = id, ID = id,
Model = model, BusName = busName,
BusNum = busNum, LicensePlate = licensePlate,
Brand = brand, Capacity = capacity
YearOfCreation = yearOfCreation
}; };
} }

View File

@ -4,7 +4,7 @@ namespace ProjectPeopleTransportation.Entities;
public class Employee public class Employee
{ {
public int Id { get; private set; } public int ID { get; private set; }
public string FirstName { get; private set; } = string.Empty; public string FirstName { get; private set; } = string.Empty;
@ -18,7 +18,7 @@ public class Employee
{ {
return new Employee return new Employee
{ {
Id = id, ID = id,
FirstName = first ?? string.Empty, FirstName = first ?? string.Empty,
LastName = last ?? string.Empty, LastName = last ?? string.Empty,
PhoneNum = phone, PhoneNum = phone,

View File

@ -10,11 +10,7 @@ public enum EmployeePost
{ {
None = 0, None = 0,
Admin = 1, Driver = 1,
Engineer = 2, Conductor = 2
Driver = 3,
Conductor = 4
} }

View File

@ -0,0 +1,21 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProjectPeopleTransportation.Entities.Enums;
[Flags]
public enum RouteListType
{
None = 0,
RouteNum1 = 1,
RouteNum2 = 2,
RouteNum3 = 4,
RouteNum4 = 8
}

View File

@ -0,0 +1,24 @@
namespace ProjectPeopleTransportation.Entities;
public class RouteGiveaway
{
public int ID { get; private set; }
public int EmployeeID { get; private set; }
public DateTime DateReceipt { get; private set; }
public IEnumerable<RouteRouteGiveaway> RouteRouteGiveaway { get; private set; } = [];
public static RouteGiveaway CreateOperation(int id, int employeeID, IEnumerable<RouteRouteGiveaway> routeRouteGiveaway)
{
return new RouteGiveaway
{
ID = id,
EmployeeID = employeeID,
DateReceipt = DateTime.Now,
RouteRouteGiveaway = routeRouteGiveaway
};
}
}

View File

@ -0,0 +1,35 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using ProjectPeopleTransportation.Entities.Enums;
namespace ProjectPeopleTransportation.Entities;
public class RouteList
{
public int ID { get; private set; }
public RouteListType RouteListType { get; private set; }
public string Name { get; private set; } = string.Empty;
public string Description { get; private set; } = string.Empty;
public static RouteList CreateEntity(int id, string name, string description, RouteListType routeListType)
{
return new RouteList
{
ID = id,
RouteListType = routeListType,
Name = name ?? string.Empty,
Description = description ?? string.Empty
};
}
}

View File

@ -0,0 +1,21 @@
namespace ProjectPeopleTransportation.Entities;
public class RouteRouteGiveaway
{
public int ID { get; private set; }
public int RouteID { get; private set; }
public int Count { get; private set; }
public static RouteRouteGiveaway CreateElement(int id, int routeID, int count)
{
return new RouteRouteGiveaway
{
ID = id,
RouteID = routeID,
Count = count
};
}
}

View File

@ -0,0 +1,38 @@
using ProjectPeopleTransportation.Entities.Enums;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Linq;
namespace ProjectPeopleTransportation.Entities;
public class StartingShift
{
public int ID { get; private set; }
public int RouteListID { get; private set; }
public int EmployeeID { get; private set; }
public int BusID { get; private set; }
public DateTime StartingShiftDate { get; private set; }
public int ShiftDuration { get; private set; }
public static StartingShift CreateOperation(int id, int routeListID, int employeeID, int busID, int shiftDuration)
{
return new StartingShift
{
ID = id,
RouteListID = routeListID,
EmployeeID = employeeID,
BusID = busID,
StartingShiftDate = DateTime.Now,
ShiftDuration = shiftDuration
};
}
}

View File

@ -1,3 +1,7 @@
using ProjectPeopleTransportation.Repositories;
using ProjectPeopleTransportation.Repositories.Implementations;
using Unity;
namespace ProjectPeopleTransportation namespace ProjectPeopleTransportation
{ {
internal static class Program internal static class Program
@ -11,7 +15,20 @@ namespace ProjectPeopleTransportation
// To customize application configuration such as set high DPI settings or default font, // To customize application configuration such as set high DPI settings or default font,
// see https://aka.ms/applicationconfiguration. // see https://aka.ms/applicationconfiguration.
ApplicationConfiguration.Initialize(); ApplicationConfiguration.Initialize();
Application.Run(new Form1()); Application.Run(CreateContainer().Resolve<Form1>());
}
private static IUnityContainer CreateContainer()
{
var container = new UnityContainer();
container.RegisterType<IBusRepository, BusRepository>();
container.RegisterType<IEmployeeRepository, EmployeeRepository>();
container.RegisterType<IRouteGiveawayRepository, RouteGiveawayRepository>();
container.RegisterType<IRouteListRepository, RouteListRepository>();
container.RegisterType<IStartingShiftRepository, StartingShiftRepository>();
return container;
} }
} }
} }

View File

@ -8,4 +8,8 @@
<ImplicitUsings>enable</ImplicitUsings> <ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup> </PropertyGroup>
<ItemGroup>
<PackageReference Include="Unity" Version="5.11.10" />
</ItemGroup>
</Project> </Project>

View File

@ -0,0 +1,16 @@
using ProjectPeopleTransportation.Entities;
namespace ProjectPeopleTransportation.Repositories;
public interface IBusRepository
{
IEnumerable<Bus> ReadBuses();
Bus ReadBusByID(int id);
void CreateBus(Bus bus);
void UpdateBus(Bus bus);
void DeleteBus(int id);
}

View File

@ -0,0 +1,16 @@
using ProjectPeopleTransportation.Entities;
namespace ProjectPeopleTransportation.Repositories;
public interface IEmployeeRepository
{
IEnumerable<Employee> ReadEmployees();
Employee ReadEmployeeByID(int id);
void CreateEmployee(Employee employee);
void UpdateEmployee(Employee employee);
void DeleteEmployee(int id);
}

View File

@ -0,0 +1,13 @@
using ProjectPeopleTransportation.Entities;
namespace ProjectPeopleTransportation.Repositories;
public interface IRouteGiveawayRepository
{
IEnumerable<RouteGiveaway> ReadRouteGiveaway(DateTime? dateForm = null, DateTime? dateTo = null,
int? employeeId = null, int? busId = null);
void CreateRouteGiveaway(RouteGiveaway routeGiveaway);
void DeleteRouteGiveaway(int id);
}

View File

@ -0,0 +1,17 @@
using ProjectPeopleTransportation.Entities;
namespace ProjectPeopleTransportation.Repositories;
public interface IRouteListRepository
{
IEnumerable<RouteList> ReadRouteLists();
RouteList ReadRouteListByID(int id);
void CreateRouteList(RouteList routeList);
void UpdateRouteList(RouteList routeList);
void DeleteRouteList(int id);
}

View File

@ -0,0 +1,11 @@
using ProjectPeopleTransportation.Entities;
namespace ProjectPeopleTransportation.Repositories;
public interface IStartingShiftRepository
{
IEnumerable<StartingShift> ReadStartingShifts(DateTime? dateForm = null, DateTime? dateTo = null, int? routeId = null,
int? employeeId = null, int? busId = null);
void CreateStartingShift(StartingShift startingShift);
}

View File

@ -0,0 +1,28 @@
using ProjectPeopleTransportation.Entities;
namespace ProjectPeopleTransportation.Repositories.Implementations;
public class BusRepository : IBusRepository
{
public void CreateBus(Bus bus)
{
}
public void DeleteBus(int id)
{
}
public Bus ReadBusByID(int id)
{
return Bus.CreateEntity(0, string.Empty, 0, 0);
}
public IEnumerable<Bus> ReadBuses()
{
return [];
}
public void UpdateBus(Bus bus)
{
}
}

View File

@ -0,0 +1,29 @@
using ProjectPeopleTransportation.Entities;
using ProjectPeopleTransportation.Entities.Enums;
namespace ProjectPeopleTransportation.Repositories.Implementations;
public class EmployeeRepository : IEmployeeRepository
{
public void CreateEmployee(Employee employee)
{
}
public void DeleteEmployee(int id)
{
}
public Employee ReadEmployeeByID(int id)
{
return Employee.CreateEntity(0, string.Empty, string.Empty, 0, EmployeePost.None);
}
public IEnumerable<Employee> ReadEmployees()
{
return [];
}
public void UpdateEmployee(Employee employee)
{
}
}

View File

@ -0,0 +1,19 @@
using ProjectPeopleTransportation.Entities;
namespace ProjectPeopleTransportation.Repositories.Implementations;
public class RouteGiveawayRepository : IRouteGiveawayRepository
{
public void CreateRouteGiveaway(RouteGiveaway routeGiveaway)
{
}
public void DeleteRouteGiveaway(int id)
{
}
public IEnumerable<RouteGiveaway> ReadRouteGiveaway(DateTime? dateForm = null, DateTime? dateTo = null, int? employeeId = null, int? busId = null)
{
return [];
}
}

View File

@ -0,0 +1,29 @@
using ProjectPeopleTransportation.Entities;
using ProjectPeopleTransportation.Entities.Enums;
namespace ProjectPeopleTransportation.Repositories.Implementations;
public class RouteListRepository : IRouteListRepository
{
public void CreateRouteList(RouteList routeList)
{
}
public void DeleteRouteList(int id)
{
}
public RouteList ReadRouteListByID(int id)
{
return RouteList.CreateEntity(0, string.Empty, string.Empty, RouteListType.None);
}
public IEnumerable<RouteList> ReadRouteLists()
{
return [];
}
public void UpdateRouteList(RouteList routeList)
{
}
}

View File

@ -0,0 +1,16 @@

using ProjectPeopleTransportation.Entities;
namespace ProjectPeopleTransportation.Repositories.Implementations;
public class StartingShiftRepository : IStartingShiftRepository
{
public void CreateStartingShift(StartingShift startingShift)
{
}
public IEnumerable<StartingShift> ReadStartingShifts(DateTime? dateForm = null, DateTime? dateTo = null, int? routeId = null, int? employeeId = null, int? busId = null)
{
return [];
}
}