Все поудалял, начинаем по новой
This commit is contained in:
parent
2f0150036e
commit
8e16f7ad6c
@ -3,11 +3,7 @@ Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 17
|
||||
VisualStudioVersion = 17.9.34714.143
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MedicalView", "MedicalView\MedicalView.csproj", "{9CEA3FF8-036C-4844-9376-8B09E8507E7F}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MedicalDatabaseContracts", "MedicalDatabaseContracts\MedicalDatabaseContracts.csproj", "{994E2E14-D535-4FDA-B380-8F0796CF3B40}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MedicalPostgresDatabase", "MedicalPostgresDatabase\MedicalPostgresDatabase.csproj", "{49D1A466-7D84-4333-B5EA-97D12606B986}"
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MedicalView", "MedicalView\MedicalView.csproj", "{9CEA3FF8-036C-4844-9376-8B09E8507E7F}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
@ -19,14 +15,6 @@ Global
|
||||
{9CEA3FF8-036C-4844-9376-8B09E8507E7F}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{9CEA3FF8-036C-4844-9376-8B09E8507E7F}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{9CEA3FF8-036C-4844-9376-8B09E8507E7F}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{994E2E14-D535-4FDA-B380-8F0796CF3B40}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{994E2E14-D535-4FDA-B380-8F0796CF3B40}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{994E2E14-D535-4FDA-B380-8F0796CF3B40}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{994E2E14-D535-4FDA-B380-8F0796CF3B40}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{49D1A466-7D84-4333-B5EA-97D12606B986}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{49D1A466-7D84-4333-B5EA-97D12606B986}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{49D1A466-7D84-4333-B5EA-97D12606B986}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{49D1A466-7D84-4333-B5EA-97D12606B986}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
9
Medical/MedicalDatabaseContracts/IModel.cs
Normal file
9
Medical/MedicalDatabaseContracts/IModel.cs
Normal file
@ -0,0 +1,9 @@
|
||||
using Npgsql;
|
||||
|
||||
namespace MedicalDatabaseContracts
|
||||
{
|
||||
public interface IModel<T>
|
||||
{
|
||||
T CreateFromDataReader(NpgsqlDataReader reader);
|
||||
}
|
||||
}
|
@ -6,4 +6,8 @@
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Npgsql" Version="8.0.2" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
@ -1,8 +1,19 @@
|
||||
namespace MedicalDatabaseContracts.Models
|
||||
using Npgsql;
|
||||
|
||||
namespace MedicalDatabaseContracts.Models
|
||||
{
|
||||
public class DiagnoseModel
|
||||
public class DiagnoseModel : IModel<DiagnoseModel>
|
||||
{
|
||||
public long? DiagnoseId { get; set; }
|
||||
public string Name { get; set;} = string.Empty;
|
||||
|
||||
public static DiagnoseModel CreateFromDataReader(NpgsqlDataReader reader)
|
||||
{
|
||||
return new DiagnoseModel
|
||||
{
|
||||
DiagnoseId = Convert.ToInt32(reader["diagnose_id"]),
|
||||
Name = Convert.ToString(reader["name"])
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
42
Medical/MedicalPostgresDatabase/DiagnosesStorage.cs
Normal file
42
Medical/MedicalPostgresDatabase/DiagnosesStorage.cs
Normal file
@ -0,0 +1,42 @@
|
||||
using MedicalDatabaseContracts;
|
||||
using MedicalDatabaseContracts.Models;
|
||||
using Npgsql;
|
||||
|
||||
namespace MedicalPostgresDatabase
|
||||
{
|
||||
public class DiagnosesStorage : IStorage<DiagnoseModel>
|
||||
{
|
||||
private MedicalDatabaseSingleton _database;
|
||||
public DiagnosesStorage()
|
||||
{
|
||||
_database = MedicalDatabaseSingleton.GetInstance();
|
||||
}
|
||||
public DiagnoseModel Create(DiagnoseModel entity)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public DiagnoseModel Delete(long id)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public DiagnoseModel Get(long id)
|
||||
{
|
||||
using var cmd = new NpgsqlCommand();
|
||||
cmd.Connection = dbconnection;
|
||||
cmd.CommandText = "";
|
||||
|
||||
}
|
||||
|
||||
public List<DiagnoseModel> GetAll()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public DiagnoseModel Update(long id, DiagnoseModel entity)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
47
Medical/MedicalPostgresDatabase/MedicalDatabaseSingleton.cs
Normal file
47
Medical/MedicalPostgresDatabase/MedicalDatabaseSingleton.cs
Normal file
@ -0,0 +1,47 @@
|
||||
using MedicalDatabaseContracts;
|
||||
using Npgsql;
|
||||
|
||||
namespace MedicalPostgresDatabase
|
||||
{
|
||||
public class MedicalDatabaseSingleton
|
||||
{
|
||||
private static MedicalDatabaseSingleton? instance;
|
||||
private NpgsqlConnection _connection;
|
||||
|
||||
public static MedicalDatabaseSingleton GetInstance()
|
||||
{
|
||||
if (instance == null)
|
||||
{
|
||||
instance = new MedicalDatabaseSingleton();
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
private MedicalDatabaseSingleton()
|
||||
{
|
||||
_connection = new NpgsqlConnection(
|
||||
connectionString: "Server=localhost;Port=5555;User Id=postgres;Password=postgres;Database=medicalbase;"
|
||||
);
|
||||
_connection.Open();
|
||||
|
||||
}
|
||||
public List<T> ExecuteQuerySelect<T>(string query) where T : IModel
|
||||
{
|
||||
using var command = new NpgsqlCommand();
|
||||
command.Connection = _connection;
|
||||
command.CommandText = query;
|
||||
NpgsqlDataReader reader = command.ExecuteReader();
|
||||
var list = new List<T>();
|
||||
while (reader.Read())
|
||||
{
|
||||
list.Add(T.CreateFromDataReader());
|
||||
}
|
||||
}
|
||||
public int ExecuteQuery(string query)
|
||||
{
|
||||
using var command = new NpgsqlCommand();
|
||||
command.Connection = _connection;
|
||||
command.CommandText = query;
|
||||
return command.ExecuteNonQuery();
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Npgsql" Version="8.0.2" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\MedicalDatabaseContracts\MedicalDatabaseContracts.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
12
Medical/MedicalView/FormMain.Designer.cs
generated
12
Medical/MedicalView/FormMain.Designer.cs
generated
@ -51,7 +51,7 @@
|
||||
menuStrip.Items.AddRange(new ToolStripItem[] { справочникиToolStripMenuItem, пациентыToolStripMenuItem1 });
|
||||
menuStrip.Location = new Point(0, 0);
|
||||
menuStrip.Name = "menuStrip";
|
||||
menuStrip.Size = new Size(584, 24);
|
||||
menuStrip.Size = new Size(755, 24);
|
||||
menuStrip.TabIndex = 0;
|
||||
menuStrip.Text = "menuStrip1";
|
||||
//
|
||||
@ -94,7 +94,7 @@
|
||||
dataGridView.Name = "dataGridView";
|
||||
dataGridView.RowTemplate.Height = 25;
|
||||
dataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
|
||||
dataGridView.Size = new Size(584, 277);
|
||||
dataGridView.Size = new Size(755, 277);
|
||||
dataGridView.TabIndex = 1;
|
||||
//
|
||||
// panel
|
||||
@ -107,7 +107,7 @@
|
||||
panel.Dock = DockStyle.Top;
|
||||
panel.Location = new Point(0, 24);
|
||||
panel.Name = "panel";
|
||||
panel.Size = new Size(584, 29);
|
||||
panel.Size = new Size(755, 29);
|
||||
panel.TabIndex = 2;
|
||||
//
|
||||
// buttonEdit
|
||||
@ -119,7 +119,6 @@
|
||||
buttonEdit.TabIndex = 4;
|
||||
buttonEdit.Text = "Изменить";
|
||||
buttonEdit.UseVisualStyleBackColor = true;
|
||||
buttonEdit.Click += this.buttonEdit_Click;
|
||||
//
|
||||
// buttonDelete
|
||||
//
|
||||
@ -130,7 +129,6 @@
|
||||
buttonDelete.TabIndex = 3;
|
||||
buttonDelete.Text = "Удалить";
|
||||
buttonDelete.UseVisualStyleBackColor = true;
|
||||
buttonDelete.Click += buttonDelete_Click;
|
||||
//
|
||||
// buttonAdd
|
||||
//
|
||||
@ -141,7 +139,6 @@
|
||||
buttonAdd.TabIndex = 2;
|
||||
buttonAdd.Text = "Добавить";
|
||||
buttonAdd.UseVisualStyleBackColor = true;
|
||||
buttonAdd.Click += this.buttonAdd_Click;
|
||||
//
|
||||
// dateTimePicker1
|
||||
//
|
||||
@ -165,7 +162,7 @@
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(584, 301);
|
||||
ClientSize = new Size(755, 301);
|
||||
Controls.Add(panel);
|
||||
Controls.Add(dataGridView);
|
||||
Controls.Add(menuStrip);
|
||||
@ -173,6 +170,7 @@
|
||||
MinimumSize = new Size(600, 340);
|
||||
Name = "FormMain";
|
||||
Text = "Записи посещений";
|
||||
Load += FormMain_Load;
|
||||
menuStrip.ResumeLayout(false);
|
||||
menuStrip.PerformLayout();
|
||||
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
|
||||
|
@ -1,14 +1,4 @@
|
||||
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;
|
||||
|
||||
namespace MedicalView.Visits
|
||||
namespace MedicalView.Visits
|
||||
{
|
||||
public partial class FormMain : Form
|
||||
{
|
||||
@ -17,7 +7,7 @@ namespace MedicalView.Visits
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private void buttonDelete_Click(object sender, EventArgs e)
|
||||
private void FormMain_Load(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
|
@ -1,3 +1,5 @@
|
||||
using MedicalView.Visits;
|
||||
|
||||
namespace MedicalView
|
||||
{
|
||||
internal static class Program
|
||||
@ -11,7 +13,7 @@ namespace MedicalView
|
||||
// To customize application configuration such as set high DPI settings or default font,
|
||||
// see https://aka.ms/applicationconfiguration.
|
||||
ApplicationConfiguration.Initialize();
|
||||
Application.Run(new Form1());
|
||||
Application.Run(new FormMain());
|
||||
}
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user