Diplom_B/DB/MainDB.cs

191 lines
5.4 KiB
C#
Raw Normal View History

2021-07-15 12:21:22 +05:00
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.EntityFrameworkCore;
namespace Diplom_B.DB
{
public class MainDB : DbContext
{
public DbSet<User> Users { get; set; }
2021-07-17 09:33:09 +05:00
public DbSet<Status> Statusy { get; set; }
public DbSet<Dogovor> Dogovory { get; set; }
2021-07-15 16:58:51 +05:00
public DbSet<Izdelie> Izdeliya { get; set; }
2021-07-17 09:33:09 +05:00
public DbSet<DogIzd> DogIzds { get; set; }
public DbSet<Zakazchik> Zakazchiki { get; set; }
public DbSet<Document> Documenty { get; set; }
2021-07-16 16:43:55 +05:00
public DbSet<Izveschenie> Izvescheniya { get; set; }
2021-07-17 09:33:09 +05:00
public DbSet<DocIzv> DocIzvs { get; set; }
public DbSet<Postavka> Postavki { get; set; }
public DbSet<Oplata> Oplaty { get; set; }
2021-07-15 16:58:51 +05:00
public MainDB() {
//Database.Migrate();
Database.EnsureCreated();
}
2021-07-15 12:21:22 +05:00
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
2021-07-17 09:33:09 +05:00
optionsBuilder.UseSqlite("Data Source=" + Directory.GetCurrentDirectory() + Path.DirectorySeparatorChar + "Diplom_B.db;");
2021-07-15 12:21:22 +05:00
}
protected override void OnModelCreating(ModelBuilder modelBuilder) { }
}
public class User
{
[Key, DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int Id { get; set; }
public string Name { get; set; }
public string Pass { get; set; }
2021-07-17 09:33:09 +05:00
public int Dog { get; set; }
public int Doc { get; set; }
public int Izv { get; set; }
public int Post { get; set; }
public int Izd { get; set; }
public int Zak { get; set; }
public int Set { get; set; }
public int Default { get; set; }
2021-07-15 12:21:22 +05:00
}
2021-07-17 09:33:09 +05:00
public class Status
2021-07-15 12:21:22 +05:00
{
2021-07-15 16:58:51 +05:00
[Key, DatabaseGenerated(DatabaseGeneratedOption.Identity)]
2021-07-15 12:21:22 +05:00
public int Id { get; set; }
2021-07-17 09:33:09 +05:00
public string Stat { get; set; }
}
public class Dogovor
{
[Key, DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int Id { get; set; }
public string DogNum { get; set; }
public List<DogIzd> DogIzds { get; set; }
[ForeignKey("Zakazchik")]
public int ZakazchikId { get; set; }
public Zakazchik Zakazchik { get; set; }
public DateTime DataPostavky { get; set; }
public string Garantiy { get; set; }
public string PrikazZapusk { get; set; }
public double Avans { get; set; }
public List<Oplata> Platejy { get; set; }
public string Primechanie { get; set; }
2021-07-15 12:21:22 +05:00
}
2021-07-15 16:58:51 +05:00
public class Izdelie
{
[Key, DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int Id { get; set; }
public string Name { get; set; }
public string DecNum { get; set; }
public string Shifr { get; set; }
public string Litera { get; set; }
public double Cena { get; set; }
public int OtdelRazrab { get; set; }
public string Ved { get; set; }
public string GlavKonstr { get; set; }
2021-07-17 09:33:09 +05:00
public List<Postavka> Postavky { get; set; }
public List<DogIzd> DogIzds { get; set; }
}
public class DogIzd
{
[Key, DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int Id { get; set; }
public int Kolvo { get; set; }
[ForeignKey("Dogovor")]
public int DogovorId { get; set; }
public Dogovor Dogovor { get; set; }
[ForeignKey("Izdelie")]
public int IzdelieId { get; set; }
public Izdelie Izdelie { get; set; }
}
public class Zakazchik
{
[Key, DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int Id { get; set; }
public string Name { get; set; }
public string Adress { get; set; }
public string Phone { get; set; }
public string Email { get; set; }
public List<Dogovor> Dogovory { get; set; }
}
public class Document
{
[Key, DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int Id { get; set; }
public string InvNum { get; set; }
public string DecNum { get; set; }
public string Name { get; set; }
public string FileName { get; set; }
public byte[] FileStruct { get; set; }
public string Primechanie { get; set; }
public List<DocIzv> DocIzvs { get; set; }
2021-07-15 16:58:51 +05:00
}
2021-07-16 16:43:55 +05:00
public class Izveschenie
{
[Key, DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int Id { get; set; }
public string IzvNum { get; set; }
public int InvNum { get; set; }
public int IzmNum { get; set; }
public string UkazZad { get; set; }
public string UkazVnedr { get; set; }
public string FileName { get; set; }
public byte[] FileStruct { get; set; }
2021-07-17 09:33:09 +05:00
public List<DocIzv> DocIzvs { get; set; }
}
public class DocIzv
{
[Key, DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int Id { get; set; }
[ForeignKey("Document")]
public int DocumentId { get; set; }
public Document Document { get; set; }
[ForeignKey("Izveschenie")]
public int IzveschenieId { get; set; }
public Izveschenie Izveschenie { get; set; }
}
public class Postavka
{
[Key, DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int Id { get; set; }
public string ZavNum { get; set; }
[ForeignKey("Dogovor")]
public int? DogovorId { get; set; }
public Dogovor Dogovor { get; set; }
[ForeignKey("Status")]
2021-07-17 22:32:53 +05:00
public int StatusId { get; set; }
2021-07-17 09:33:09 +05:00
public Status Status { get; set; }
public DateTime DataPostavki { get; set; }
public string Primechanie { get; set; }
2021-07-17 22:32:53 +05:00
[ForeignKey("Izdelie")]
2021-07-17 09:33:09 +05:00
public int? IzdelieId { get; set; }
public Izdelie Izdelie { get; set; }
2021-07-16 16:43:55 +05:00
}
2021-07-17 09:33:09 +05:00
public class Oplata
{
[Key, DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int Id { get; set; }
public double Summa { get; set; }
[ForeignKey("Dogovor")]
public int DogovorId { get; set; }
public Dogovor Dogovor { get; set; }
}
2021-07-15 12:21:22 +05:00
}