313 lines
12 KiB
C#
313 lines
12 KiB
C#
using SportCompetitionsContracts.BindingModels;
|
||
using SportCompetitionsContracts.BusinessLogicsContracts;
|
||
using SportCompetitionsDatabaseImplement;
|
||
using SportCompetitionsDatabaseImplement.Models;
|
||
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;
|
||
using SportCompetitionsMongo;
|
||
|
||
namespace SportCompetitionsView
|
||
{
|
||
public partial class FormMain : Form
|
||
{
|
||
private ICompetitionLogic _logicC;
|
||
private ITeamLogic _logicT;
|
||
public FormMain(ITeamLogic logicT, ICompetitionLogic logicC)
|
||
{
|
||
InitializeComponent();
|
||
_logicT = logicT;
|
||
_logicC = logicC;
|
||
}
|
||
|
||
private void CompetitionToolStripMenuItem_Click(object sender, EventArgs e)
|
||
{
|
||
var service = Program.ServiceProvider?.GetService(typeof(FormCompetitions));
|
||
if (service is FormCompetitions form)
|
||
{
|
||
form.ShowDialog();
|
||
}
|
||
}
|
||
|
||
private void TeamsToolStripMenuItem_Click(object sender, EventArgs e)
|
||
{
|
||
var service = Program.ServiceProvider?.GetService(typeof(FormTeams));
|
||
if (service is FormTeams form)
|
||
{
|
||
form.ShowDialog();
|
||
}
|
||
}
|
||
|
||
private void MembersToolStripMenuItem_Click(object sender, EventArgs e)
|
||
{
|
||
var service = Program.ServiceProvider?.GetService(typeof(FormMembers));
|
||
if (service is FormMembers form)
|
||
{
|
||
form.ShowDialog();
|
||
}
|
||
}
|
||
private void RecordsToolStripMenuItem_Click(object sender, EventArgs e)
|
||
{
|
||
var service = Program.ServiceProvider?.GetService(typeof(FormRecords));
|
||
if (service is FormRecords form)
|
||
{
|
||
form.ShowDialog();
|
||
}
|
||
}
|
||
|
||
private void ResultsToolStripMenuItem_Click(object sender, EventArgs e)
|
||
{
|
||
var service = Program.ServiceProvider?.GetService(typeof(FormResults));
|
||
if (service is FormResults form)
|
||
{
|
||
form.ShowDialog();
|
||
}
|
||
}
|
||
private void buttonTest1_Click(object sender, EventArgs e)
|
||
{
|
||
DateTime startCreation = DateTime.Now;
|
||
|
||
for (int i = 1; i <= 100; i++)
|
||
{
|
||
CompetitionBindingModel model = new CompetitionBindingModel()
|
||
{
|
||
Id = i + 100,
|
||
CompetitionName = "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> " + i,
|
||
CompetitionDateHolding = DateTime.Now,
|
||
CompetitionCity = "<22><><EFBFBD><EFBFBD><EFBFBD> " + i
|
||
};
|
||
_logicC.Create(model);
|
||
}
|
||
|
||
DateTime stopCreation = DateTime.Now;
|
||
TimeSpan creationTime = stopCreation - startCreation;
|
||
|
||
MessageBox.Show($"<22><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: {creationTime.TotalMilliseconds}", "Test", MessageBoxButtons.OK);
|
||
}
|
||
private void buttonTest2_Click(object sender, EventArgs e)
|
||
{
|
||
DateTime startDeletion = DateTime.Now;
|
||
for (int i = 1; i <= 100; i++)
|
||
{
|
||
_logicC.Delete(new CompetitionBindingModel { Id = i + 100 });
|
||
}
|
||
|
||
DateTime stopDeletion = DateTime.Now;
|
||
TimeSpan deletionTime = stopDeletion - startDeletion;
|
||
|
||
MessageBox.Show($"<22><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: {deletionTime.TotalMilliseconds}", "Test", MessageBoxButtons.OK);
|
||
}
|
||
private void buttonTest3_Click(object sender, EventArgs e)
|
||
{
|
||
DateTime startCreation = DateTime.Now;
|
||
|
||
for (int i = 1; i <= 1000; i++)
|
||
{
|
||
TeamBindingModel model2 = new TeamBindingModel()
|
||
{
|
||
Id = i + 100,
|
||
TeamName = "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> " + i,
|
||
TeamCountry = "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> " + i,
|
||
};
|
||
_logicT.Create(model2);
|
||
}
|
||
|
||
DateTime stopCreation = DateTime.Now;
|
||
TimeSpan creationTime = stopCreation - startCreation;
|
||
|
||
MessageBox.Show($"<22><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: {creationTime.TotalMilliseconds} <20><>", "Test", MessageBoxButtons.OK);
|
||
}
|
||
private void buttonTest4_Click(object sender, EventArgs e)
|
||
{
|
||
DateTime startDeletion = DateTime.Now;
|
||
for (int i = 1; i <= 1000; i++)
|
||
{
|
||
_logicT.Delete(new TeamBindingModel { Id = i + 100 });
|
||
}
|
||
|
||
DateTime stopDeletion = DateTime.Now;
|
||
TimeSpan deletionTime = stopDeletion - startDeletion;
|
||
|
||
MessageBox.Show($"<22><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: {deletionTime.TotalMilliseconds} <20><>", "Test", MessageBoxButtons.OK);
|
||
}
|
||
private void button_Click(object sender, EventArgs e)
|
||
{
|
||
DateTime start = DateTime.Now;
|
||
|
||
using (var db = new SportCompetitionsDatabase())
|
||
{
|
||
var query = from member in db.Members
|
||
join team in db.Teams on member.TeamId equals team.Id
|
||
select new
|
||
{
|
||
member.MemberFCs,
|
||
member.MemberBirthDate,
|
||
member.MemberGender,
|
||
team.TeamName,
|
||
team.TeamCountry
|
||
};
|
||
|
||
var result = query.ToList();
|
||
|
||
DateTime stop = DateTime.Now;
|
||
TimeSpan queryTime = stop - start;
|
||
|
||
dataGridView1.DataSource = result;
|
||
|
||
MessageBox.Show($"<22><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: {queryTime.TotalMilliseconds} <20><>", "<22><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||
}
|
||
}
|
||
|
||
private void button2_Click(object sender, EventArgs e)
|
||
{
|
||
DateTime start = DateTime.Now;
|
||
|
||
using (var db = new SportCompetitionsDatabase())
|
||
{
|
||
var query = from result2 in db.Results
|
||
join team in db.Teams on result2.TeamId equals team.Id
|
||
join competition in db.Competitions on result2.CompetitionId equals competition.Id
|
||
select new
|
||
{
|
||
ResultName = result2.ResultName,
|
||
TeamName = team.TeamName,
|
||
TeamCountry = team.TeamCountry,
|
||
CompetitionName = competition.CompetitionName,
|
||
CompetitionDateHolding = competition.CompetitionDateHolding,
|
||
CompetitionCity = competition.CompetitionCity,
|
||
ResultPosition = result2.ResultPosition
|
||
};
|
||
|
||
var result = query.ToList();
|
||
|
||
DateTime stop = DateTime.Now;
|
||
TimeSpan queryTime = stop - start;
|
||
|
||
dataGridView1.DataSource = result;
|
||
|
||
MessageBox.Show($"<22><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: {queryTime.TotalMilliseconds} <20><>", "<22><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||
}
|
||
}
|
||
|
||
private void butto3n_Click(object sender, EventArgs e)
|
||
{
|
||
DateTime start = DateTime.Now;
|
||
|
||
using (var db = new SportCompetitionsDatabase())
|
||
{
|
||
var query = db.Records.ToList();
|
||
|
||
DateTime stop = DateTime.Now;
|
||
TimeSpan queryTime = stop - start;
|
||
|
||
dataGridView1.DataSource = query;
|
||
|
||
MessageBox.Show($"<22><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: {queryTime.TotalMilliseconds} <20><>", "<22><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||
}
|
||
}
|
||
|
||
private void buttonOmega_Click(object sender, EventArgs e)
|
||
{
|
||
DateTime start = DateTime.Now;
|
||
|
||
using (var db = new SportCompetitionsDatabase())
|
||
{
|
||
var query = from t in db.Teams
|
||
join m in db.Members on t.Id equals m.TeamId
|
||
join r in db.Results on t.Id equals r.TeamId
|
||
join rec in db.Records on m.Id equals rec.MemberId
|
||
join c in db.Competitions on r.CompetitionId equals c.Id
|
||
select new
|
||
{
|
||
t.TeamName,
|
||
t.TeamCountry,
|
||
m.MemberFCs,
|
||
m.MemberBirthDate,
|
||
m.MemberGender,
|
||
c.CompetitionName,
|
||
c.CompetitionDateHolding,
|
||
c.CompetitionCity,
|
||
r.ResultName,
|
||
r.ResultPosition,
|
||
rec.RecordName,
|
||
rec.RecordDecriptiption,
|
||
rec.RecordDate,
|
||
rec.RecordValue
|
||
};
|
||
|
||
var result = query.ToList();
|
||
|
||
DateTime stop = DateTime.Now;
|
||
TimeSpan queryTime = stop - start;
|
||
|
||
var form = new Form();
|
||
form.Width = 800;
|
||
form.Height = 600;
|
||
|
||
var dataGridView = new DataGridView();
|
||
dataGridView.Dock = DockStyle.Fill;
|
||
dataGridView.AutoGenerateColumns = true;
|
||
dataGridView.DataSource = result;
|
||
|
||
form.Controls.Add(dataGridView);
|
||
|
||
form.ShowDialog();
|
||
|
||
MessageBox.Show($"<22><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: {queryTime.TotalMilliseconds} <20><>", "<22><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||
}
|
||
}
|
||
|
||
private void buttonOMEGA2_Click(object sender, EventArgs e)
|
||
{
|
||
DateTime start = DateTime.Now;
|
||
|
||
using (var db = new SportCompetitionsDatabase())
|
||
{
|
||
var query = from m in db.Members
|
||
join t in db.Teams on m.TeamId equals t.Id
|
||
join r in db.Results on m.TeamId equals r.TeamId
|
||
where m.MemberGender.StartsWith("<22>")
|
||
select new
|
||
{
|
||
MemberFCs = m.MemberFCs,
|
||
MemberBirthDate = m.MemberBirthDate,
|
||
MemberGender = m.MemberGender,
|
||
TeamName = t.TeamName,
|
||
TeamCountry = t.TeamCountry,
|
||
ResultName = r.ResultName,
|
||
ResultPosition = r.ResultPosition
|
||
};
|
||
|
||
var result = query.ToList();
|
||
|
||
DateTime stop = DateTime.Now;
|
||
TimeSpan queryTime = stop - start;
|
||
|
||
var form = new Form();
|
||
form.Width = 1000;
|
||
form.Height = 600;
|
||
|
||
var dataGridView = new DataGridView();
|
||
dataGridView.Dock = DockStyle.Fill;
|
||
dataGridView.AutoGenerateColumns = true;
|
||
dataGridView.DataSource = result;
|
||
|
||
form.Controls.Add(dataGridView);
|
||
|
||
form.ShowDialog();
|
||
|
||
MessageBox.Show($"<22><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: {queryTime.TotalMilliseconds} <20><>", "<22><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||
}
|
||
}
|
||
private void buttonPsqlToMongo_Click(object sender, EventArgs e)
|
||
{
|
||
PostgresToMongo.Convert();
|
||
}
|
||
}
|
||
} |