208 lines
5.9 KiB
C#
208 lines
5.9 KiB
C#
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; }
|
|
public DbSet<Status> Statusy { get; set; }
|
|
public DbSet<Dogovor> Dogovory { get; set; }
|
|
public DbSet<Izdelie> Izdeliya { get; set; }
|
|
public DbSet<DogIzd> DogIzds { get; set; }
|
|
public DbSet<Zakazchik> Zakazchiki { get; set; }
|
|
public DbSet<Document> Documenty { get; set; }
|
|
public DbSet<Izveschenie> Izvescheniya { get; set; }
|
|
public DbSet<DocIzv> DocIzvs { get; set; }
|
|
public DbSet<Postavka> Postavki { get; set; }
|
|
public DbSet<Platej> Platejy { get; set; }
|
|
public DbSet<DogDoc> DogDocs { get; set; }
|
|
|
|
|
|
public MainDB() {
|
|
//Database.Migrate();
|
|
Database.EnsureCreated();
|
|
}
|
|
|
|
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
|
|
{
|
|
optionsBuilder.UseSqlite("Data Source=" + Directory.GetCurrentDirectory() + Path.DirectorySeparatorChar + "Diplom_B.db;");
|
|
}
|
|
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; }
|
|
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; }
|
|
}
|
|
public class Status
|
|
{
|
|
[Key, DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
|
public int Id { get; set; }
|
|
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 List<Platej> Platejy { get; set; }
|
|
public string Primechanie { get; set; }
|
|
public List<DogDoc> DogDocs { get; set; }
|
|
public List<Postavka> Postavky { get; set; }
|
|
}
|
|
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; }
|
|
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; }
|
|
public List<DogDoc> DogDocs { get; set; }
|
|
}
|
|
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; }
|
|
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")]
|
|
public int StatusId { get; set; }
|
|
public Status Status { get; set; }
|
|
|
|
public DateTime DataPostavki { get; set; }
|
|
public string Primechanie { get; set; }
|
|
|
|
[ForeignKey("Izdelie")]
|
|
public int? IzdelieId { get; set; }
|
|
public Izdelie Izdelie { get; set; }
|
|
}
|
|
public class Platej
|
|
{
|
|
[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; }
|
|
}
|
|
public class DogDoc
|
|
{
|
|
[Key, DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
|
public int Id { get; set; }
|
|
|
|
[ForeignKey("Dogovor")]
|
|
public int DogovorId { get; set; }
|
|
public Dogovor Dogovor { get; set; }
|
|
|
|
[ForeignKey("Document")]
|
|
public int DocumentId { get; set; }
|
|
public Document Document { get; set; }
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|