Compare commits
2 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
b762d97176 | ||
|
aac129127d |
@ -3,7 +3,17 @@ Microsoft Visual Studio Solution File, Format Version 12.00
|
|||||||
# Visual Studio Version 17
|
# Visual Studio Version 17
|
||||||
VisualStudioVersion = 17.9.34622.214
|
VisualStudioVersion = 17.9.34622.214
|
||||||
MinimumVisualStudioVersion = 10.0.40219.1
|
MinimumVisualStudioVersion = 10.0.40219.1
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BulletinBoard", "BulletinBoard\BulletinBoard.csproj", "{262F1FD4-C5DD-42F3-B47A-8CB10414C3DE}"
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BulletinBoard", "BulletinBoard\BulletinBoard.csproj", "{262F1FD4-C5DD-42F3-B47A-8CB10414C3DE}"
|
||||||
|
EndProject
|
||||||
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BulletinBoardDataModels", "BulletinBoardDataModels\BulletinBoardDataModels.csproj", "{3A231055-0630-40A9-9CF3-46ED940FC979}"
|
||||||
|
EndProject
|
||||||
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BulletinBoardContracts", "BulletinBoardContracts\BulletinBoardContracts.csproj", "{8919A139-11E5-4694-832F-59F30E9EA9F1}"
|
||||||
|
EndProject
|
||||||
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BulletinBoardBusinessLogic", "BulletinBoardLogic\BulletinBoardBusinessLogic.csproj", "{72DACBCC-49A3-45EF-BCA1-01EFF894AB7C}"
|
||||||
|
EndProject
|
||||||
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BulletinBoardDatabase", "BulletinBoardDatabase\BulletinBoardDatabase.csproj", "{3F3F12A5-6E0B-4AC1-AC39-311C5F9A53D9}"
|
||||||
|
EndProject
|
||||||
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BulletinBoardMongoDB", "BulletinBoardMongoDB\BulletinBoardMongoDB.csproj", "{479AE201-5D20-4238-8C31-C56336CA9120}"
|
||||||
EndProject
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
@ -15,6 +25,26 @@ Global
|
|||||||
{262F1FD4-C5DD-42F3-B47A-8CB10414C3DE}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{262F1FD4-C5DD-42F3-B47A-8CB10414C3DE}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{262F1FD4-C5DD-42F3-B47A-8CB10414C3DE}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{262F1FD4-C5DD-42F3-B47A-8CB10414C3DE}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
{262F1FD4-C5DD-42F3-B47A-8CB10414C3DE}.Release|Any CPU.Build.0 = Release|Any CPU
|
{262F1FD4-C5DD-42F3-B47A-8CB10414C3DE}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{3A231055-0630-40A9-9CF3-46ED940FC979}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{3A231055-0630-40A9-9CF3-46ED940FC979}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{3A231055-0630-40A9-9CF3-46ED940FC979}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{3A231055-0630-40A9-9CF3-46ED940FC979}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{8919A139-11E5-4694-832F-59F30E9EA9F1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{8919A139-11E5-4694-832F-59F30E9EA9F1}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{8919A139-11E5-4694-832F-59F30E9EA9F1}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{8919A139-11E5-4694-832F-59F30E9EA9F1}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{72DACBCC-49A3-45EF-BCA1-01EFF894AB7C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{72DACBCC-49A3-45EF-BCA1-01EFF894AB7C}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{72DACBCC-49A3-45EF-BCA1-01EFF894AB7C}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{72DACBCC-49A3-45EF-BCA1-01EFF894AB7C}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{3F3F12A5-6E0B-4AC1-AC39-311C5F9A53D9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{3F3F12A5-6E0B-4AC1-AC39-311C5F9A53D9}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{3F3F12A5-6E0B-4AC1-AC39-311C5F9A53D9}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{3F3F12A5-6E0B-4AC1-AC39-311C5F9A53D9}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{479AE201-5D20-4238-8C31-C56336CA9120}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{479AE201-5D20-4238-8C31-C56336CA9120}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{479AE201-5D20-4238-8C31-C56336CA9120}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{479AE201-5D20-4238-8C31-C56336CA9120}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
|
@ -1,23 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Data;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace WebsiteForPlacingAds
|
|
||||||
{
|
|
||||||
public abstract class AbstractManagmentDatabase
|
|
||||||
{
|
|
||||||
public abstract DataTable getEntryById(string tableName, int id);
|
|
||||||
public abstract Object getRowTableById(string tableName, string columnName, int id);
|
|
||||||
public abstract Object getRowTableById(DataTable table, string columnName, int i);
|
|
||||||
public abstract void ExecuteNonQuery(string query);
|
|
||||||
public abstract DataTable ExecuteQuery(string query);
|
|
||||||
public abstract DataTable getAllEntry(string tableName);
|
|
||||||
public abstract void insertInto(string tableName, params string[] values);
|
|
||||||
public abstract void deleteEntry(string tableName, int id);
|
|
||||||
public abstract void deleteEntry(string tableName, string name);
|
|
||||||
public abstract void reduceSeq(string seq, int currval);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,274 +0,0 @@
|
|||||||
namespace WebsiteForPlacingAds
|
|
||||||
{
|
|
||||||
partial class CreateAdsForm
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Required designer variable.
|
|
||||||
/// </summary>
|
|
||||||
private System.ComponentModel.IContainer components = null;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Clean up any resources being used.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
|
||||||
protected override void Dispose(bool disposing)
|
|
||||||
{
|
|
||||||
if (disposing && (components != null))
|
|
||||||
{
|
|
||||||
components.Dispose();
|
|
||||||
}
|
|
||||||
base.Dispose(disposing);
|
|
||||||
}
|
|
||||||
|
|
||||||
#region Windows Form Designer generated code
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Required method for Designer support - do not modify
|
|
||||||
/// the contents of this method with the code editor.
|
|
||||||
/// </summary>
|
|
||||||
private void InitializeComponent()
|
|
||||||
{
|
|
||||||
buttonCreateAd = new Button();
|
|
||||||
labelHeading = new Label();
|
|
||||||
textBoxHeading = new TextBox();
|
|
||||||
textBoxPrice = new TextBox();
|
|
||||||
labelPrice = new Label();
|
|
||||||
textBoxDate = new TextBox();
|
|
||||||
labelDate = new Label();
|
|
||||||
labelSubcategory = new Label();
|
|
||||||
labelCategory = new Label();
|
|
||||||
textBoxStatus = new TextBox();
|
|
||||||
labelStatus = new Label();
|
|
||||||
labelClient = new Label();
|
|
||||||
comboBoxSubcategory = new ComboBox();
|
|
||||||
comboBoxCategory = new ComboBox();
|
|
||||||
comboBoxClient = new ComboBox();
|
|
||||||
label1 = new Label();
|
|
||||||
comboBoxCity = new ComboBox();
|
|
||||||
label2 = new Label();
|
|
||||||
comboBoxRegion = new ComboBox();
|
|
||||||
SuspendLayout();
|
|
||||||
//
|
|
||||||
// buttonCreateAd
|
|
||||||
//
|
|
||||||
buttonCreateAd.Location = new Point(43, 443);
|
|
||||||
buttonCreateAd.Margin = new Padding(3, 2, 3, 2);
|
|
||||||
buttonCreateAd.Name = "buttonCreateAd";
|
|
||||||
buttonCreateAd.Size = new Size(239, 29);
|
|
||||||
buttonCreateAd.TabIndex = 0;
|
|
||||||
buttonCreateAd.Text = "Разместить объявление";
|
|
||||||
buttonCreateAd.UseVisualStyleBackColor = true;
|
|
||||||
buttonCreateAd.Click += buttonCreateAd_Click;
|
|
||||||
//
|
|
||||||
// labelHeading
|
|
||||||
//
|
|
||||||
labelHeading.AutoSize = true;
|
|
||||||
labelHeading.Location = new Point(43, 8);
|
|
||||||
labelHeading.Name = "labelHeading";
|
|
||||||
labelHeading.Size = new Size(65, 15);
|
|
||||||
labelHeading.TabIndex = 1;
|
|
||||||
labelHeading.Text = "Заголовок";
|
|
||||||
//
|
|
||||||
// textBoxHeading
|
|
||||||
//
|
|
||||||
textBoxHeading.Location = new Point(43, 26);
|
|
||||||
textBoxHeading.Margin = new Padding(3, 2, 3, 2);
|
|
||||||
textBoxHeading.Name = "textBoxHeading";
|
|
||||||
textBoxHeading.Size = new Size(239, 23);
|
|
||||||
textBoxHeading.TabIndex = 2;
|
|
||||||
//
|
|
||||||
// textBoxPrice
|
|
||||||
//
|
|
||||||
textBoxPrice.Location = new Point(43, 72);
|
|
||||||
textBoxPrice.Margin = new Padding(3, 2, 3, 2);
|
|
||||||
textBoxPrice.Name = "textBoxPrice";
|
|
||||||
textBoxPrice.Size = new Size(239, 23);
|
|
||||||
textBoxPrice.TabIndex = 4;
|
|
||||||
//
|
|
||||||
// labelPrice
|
|
||||||
//
|
|
||||||
labelPrice.AutoSize = true;
|
|
||||||
labelPrice.Location = new Point(43, 55);
|
|
||||||
labelPrice.Name = "labelPrice";
|
|
||||||
labelPrice.Size = new Size(35, 15);
|
|
||||||
labelPrice.TabIndex = 3;
|
|
||||||
labelPrice.Text = "Цена";
|
|
||||||
//
|
|
||||||
// textBoxDate
|
|
||||||
//
|
|
||||||
textBoxDate.Location = new Point(43, 118);
|
|
||||||
textBoxDate.Margin = new Padding(3, 2, 3, 2);
|
|
||||||
textBoxDate.Name = "textBoxDate";
|
|
||||||
textBoxDate.Size = new Size(239, 23);
|
|
||||||
textBoxDate.TabIndex = 6;
|
|
||||||
//
|
|
||||||
// labelDate
|
|
||||||
//
|
|
||||||
labelDate.AutoSize = true;
|
|
||||||
labelDate.Location = new Point(43, 101);
|
|
||||||
labelDate.Name = "labelDate";
|
|
||||||
labelDate.Size = new Size(105, 15);
|
|
||||||
labelDate.TabIndex = 5;
|
|
||||||
labelDate.Text = "Дата размещения";
|
|
||||||
//
|
|
||||||
// labelSubcategory
|
|
||||||
//
|
|
||||||
labelSubcategory.AutoSize = true;
|
|
||||||
labelSubcategory.Location = new Point(43, 292);
|
|
||||||
labelSubcategory.Name = "labelSubcategory";
|
|
||||||
labelSubcategory.Size = new Size(84, 15);
|
|
||||||
labelSubcategory.TabIndex = 11;
|
|
||||||
labelSubcategory.Text = "Подкатегория";
|
|
||||||
//
|
|
||||||
// labelCategory
|
|
||||||
//
|
|
||||||
labelCategory.AutoSize = true;
|
|
||||||
labelCategory.Location = new Point(43, 246);
|
|
||||||
labelCategory.Name = "labelCategory";
|
|
||||||
labelCategory.Size = new Size(63, 15);
|
|
||||||
labelCategory.TabIndex = 9;
|
|
||||||
labelCategory.Text = "Категория";
|
|
||||||
//
|
|
||||||
// textBoxStatus
|
|
||||||
//
|
|
||||||
textBoxStatus.Location = new Point(43, 166);
|
|
||||||
textBoxStatus.Margin = new Padding(3, 2, 3, 2);
|
|
||||||
textBoxStatus.Name = "textBoxStatus";
|
|
||||||
textBoxStatus.Size = new Size(239, 23);
|
|
||||||
textBoxStatus.TabIndex = 8;
|
|
||||||
//
|
|
||||||
// labelStatus
|
|
||||||
//
|
|
||||||
labelStatus.AutoSize = true;
|
|
||||||
labelStatus.Location = new Point(43, 148);
|
|
||||||
labelStatus.Name = "labelStatus";
|
|
||||||
labelStatus.Size = new Size(43, 15);
|
|
||||||
labelStatus.TabIndex = 7;
|
|
||||||
labelStatus.Text = "Статус";
|
|
||||||
//
|
|
||||||
// labelClient
|
|
||||||
//
|
|
||||||
labelClient.AutoSize = true;
|
|
||||||
labelClient.Location = new Point(43, 196);
|
|
||||||
labelClient.Name = "labelClient";
|
|
||||||
labelClient.Size = new Size(46, 15);
|
|
||||||
labelClient.TabIndex = 13;
|
|
||||||
labelClient.Text = "Клиент";
|
|
||||||
//
|
|
||||||
// comboBoxSubcategory
|
|
||||||
//
|
|
||||||
comboBoxSubcategory.FormattingEnabled = true;
|
|
||||||
comboBoxSubcategory.Location = new Point(43, 310);
|
|
||||||
comboBoxSubcategory.Margin = new Padding(3, 2, 3, 2);
|
|
||||||
comboBoxSubcategory.Name = "comboBoxSubcategory";
|
|
||||||
comboBoxSubcategory.Size = new Size(239, 23);
|
|
||||||
comboBoxSubcategory.TabIndex = 15;
|
|
||||||
//
|
|
||||||
// comboBoxCategory
|
|
||||||
//
|
|
||||||
comboBoxCategory.FormattingEnabled = true;
|
|
||||||
comboBoxCategory.Location = new Point(43, 263);
|
|
||||||
comboBoxCategory.Margin = new Padding(3, 2, 3, 2);
|
|
||||||
comboBoxCategory.Name = "comboBoxCategory";
|
|
||||||
comboBoxCategory.Size = new Size(239, 23);
|
|
||||||
comboBoxCategory.TabIndex = 16;
|
|
||||||
//
|
|
||||||
// comboBoxClient
|
|
||||||
//
|
|
||||||
comboBoxClient.FormattingEnabled = true;
|
|
||||||
comboBoxClient.Location = new Point(43, 213);
|
|
||||||
comboBoxClient.Margin = new Padding(3, 2, 3, 2);
|
|
||||||
comboBoxClient.Name = "comboBoxClient";
|
|
||||||
comboBoxClient.Size = new Size(239, 23);
|
|
||||||
comboBoxClient.TabIndex = 17;
|
|
||||||
//
|
|
||||||
// label1
|
|
||||||
//
|
|
||||||
label1.AutoSize = true;
|
|
||||||
label1.Location = new Point(43, 341);
|
|
||||||
label1.Name = "label1";
|
|
||||||
label1.Size = new Size(46, 15);
|
|
||||||
label1.TabIndex = 22;
|
|
||||||
label1.Text = "Регион";
|
|
||||||
//
|
|
||||||
// comboBoxCity
|
|
||||||
//
|
|
||||||
comboBoxCity.FormattingEnabled = true;
|
|
||||||
comboBoxCity.Location = new Point(43, 400);
|
|
||||||
comboBoxCity.Margin = new Padding(3, 2, 3, 2);
|
|
||||||
comboBoxCity.Name = "comboBoxCity";
|
|
||||||
comboBoxCity.Size = new Size(239, 23);
|
|
||||||
comboBoxCity.TabIndex = 23;
|
|
||||||
//
|
|
||||||
// label2
|
|
||||||
//
|
|
||||||
label2.AutoSize = true;
|
|
||||||
label2.Location = new Point(43, 384);
|
|
||||||
label2.Name = "label2";
|
|
||||||
label2.Size = new Size(40, 15);
|
|
||||||
label2.TabIndex = 24;
|
|
||||||
label2.Text = "Город";
|
|
||||||
//
|
|
||||||
// comboBoxRegion
|
|
||||||
//
|
|
||||||
comboBoxRegion.FormattingEnabled = true;
|
|
||||||
comboBoxRegion.Location = new Point(43, 359);
|
|
||||||
comboBoxRegion.Margin = new Padding(3, 2, 3, 2);
|
|
||||||
comboBoxRegion.Name = "comboBoxRegion";
|
|
||||||
comboBoxRegion.Size = new Size(239, 23);
|
|
||||||
comboBoxRegion.TabIndex = 25;
|
|
||||||
//
|
|
||||||
// CreateAdsForm
|
|
||||||
//
|
|
||||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
|
||||||
AutoScaleMode = AutoScaleMode.Font;
|
|
||||||
ClientSize = new Size(324, 483);
|
|
||||||
Controls.Add(label2);
|
|
||||||
Controls.Add(label1);
|
|
||||||
Controls.Add(comboBoxRegion);
|
|
||||||
Controls.Add(comboBoxCity);
|
|
||||||
Controls.Add(comboBoxClient);
|
|
||||||
Controls.Add(comboBoxCategory);
|
|
||||||
Controls.Add(comboBoxSubcategory);
|
|
||||||
Controls.Add(labelClient);
|
|
||||||
Controls.Add(labelSubcategory);
|
|
||||||
Controls.Add(labelCategory);
|
|
||||||
Controls.Add(textBoxStatus);
|
|
||||||
Controls.Add(labelStatus);
|
|
||||||
Controls.Add(textBoxDate);
|
|
||||||
Controls.Add(labelDate);
|
|
||||||
Controls.Add(textBoxPrice);
|
|
||||||
Controls.Add(labelPrice);
|
|
||||||
Controls.Add(textBoxHeading);
|
|
||||||
Controls.Add(labelHeading);
|
|
||||||
Controls.Add(buttonCreateAd);
|
|
||||||
Margin = new Padding(3, 2, 3, 2);
|
|
||||||
Name = "CreateAdsForm";
|
|
||||||
Text = "Объявления";
|
|
||||||
ResumeLayout(false);
|
|
||||||
PerformLayout();
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
private Button buttonCreateAd;
|
|
||||||
private Label labelHeading;
|
|
||||||
private TextBox textBoxHeading;
|
|
||||||
private TextBox textBoxPrice;
|
|
||||||
private Label labelPrice;
|
|
||||||
private TextBox textBoxDate;
|
|
||||||
private Label labelDate;
|
|
||||||
private Label labelSubcategory;
|
|
||||||
private Label labelCategory;
|
|
||||||
private TextBox textBoxStatus;
|
|
||||||
private Label labelStatus;
|
|
||||||
private Label labelClient;
|
|
||||||
private ComboBox comboBoxSubcategory;
|
|
||||||
private ComboBox comboBoxCategory;
|
|
||||||
private ComboBox comboBoxClient;
|
|
||||||
private Label label1;
|
|
||||||
private ComboBox comboBoxRegion;
|
|
||||||
private Label label2;
|
|
||||||
private ComboBox comboBoxCity;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,103 +0,0 @@
|
|||||||
using System.Data;
|
|
||||||
|
|
||||||
namespace WebsiteForPlacingAds
|
|
||||||
{
|
|
||||||
public partial class CreateAdsForm : Form
|
|
||||||
{
|
|
||||||
AbstractManagmentDatabase managmentDatabase;
|
|
||||||
public CreateAdsForm(AbstractManagmentDatabase managmentDatabase)
|
|
||||||
{
|
|
||||||
InitializeComponent();
|
|
||||||
this.managmentDatabase = managmentDatabase;
|
|
||||||
LoadData();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void buttonCreateAd_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
string[] client = comboBoxClient.SelectedItem.ToString().Split(" ");
|
|
||||||
string[] category = comboBoxCategory.SelectedItem.ToString().Split(" ");
|
|
||||||
string[] subcategory = comboBoxSubcategory.SelectedItem.ToString().Split(" ");
|
|
||||||
string[] region = comboBoxCategory.SelectedItem.ToString().Split(" ");
|
|
||||||
string[] city = comboBoxSubcategory.SelectedItem.ToString().Split(" ");
|
|
||||||
|
|
||||||
string heading = textBoxHeading.Text;
|
|
||||||
string price = textBoxPrice.Text;
|
|
||||||
string date = textBoxDate.Text;
|
|
||||||
string status = textBoxStatus.Text;
|
|
||||||
string client_id = client[0];
|
|
||||||
string category_id = category[0];
|
|
||||||
string subcategory_id = subcategory[0];
|
|
||||||
string region_id = region[0];
|
|
||||||
string city_id = city[0];
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
DateTime start = DateTime.Now;
|
|
||||||
|
|
||||||
managmentDatabase.insertInto("ads", $"'{heading}'", price, $"'{date}'", $"'{status}'", client_id, category_id, subcategory_id, region_id, city_id);
|
|
||||||
MessageBox.Show("Äîáàâëåíî!");
|
|
||||||
LoadData();
|
|
||||||
|
|
||||||
DateTime end = DateTime.Now;
|
|
||||||
TimeSpan duration = end - start;
|
|
||||||
MessageBox.Show($"Äîáàâëåíî! Âðåìÿ âûïîëíåíèÿ: {duration.TotalMilliseconds} ìñ");
|
|
||||||
|
|
||||||
// Çàêðûòü òåêóùóþ ôîðìó ïîñëå âûïîëíåíèÿ äåéñòâèé
|
|
||||||
this.Close();
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
MessageBox.Show("Íå óäàëîñü äîáàâèòü");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void LoadData()
|
|
||||||
{
|
|
||||||
comboBoxCategory.Items.Clear();
|
|
||||||
comboBoxSubcategory.Items.Clear();
|
|
||||||
comboBoxClient.Items.Clear();
|
|
||||||
comboBoxRegion.Items.Clear();
|
|
||||||
comboBoxCity.Items.Clear();
|
|
||||||
DataTable result = managmentDatabase.getAllEntry("CATEGORIES");
|
|
||||||
string[] id_names = new string[result.Rows.Count];
|
|
||||||
for (int i = 0; i < result.Rows.Count; i++)
|
|
||||||
{
|
|
||||||
id_names[i] = managmentDatabase.getRowTableById(result, "categories_id", i).ToString() + ". " + managmentDatabase.getRowTableById(result, "name", i).ToString();
|
|
||||||
comboBoxCategory.Items.Add(id_names[i]);
|
|
||||||
}
|
|
||||||
|
|
||||||
result = managmentDatabase.getAllEntry("SUBCATEGORIES");
|
|
||||||
id_names = new string[result.Rows.Count];
|
|
||||||
for (int i = 0; i < result.Rows.Count; i++)
|
|
||||||
{
|
|
||||||
id_names[i] = managmentDatabase.getRowTableById(result, "subcategories_id", i).ToString() + ". " + managmentDatabase.getRowTableById(result, "name", i).ToString();
|
|
||||||
comboBoxSubcategory.Items.Add(id_names[i]);
|
|
||||||
}
|
|
||||||
|
|
||||||
result = managmentDatabase.getAllEntry("CLIENTS");
|
|
||||||
string[] id_names_surnames = new string[result.Rows.Count];
|
|
||||||
for (int i = 0; i < result.Rows.Count; i++)
|
|
||||||
{
|
|
||||||
id_names_surnames[i] = managmentDatabase.getRowTableById(result, "clients_id", i).ToString().Trim() + ". " + managmentDatabase.getRowTableById(result, "name", i).ToString().Trim() + " " + managmentDatabase.getRowTableById(result, "surname", i).ToString().Trim();
|
|
||||||
comboBoxClient.Items.Add(id_names_surnames[i]);
|
|
||||||
}
|
|
||||||
|
|
||||||
result = managmentDatabase.getAllEntry("REGIONS");
|
|
||||||
id_names = new string[result.Rows.Count];
|
|
||||||
for (int i = 0; i < result.Rows.Count; i++)
|
|
||||||
{
|
|
||||||
id_names[i] = managmentDatabase.getRowTableById(result, "regions_id", i).ToString() + ". " + managmentDatabase.getRowTableById(result, "name", i).ToString();
|
|
||||||
comboBoxRegion.Items.Add(id_names[i]);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
result = managmentDatabase.getAllEntry("CITIES");
|
|
||||||
id_names = new string[result.Rows.Count];
|
|
||||||
for (int i = 0; i < result.Rows.Count; i++)
|
|
||||||
{
|
|
||||||
id_names[i] = managmentDatabase.getRowTableById(result, "cities_id", i).ToString() + ". " + managmentDatabase.getRowTableById(result, "name", i).ToString();
|
|
||||||
comboBoxCity.Items.Add(id_names[i]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,84 +0,0 @@
|
|||||||
namespace WebsiteForPlacingAds
|
|
||||||
{
|
|
||||||
partial class DeleteAdsForm
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Required designer variable.
|
|
||||||
/// </summary>
|
|
||||||
private System.ComponentModel.IContainer components = null;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Clean up any resources being used.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
|
||||||
protected override void Dispose(bool disposing)
|
|
||||||
{
|
|
||||||
if (disposing && (components != null))
|
|
||||||
{
|
|
||||||
components.Dispose();
|
|
||||||
}
|
|
||||||
base.Dispose(disposing);
|
|
||||||
}
|
|
||||||
|
|
||||||
#region Windows Form Designer generated code
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Required method for Designer support - do not modify
|
|
||||||
/// the contents of this method with the code editor.
|
|
||||||
/// </summary>
|
|
||||||
private void InitializeComponent()
|
|
||||||
{
|
|
||||||
this.label1 = new System.Windows.Forms.Label();
|
|
||||||
this.buttonDeleteAd = new System.Windows.Forms.Button();
|
|
||||||
this.comboBoxDeleteAds = new System.Windows.Forms.ComboBox();
|
|
||||||
this.SuspendLayout();
|
|
||||||
//
|
|
||||||
// label1
|
|
||||||
//
|
|
||||||
this.label1.AutoSize = true;
|
|
||||||
this.label1.Location = new System.Drawing.Point(80, 22);
|
|
||||||
this.label1.Name = "label1";
|
|
||||||
this.label1.Size = new System.Drawing.Size(338, 20);
|
|
||||||
this.label1.TabIndex = 0;
|
|
||||||
this.label1.Text = "Выберите объявление, которое хотите удалить";
|
|
||||||
//
|
|
||||||
// buttonDeleteAd
|
|
||||||
//
|
|
||||||
this.buttonDeleteAd.Location = new System.Drawing.Point(151, 113);
|
|
||||||
this.buttonDeleteAd.Name = "buttonDeleteAd";
|
|
||||||
this.buttonDeleteAd.Size = new System.Drawing.Size(186, 37);
|
|
||||||
this.buttonDeleteAd.TabIndex = 1;
|
|
||||||
this.buttonDeleteAd.Text = "Удалить";
|
|
||||||
this.buttonDeleteAd.UseVisualStyleBackColor = true;
|
|
||||||
this.buttonDeleteAd.Click += new System.EventHandler(this.buttonDeleteAd_Click);
|
|
||||||
//
|
|
||||||
// comboBoxDeleteAds
|
|
||||||
//
|
|
||||||
this.comboBoxDeleteAds.FormattingEnabled = true;
|
|
||||||
this.comboBoxDeleteAds.Location = new System.Drawing.Point(40, 64);
|
|
||||||
this.comboBoxDeleteAds.Name = "comboBoxDeleteAds";
|
|
||||||
this.comboBoxDeleteAds.Size = new System.Drawing.Size(419, 28);
|
|
||||||
this.comboBoxDeleteAds.TabIndex = 2;
|
|
||||||
//
|
|
||||||
// DeleteAdsForm
|
|
||||||
//
|
|
||||||
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
|
|
||||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
|
||||||
this.ClientSize = new System.Drawing.Size(505, 175);
|
|
||||||
this.Controls.Add(this.comboBoxDeleteAds);
|
|
||||||
this.Controls.Add(this.buttonDeleteAd);
|
|
||||||
this.Controls.Add(this.label1);
|
|
||||||
this.Name = "DeleteAdsForm";
|
|
||||||
this.Text = "Удалить объявление";
|
|
||||||
this.ResumeLayout(false);
|
|
||||||
this.PerformLayout();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
private Label label1;
|
|
||||||
private Button buttonDeleteAd;
|
|
||||||
private ComboBox comboBoxDeleteAds;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,71 +0,0 @@
|
|||||||
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 WebsiteForPlacingAds
|
|
||||||
{
|
|
||||||
public partial class DeleteAdsForm : Form
|
|
||||||
{
|
|
||||||
AbstractManagmentDatabase managmentDatabase;
|
|
||||||
private int setval_seq;
|
|
||||||
public DeleteAdsForm(AbstractManagmentDatabase managmentDatabase)
|
|
||||||
{
|
|
||||||
InitializeComponent();
|
|
||||||
this.managmentDatabase = managmentDatabase;
|
|
||||||
LoadData();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void buttonDeleteAd_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
string[] ads = comboBoxDeleteAds.SelectedItem.ToString().Split("|");
|
|
||||||
string ad_id = ads[0].Trim();
|
|
||||||
string query = $"DELETE FROM ADS WHERE ads_id = {ad_id}";
|
|
||||||
string query_seq_reduction = $"SELECT setval('seq_ads', {setval_seq - 1});";
|
|
||||||
try
|
|
||||||
{
|
|
||||||
DateTime start = DateTime.Now;
|
|
||||||
|
|
||||||
managmentDatabase.deleteEntry("ads", int.Parse(ad_id));
|
|
||||||
if (setval_seq > 0) managmentDatabase.reduceSeq("seq_ads", setval_seq);
|
|
||||||
MessageBox.Show("Удалено!");
|
|
||||||
LoadData();
|
|
||||||
|
|
||||||
DateTime end = DateTime.Now;
|
|
||||||
TimeSpan duration = end - start;
|
|
||||||
MessageBox.Show($"Добавлено! Время выполнения: {duration.TotalMilliseconds} мс");
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
MessageBox.Show("Не удалось удалить");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
public void LoadData()
|
|
||||||
{
|
|
||||||
comboBoxDeleteAds.Items.Clear();
|
|
||||||
DataTable result = managmentDatabase.getAllEntry("ADS");
|
|
||||||
setval_seq = result.Rows.Count;
|
|
||||||
string Ads = "";
|
|
||||||
for (int i = 0; i < result.Rows.Count; i++)
|
|
||||||
{
|
|
||||||
setval_seq = Math.Max(Convert.ToInt32(managmentDatabase.getRowTableById(result, "ads_id", i)), setval_seq);
|
|
||||||
Ads = managmentDatabase.getRowTableById(result, "ads_id", i).ToString() + " | " +
|
|
||||||
managmentDatabase.getRowTableById(result, "heading", i).ToString() + " | " +
|
|
||||||
managmentDatabase.getRowTableById(result, "price", i).ToString() + " | " +
|
|
||||||
((DateTime)managmentDatabase.getRowTableById(result, "date_of_placement", i)).ToString("dd.MM.yyy") + " | " +
|
|
||||||
managmentDatabase.getRowTableById(result, "status", i).ToString() + " | " +
|
|
||||||
managmentDatabase.getRowTableById(result, "client_id", i).ToString() + " | " +
|
|
||||||
managmentDatabase.getRowTableById(result, "category_id", i).ToString() + " | " +
|
|
||||||
managmentDatabase.getRowTableById(result, "subcategory_id", i).ToString() + " | " +
|
|
||||||
managmentDatabase.getRowTableById(result, "region_id", i).ToString() + " | " +
|
|
||||||
managmentDatabase.getRowTableById(result, "city_id", i).ToString() + "\n";
|
|
||||||
comboBoxDeleteAds.Items.Add(Ads);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,74 +0,0 @@
|
|||||||
namespace WebsiteForPlacingAds
|
|
||||||
{
|
|
||||||
partial class ListAdsForm
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Required designer variable.
|
|
||||||
/// </summary>
|
|
||||||
private System.ComponentModel.IContainer components = null;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Clean up any resources being used.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
|
||||||
protected override void Dispose(bool disposing)
|
|
||||||
{
|
|
||||||
if (disposing && (components != null))
|
|
||||||
{
|
|
||||||
components.Dispose();
|
|
||||||
}
|
|
||||||
base.Dispose(disposing);
|
|
||||||
}
|
|
||||||
|
|
||||||
#region Windows Form Designer generated code
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Required method for Designer support - do not modify
|
|
||||||
/// the contents of this method with the code editor.
|
|
||||||
/// </summary>
|
|
||||||
private void InitializeComponent()
|
|
||||||
{
|
|
||||||
this.label1 = new System.Windows.Forms.Label();
|
|
||||||
this.labelListAds = new System.Windows.Forms.Label();
|
|
||||||
this.SuspendLayout();
|
|
||||||
//
|
|
||||||
// label1
|
|
||||||
//
|
|
||||||
this.label1.AutoSize = true;
|
|
||||||
this.label1.BackColor = System.Drawing.SystemColors.Control;
|
|
||||||
this.label1.Font = new System.Drawing.Font("Segoe UI", 11F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
|
|
||||||
this.label1.Location = new System.Drawing.Point(12, 9);
|
|
||||||
this.label1.Name = "label1";
|
|
||||||
this.label1.Size = new System.Drawing.Size(186, 25);
|
|
||||||
this.label1.TabIndex = 0;
|
|
||||||
this.label1.Text = "Список объявлений";
|
|
||||||
//
|
|
||||||
// labelListAds
|
|
||||||
//
|
|
||||||
this.labelListAds.AutoSize = true;
|
|
||||||
this.labelListAds.Font = new System.Drawing.Font("Segoe UI", 10F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
|
|
||||||
this.labelListAds.Location = new System.Drawing.Point(12, 47);
|
|
||||||
this.labelListAds.Name = "labelListAds";
|
|
||||||
this.labelListAds.Size = new System.Drawing.Size(0, 23);
|
|
||||||
this.labelListAds.TabIndex = 1;
|
|
||||||
//
|
|
||||||
// ListAdsForm
|
|
||||||
//
|
|
||||||
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
|
|
||||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
|
||||||
this.ClientSize = new System.Drawing.Size(800, 450);
|
|
||||||
this.Controls.Add(this.labelListAds);
|
|
||||||
this.Controls.Add(this.label1);
|
|
||||||
this.Name = "ListAdsForm";
|
|
||||||
this.Text = "ListAdsForm";
|
|
||||||
this.ResumeLayout(false);
|
|
||||||
this.PerformLayout();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
private Label label1;
|
|
||||||
private Label labelListAds;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,50 +0,0 @@
|
|||||||
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 System.Windows.Forms.VisualStyles;
|
|
||||||
|
|
||||||
namespace WebsiteForPlacingAds
|
|
||||||
{
|
|
||||||
public partial class ListAdsForm : Form
|
|
||||||
{
|
|
||||||
AbstractManagmentDatabase managmentDatabase;
|
|
||||||
public ListAdsForm(AbstractManagmentDatabase managmentDatabase)
|
|
||||||
{
|
|
||||||
InitializeComponent();
|
|
||||||
this.managmentDatabase = managmentDatabase;
|
|
||||||
LoadData();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void LoadData()
|
|
||||||
{
|
|
||||||
DateTime start = DateTime.Now;
|
|
||||||
|
|
||||||
DataTable result = managmentDatabase.getAllEntry("ADS");
|
|
||||||
string listAds = "";
|
|
||||||
for (int i = 0; i < result.Rows.Count; i++)
|
|
||||||
{
|
|
||||||
listAds += managmentDatabase.getRowTableById(result, "ads_id", i).ToString() + " | " +
|
|
||||||
managmentDatabase.getRowTableById(result, "heading", i).ToString() + " | " +
|
|
||||||
managmentDatabase.getRowTableById(result, "price", i).ToString() + " | " +
|
|
||||||
((DateTime)managmentDatabase.getRowTableById(result, "date_of_placement", i)).ToString("dd.MM.yyy") + " | " +
|
|
||||||
managmentDatabase.getRowTableById(result, "status", i).ToString() + " | " +
|
|
||||||
managmentDatabase.getRowTableById(result, "client_id", i).ToString() + " | " +
|
|
||||||
managmentDatabase.getRowTableById(result, "category_id", i).ToString() + " | " +
|
|
||||||
managmentDatabase.getRowTableById(result, "subcategory_id", i).ToString() + " | " +
|
|
||||||
managmentDatabase.getRowTableById(result, "region_id", i).ToString() + " | " +
|
|
||||||
managmentDatabase.getRowTableById(result, "city_id", i).ToString() + "\n";
|
|
||||||
}
|
|
||||||
labelListAds.Text = listAds;
|
|
||||||
|
|
||||||
DateTime end = DateTime.Now;
|
|
||||||
TimeSpan duration = end - start;
|
|
||||||
MessageBox.Show($"Список загружен! Время выполнения: {duration.TotalMilliseconds} мс");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,251 +0,0 @@
|
|||||||
namespace WebsiteForPlacingAds
|
|
||||||
{
|
|
||||||
partial class UpdateAdsForm
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Required designer variable.
|
|
||||||
/// </summary>
|
|
||||||
private System.ComponentModel.IContainer components = null;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Clean up any resources being used.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
|
||||||
protected override void Dispose(bool disposing)
|
|
||||||
{
|
|
||||||
if (disposing && (components != null))
|
|
||||||
{
|
|
||||||
components.Dispose();
|
|
||||||
}
|
|
||||||
base.Dispose(disposing);
|
|
||||||
}
|
|
||||||
|
|
||||||
#region Windows Form Designer generated code
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Required method for Designer support - do not modify
|
|
||||||
/// the contents of this method with the code editor.
|
|
||||||
/// </summary>
|
|
||||||
private void InitializeComponent()
|
|
||||||
{
|
|
||||||
comboBoxClient = new ComboBox();
|
|
||||||
comboBoxCategory = new ComboBox();
|
|
||||||
comboBoxSubcategory = new ComboBox();
|
|
||||||
labelClient = new Label();
|
|
||||||
labelSubcategory = new Label();
|
|
||||||
labelCategory = new Label();
|
|
||||||
textBoxStatus = new TextBox();
|
|
||||||
labelStatus = new Label();
|
|
||||||
textBoxDate = new TextBox();
|
|
||||||
labelDate = new Label();
|
|
||||||
textBoxPrice = new TextBox();
|
|
||||||
labelPrice = new Label();
|
|
||||||
textBoxHeading = new TextBox();
|
|
||||||
labelHeading = new Label();
|
|
||||||
buttonUpdateAd = new Button();
|
|
||||||
label1 = new Label();
|
|
||||||
comboBoxUpdateAd = new ComboBox();
|
|
||||||
SuspendLayout();
|
|
||||||
//
|
|
||||||
// comboBoxClient
|
|
||||||
//
|
|
||||||
comboBoxClient.FormattingEnabled = true;
|
|
||||||
comboBoxClient.Location = new Point(81, 278);
|
|
||||||
comboBoxClient.Margin = new Padding(3, 2, 3, 2);
|
|
||||||
comboBoxClient.Name = "comboBoxClient";
|
|
||||||
comboBoxClient.Size = new Size(239, 23);
|
|
||||||
comboBoxClient.TabIndex = 32;
|
|
||||||
//
|
|
||||||
// comboBoxCategory
|
|
||||||
//
|
|
||||||
comboBoxCategory.FormattingEnabled = true;
|
|
||||||
comboBoxCategory.Location = new Point(81, 328);
|
|
||||||
comboBoxCategory.Margin = new Padding(3, 2, 3, 2);
|
|
||||||
comboBoxCategory.Name = "comboBoxCategory";
|
|
||||||
comboBoxCategory.Size = new Size(239, 23);
|
|
||||||
comboBoxCategory.TabIndex = 31;
|
|
||||||
//
|
|
||||||
// comboBoxSubcategory
|
|
||||||
//
|
|
||||||
comboBoxSubcategory.FormattingEnabled = true;
|
|
||||||
comboBoxSubcategory.Location = new Point(81, 375);
|
|
||||||
comboBoxSubcategory.Margin = new Padding(3, 2, 3, 2);
|
|
||||||
comboBoxSubcategory.Name = "comboBoxSubcategory";
|
|
||||||
comboBoxSubcategory.Size = new Size(239, 23);
|
|
||||||
comboBoxSubcategory.TabIndex = 30;
|
|
||||||
//
|
|
||||||
// labelClient
|
|
||||||
//
|
|
||||||
labelClient.AutoSize = true;
|
|
||||||
labelClient.Location = new Point(81, 261);
|
|
||||||
labelClient.Name = "labelClient";
|
|
||||||
labelClient.Size = new Size(46, 15);
|
|
||||||
labelClient.TabIndex = 29;
|
|
||||||
labelClient.Text = "Клиент";
|
|
||||||
//
|
|
||||||
// labelSubcategory
|
|
||||||
//
|
|
||||||
labelSubcategory.AutoSize = true;
|
|
||||||
labelSubcategory.Location = new Point(81, 358);
|
|
||||||
labelSubcategory.Name = "labelSubcategory";
|
|
||||||
labelSubcategory.Size = new Size(84, 15);
|
|
||||||
labelSubcategory.TabIndex = 28;
|
|
||||||
labelSubcategory.Text = "Подкатегория";
|
|
||||||
//
|
|
||||||
// labelCategory
|
|
||||||
//
|
|
||||||
labelCategory.AutoSize = true;
|
|
||||||
labelCategory.Location = new Point(81, 311);
|
|
||||||
labelCategory.Name = "labelCategory";
|
|
||||||
labelCategory.Size = new Size(63, 15);
|
|
||||||
labelCategory.TabIndex = 27;
|
|
||||||
labelCategory.Text = "Категория";
|
|
||||||
//
|
|
||||||
// textBoxStatus
|
|
||||||
//
|
|
||||||
textBoxStatus.Location = new Point(81, 231);
|
|
||||||
textBoxStatus.Margin = new Padding(3, 2, 3, 2);
|
|
||||||
textBoxStatus.Name = "textBoxStatus";
|
|
||||||
textBoxStatus.Size = new Size(239, 23);
|
|
||||||
textBoxStatus.TabIndex = 26;
|
|
||||||
//
|
|
||||||
// labelStatus
|
|
||||||
//
|
|
||||||
labelStatus.AutoSize = true;
|
|
||||||
labelStatus.Location = new Point(81, 214);
|
|
||||||
labelStatus.Name = "labelStatus";
|
|
||||||
labelStatus.Size = new Size(43, 15);
|
|
||||||
labelStatus.TabIndex = 25;
|
|
||||||
labelStatus.Text = "Статус";
|
|
||||||
//
|
|
||||||
// textBoxDate
|
|
||||||
//
|
|
||||||
textBoxDate.Location = new Point(81, 184);
|
|
||||||
textBoxDate.Margin = new Padding(3, 2, 3, 2);
|
|
||||||
textBoxDate.Name = "textBoxDate";
|
|
||||||
textBoxDate.Size = new Size(239, 23);
|
|
||||||
textBoxDate.TabIndex = 24;
|
|
||||||
//
|
|
||||||
// labelDate
|
|
||||||
//
|
|
||||||
labelDate.AutoSize = true;
|
|
||||||
labelDate.Location = new Point(81, 166);
|
|
||||||
labelDate.Name = "labelDate";
|
|
||||||
labelDate.Size = new Size(105, 15);
|
|
||||||
labelDate.TabIndex = 23;
|
|
||||||
labelDate.Text = "Дата размещения";
|
|
||||||
//
|
|
||||||
// textBoxPrice
|
|
||||||
//
|
|
||||||
textBoxPrice.Location = new Point(81, 137);
|
|
||||||
textBoxPrice.Margin = new Padding(3, 2, 3, 2);
|
|
||||||
textBoxPrice.Name = "textBoxPrice";
|
|
||||||
textBoxPrice.Size = new Size(239, 23);
|
|
||||||
textBoxPrice.TabIndex = 22;
|
|
||||||
//
|
|
||||||
// labelPrice
|
|
||||||
//
|
|
||||||
labelPrice.AutoSize = true;
|
|
||||||
labelPrice.Location = new Point(81, 120);
|
|
||||||
labelPrice.Name = "labelPrice";
|
|
||||||
labelPrice.Size = new Size(35, 15);
|
|
||||||
labelPrice.TabIndex = 21;
|
|
||||||
labelPrice.Text = "Цена";
|
|
||||||
//
|
|
||||||
// textBoxHeading
|
|
||||||
//
|
|
||||||
textBoxHeading.Location = new Point(81, 91);
|
|
||||||
textBoxHeading.Margin = new Padding(3, 2, 3, 2);
|
|
||||||
textBoxHeading.Name = "textBoxHeading";
|
|
||||||
textBoxHeading.Size = new Size(239, 23);
|
|
||||||
textBoxHeading.TabIndex = 20;
|
|
||||||
//
|
|
||||||
// labelHeading
|
|
||||||
//
|
|
||||||
labelHeading.AutoSize = true;
|
|
||||||
labelHeading.Location = new Point(81, 74);
|
|
||||||
labelHeading.Name = "labelHeading";
|
|
||||||
labelHeading.Size = new Size(65, 15);
|
|
||||||
labelHeading.TabIndex = 19;
|
|
||||||
labelHeading.Text = "Заголовок";
|
|
||||||
//
|
|
||||||
// buttonUpdateAd
|
|
||||||
//
|
|
||||||
buttonUpdateAd.Location = new Point(81, 425);
|
|
||||||
buttonUpdateAd.Margin = new Padding(3, 2, 3, 2);
|
|
||||||
buttonUpdateAd.Name = "buttonUpdateAd";
|
|
||||||
buttonUpdateAd.Size = new Size(239, 29);
|
|
||||||
buttonUpdateAd.TabIndex = 18;
|
|
||||||
buttonUpdateAd.Text = "Изменить объявление";
|
|
||||||
buttonUpdateAd.UseVisualStyleBackColor = true;
|
|
||||||
buttonUpdateAd.Click += buttonUpdateAd_Click;
|
|
||||||
//
|
|
||||||
// label1
|
|
||||||
//
|
|
||||||
label1.AutoSize = true;
|
|
||||||
label1.Location = new Point(51, 15);
|
|
||||||
label1.Name = "label1";
|
|
||||||
label1.Size = new Size(275, 15);
|
|
||||||
label1.TabIndex = 33;
|
|
||||||
label1.Text = "Выберите объявление, которое хотите обновить";
|
|
||||||
//
|
|
||||||
// comboBoxUpdateAd
|
|
||||||
//
|
|
||||||
comboBoxUpdateAd.FormattingEnabled = true;
|
|
||||||
comboBoxUpdateAd.Location = new Point(10, 39);
|
|
||||||
comboBoxUpdateAd.Margin = new Padding(3, 2, 3, 2);
|
|
||||||
comboBoxUpdateAd.Name = "comboBoxUpdateAd";
|
|
||||||
comboBoxUpdateAd.Size = new Size(377, 23);
|
|
||||||
comboBoxUpdateAd.TabIndex = 34;
|
|
||||||
comboBoxUpdateAd.SelectedIndexChanged += comboBoxUpdateAd_SelectedIndexChanged;
|
|
||||||
//
|
|
||||||
// UpdateAdsForm
|
|
||||||
//
|
|
||||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
|
||||||
AutoScaleMode = AutoScaleMode.Font;
|
|
||||||
ClientSize = new Size(397, 473);
|
|
||||||
Controls.Add(comboBoxUpdateAd);
|
|
||||||
Controls.Add(label1);
|
|
||||||
Controls.Add(comboBoxClient);
|
|
||||||
Controls.Add(comboBoxCategory);
|
|
||||||
Controls.Add(comboBoxSubcategory);
|
|
||||||
Controls.Add(labelClient);
|
|
||||||
Controls.Add(labelSubcategory);
|
|
||||||
Controls.Add(labelCategory);
|
|
||||||
Controls.Add(textBoxStatus);
|
|
||||||
Controls.Add(labelStatus);
|
|
||||||
Controls.Add(textBoxDate);
|
|
||||||
Controls.Add(labelDate);
|
|
||||||
Controls.Add(textBoxPrice);
|
|
||||||
Controls.Add(labelPrice);
|
|
||||||
Controls.Add(textBoxHeading);
|
|
||||||
Controls.Add(labelHeading);
|
|
||||||
Controls.Add(buttonUpdateAd);
|
|
||||||
Margin = new Padding(3, 2, 3, 2);
|
|
||||||
Name = "UpdateAdsForm";
|
|
||||||
Text = "Обновить объявление";
|
|
||||||
ResumeLayout(false);
|
|
||||||
PerformLayout();
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
private ComboBox comboBoxClient;
|
|
||||||
private ComboBox comboBoxCategory;
|
|
||||||
private ComboBox comboBoxSubcategory;
|
|
||||||
private Label labelClient;
|
|
||||||
private Label labelSubcategory;
|
|
||||||
private Label labelCategory;
|
|
||||||
private TextBox textBoxStatus;
|
|
||||||
private Label labelStatus;
|
|
||||||
private TextBox textBoxDate;
|
|
||||||
private Label labelDate;
|
|
||||||
private TextBox textBoxPrice;
|
|
||||||
private Label labelPrice;
|
|
||||||
private TextBox textBoxHeading;
|
|
||||||
private Label labelHeading;
|
|
||||||
private Button buttonUpdateAd;
|
|
||||||
private Label label1;
|
|
||||||
private ComboBox comboBoxUpdateAd;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,154 +0,0 @@
|
|||||||
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 WebsiteForPlacingAds
|
|
||||||
{
|
|
||||||
public partial class UpdateAdsForm : Form
|
|
||||||
{
|
|
||||||
//PostgreSqlDatabase psd;
|
|
||||||
AbstractManagmentDatabase managmentDatabase;
|
|
||||||
public UpdateAdsForm(AbstractManagmentDatabase managmentDatabase)
|
|
||||||
{
|
|
||||||
InitializeComponent();
|
|
||||||
this.managmentDatabase = managmentDatabase;
|
|
||||||
LoadData();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void buttonUpdateAd_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
string[] selectedAds = comboBoxUpdateAd.SelectedItem.ToString().Split("|");
|
|
||||||
int ads_id = int.Parse(selectedAds[0].Trim());
|
|
||||||
|
|
||||||
string query = $"UPDATE ads SET ";
|
|
||||||
int len = query.Length;
|
|
||||||
|
|
||||||
|
|
||||||
string oldHeading = managmentDatabase.getRowTableById("ads", "heading", ads_id).ToString();
|
|
||||||
string oldPrice = managmentDatabase.getRowTableById("ads", "heading", ads_id).ToString();
|
|
||||||
string oldDate = ((DateTime)managmentDatabase.getRowTableById("ads", "date_of_placement", ads_id)).ToString("dd.MM.yyyy");
|
|
||||||
string oldStatus = managmentDatabase.getRowTableById("ads", "status", ads_id).ToString();
|
|
||||||
string[] oldClient = managmentDatabase.getRowTableById("ads", "client_id", ads_id).ToString().Split(" ");
|
|
||||||
string[] oldCategory = managmentDatabase.getRowTableById("ads", "category_id", ads_id).ToString().Split(" ");
|
|
||||||
string[] oldSubcategory = managmentDatabase.getRowTableById("ads", "subcategory_id", ads_id).ToString().Split(" ");
|
|
||||||
|
|
||||||
|
|
||||||
string newHeading = textBoxHeading.Text;
|
|
||||||
string newPrice = textBoxPrice.Text;
|
|
||||||
string newDate = textBoxDate.Text;
|
|
||||||
string newStatus = textBoxStatus.Text;
|
|
||||||
string[] newClient = comboBoxClient.SelectedItem.ToString().Split(" ");
|
|
||||||
string[] newCategory = comboBoxCategory.SelectedItem.ToString().Split(" ");
|
|
||||||
string[] newSubcategory = comboBoxSubcategory.SelectedItem.ToString().Split(" ");
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
query = oldHeading == newHeading ? query : query + $"heading = '{newHeading}', ";
|
|
||||||
query = oldPrice == newPrice ? query : query + $"price = {newPrice}, ";
|
|
||||||
query = oldDate == newDate ? query : query + $"date_of_placement = '{newDate}', ";
|
|
||||||
query = oldStatus == newStatus ? query : query + $"status = '{newStatus}', ";
|
|
||||||
query = oldClient[0].Trim() == newClient[0].Trim() ? query : query + $"client_id = '{newClient[0].Substring(0, newClient[0].IndexOf("."))}', ";
|
|
||||||
query = oldCategory[0].Trim() == newCategory[0].Trim() ? query : query + $"category_id = '{newCategory[0].Substring(0, newCategory[0].IndexOf("."))}', ";
|
|
||||||
query = oldSubcategory[0].Trim() == newSubcategory[0].Trim() ? query : query + $"subcategory_id = '{newSubcategory[0].Substring(0, newSubcategory[0].IndexOf("."))}', ";
|
|
||||||
|
|
||||||
|
|
||||||
if (len != query.Length)
|
|
||||||
{
|
|
||||||
query = query.TrimEnd(' ');
|
|
||||||
query = query.TrimEnd(',');
|
|
||||||
query += $" WHERE ADS_ID = {ads_id};";
|
|
||||||
}
|
|
||||||
try
|
|
||||||
{
|
|
||||||
DateTime start = DateTime.Now;
|
|
||||||
|
|
||||||
managmentDatabase.ExecuteNonQuery(query);
|
|
||||||
MessageBox.Show("Данные успешно обновлены!");
|
|
||||||
|
|
||||||
DateTime end = DateTime.Now;
|
|
||||||
TimeSpan duration = end - start;
|
|
||||||
MessageBox.Show($"Добавлено! Время выполнения: {duration.TotalMilliseconds} мс");
|
|
||||||
}
|
|
||||||
catch (Exception)
|
|
||||||
{
|
|
||||||
|
|
||||||
MessageBox.Show("Данные не обновились");
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
public void LoadData()
|
|
||||||
{
|
|
||||||
comboBoxUpdateAd.Items.Clear();
|
|
||||||
DataTable result = managmentDatabase.getAllEntry("Ads");
|
|
||||||
string Ads = "";
|
|
||||||
for (int i = 0; i < result.Rows.Count; i++)
|
|
||||||
{
|
|
||||||
Ads = result.Rows[i]["ads_id"].ToString() + " | " +
|
|
||||||
(string)result.Rows[i]["heading"] + " | " +
|
|
||||||
result.Rows[i]["price"].ToString() + " | " +
|
|
||||||
((DateTime)result.Rows[i]["date_of_placement"]).ToString("dd.MM.yyyy") + " | " +
|
|
||||||
(string)result.Rows[i]["status"] + " | " +
|
|
||||||
result.Rows[i]["client_id"].ToString() + " | " +
|
|
||||||
result.Rows[i]["category_id"].ToString() + " | " +
|
|
||||||
result.Rows[i]["subcategory_id"].ToString() + "\n";
|
|
||||||
comboBoxUpdateAd.Items.Add(Ads);
|
|
||||||
}
|
|
||||||
comboBoxCategory.Items.Clear();
|
|
||||||
comboBoxSubcategory.Items.Clear();
|
|
||||||
comboBoxClient.Items.Clear();
|
|
||||||
|
|
||||||
result = managmentDatabase.getAllEntry("Categories");
|
|
||||||
string[] id_names = new string[result.Rows.Count];
|
|
||||||
for (int i = 0; i < result.Rows.Count; i++)
|
|
||||||
{
|
|
||||||
id_names[i] = result.Rows[i]["categories_id"].ToString() + ". " + (string)result.Rows[i]["name"];
|
|
||||||
comboBoxCategory.Items.Add(id_names[i]);
|
|
||||||
}
|
|
||||||
result = managmentDatabase.getAllEntry("Subcategories");
|
|
||||||
id_names = new string[result.Rows.Count];
|
|
||||||
for (int i = 0; i < result.Rows.Count; i++)
|
|
||||||
{
|
|
||||||
id_names[i] = result.Rows[i]["subcategories_id"].ToString() + ". " + (string)result.Rows[i]["name"];
|
|
||||||
comboBoxSubcategory.Items.Add(id_names[i]);
|
|
||||||
}
|
|
||||||
result = managmentDatabase.getAllEntry("Clients");
|
|
||||||
string[] id_names_surnames = new string[result.Rows.Count];
|
|
||||||
for (int i = 0; i < result.Rows.Count; i++)
|
|
||||||
{
|
|
||||||
id_names_surnames[i] = result.Rows[i]["clients_id"].ToString().Trim() + ". " + ((string)result.Rows[i]["name"]).Trim() + " " + ((string)result.Rows[i]["surname"]).Trim();
|
|
||||||
comboBoxClient.Items.Add(id_names_surnames[i]);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
public void LoadDataSelectedItem(int ads_id)
|
|
||||||
{
|
|
||||||
DataTable result = managmentDatabase.getEntryById("ads", ads_id);
|
|
||||||
textBoxHeading.Text = (string)result.Rows[0]["heading"];
|
|
||||||
textBoxPrice.Text = result.Rows[0]["price"].ToString();
|
|
||||||
textBoxDate.Text = ((DateTime)result.Rows[0]["date_of_placement"]).ToString("dd.MM.yyyy");
|
|
||||||
textBoxStatus.Text = (string)result.Rows[0]["status"];
|
|
||||||
|
|
||||||
comboBoxCategory.SelectedItem = result.Rows[0]["category_id"].ToString() + ". " + managmentDatabase.getRowTableById("categories", "name", Convert.ToInt32(result.Rows[0]["id_category"])).ToString();
|
|
||||||
|
|
||||||
comboBoxSubcategory.SelectedItem = result.Rows[0]["subcategory_id"].ToString() + ". " + managmentDatabase.getRowTableById("subcategories", "name", Convert.ToInt32(result.Rows[0]["id_subcategory"])).ToString();
|
|
||||||
|
|
||||||
comboBoxClient.SelectedItem = result.Rows[0]["id_client"].ToString().Trim() + ". " +
|
|
||||||
managmentDatabase.getRowTableById("clients", "name", Convert.ToInt32(result.Rows[0]["client_id"])).ToString().Trim() + " " +
|
|
||||||
managmentDatabase.getRowTableById("clients", "surname", Convert.ToInt32(result.Rows[0]["client_id"])).ToString().Trim();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private void comboBoxUpdateAd_SelectedIndexChanged(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
string[] selectedItems = comboBoxUpdateAd.SelectedItem.ToString().Split("|");
|
|
||||||
int ads_id = int.Parse(selectedItems[0].Trim());
|
|
||||||
LoadDataSelectedItem(ads_id);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -2,20 +2,26 @@
|
|||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<OutputType>WinExe</OutputType>
|
<OutputType>WinExe</OutputType>
|
||||||
<TargetFramework>net6.0-windows</TargetFramework>
|
<TargetFramework>net8.0-windows7.0</TargetFramework>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
<UseWindowsForms>true</UseWindowsForms>
|
<UseWindowsForms>true</UseWindowsForms>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Npgsql" Version="8.0.2" />
|
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="8.0.3">
|
||||||
|
<PrivateAssets>all</PrivateAssets>
|
||||||
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
|
</PackageReference>
|
||||||
|
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="8.0.0" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Update="RegionsForm\CreateRegionsForm.cs">
|
<ProjectReference Include="..\BulletinBoardContracts\BulletinBoardContracts.csproj" />
|
||||||
<SubType>Form</SubType>
|
<ProjectReference Include="..\BulletinBoardLogic\BulletinBoardBusinessLogic.csproj" />
|
||||||
</Compile>
|
<ProjectReference Include="..\BulletinBoardMongoDB\BulletinBoardMongoDB.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</Project>
|
</Project>
|
@ -1,86 +0,0 @@
|
|||||||
namespace WebsiteForPlacingAds
|
|
||||||
{
|
|
||||||
partial class CreateCategoriesForm
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Required designer variable.
|
|
||||||
/// </summary>
|
|
||||||
private System.ComponentModel.IContainer components = null;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Clean up any resources being used.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
|
||||||
protected override void Dispose(bool disposing)
|
|
||||||
{
|
|
||||||
if (disposing && (components != null))
|
|
||||||
{
|
|
||||||
components.Dispose();
|
|
||||||
}
|
|
||||||
base.Dispose(disposing);
|
|
||||||
}
|
|
||||||
|
|
||||||
#region Windows Form Designer generated code
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Required method for Designer support - do not modify
|
|
||||||
/// the contents of this method with the code editor.
|
|
||||||
/// </summary>
|
|
||||||
private void InitializeComponent()
|
|
||||||
{
|
|
||||||
this.buttonCreateCategory = new System.Windows.Forms.Button();
|
|
||||||
this.labelName = new System.Windows.Forms.Label();
|
|
||||||
this.textBoxName = new System.Windows.Forms.TextBox();
|
|
||||||
this.SuspendLayout();
|
|
||||||
//
|
|
||||||
// buttonCreateCategory
|
|
||||||
//
|
|
||||||
this.buttonCreateCategory.Location = new System.Drawing.Point(43, 70);
|
|
||||||
this.buttonCreateCategory.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
|
||||||
this.buttonCreateCategory.Name = "buttonCreateCategory";
|
|
||||||
this.buttonCreateCategory.Size = new System.Drawing.Size(239, 29);
|
|
||||||
this.buttonCreateCategory.TabIndex = 0;
|
|
||||||
this.buttonCreateCategory.Text = "Добавить категорию";
|
|
||||||
this.buttonCreateCategory.UseVisualStyleBackColor = true;
|
|
||||||
this.buttonCreateCategory.Click += new System.EventHandler(this.buttonCreateCategory_Click);
|
|
||||||
//
|
|
||||||
// labelName
|
|
||||||
//
|
|
||||||
this.labelName.AutoSize = true;
|
|
||||||
this.labelName.Location = new System.Drawing.Point(43, 8);
|
|
||||||
this.labelName.Name = "labelName";
|
|
||||||
this.labelName.Size = new System.Drawing.Size(59, 15);
|
|
||||||
this.labelName.TabIndex = 1;
|
|
||||||
this.labelName.Text = "Название";
|
|
||||||
//
|
|
||||||
// textBoxName
|
|
||||||
//
|
|
||||||
this.textBoxName.Location = new System.Drawing.Point(43, 26);
|
|
||||||
this.textBoxName.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
|
||||||
this.textBoxName.Name = "textBoxName";
|
|
||||||
this.textBoxName.Size = new System.Drawing.Size(239, 23);
|
|
||||||
this.textBoxName.TabIndex = 2;
|
|
||||||
//
|
|
||||||
// CreateCategoriesForm
|
|
||||||
//
|
|
||||||
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
|
||||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
|
||||||
this.ClientSize = new System.Drawing.Size(324, 127);
|
|
||||||
this.Controls.Add(this.textBoxName);
|
|
||||||
this.Controls.Add(this.labelName);
|
|
||||||
this.Controls.Add(this.buttonCreateCategory);
|
|
||||||
this.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
|
||||||
this.Name = "CreateCategoriesForm";
|
|
||||||
this.Text = "Категория";
|
|
||||||
this.ResumeLayout(false);
|
|
||||||
this.PerformLayout();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
private Button buttonCreateCategory;
|
|
||||||
private Label labelName;
|
|
||||||
private TextBox textBoxName;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,35 +0,0 @@
|
|||||||
using System.Data;
|
|
||||||
|
|
||||||
namespace WebsiteForPlacingAds
|
|
||||||
{
|
|
||||||
public partial class CreateCategoriesForm : Form
|
|
||||||
{
|
|
||||||
AbstractManagmentDatabase managmentDatabase;
|
|
||||||
public CreateCategoriesForm(AbstractManagmentDatabase managmentDatabase)
|
|
||||||
{
|
|
||||||
InitializeComponent();
|
|
||||||
this.managmentDatabase = managmentDatabase;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void buttonCreateCategory_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
string name = textBoxName.Text;
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
DateTime start = DateTime.Now;
|
|
||||||
|
|
||||||
managmentDatabase.insertInto("categories", $"'{name}'");
|
|
||||||
MessageBox.Show("Äîáàâëåíî!");
|
|
||||||
|
|
||||||
DateTime end = DateTime.Now;
|
|
||||||
TimeSpan duration = end - start;
|
|
||||||
MessageBox.Show($"Äîáàâëåíî! Âðåìÿ âûïîëíåíèÿ: {duration.TotalMilliseconds} ìñ");
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
MessageBox.Show("Íå óäàëîñü äîáàâèòü");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,87 +0,0 @@
|
|||||||
namespace WebsiteForPlacingAds
|
|
||||||
{
|
|
||||||
partial class DeleteCategoriesForm
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Required designer variable.
|
|
||||||
/// </summary>
|
|
||||||
private System.ComponentModel.IContainer components = null;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Clean up any resources being used.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
|
||||||
protected override void Dispose(bool disposing)
|
|
||||||
{
|
|
||||||
if (disposing && (components != null))
|
|
||||||
{
|
|
||||||
components.Dispose();
|
|
||||||
}
|
|
||||||
base.Dispose(disposing);
|
|
||||||
}
|
|
||||||
|
|
||||||
#region Windows Form Designer generated code
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Required method for Designer support - do not modify
|
|
||||||
/// the contents of this method with the code editor.
|
|
||||||
/// </summary>
|
|
||||||
private void InitializeComponent()
|
|
||||||
{
|
|
||||||
this.label1 = new System.Windows.Forms.Label();
|
|
||||||
this.buttonDeleteCategory = new System.Windows.Forms.Button();
|
|
||||||
this.comboBoxDeleteCategories = new System.Windows.Forms.ComboBox();
|
|
||||||
this.SuspendLayout();
|
|
||||||
//
|
|
||||||
// label1
|
|
||||||
//
|
|
||||||
this.label1.AutoSize = true;
|
|
||||||
this.label1.Location = new System.Drawing.Point(70, 16);
|
|
||||||
this.label1.Name = "label1";
|
|
||||||
this.label1.Size = new System.Drawing.Size(262, 15);
|
|
||||||
this.label1.TabIndex = 0;
|
|
||||||
this.label1.Text = "Выберите категорию, которую хотите удалить";
|
|
||||||
//
|
|
||||||
// buttonDeleteCategory
|
|
||||||
//
|
|
||||||
this.buttonDeleteCategory.Location = new System.Drawing.Point(132, 85);
|
|
||||||
this.buttonDeleteCategory.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
|
||||||
this.buttonDeleteCategory.Name = "buttonDeleteCategory";
|
|
||||||
this.buttonDeleteCategory.Size = new System.Drawing.Size(163, 28);
|
|
||||||
this.buttonDeleteCategory.TabIndex = 1;
|
|
||||||
this.buttonDeleteCategory.Text = "Удалить";
|
|
||||||
this.buttonDeleteCategory.UseVisualStyleBackColor = true;
|
|
||||||
this.buttonDeleteCategory.Click += new System.EventHandler(this.buttonDeleteCategory_Click);
|
|
||||||
//
|
|
||||||
// comboBoxDeleteCategories
|
|
||||||
//
|
|
||||||
this.comboBoxDeleteCategories.FormattingEnabled = true;
|
|
||||||
this.comboBoxDeleteCategories.Location = new System.Drawing.Point(35, 48);
|
|
||||||
this.comboBoxDeleteCategories.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
|
||||||
this.comboBoxDeleteCategories.Name = "comboBoxDeleteCategories";
|
|
||||||
this.comboBoxDeleteCategories.Size = new System.Drawing.Size(367, 23);
|
|
||||||
this.comboBoxDeleteCategories.TabIndex = 2;
|
|
||||||
//
|
|
||||||
// DeleteCategoriesForm
|
|
||||||
//
|
|
||||||
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
|
||||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
|
||||||
this.ClientSize = new System.Drawing.Size(442, 131);
|
|
||||||
this.Controls.Add(this.comboBoxDeleteCategories);
|
|
||||||
this.Controls.Add(this.buttonDeleteCategory);
|
|
||||||
this.Controls.Add(this.label1);
|
|
||||||
this.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
|
||||||
this.Name = "DeleteCategoriesForm";
|
|
||||||
this.Text = "Удалить категорию";
|
|
||||||
this.ResumeLayout(false);
|
|
||||||
this.PerformLayout();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
private Label label1;
|
|
||||||
private Button buttonDeleteCategory;
|
|
||||||
private ComboBox comboBoxDeleteCategories;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,61 +0,0 @@
|
|||||||
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 WebsiteForPlacingAds
|
|
||||||
{
|
|
||||||
public partial class DeleteCategoriesForm : Form
|
|
||||||
{
|
|
||||||
AbstractManagmentDatabase managmentDatabase;
|
|
||||||
private int setval_seq;
|
|
||||||
public DeleteCategoriesForm(AbstractManagmentDatabase managmentDatabase)
|
|
||||||
{
|
|
||||||
InitializeComponent();
|
|
||||||
this.managmentDatabase = managmentDatabase;
|
|
||||||
LoadData();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void buttonDeleteCategory_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
string[] categories = comboBoxDeleteCategories.SelectedItem.ToString().Split("|");
|
|
||||||
string category_id = categories[0].Trim();
|
|
||||||
try
|
|
||||||
{
|
|
||||||
DateTime start = DateTime.Now;
|
|
||||||
|
|
||||||
managmentDatabase.deleteEntry("categories", int.Parse(category_id));
|
|
||||||
LoadData();
|
|
||||||
if (setval_seq > 0) managmentDatabase.reduceSeq("seq_categories", setval_seq);
|
|
||||||
MessageBox.Show("Удалено!");
|
|
||||||
|
|
||||||
DateTime end = DateTime.Now;
|
|
||||||
TimeSpan duration = end - start;
|
|
||||||
MessageBox.Show($"Добавлено! Время выполнения: {duration.TotalMilliseconds} мс");
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
MessageBox.Show("Не удалось удалить");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
public void LoadData()
|
|
||||||
{
|
|
||||||
comboBoxDeleteCategories.Items.Clear();
|
|
||||||
DataTable result = managmentDatabase.getAllEntry("Categories");
|
|
||||||
setval_seq = result.Rows.Count;
|
|
||||||
string Categories = "";
|
|
||||||
for (int i = 0; i < result.Rows.Count; i++)
|
|
||||||
{
|
|
||||||
setval_seq = Math.Max(Convert.ToInt32(managmentDatabase.getRowTableById(result, "categories_id", i)), setval_seq);
|
|
||||||
Categories = managmentDatabase.getRowTableById(result, "categories_id", i).ToString() + " | " +
|
|
||||||
managmentDatabase.getRowTableById(result, "name", i).ToString() + "\n";
|
|
||||||
comboBoxDeleteCategories.Items.Add(Categories);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,60 +0,0 @@
|
|||||||
<root>
|
|
||||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
|
||||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
|
||||||
<xsd:element name="root" msdata:IsDataSet="true">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:choice maxOccurs="unbounded">
|
|
||||||
<xsd:element name="metadata">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
|
||||||
<xsd:attribute name="type" type="xsd:string" />
|
|
||||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
|
||||||
<xsd:attribute ref="xml:space" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="assembly">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:attribute name="alias" type="xsd:string" />
|
|
||||||
<xsd:attribute name="name" type="xsd:string" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="data">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
|
||||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
|
||||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
|
||||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
|
||||||
<xsd:attribute ref="xml:space" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="resheader">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
</xsd:choice>
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
</xsd:schema>
|
|
||||||
<resheader name="resmimetype">
|
|
||||||
<value>text/microsoft-resx</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="version">
|
|
||||||
<value>2.0</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="reader">
|
|
||||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="writer">
|
|
||||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
|
||||||
</resheader>
|
|
||||||
</root>
|
|
@ -1,75 +0,0 @@
|
|||||||
namespace WebsiteForPlacingAds
|
|
||||||
{
|
|
||||||
partial class ListCategoriesForm
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Required designer variable.
|
|
||||||
/// </summary>
|
|
||||||
private System.ComponentModel.IContainer components = null;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Clean up any resources being used.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
|
||||||
protected override void Dispose(bool disposing)
|
|
||||||
{
|
|
||||||
if (disposing && (components != null))
|
|
||||||
{
|
|
||||||
components.Dispose();
|
|
||||||
}
|
|
||||||
base.Dispose(disposing);
|
|
||||||
}
|
|
||||||
|
|
||||||
#region Windows Form Designer generated code
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Required method for Designer support - do not modify
|
|
||||||
/// the contents of this method with the code editor.
|
|
||||||
/// </summary>
|
|
||||||
private void InitializeComponent()
|
|
||||||
{
|
|
||||||
this.label1 = new System.Windows.Forms.Label();
|
|
||||||
this.labelListCategories = new System.Windows.Forms.Label();
|
|
||||||
this.SuspendLayout();
|
|
||||||
//
|
|
||||||
// label1
|
|
||||||
//
|
|
||||||
this.label1.AutoSize = true;
|
|
||||||
this.label1.BackColor = System.Drawing.SystemColors.Control;
|
|
||||||
this.label1.Font = new System.Drawing.Font("Segoe UI", 11F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
|
|
||||||
this.label1.Location = new System.Drawing.Point(10, 7);
|
|
||||||
this.label1.Name = "label1";
|
|
||||||
this.label1.Size = new System.Drawing.Size(134, 20);
|
|
||||||
this.label1.TabIndex = 0;
|
|
||||||
this.label1.Text = "Список категорий";
|
|
||||||
//
|
|
||||||
// labelListCategories
|
|
||||||
//
|
|
||||||
this.labelListCategories.AutoSize = true;
|
|
||||||
this.labelListCategories.Font = new System.Drawing.Font("Segoe UI", 10F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
|
|
||||||
this.labelListCategories.Location = new System.Drawing.Point(10, 35);
|
|
||||||
this.labelListCategories.Name = "labelListCategories";
|
|
||||||
this.labelListCategories.Size = new System.Drawing.Size(0, 19);
|
|
||||||
this.labelListCategories.TabIndex = 1;
|
|
||||||
//
|
|
||||||
// ListCategoriesForm
|
|
||||||
//
|
|
||||||
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
|
||||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
|
||||||
this.ClientSize = new System.Drawing.Size(700, 338);
|
|
||||||
this.Controls.Add(this.labelListCategories);
|
|
||||||
this.Controls.Add(this.label1);
|
|
||||||
this.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
|
||||||
this.Name = "ListCategoriesForm";
|
|
||||||
this.Text = "Список категорий";
|
|
||||||
this.ResumeLayout(false);
|
|
||||||
this.PerformLayout();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
private Label label1;
|
|
||||||
private Label labelListCategories;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,42 +0,0 @@
|
|||||||
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 System.Windows.Forms.VisualStyles;
|
|
||||||
|
|
||||||
namespace WebsiteForPlacingAds
|
|
||||||
{
|
|
||||||
public partial class ListCategoriesForm : Form
|
|
||||||
{
|
|
||||||
AbstractManagmentDatabase managmentDatabase;
|
|
||||||
public ListCategoriesForm(AbstractManagmentDatabase managmentDatabase)
|
|
||||||
{
|
|
||||||
InitializeComponent();
|
|
||||||
this.managmentDatabase = managmentDatabase;
|
|
||||||
LoadData();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void LoadData()
|
|
||||||
{
|
|
||||||
DateTime start = DateTime.Now;
|
|
||||||
|
|
||||||
DataTable result = managmentDatabase.getAllEntry("Categories");
|
|
||||||
string listCategories = "";
|
|
||||||
for (int i = 0; i < result.Rows.Count; i++)
|
|
||||||
{
|
|
||||||
listCategories += managmentDatabase.getRowTableById(result, "categories_id", i).ToString() + " | " +
|
|
||||||
managmentDatabase.getRowTableById(result, "name", i).ToString() + "\n";
|
|
||||||
}
|
|
||||||
labelListCategories.Text = listCategories;
|
|
||||||
|
|
||||||
DateTime end = DateTime.Now;
|
|
||||||
TimeSpan duration = end - start;
|
|
||||||
MessageBox.Show($"Список загружен! Время выполнения: {duration.TotalMilliseconds} мс");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,60 +0,0 @@
|
|||||||
<root>
|
|
||||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
|
||||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
|
||||||
<xsd:element name="root" msdata:IsDataSet="true">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:choice maxOccurs="unbounded">
|
|
||||||
<xsd:element name="metadata">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
|
||||||
<xsd:attribute name="type" type="xsd:string" />
|
|
||||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
|
||||||
<xsd:attribute ref="xml:space" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="assembly">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:attribute name="alias" type="xsd:string" />
|
|
||||||
<xsd:attribute name="name" type="xsd:string" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="data">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
|
||||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
|
||||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
|
||||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
|
||||||
<xsd:attribute ref="xml:space" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="resheader">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
</xsd:choice>
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
</xsd:schema>
|
|
||||||
<resheader name="resmimetype">
|
|
||||||
<value>text/microsoft-resx</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="version">
|
|
||||||
<value>2.0</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="reader">
|
|
||||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="writer">
|
|
||||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
|
||||||
</resheader>
|
|
||||||
</root>
|
|
@ -1,110 +0,0 @@
|
|||||||
namespace WebsiteForPlacingAds
|
|
||||||
{
|
|
||||||
partial class UpdateCategoriesForm
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Required designer variable.
|
|
||||||
/// </summary>
|
|
||||||
private System.ComponentModel.IContainer components = null;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Clean up any resources being used.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
|
||||||
protected override void Dispose(bool disposing)
|
|
||||||
{
|
|
||||||
if (disposing && (components != null))
|
|
||||||
{
|
|
||||||
components.Dispose();
|
|
||||||
}
|
|
||||||
base.Dispose(disposing);
|
|
||||||
}
|
|
||||||
|
|
||||||
#region Windows Form Designer generated code
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Required method for Designer support - do not modify
|
|
||||||
/// the contents of this method with the code editor.
|
|
||||||
/// </summary>
|
|
||||||
private void InitializeComponent()
|
|
||||||
{
|
|
||||||
this.label1 = new System.Windows.Forms.Label();
|
|
||||||
this.comboBoxUpdateCategory = new System.Windows.Forms.ComboBox();
|
|
||||||
this.textBoxName = new System.Windows.Forms.TextBox();
|
|
||||||
this.labelName = new System.Windows.Forms.Label();
|
|
||||||
this.buttonUpdateCategory = new System.Windows.Forms.Button();
|
|
||||||
this.SuspendLayout();
|
|
||||||
//
|
|
||||||
// label1
|
|
||||||
//
|
|
||||||
this.label1.AutoSize = true;
|
|
||||||
this.label1.Location = new System.Drawing.Point(51, 15);
|
|
||||||
this.label1.Name = "label1";
|
|
||||||
this.label1.Size = new System.Drawing.Size(271, 15);
|
|
||||||
this.label1.TabIndex = 33;
|
|
||||||
this.label1.Text = "Выберите категорию, которую хотите обновить";
|
|
||||||
//
|
|
||||||
// comboBoxUpdateCategory
|
|
||||||
//
|
|
||||||
this.comboBoxUpdateCategory.FormattingEnabled = true;
|
|
||||||
this.comboBoxUpdateCategory.Location = new System.Drawing.Point(10, 39);
|
|
||||||
this.comboBoxUpdateCategory.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
|
||||||
this.comboBoxUpdateCategory.Name = "comboBoxUpdateCategory";
|
|
||||||
this.comboBoxUpdateCategory.Size = new System.Drawing.Size(377, 23);
|
|
||||||
this.comboBoxUpdateCategory.TabIndex = 34;
|
|
||||||
this.comboBoxUpdateCategory.SelectedIndexChanged += new System.EventHandler(this.comboBoxUpdateCategory_SelectedIndexChanged);
|
|
||||||
//
|
|
||||||
// textBoxName
|
|
||||||
//
|
|
||||||
this.textBoxName.Location = new System.Drawing.Point(78, 96);
|
|
||||||
this.textBoxName.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
|
||||||
this.textBoxName.Name = "textBoxName";
|
|
||||||
this.textBoxName.Size = new System.Drawing.Size(239, 23);
|
|
||||||
this.textBoxName.TabIndex = 37;
|
|
||||||
//
|
|
||||||
// labelName
|
|
||||||
//
|
|
||||||
this.labelName.AutoSize = true;
|
|
||||||
this.labelName.Location = new System.Drawing.Point(78, 78);
|
|
||||||
this.labelName.Name = "labelName";
|
|
||||||
this.labelName.Size = new System.Drawing.Size(59, 15);
|
|
||||||
this.labelName.TabIndex = 36;
|
|
||||||
this.labelName.Text = "Название";
|
|
||||||
//
|
|
||||||
// buttonUpdateCategory
|
|
||||||
//
|
|
||||||
this.buttonUpdateCategory.Location = new System.Drawing.Point(78, 140);
|
|
||||||
this.buttonUpdateCategory.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
|
||||||
this.buttonUpdateCategory.Name = "buttonUpdateCategory";
|
|
||||||
this.buttonUpdateCategory.Size = new System.Drawing.Size(239, 29);
|
|
||||||
this.buttonUpdateCategory.TabIndex = 35;
|
|
||||||
this.buttonUpdateCategory.Text = "Обновить категорию";
|
|
||||||
this.buttonUpdateCategory.UseVisualStyleBackColor = true;
|
|
||||||
this.buttonUpdateCategory.Click += new System.EventHandler(this.buttonUpdateCategory_Click_1);
|
|
||||||
//
|
|
||||||
// UpdateCategoriesForm
|
|
||||||
//
|
|
||||||
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
|
||||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
|
||||||
this.ClientSize = new System.Drawing.Size(397, 190);
|
|
||||||
this.Controls.Add(this.textBoxName);
|
|
||||||
this.Controls.Add(this.labelName);
|
|
||||||
this.Controls.Add(this.buttonUpdateCategory);
|
|
||||||
this.Controls.Add(this.comboBoxUpdateCategory);
|
|
||||||
this.Controls.Add(this.label1);
|
|
||||||
this.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
|
||||||
this.Name = "UpdateCategoriesForm";
|
|
||||||
this.Text = "Обновить категорию";
|
|
||||||
this.ResumeLayout(false);
|
|
||||||
this.PerformLayout();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
private Label label1;
|
|
||||||
private ComboBox comboBoxUpdateCategory;
|
|
||||||
private TextBox textBoxName;
|
|
||||||
private Label labelName;
|
|
||||||
private Button buttonUpdateCategory;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,86 +0,0 @@
|
|||||||
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 WebsiteForPlacingAds
|
|
||||||
{
|
|
||||||
public partial class UpdateCategoriesForm : Form
|
|
||||||
{
|
|
||||||
AbstractManagmentDatabase managmentDatabase;
|
|
||||||
public UpdateCategoriesForm(AbstractManagmentDatabase managmentDatabase)
|
|
||||||
{
|
|
||||||
InitializeComponent();
|
|
||||||
this.managmentDatabase = managmentDatabase;
|
|
||||||
LoadData();
|
|
||||||
}
|
|
||||||
public void LoadData()
|
|
||||||
{
|
|
||||||
comboBoxUpdateCategory.Items.Clear();
|
|
||||||
DataTable result = managmentDatabase.getAllEntry("Categories");
|
|
||||||
string Categories = "";
|
|
||||||
for (int i = 0; i < result.Rows.Count; i++)
|
|
||||||
{
|
|
||||||
Categories = result.Rows[i]["categories_id"].ToString() + " | " +
|
|
||||||
(string)result.Rows[i]["name"] + "\n";
|
|
||||||
comboBoxUpdateCategory.Items.Add(Categories);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
public void LoadDataSelectedItem(int categories_id)
|
|
||||||
{
|
|
||||||
DataTable result = managmentDatabase.getEntryById("categories", categories_id);
|
|
||||||
textBoxName.Text = managmentDatabase.getRowTableById(result, "name", 0).ToString();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void comboBoxUpdateCategory_SelectedIndexChanged(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
string[] selectedItems = comboBoxUpdateCategory.SelectedItem.ToString().Split("|");
|
|
||||||
int category_id = int.Parse(selectedItems[0].Trim());
|
|
||||||
LoadDataSelectedItem(category_id);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void buttonUpdateCategory_Click_1(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
string[] selectedCategory = comboBoxUpdateCategory.SelectedItem.ToString().Split("|");
|
|
||||||
int category_id = int.Parse(selectedCategory[0].Trim());
|
|
||||||
|
|
||||||
string query = $"UPDATE Categories SET ";
|
|
||||||
int len = query.Length;
|
|
||||||
|
|
||||||
|
|
||||||
string oldName = managmentDatabase.getRowTableById("categories", "name", category_id).ToString();
|
|
||||||
|
|
||||||
string newName = textBoxName.Text;
|
|
||||||
|
|
||||||
|
|
||||||
query = oldName == newName ? query : query + $"name = '{newName}', ";
|
|
||||||
if (len != query.Length)
|
|
||||||
{
|
|
||||||
query = query.TrimEnd(' ');
|
|
||||||
query = query.TrimEnd(',');
|
|
||||||
query += $" WHERE Categories_ID = {category_id};";
|
|
||||||
}
|
|
||||||
try
|
|
||||||
{
|
|
||||||
DateTime start = DateTime.Now;
|
|
||||||
|
|
||||||
managmentDatabase.ExecuteNonQuery(query);
|
|
||||||
MessageBox.Show("Данные успешно обновлены!");
|
|
||||||
|
|
||||||
DateTime end = DateTime.Now;
|
|
||||||
TimeSpan duration = end - start;
|
|
||||||
MessageBox.Show($"Добавлено! Время выполнения: {duration.TotalMilliseconds} мс");
|
|
||||||
}
|
|
||||||
catch (Exception)
|
|
||||||
{
|
|
||||||
|
|
||||||
MessageBox.Show("Данные не обновились");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,60 +0,0 @@
|
|||||||
<root>
|
|
||||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
|
||||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
|
||||||
<xsd:element name="root" msdata:IsDataSet="true">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:choice maxOccurs="unbounded">
|
|
||||||
<xsd:element name="metadata">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
|
||||||
<xsd:attribute name="type" type="xsd:string" />
|
|
||||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
|
||||||
<xsd:attribute ref="xml:space" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="assembly">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:attribute name="alias" type="xsd:string" />
|
|
||||||
<xsd:attribute name="name" type="xsd:string" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="data">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
|
||||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
|
||||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
|
||||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
|
||||||
<xsd:attribute ref="xml:space" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="resheader">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
</xsd:choice>
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
</xsd:schema>
|
|
||||||
<resheader name="resmimetype">
|
|
||||||
<value>text/microsoft-resx</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="version">
|
|
||||||
<value>2.0</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="reader">
|
|
||||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="writer">
|
|
||||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
|
||||||
</resheader>
|
|
||||||
</root>
|
|
@ -1,109 +0,0 @@
|
|||||||
namespace WebsiteForPlacingAds
|
|
||||||
{
|
|
||||||
partial class CreateCitiesForm
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Required designer variable.
|
|
||||||
/// </summary>
|
|
||||||
private System.ComponentModel.IContainer components = null;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Clean up any resources being used.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
|
||||||
protected override void Dispose(bool disposing)
|
|
||||||
{
|
|
||||||
if (disposing && (components != null))
|
|
||||||
{
|
|
||||||
components.Dispose();
|
|
||||||
}
|
|
||||||
base.Dispose(disposing);
|
|
||||||
}
|
|
||||||
|
|
||||||
#region Windows Form Designer generated code
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Required method for Designer support - do not modify
|
|
||||||
/// the contents of this method with the code editor.
|
|
||||||
/// </summary>
|
|
||||||
private void InitializeComponent()
|
|
||||||
{
|
|
||||||
buttonCreateCity = new Button();
|
|
||||||
labelName = new Label();
|
|
||||||
textBoxName = new TextBox();
|
|
||||||
labelCategory = new Label();
|
|
||||||
comboBoxRegion = new ComboBox();
|
|
||||||
SuspendLayout();
|
|
||||||
//
|
|
||||||
// buttonCreateCity
|
|
||||||
//
|
|
||||||
buttonCreateCity.Location = new Point(43, 111);
|
|
||||||
buttonCreateCity.Margin = new Padding(3, 2, 3, 2);
|
|
||||||
buttonCreateCity.Name = "buttonCreateCity";
|
|
||||||
buttonCreateCity.Size = new Size(239, 29);
|
|
||||||
buttonCreateCity.TabIndex = 0;
|
|
||||||
buttonCreateCity.Text = "Добавить город";
|
|
||||||
buttonCreateCity.UseVisualStyleBackColor = true;
|
|
||||||
buttonCreateCity.Click += buttonCreateCity_Click;
|
|
||||||
//
|
|
||||||
// labelName
|
|
||||||
//
|
|
||||||
labelName.AutoSize = true;
|
|
||||||
labelName.Location = new Point(43, 8);
|
|
||||||
labelName.Name = "labelName";
|
|
||||||
labelName.Size = new Size(59, 15);
|
|
||||||
labelName.TabIndex = 1;
|
|
||||||
labelName.Text = "Название";
|
|
||||||
//
|
|
||||||
// textBoxName
|
|
||||||
//
|
|
||||||
textBoxName.Location = new Point(43, 26);
|
|
||||||
textBoxName.Margin = new Padding(3, 2, 3, 2);
|
|
||||||
textBoxName.Name = "textBoxName";
|
|
||||||
textBoxName.Size = new Size(239, 23);
|
|
||||||
textBoxName.TabIndex = 2;
|
|
||||||
//
|
|
||||||
// labelCategory
|
|
||||||
//
|
|
||||||
labelCategory.AutoSize = true;
|
|
||||||
labelCategory.Location = new Point(43, 62);
|
|
||||||
labelCategory.Name = "labelCategory";
|
|
||||||
labelCategory.Size = new Size(46, 15);
|
|
||||||
labelCategory.TabIndex = 20;
|
|
||||||
labelCategory.Text = "Регион";
|
|
||||||
//
|
|
||||||
// comboBoxRegion
|
|
||||||
//
|
|
||||||
comboBoxRegion.FormattingEnabled = true;
|
|
||||||
comboBoxRegion.Location = new Point(43, 78);
|
|
||||||
comboBoxRegion.Margin = new Padding(3, 2, 3, 2);
|
|
||||||
comboBoxRegion.Name = "comboBoxRegion";
|
|
||||||
comboBoxRegion.Size = new Size(239, 23);
|
|
||||||
comboBoxRegion.TabIndex = 19;
|
|
||||||
//
|
|
||||||
// CreateCitiesForm
|
|
||||||
//
|
|
||||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
|
||||||
AutoScaleMode = AutoScaleMode.Font;
|
|
||||||
ClientSize = new Size(324, 163);
|
|
||||||
Controls.Add(labelCategory);
|
|
||||||
Controls.Add(comboBoxRegion);
|
|
||||||
Controls.Add(textBoxName);
|
|
||||||
Controls.Add(labelName);
|
|
||||||
Controls.Add(buttonCreateCity);
|
|
||||||
Margin = new Padding(3, 2, 3, 2);
|
|
||||||
Name = "CreateCitiesForm";
|
|
||||||
Text = "Добавить Город";
|
|
||||||
ResumeLayout(false);
|
|
||||||
PerformLayout();
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
private Button buttonCreateCity;
|
|
||||||
private Label labelName;
|
|
||||||
private TextBox textBoxName;
|
|
||||||
private Label labelCategory;
|
|
||||||
private ComboBox comboBoxRegion;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,56 +0,0 @@
|
|||||||
using System.Data;
|
|
||||||
|
|
||||||
namespace WebsiteForPlacingAds
|
|
||||||
{
|
|
||||||
public partial class CreateCitiesForm : Form
|
|
||||||
{
|
|
||||||
AbstractManagmentDatabase managmentDatabase;
|
|
||||||
public CreateCitiesForm(AbstractManagmentDatabase managmentDatabase)
|
|
||||||
{
|
|
||||||
InitializeComponent();
|
|
||||||
this.managmentDatabase = managmentDatabase;
|
|
||||||
LoadData();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void buttonCreateCity_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
string name = textBoxName.Text;
|
|
||||||
|
|
||||||
string[] region = comboBoxRegion.SelectedItem.ToString().Split(" ");
|
|
||||||
|
|
||||||
string regions_id = region[0];
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
DateTime start = DateTime.Now;
|
|
||||||
|
|
||||||
managmentDatabase.insertInto("cities", $"'{name}'", regions_id);
|
|
||||||
MessageBox.Show("Äîáàâëåíî!");
|
|
||||||
LoadData();
|
|
||||||
|
|
||||||
DateTime end = DateTime.Now;
|
|
||||||
TimeSpan duration = end - start;
|
|
||||||
MessageBox.Show($"Äîáàâëåíî! Âðåìÿ âûïîëíåíèÿ: {duration.TotalMilliseconds} ìñ");
|
|
||||||
|
|
||||||
// Çàêðûòü òåêóùóþ ôîðìó ïîñëå âûïîëíåíèÿ äåéñòâèé
|
|
||||||
this.Close();
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
MessageBox.Show("Íå óäàëîñü äîáàâèòü");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void LoadData()
|
|
||||||
{
|
|
||||||
comboBoxRegion.Items.Clear();
|
|
||||||
DataTable result = managmentDatabase.getAllEntry("REGIONS");
|
|
||||||
string[] id_names = new string[result.Rows.Count];
|
|
||||||
for (int i = 0; i < result.Rows.Count; i++)
|
|
||||||
{
|
|
||||||
id_names[i] = managmentDatabase.getRowTableById(result, "regions_id", i).ToString() + ". " + managmentDatabase.getRowTableById(result, "name", i).ToString();
|
|
||||||
comboBoxRegion.Items.Add(id_names[i]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,86 +0,0 @@
|
|||||||
namespace WebsiteForPlacingAds
|
|
||||||
{
|
|
||||||
partial class DeleteCitiesForm
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Required designer variable.
|
|
||||||
/// </summary>
|
|
||||||
private System.ComponentModel.IContainer components = null;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Clean up any resources being used.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
|
||||||
protected override void Dispose(bool disposing)
|
|
||||||
{
|
|
||||||
if (disposing && (components != null))
|
|
||||||
{
|
|
||||||
components.Dispose();
|
|
||||||
}
|
|
||||||
base.Dispose(disposing);
|
|
||||||
}
|
|
||||||
|
|
||||||
#region Windows Form Designer generated code
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Required method for Designer support - do not modify
|
|
||||||
/// the contents of this method with the code editor.
|
|
||||||
/// </summary>
|
|
||||||
private void InitializeComponent()
|
|
||||||
{
|
|
||||||
label1 = new Label();
|
|
||||||
buttonDeleteCity = new Button();
|
|
||||||
comboBoxDeleteCities = new ComboBox();
|
|
||||||
SuspendLayout();
|
|
||||||
//
|
|
||||||
// label1
|
|
||||||
//
|
|
||||||
label1.AutoSize = true;
|
|
||||||
label1.Location = new Point(70, 16);
|
|
||||||
label1.Name = "label1";
|
|
||||||
label1.Size = new Size(235, 15);
|
|
||||||
label1.TabIndex = 0;
|
|
||||||
label1.Text = "Выберите город, которую хотите удалить";
|
|
||||||
//
|
|
||||||
// buttonDeleteCity
|
|
||||||
//
|
|
||||||
buttonDeleteCity.Location = new Point(132, 85);
|
|
||||||
buttonDeleteCity.Margin = new Padding(3, 2, 3, 2);
|
|
||||||
buttonDeleteCity.Name = "buttonDeleteCity";
|
|
||||||
buttonDeleteCity.Size = new Size(163, 28);
|
|
||||||
buttonDeleteCity.TabIndex = 1;
|
|
||||||
buttonDeleteCity.Text = "Удалить";
|
|
||||||
buttonDeleteCity.UseVisualStyleBackColor = true;
|
|
||||||
buttonDeleteCity.Click += buttonDeleteCity_Click;
|
|
||||||
//
|
|
||||||
// comboBoxDeleteCities
|
|
||||||
//
|
|
||||||
comboBoxDeleteCities.FormattingEnabled = true;
|
|
||||||
comboBoxDeleteCities.Location = new Point(35, 48);
|
|
||||||
comboBoxDeleteCities.Margin = new Padding(3, 2, 3, 2);
|
|
||||||
comboBoxDeleteCities.Name = "comboBoxDeleteCities";
|
|
||||||
comboBoxDeleteCities.Size = new Size(367, 23);
|
|
||||||
comboBoxDeleteCities.TabIndex = 2;
|
|
||||||
//
|
|
||||||
// DeleteCitiesForm
|
|
||||||
//
|
|
||||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
|
||||||
AutoScaleMode = AutoScaleMode.Font;
|
|
||||||
ClientSize = new Size(442, 131);
|
|
||||||
Controls.Add(comboBoxDeleteCities);
|
|
||||||
Controls.Add(buttonDeleteCity);
|
|
||||||
Controls.Add(label1);
|
|
||||||
Margin = new Padding(3, 2, 3, 2);
|
|
||||||
Name = "DeleteCitiesForm";
|
|
||||||
Text = "Удалить город";
|
|
||||||
ResumeLayout(false);
|
|
||||||
PerformLayout();
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
private Label label1;
|
|
||||||
private Button buttonDeleteCity;
|
|
||||||
private ComboBox comboBoxDeleteCities;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,61 +0,0 @@
|
|||||||
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 WebsiteForPlacingAds
|
|
||||||
{
|
|
||||||
public partial class DeleteCitiesForm : Form
|
|
||||||
{
|
|
||||||
AbstractManagmentDatabase managmentDatabase;
|
|
||||||
private int setval_seq;
|
|
||||||
public DeleteCitiesForm(AbstractManagmentDatabase managmentDatabase)
|
|
||||||
{
|
|
||||||
InitializeComponent();
|
|
||||||
this.managmentDatabase = managmentDatabase;
|
|
||||||
LoadData();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void buttonDeleteCity_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
string[] categories = comboBoxDeleteCities.SelectedItem.ToString().Split("|");
|
|
||||||
string category_id = categories[0].Trim();
|
|
||||||
try
|
|
||||||
{
|
|
||||||
DateTime start = DateTime.Now;
|
|
||||||
|
|
||||||
managmentDatabase.deleteEntry("cities", int.Parse(category_id));
|
|
||||||
LoadData();
|
|
||||||
if (setval_seq > 0) managmentDatabase.reduceSeq("seq_cities", setval_seq);
|
|
||||||
MessageBox.Show("Удалено!");
|
|
||||||
|
|
||||||
DateTime end = DateTime.Now;
|
|
||||||
TimeSpan duration = end - start;
|
|
||||||
MessageBox.Show($"Добавлено! Время выполнения: {duration.TotalMilliseconds} мс");
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
MessageBox.Show("Не удалось удалить");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
public void LoadData()
|
|
||||||
{
|
|
||||||
comboBoxDeleteCities.Items.Clear();
|
|
||||||
DataTable result = managmentDatabase.getAllEntry("Cities");
|
|
||||||
setval_seq = result.Rows.Count;
|
|
||||||
string Regions = "";
|
|
||||||
for (int i = 0; i < result.Rows.Count; i++)
|
|
||||||
{
|
|
||||||
setval_seq = Math.Max(Convert.ToInt32(managmentDatabase.getRowTableById(result, "cities_id", i)), setval_seq);
|
|
||||||
Regions = managmentDatabase.getRowTableById(result, "cities_id", i).ToString() + " | " +
|
|
||||||
managmentDatabase.getRowTableById(result, "name", i).ToString() + "\n";
|
|
||||||
comboBoxDeleteCities.Items.Add(Regions);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,74 +0,0 @@
|
|||||||
namespace WebsiteForPlacingAds
|
|
||||||
{
|
|
||||||
partial class ListCitiesForm
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Required designer variable.
|
|
||||||
/// </summary>
|
|
||||||
private System.ComponentModel.IContainer components = null;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Clean up any resources being used.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
|
||||||
protected override void Dispose(bool disposing)
|
|
||||||
{
|
|
||||||
if (disposing && (components != null))
|
|
||||||
{
|
|
||||||
components.Dispose();
|
|
||||||
}
|
|
||||||
base.Dispose(disposing);
|
|
||||||
}
|
|
||||||
|
|
||||||
#region Windows Form Designer generated code
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Required method for Designer support - do not modify
|
|
||||||
/// the contents of this method with the code editor.
|
|
||||||
/// </summary>
|
|
||||||
private void InitializeComponent()
|
|
||||||
{
|
|
||||||
label1 = new Label();
|
|
||||||
labelListCities = new Label();
|
|
||||||
SuspendLayout();
|
|
||||||
//
|
|
||||||
// label1
|
|
||||||
//
|
|
||||||
label1.AutoSize = true;
|
|
||||||
label1.BackColor = SystemColors.Control;
|
|
||||||
label1.Font = new Font("Segoe UI", 11F, FontStyle.Regular, GraphicsUnit.Point);
|
|
||||||
label1.Location = new Point(10, 7);
|
|
||||||
label1.Name = "label1";
|
|
||||||
label1.Size = new Size(121, 20);
|
|
||||||
label1.TabIndex = 0;
|
|
||||||
label1.Text = "Список городов";
|
|
||||||
//
|
|
||||||
// labelListCities
|
|
||||||
//
|
|
||||||
labelListCities.AutoSize = true;
|
|
||||||
labelListCities.Font = new Font("Segoe UI", 10F, FontStyle.Regular, GraphicsUnit.Point);
|
|
||||||
labelListCities.Location = new Point(10, 35);
|
|
||||||
labelListCities.Name = "labelListCities";
|
|
||||||
labelListCities.Size = new Size(0, 19);
|
|
||||||
labelListCities.TabIndex = 1;
|
|
||||||
//
|
|
||||||
// ListCitiesForm
|
|
||||||
//
|
|
||||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
|
||||||
AutoScaleMode = AutoScaleMode.Font;
|
|
||||||
ClientSize = new Size(700, 338);
|
|
||||||
Controls.Add(labelListCities);
|
|
||||||
Controls.Add(label1);
|
|
||||||
Margin = new Padding(3, 2, 3, 2);
|
|
||||||
Name = "ListCitiesForm";
|
|
||||||
Text = "Список городов";
|
|
||||||
ResumeLayout(false);
|
|
||||||
PerformLayout();
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
private Label label1;
|
|
||||||
private Label labelListCities;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,42 +0,0 @@
|
|||||||
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 System.Windows.Forms.VisualStyles;
|
|
||||||
|
|
||||||
namespace WebsiteForPlacingAds
|
|
||||||
{
|
|
||||||
public partial class ListCitiesForm : Form
|
|
||||||
{
|
|
||||||
AbstractManagmentDatabase managmentDatabase;
|
|
||||||
public ListCitiesForm(AbstractManagmentDatabase managmentDatabase)
|
|
||||||
{
|
|
||||||
InitializeComponent();
|
|
||||||
this.managmentDatabase = managmentDatabase;
|
|
||||||
LoadData();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void LoadData()
|
|
||||||
{
|
|
||||||
DateTime start = DateTime.Now;
|
|
||||||
|
|
||||||
DataTable result = managmentDatabase.getAllEntry("Cities");
|
|
||||||
string listCities = "";
|
|
||||||
for (int i = 0; i < result.Rows.Count; i++)
|
|
||||||
{
|
|
||||||
listCities += managmentDatabase.getRowTableById(result, "cities_id", i).ToString() + " | " +
|
|
||||||
managmentDatabase.getRowTableById(result, "name", i).ToString() + "\n";
|
|
||||||
}
|
|
||||||
labelListCities.Text = listCities;
|
|
||||||
|
|
||||||
DateTime end = DateTime.Now;
|
|
||||||
TimeSpan duration = end - start;
|
|
||||||
MessageBox.Show($"Добавлено! Время выполнения: {duration.TotalMilliseconds} мс");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,111 +0,0 @@
|
|||||||
namespace WebsiteForPlacingAds
|
|
||||||
{
|
|
||||||
partial class UpdateCitiesForm
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Required designer variable.
|
|
||||||
/// </summary>
|
|
||||||
private System.ComponentModel.IContainer components = null;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Clean up any resources being used.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
|
||||||
protected override void Dispose(bool disposing)
|
|
||||||
{
|
|
||||||
if (disposing && (components != null))
|
|
||||||
{
|
|
||||||
components.Dispose();
|
|
||||||
}
|
|
||||||
base.Dispose(disposing);
|
|
||||||
}
|
|
||||||
|
|
||||||
#region Windows Form Designer generated code
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Required method for Designer support - do not modify
|
|
||||||
/// the contents of this method with the code editor.
|
|
||||||
/// </summary>
|
|
||||||
private void InitializeComponent()
|
|
||||||
{
|
|
||||||
label1 = new Label();
|
|
||||||
comboBoxUpdateCity = new ComboBox();
|
|
||||||
textBoxName = new TextBox();
|
|
||||||
labelName = new Label();
|
|
||||||
buttonUpdateCity = new Button();
|
|
||||||
SuspendLayout();
|
|
||||||
//
|
|
||||||
// label1
|
|
||||||
//
|
|
||||||
label1.AutoSize = true;
|
|
||||||
label1.Location = new Point(51, 15);
|
|
||||||
label1.Name = "label1";
|
|
||||||
label1.Size = new Size(244, 15);
|
|
||||||
label1.TabIndex = 33;
|
|
||||||
label1.Text = "Выберите город, который хотите обновить";
|
|
||||||
//
|
|
||||||
// comboBoxUpdateCity
|
|
||||||
//
|
|
||||||
comboBoxUpdateCity.FormattingEnabled = true;
|
|
||||||
comboBoxUpdateCity.Location = new Point(10, 39);
|
|
||||||
comboBoxUpdateCity.Margin = new Padding(3, 2, 3, 2);
|
|
||||||
comboBoxUpdateCity.Name = "comboBoxUpdateCity";
|
|
||||||
comboBoxUpdateCity.Size = new Size(377, 23);
|
|
||||||
comboBoxUpdateCity.TabIndex = 34;
|
|
||||||
comboBoxUpdateCity.SelectedIndexChanged += comboBoxUpdateCity_SelectedIndexChanged;
|
|
||||||
//
|
|
||||||
// textBoxName
|
|
||||||
//
|
|
||||||
textBoxName.Location = new Point(78, 96);
|
|
||||||
textBoxName.Margin = new Padding(3, 2, 3, 2);
|
|
||||||
textBoxName.Name = "textBoxName";
|
|
||||||
textBoxName.Size = new Size(239, 23);
|
|
||||||
textBoxName.TabIndex = 37;
|
|
||||||
//
|
|
||||||
// labelName
|
|
||||||
//
|
|
||||||
labelName.AutoSize = true;
|
|
||||||
labelName.Location = new Point(78, 78);
|
|
||||||
labelName.Name = "labelName";
|
|
||||||
labelName.Size = new Size(59, 15);
|
|
||||||
labelName.TabIndex = 36;
|
|
||||||
labelName.Text = "Название";
|
|
||||||
//
|
|
||||||
// buttonUpdateCity
|
|
||||||
//
|
|
||||||
buttonUpdateCity.Location = new Point(78, 140);
|
|
||||||
buttonUpdateCity.Margin = new Padding(3, 2, 3, 2);
|
|
||||||
buttonUpdateCity.Name = "buttonUpdateCity";
|
|
||||||
buttonUpdateCity.Size = new Size(239, 29);
|
|
||||||
buttonUpdateCity.TabIndex = 35;
|
|
||||||
buttonUpdateCity.Text = "Обновить город";
|
|
||||||
buttonUpdateCity.UseVisualStyleBackColor = true;
|
|
||||||
buttonUpdateCity.Click += buttonUpdateCity_Click_1;
|
|
||||||
//
|
|
||||||
// UpdateCitiesForm
|
|
||||||
//
|
|
||||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
|
||||||
AutoScaleMode = AutoScaleMode.Font;
|
|
||||||
ClientSize = new Size(397, 190);
|
|
||||||
Controls.Add(textBoxName);
|
|
||||||
Controls.Add(labelName);
|
|
||||||
Controls.Add(buttonUpdateCity);
|
|
||||||
Controls.Add(comboBoxUpdateCity);
|
|
||||||
Controls.Add(label1);
|
|
||||||
Margin = new Padding(3, 2, 3, 2);
|
|
||||||
Name = "UpdateCitiesForm";
|
|
||||||
Text = "Обновить город";
|
|
||||||
ResumeLayout(false);
|
|
||||||
PerformLayout();
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
|
|
||||||
private Label label1;
|
|
||||||
private ComboBox comboBoxUpdateCity;
|
|
||||||
private TextBox textBoxName;
|
|
||||||
private Label labelName;
|
|
||||||
private Button buttonUpdateCity;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,86 +0,0 @@
|
|||||||
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 WebsiteForPlacingAds
|
|
||||||
{
|
|
||||||
public partial class UpdateCitiesForm : Form
|
|
||||||
{
|
|
||||||
AbstractManagmentDatabase managmentDatabase;
|
|
||||||
public UpdateCitiesForm(AbstractManagmentDatabase managmentDatabase)
|
|
||||||
{
|
|
||||||
InitializeComponent();
|
|
||||||
this.managmentDatabase = managmentDatabase;
|
|
||||||
LoadData();
|
|
||||||
}
|
|
||||||
public void LoadData()
|
|
||||||
{
|
|
||||||
DateTime start = DateTime.Now;
|
|
||||||
|
|
||||||
comboBoxUpdateCity.Items.Clear();
|
|
||||||
DataTable result = managmentDatabase.getAllEntry("Cities");
|
|
||||||
string Cities = "";
|
|
||||||
for (int i = 0; i < result.Rows.Count; i++)
|
|
||||||
{
|
|
||||||
Cities = result.Rows[i]["cities_id"].ToString() + " | " +
|
|
||||||
(string)result.Rows[i]["name"] + "\n";
|
|
||||||
comboBoxUpdateCity.Items.Add(Cities);
|
|
||||||
}
|
|
||||||
|
|
||||||
DateTime end = DateTime.Now;
|
|
||||||
TimeSpan duration = end - start;
|
|
||||||
MessageBox.Show($"Добавлено! Время выполнения: {duration.TotalMilliseconds} мс");
|
|
||||||
}
|
|
||||||
public void LoadDataSelectedItem(int cities_id)
|
|
||||||
{
|
|
||||||
DataTable result = managmentDatabase.getEntryById("regions", cities_id);
|
|
||||||
textBoxName.Text = managmentDatabase.getRowTableById(result, "name", 0).ToString();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void comboBoxUpdateCity_SelectedIndexChanged(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
string[] selectedItems = comboBoxUpdateCity.SelectedItem.ToString().Split("|");
|
|
||||||
int city_id = int.Parse(selectedItems[0].Trim());
|
|
||||||
LoadDataSelectedItem(city_id);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void buttonUpdateCity_Click_1(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
string[] selectedCategory = comboBoxUpdateCity.SelectedItem.ToString().Split("|");
|
|
||||||
int city_id = int.Parse(selectedCategory[0].Trim());
|
|
||||||
|
|
||||||
string query = $"UPDATE Cities SET ";
|
|
||||||
int len = query.Length;
|
|
||||||
|
|
||||||
|
|
||||||
string oldName = managmentDatabase.getRowTableById("cities", "name", city_id).ToString();
|
|
||||||
|
|
||||||
string newName = textBoxName.Text;
|
|
||||||
|
|
||||||
|
|
||||||
query = oldName == newName ? query : query + $"name = '{newName}', ";
|
|
||||||
if (len != query.Length)
|
|
||||||
{
|
|
||||||
query = query.TrimEnd(' ');
|
|
||||||
query = query.TrimEnd(',');
|
|
||||||
query += $" WHERE Cities_ID = {city_id};";
|
|
||||||
}
|
|
||||||
try
|
|
||||||
{
|
|
||||||
managmentDatabase.ExecuteNonQuery(query);
|
|
||||||
MessageBox.Show("Данные успешно обновлены!");
|
|
||||||
}
|
|
||||||
catch (Exception)
|
|
||||||
{
|
|
||||||
|
|
||||||
MessageBox.Show("Данные не обновились");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,201 +0,0 @@
|
|||||||
namespace WebsiteForPlacingAds
|
|
||||||
{
|
|
||||||
partial class CreateClientsForm
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Required designer variable.
|
|
||||||
/// </summary>
|
|
||||||
private System.ComponentModel.IContainer components = null;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Clean up any resources being used.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
|
||||||
protected override void Dispose(bool disposing)
|
|
||||||
{
|
|
||||||
if (disposing && (components != null))
|
|
||||||
{
|
|
||||||
components.Dispose();
|
|
||||||
}
|
|
||||||
base.Dispose(disposing);
|
|
||||||
}
|
|
||||||
|
|
||||||
#region Windows Form Designer generated code
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Required method for Designer support - do not modify
|
|
||||||
/// the contents of this method with the code editor.
|
|
||||||
/// </summary>
|
|
||||||
private void InitializeComponent()
|
|
||||||
{
|
|
||||||
this.buttonCreateClient = new System.Windows.Forms.Button();
|
|
||||||
this.labelName = new System.Windows.Forms.Label();
|
|
||||||
this.textBoxName = new System.Windows.Forms.TextBox();
|
|
||||||
this.textBoxSurname = new System.Windows.Forms.TextBox();
|
|
||||||
this.labelSurname = new System.Windows.Forms.Label();
|
|
||||||
this.textBoxPatronymic = new System.Windows.Forms.TextBox();
|
|
||||||
this.labelPatronymic = new System.Windows.Forms.Label();
|
|
||||||
this.labelDate = new System.Windows.Forms.Label();
|
|
||||||
this.textBoxEmail = new System.Windows.Forms.TextBox();
|
|
||||||
this.labelEmail = new System.Windows.Forms.Label();
|
|
||||||
this.labelPhoneNumber = new System.Windows.Forms.Label();
|
|
||||||
this.textBoxPhoneNumber = new System.Windows.Forms.TextBox();
|
|
||||||
this.textBoxDate = new System.Windows.Forms.TextBox();
|
|
||||||
this.SuspendLayout();
|
|
||||||
//
|
|
||||||
// buttonCreateClient
|
|
||||||
//
|
|
||||||
this.buttonCreateClient.Location = new System.Drawing.Point(43, 346);
|
|
||||||
this.buttonCreateClient.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
|
||||||
this.buttonCreateClient.Name = "buttonCreateClient";
|
|
||||||
this.buttonCreateClient.Size = new System.Drawing.Size(239, 29);
|
|
||||||
this.buttonCreateClient.TabIndex = 0;
|
|
||||||
this.buttonCreateClient.Text = "Создать клиента";
|
|
||||||
this.buttonCreateClient.UseVisualStyleBackColor = true;
|
|
||||||
this.buttonCreateClient.Click += new System.EventHandler(this.buttonCreateClient_Click);
|
|
||||||
//
|
|
||||||
// labelName
|
|
||||||
//
|
|
||||||
this.labelName.AutoSize = true;
|
|
||||||
this.labelName.Location = new System.Drawing.Point(43, 8);
|
|
||||||
this.labelName.Name = "labelName";
|
|
||||||
this.labelName.Size = new System.Drawing.Size(31, 15);
|
|
||||||
this.labelName.TabIndex = 1;
|
|
||||||
this.labelName.Text = "Имя";
|
|
||||||
//
|
|
||||||
// textBoxName
|
|
||||||
//
|
|
||||||
this.textBoxName.Location = new System.Drawing.Point(43, 26);
|
|
||||||
this.textBoxName.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
|
||||||
this.textBoxName.Name = "textBoxName";
|
|
||||||
this.textBoxName.Size = new System.Drawing.Size(239, 23);
|
|
||||||
this.textBoxName.TabIndex = 2;
|
|
||||||
//
|
|
||||||
// textBoxSurname
|
|
||||||
//
|
|
||||||
this.textBoxSurname.Location = new System.Drawing.Point(43, 72);
|
|
||||||
this.textBoxSurname.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
|
||||||
this.textBoxSurname.Name = "textBoxSurname";
|
|
||||||
this.textBoxSurname.Size = new System.Drawing.Size(239, 23);
|
|
||||||
this.textBoxSurname.TabIndex = 4;
|
|
||||||
//
|
|
||||||
// labelSurname
|
|
||||||
//
|
|
||||||
this.labelSurname.AutoSize = true;
|
|
||||||
this.labelSurname.Location = new System.Drawing.Point(43, 55);
|
|
||||||
this.labelSurname.Name = "labelSurname";
|
|
||||||
this.labelSurname.Size = new System.Drawing.Size(58, 15);
|
|
||||||
this.labelSurname.TabIndex = 3;
|
|
||||||
this.labelSurname.Text = "Фамилия";
|
|
||||||
//
|
|
||||||
// textBoxPatronymic
|
|
||||||
//
|
|
||||||
this.textBoxPatronymic.Location = new System.Drawing.Point(43, 118);
|
|
||||||
this.textBoxPatronymic.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
|
||||||
this.textBoxPatronymic.Name = "textBoxPatronymic";
|
|
||||||
this.textBoxPatronymic.Size = new System.Drawing.Size(239, 23);
|
|
||||||
this.textBoxPatronymic.TabIndex = 6;
|
|
||||||
//
|
|
||||||
// labelPatronymic
|
|
||||||
//
|
|
||||||
this.labelPatronymic.AutoSize = true;
|
|
||||||
this.labelPatronymic.Location = new System.Drawing.Point(43, 101);
|
|
||||||
this.labelPatronymic.Name = "labelPatronymic";
|
|
||||||
this.labelPatronymic.Size = new System.Drawing.Size(58, 15);
|
|
||||||
this.labelPatronymic.TabIndex = 5;
|
|
||||||
this.labelPatronymic.Text = "Отчество";
|
|
||||||
//
|
|
||||||
// labelDate
|
|
||||||
//
|
|
||||||
this.labelDate.AutoSize = true;
|
|
||||||
this.labelDate.Location = new System.Drawing.Point(43, 246);
|
|
||||||
this.labelDate.Name = "labelDate";
|
|
||||||
this.labelDate.Size = new System.Drawing.Size(105, 15);
|
|
||||||
this.labelDate.TabIndex = 9;
|
|
||||||
this.labelDate.Text = "Дата регистрации";
|
|
||||||
//
|
|
||||||
// textBoxEmail
|
|
||||||
//
|
|
||||||
this.textBoxEmail.Location = new System.Drawing.Point(43, 166);
|
|
||||||
this.textBoxEmail.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
|
||||||
this.textBoxEmail.Name = "textBoxEmail";
|
|
||||||
this.textBoxEmail.Size = new System.Drawing.Size(239, 23);
|
|
||||||
this.textBoxEmail.TabIndex = 8;
|
|
||||||
//
|
|
||||||
// labelEmail
|
|
||||||
//
|
|
||||||
this.labelEmail.AutoSize = true;
|
|
||||||
this.labelEmail.Location = new System.Drawing.Point(43, 148);
|
|
||||||
this.labelEmail.Name = "labelEmail";
|
|
||||||
this.labelEmail.Size = new System.Drawing.Size(41, 15);
|
|
||||||
this.labelEmail.TabIndex = 7;
|
|
||||||
this.labelEmail.Text = "Почта";
|
|
||||||
//
|
|
||||||
// labelPhoneNumber
|
|
||||||
//
|
|
||||||
this.labelPhoneNumber.AutoSize = true;
|
|
||||||
this.labelPhoneNumber.Location = new System.Drawing.Point(43, 196);
|
|
||||||
this.labelPhoneNumber.Name = "labelPhoneNumber";
|
|
||||||
this.labelPhoneNumber.Size = new System.Drawing.Size(101, 15);
|
|
||||||
this.labelPhoneNumber.TabIndex = 13;
|
|
||||||
this.labelPhoneNumber.Text = "Номер телефона";
|
|
||||||
//
|
|
||||||
// textBoxPhoneNumber
|
|
||||||
//
|
|
||||||
this.textBoxPhoneNumber.Location = new System.Drawing.Point(43, 213);
|
|
||||||
this.textBoxPhoneNumber.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
|
||||||
this.textBoxPhoneNumber.Name = "textBoxPhoneNumber";
|
|
||||||
this.textBoxPhoneNumber.Size = new System.Drawing.Size(239, 23);
|
|
||||||
this.textBoxPhoneNumber.TabIndex = 14;
|
|
||||||
//
|
|
||||||
// textBoxDate
|
|
||||||
//
|
|
||||||
this.textBoxDate.Location = new System.Drawing.Point(43, 263);
|
|
||||||
this.textBoxDate.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
|
||||||
this.textBoxDate.Name = "textBoxDate";
|
|
||||||
this.textBoxDate.Size = new System.Drawing.Size(239, 23);
|
|
||||||
this.textBoxDate.TabIndex = 15;
|
|
||||||
//
|
|
||||||
// CreateClientsForm
|
|
||||||
//
|
|
||||||
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
|
||||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
|
||||||
this.ClientSize = new System.Drawing.Size(324, 398);
|
|
||||||
this.Controls.Add(this.textBoxDate);
|
|
||||||
this.Controls.Add(this.textBoxPhoneNumber);
|
|
||||||
this.Controls.Add(this.labelPhoneNumber);
|
|
||||||
this.Controls.Add(this.labelDate);
|
|
||||||
this.Controls.Add(this.textBoxEmail);
|
|
||||||
this.Controls.Add(this.labelEmail);
|
|
||||||
this.Controls.Add(this.textBoxPatronymic);
|
|
||||||
this.Controls.Add(this.labelPatronymic);
|
|
||||||
this.Controls.Add(this.textBoxSurname);
|
|
||||||
this.Controls.Add(this.labelSurname);
|
|
||||||
this.Controls.Add(this.textBoxName);
|
|
||||||
this.Controls.Add(this.labelName);
|
|
||||||
this.Controls.Add(this.buttonCreateClient);
|
|
||||||
this.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
|
||||||
this.Name = "CreateClientsForm";
|
|
||||||
this.Text = "Клиенты";
|
|
||||||
this.ResumeLayout(false);
|
|
||||||
this.PerformLayout();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
private Button buttonCreateClient;
|
|
||||||
private Label labelName;
|
|
||||||
private TextBox textBoxName;
|
|
||||||
private TextBox textBoxSurname;
|
|
||||||
private Label labelSurname;
|
|
||||||
private TextBox textBoxPatronymic;
|
|
||||||
private Label labelPatronymic;
|
|
||||||
private Label labelDate;
|
|
||||||
private TextBox textBoxEmail;
|
|
||||||
private Label labelEmail;
|
|
||||||
private Label labelPhoneNumber;
|
|
||||||
private TextBox textBoxPhoneNumber;
|
|
||||||
private TextBox textBoxDate;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,45 +0,0 @@
|
|||||||
using System.Data;
|
|
||||||
|
|
||||||
namespace WebsiteForPlacingAds
|
|
||||||
{
|
|
||||||
public partial class CreateClientsForm : Form
|
|
||||||
{
|
|
||||||
//PostgreSqlDatabase psd;
|
|
||||||
AbstractManagmentDatabase managmentDatabase;
|
|
||||||
public CreateClientsForm(AbstractManagmentDatabase managmentDatabase)
|
|
||||||
{
|
|
||||||
InitializeComponent();
|
|
||||||
this.managmentDatabase = managmentDatabase;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void buttonCreateClient_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
string name = textBoxName.Text;
|
|
||||||
string surname = textBoxSurname.Text;
|
|
||||||
string patronymic = textBoxPatronymic.Text;
|
|
||||||
string email = textBoxEmail.Text;
|
|
||||||
string phoneNumber = textBoxPhoneNumber.Text;
|
|
||||||
string date = textBoxDate.Text;
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
DateTime start = DateTime.Now;
|
|
||||||
|
|
||||||
if (patronymic != null)
|
|
||||||
managmentDatabase.insertInto("clients", $"'{name}'", $"'{surname}'", $"'{patronymic}'", $"'{email}'", $"{phoneNumber}", $"'{date}'");
|
|
||||||
else managmentDatabase.insertInto("clients", $"'{name}'", $"'{surname}'", $"{patronymic}", $"'{email}'", $"{phoneNumber}", $"'{date}'");
|
|
||||||
|
|
||||||
DateTime end = DateTime.Now;
|
|
||||||
TimeSpan duration = end - start;
|
|
||||||
MessageBox.Show($"Äîáàâëåíî! Âðåìÿ âûïîëíåíèÿ: {duration.TotalMilliseconds} ìñ");
|
|
||||||
|
|
||||||
// Çàêðûòü òåêóùóþ ôîðìó ïîñëå âûïîëíåíèÿ äåéñòâèé
|
|
||||||
this.Close();
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
MessageBox.Show("Íå óäàëîñü äîáàâèòü");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,60 +0,0 @@
|
|||||||
<root>
|
|
||||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
|
||||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
|
||||||
<xsd:element name="root" msdata:IsDataSet="true">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:choice maxOccurs="unbounded">
|
|
||||||
<xsd:element name="metadata">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
|
||||||
<xsd:attribute name="type" type="xsd:string" />
|
|
||||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
|
||||||
<xsd:attribute ref="xml:space" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="assembly">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:attribute name="alias" type="xsd:string" />
|
|
||||||
<xsd:attribute name="name" type="xsd:string" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="data">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
|
||||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
|
||||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
|
||||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
|
||||||
<xsd:attribute ref="xml:space" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="resheader">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
</xsd:choice>
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
</xsd:schema>
|
|
||||||
<resheader name="resmimetype">
|
|
||||||
<value>text/microsoft-resx</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="version">
|
|
||||||
<value>2.0</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="reader">
|
|
||||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="writer">
|
|
||||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
|
||||||
</resheader>
|
|
||||||
</root>
|
|
@ -1,87 +0,0 @@
|
|||||||
namespace WebsiteForPlacingAds
|
|
||||||
{
|
|
||||||
partial class DeleteClientsForm
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Required designer variable.
|
|
||||||
/// </summary>
|
|
||||||
private System.ComponentModel.IContainer components = null;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Clean up any resources being used.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
|
||||||
protected override void Dispose(bool disposing)
|
|
||||||
{
|
|
||||||
if (disposing && (components != null))
|
|
||||||
{
|
|
||||||
components.Dispose();
|
|
||||||
}
|
|
||||||
base.Dispose(disposing);
|
|
||||||
}
|
|
||||||
|
|
||||||
#region Windows Form Designer generated code
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Required method for Designer support - do not modify
|
|
||||||
/// the contents of this method with the code editor.
|
|
||||||
/// </summary>
|
|
||||||
private void InitializeComponent()
|
|
||||||
{
|
|
||||||
this.label1 = new System.Windows.Forms.Label();
|
|
||||||
this.buttonDeleteClient = new System.Windows.Forms.Button();
|
|
||||||
this.comboBoxDeleteClients = new System.Windows.Forms.ComboBox();
|
|
||||||
this.SuspendLayout();
|
|
||||||
//
|
|
||||||
// label1
|
|
||||||
//
|
|
||||||
this.label1.AutoSize = true;
|
|
||||||
this.label1.Location = new System.Drawing.Point(70, 16);
|
|
||||||
this.label1.Name = "label1";
|
|
||||||
this.label1.Size = new System.Drawing.Size(266, 15);
|
|
||||||
this.label1.TabIndex = 0;
|
|
||||||
this.label1.Text = "Выберите объявление, которое хотите удалить";
|
|
||||||
//
|
|
||||||
// buttonDeleteClient
|
|
||||||
//
|
|
||||||
this.buttonDeleteClient.Location = new System.Drawing.Point(132, 85);
|
|
||||||
this.buttonDeleteClient.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
|
||||||
this.buttonDeleteClient.Name = "buttonDeleteClient";
|
|
||||||
this.buttonDeleteClient.Size = new System.Drawing.Size(163, 28);
|
|
||||||
this.buttonDeleteClient.TabIndex = 1;
|
|
||||||
this.buttonDeleteClient.Text = "Удалить";
|
|
||||||
this.buttonDeleteClient.UseVisualStyleBackColor = true;
|
|
||||||
this.buttonDeleteClient.Click += new System.EventHandler(this.buttonDeleteAd_Click);
|
|
||||||
//
|
|
||||||
// comboBoxDeleteClients
|
|
||||||
//
|
|
||||||
this.comboBoxDeleteClients.FormattingEnabled = true;
|
|
||||||
this.comboBoxDeleteClients.Location = new System.Drawing.Point(35, 48);
|
|
||||||
this.comboBoxDeleteClients.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
|
||||||
this.comboBoxDeleteClients.Name = "comboBoxDeleteClients";
|
|
||||||
this.comboBoxDeleteClients.Size = new System.Drawing.Size(367, 23);
|
|
||||||
this.comboBoxDeleteClients.TabIndex = 2;
|
|
||||||
//
|
|
||||||
// DeleteClientsForm
|
|
||||||
//
|
|
||||||
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
|
||||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
|
||||||
this.ClientSize = new System.Drawing.Size(442, 131);
|
|
||||||
this.Controls.Add(this.comboBoxDeleteClients);
|
|
||||||
this.Controls.Add(this.buttonDeleteClient);
|
|
||||||
this.Controls.Add(this.label1);
|
|
||||||
this.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
|
||||||
this.Name = "DeleteClientsForm";
|
|
||||||
this.Text = "Удалить объявление";
|
|
||||||
this.ResumeLayout(false);
|
|
||||||
this.PerformLayout();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
private Label label1;
|
|
||||||
private Button buttonDeleteClient;
|
|
||||||
private ComboBox comboBoxDeleteClients;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,68 +0,0 @@
|
|||||||
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 WebsiteForPlacingAds
|
|
||||||
{
|
|
||||||
public partial class DeleteClientsForm : Form
|
|
||||||
{
|
|
||||||
AbstractManagmentDatabase managmentDatabase;
|
|
||||||
private int setval_seq;
|
|
||||||
public DeleteClientsForm(AbstractManagmentDatabase managmentDatabase)
|
|
||||||
{
|
|
||||||
InitializeComponent();
|
|
||||||
this.managmentDatabase = managmentDatabase;
|
|
||||||
LoadData();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void buttonDeleteAd_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
string[] clients = comboBoxDeleteClients.SelectedItem.ToString().Split("|");
|
|
||||||
string client_id = clients[0].Trim();
|
|
||||||
//string query = $"DELETE FROM ADS WHERE ads_id = {ad_id}";
|
|
||||||
//string query_seq_reduction = $"SELECT setval('seq_ads', {setval_seq - 1});";
|
|
||||||
try
|
|
||||||
{
|
|
||||||
DateTime start = DateTime.Now;
|
|
||||||
|
|
||||||
managmentDatabase.deleteEntry("clients", int.Parse(client_id));
|
|
||||||
LoadData();
|
|
||||||
if (setval_seq > 0) managmentDatabase.reduceSeq("seq_clients", setval_seq);
|
|
||||||
|
|
||||||
DateTime end = DateTime.Now;
|
|
||||||
TimeSpan duration = end - start;
|
|
||||||
|
|
||||||
MessageBox.Show($"Удалено! Время выполнения: {duration.TotalMilliseconds} мс");
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
MessageBox.Show("Не удалось удалить");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
public void LoadData()
|
|
||||||
{
|
|
||||||
comboBoxDeleteClients.Items.Clear();
|
|
||||||
DataTable result = managmentDatabase.getAllEntry("Clients");
|
|
||||||
setval_seq = result.Rows.Count;
|
|
||||||
string Clients = "";
|
|
||||||
for (int i = 0; i < result.Rows.Count; i++)
|
|
||||||
{
|
|
||||||
setval_seq = Math.Max(Convert.ToInt32(managmentDatabase.getRowTableById(result, "clients_id", i)), setval_seq);
|
|
||||||
Clients = managmentDatabase.getRowTableById(result, "clients_id", i).ToString() + " | " +
|
|
||||||
managmentDatabase.getRowTableById(result, "name", i).ToString() + " | " +
|
|
||||||
managmentDatabase.getRowTableById(result, "surname", i).ToString() + " | " +
|
|
||||||
managmentDatabase.getRowTableById(result, "patronymic", i).ToString() + " | " +
|
|
||||||
managmentDatabase.getRowTableById(result, "email", i).ToString() + " | " +
|
|
||||||
managmentDatabase.getRowTableById(result, "phone_number", i).ToString() + " | " +
|
|
||||||
((DateTime)managmentDatabase.getRowTableById(result, "registration_date", i)).ToString("dd.MM.yyy") + "\n";
|
|
||||||
comboBoxDeleteClients.Items.Add(Clients);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,60 +0,0 @@
|
|||||||
<root>
|
|
||||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
|
||||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
|
||||||
<xsd:element name="root" msdata:IsDataSet="true">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:choice maxOccurs="unbounded">
|
|
||||||
<xsd:element name="metadata">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
|
||||||
<xsd:attribute name="type" type="xsd:string" />
|
|
||||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
|
||||||
<xsd:attribute ref="xml:space" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="assembly">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:attribute name="alias" type="xsd:string" />
|
|
||||||
<xsd:attribute name="name" type="xsd:string" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="data">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
|
||||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
|
||||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
|
||||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
|
||||||
<xsd:attribute ref="xml:space" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="resheader">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
</xsd:choice>
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
</xsd:schema>
|
|
||||||
<resheader name="resmimetype">
|
|
||||||
<value>text/microsoft-resx</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="version">
|
|
||||||
<value>2.0</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="reader">
|
|
||||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="writer">
|
|
||||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
|
||||||
</resheader>
|
|
||||||
</root>
|
|
@ -1,75 +0,0 @@
|
|||||||
namespace WebsiteForPlacingAds
|
|
||||||
{
|
|
||||||
partial class ListClientsForm
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Required designer variable.
|
|
||||||
/// </summary>
|
|
||||||
private System.ComponentModel.IContainer components = null;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Clean up any resources being used.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
|
||||||
protected override void Dispose(bool disposing)
|
|
||||||
{
|
|
||||||
if (disposing && (components != null))
|
|
||||||
{
|
|
||||||
components.Dispose();
|
|
||||||
}
|
|
||||||
base.Dispose(disposing);
|
|
||||||
}
|
|
||||||
|
|
||||||
#region Windows Form Designer generated code
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Required method for Designer support - do not modify
|
|
||||||
/// the contents of this method with the code editor.
|
|
||||||
/// </summary>
|
|
||||||
private void InitializeComponent()
|
|
||||||
{
|
|
||||||
this.label1 = new System.Windows.Forms.Label();
|
|
||||||
this.labelListClients = new System.Windows.Forms.Label();
|
|
||||||
this.SuspendLayout();
|
|
||||||
//
|
|
||||||
// label1
|
|
||||||
//
|
|
||||||
this.label1.AutoSize = true;
|
|
||||||
this.label1.BackColor = System.Drawing.SystemColors.Control;
|
|
||||||
this.label1.Font = new System.Drawing.Font("Segoe UI", 11F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
|
|
||||||
this.label1.Location = new System.Drawing.Point(10, 7);
|
|
||||||
this.label1.Name = "label1";
|
|
||||||
this.label1.Size = new System.Drawing.Size(127, 20);
|
|
||||||
this.label1.TabIndex = 0;
|
|
||||||
this.label1.Text = "Список клиентов";
|
|
||||||
//
|
|
||||||
// labelListClients
|
|
||||||
//
|
|
||||||
this.labelListClients.AutoSize = true;
|
|
||||||
this.labelListClients.Font = new System.Drawing.Font("Segoe UI", 10F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
|
|
||||||
this.labelListClients.Location = new System.Drawing.Point(10, 35);
|
|
||||||
this.labelListClients.Name = "labelListClients";
|
|
||||||
this.labelListClients.Size = new System.Drawing.Size(0, 19);
|
|
||||||
this.labelListClients.TabIndex = 1;
|
|
||||||
//
|
|
||||||
// ListClientsForm
|
|
||||||
//
|
|
||||||
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
|
||||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
|
||||||
this.ClientSize = new System.Drawing.Size(700, 338);
|
|
||||||
this.Controls.Add(this.labelListClients);
|
|
||||||
this.Controls.Add(this.label1);
|
|
||||||
this.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
|
||||||
this.Name = "ListClientsForm";
|
|
||||||
this.Text = "Список клиентов";
|
|
||||||
this.ResumeLayout(false);
|
|
||||||
this.PerformLayout();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
private Label label1;
|
|
||||||
private Label labelListClients;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,48 +0,0 @@
|
|||||||
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 System.Windows.Forms.VisualStyles;
|
|
||||||
|
|
||||||
namespace WebsiteForPlacingAds
|
|
||||||
{
|
|
||||||
public partial class ListClientsForm : Form
|
|
||||||
{
|
|
||||||
AbstractManagmentDatabase managmentDatabase;
|
|
||||||
public ListClientsForm(AbstractManagmentDatabase managmentDatabase)
|
|
||||||
{
|
|
||||||
InitializeComponent();
|
|
||||||
this.managmentDatabase = managmentDatabase;
|
|
||||||
LoadData();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void LoadData()
|
|
||||||
{
|
|
||||||
DateTime start = DateTime.Now;
|
|
||||||
|
|
||||||
DataTable result = managmentDatabase.getAllEntry("clients");
|
|
||||||
string listClients = "";
|
|
||||||
for (int i = 0; i < result.Rows.Count; i++)
|
|
||||||
{
|
|
||||||
listClients += managmentDatabase.getRowTableById(result, "clients_id", i).ToString() + " | " +
|
|
||||||
managmentDatabase.getRowTableById(result, "name", i).ToString() + " | " +
|
|
||||||
managmentDatabase.getRowTableById(result, "surname", i).ToString() + " | " +
|
|
||||||
managmentDatabase.getRowTableById(result, "patronymic", i).ToString() + " | " +
|
|
||||||
managmentDatabase.getRowTableById(result, "email", i).ToString() + " | " +
|
|
||||||
managmentDatabase.getRowTableById(result, "phone_number", i).ToString() + " | " +
|
|
||||||
((DateTime)managmentDatabase.getRowTableById(result, "registration_date", i)).ToString("dd.MM.yyy") + "\n";
|
|
||||||
}
|
|
||||||
labelListClients.Text = listClients;
|
|
||||||
|
|
||||||
|
|
||||||
DateTime end = DateTime.Now;
|
|
||||||
TimeSpan duration = end - start;
|
|
||||||
MessageBox.Show($"Список загружен! Время выполнения: {duration.TotalMilliseconds} мс");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,60 +0,0 @@
|
|||||||
<root>
|
|
||||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
|
||||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
|
||||||
<xsd:element name="root" msdata:IsDataSet="true">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:choice maxOccurs="unbounded">
|
|
||||||
<xsd:element name="metadata">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
|
||||||
<xsd:attribute name="type" type="xsd:string" />
|
|
||||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
|
||||||
<xsd:attribute ref="xml:space" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="assembly">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:attribute name="alias" type="xsd:string" />
|
|
||||||
<xsd:attribute name="name" type="xsd:string" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="data">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
|
||||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
|
||||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
|
||||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
|
||||||
<xsd:attribute ref="xml:space" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="resheader">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
</xsd:choice>
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
</xsd:schema>
|
|
||||||
<resheader name="resmimetype">
|
|
||||||
<value>text/microsoft-resx</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="version">
|
|
||||||
<value>2.0</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="reader">
|
|
||||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="writer">
|
|
||||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
|
||||||
</resheader>
|
|
||||||
</root>
|
|
@ -1,225 +0,0 @@
|
|||||||
namespace WebsiteForPlacingAds
|
|
||||||
{
|
|
||||||
partial class UpdateClientsForm
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Required designer variable.
|
|
||||||
/// </summary>
|
|
||||||
private System.ComponentModel.IContainer components = null;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Clean up any resources being used.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
|
||||||
protected override void Dispose(bool disposing)
|
|
||||||
{
|
|
||||||
if (disposing && (components != null))
|
|
||||||
{
|
|
||||||
components.Dispose();
|
|
||||||
}
|
|
||||||
base.Dispose(disposing);
|
|
||||||
}
|
|
||||||
|
|
||||||
#region Windows Form Designer generated code
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Required method for Designer support - do not modify
|
|
||||||
/// the contents of this method with the code editor.
|
|
||||||
/// </summary>
|
|
||||||
private void InitializeComponent()
|
|
||||||
{
|
|
||||||
this.buttonUpdateClient = new System.Windows.Forms.Button();
|
|
||||||
this.label1 = new System.Windows.Forms.Label();
|
|
||||||
this.comboBoxUpdateClient = new System.Windows.Forms.ComboBox();
|
|
||||||
this.textBoxDate = new System.Windows.Forms.TextBox();
|
|
||||||
this.textBoxPhoneNumber = new System.Windows.Forms.TextBox();
|
|
||||||
this.labelPhoneNumber = new System.Windows.Forms.Label();
|
|
||||||
this.labelDate = new System.Windows.Forms.Label();
|
|
||||||
this.textBoxEmail = new System.Windows.Forms.TextBox();
|
|
||||||
this.labelEmail = new System.Windows.Forms.Label();
|
|
||||||
this.textBoxPatronymic = new System.Windows.Forms.TextBox();
|
|
||||||
this.labelPatronymic = new System.Windows.Forms.Label();
|
|
||||||
this.textBoxSurname = new System.Windows.Forms.TextBox();
|
|
||||||
this.labelSurname = new System.Windows.Forms.Label();
|
|
||||||
this.textBoxName = new System.Windows.Forms.TextBox();
|
|
||||||
this.labelName = new System.Windows.Forms.Label();
|
|
||||||
this.SuspendLayout();
|
|
||||||
//
|
|
||||||
// buttonUpdateClient
|
|
||||||
//
|
|
||||||
this.buttonUpdateClient.Location = new System.Drawing.Point(81, 407);
|
|
||||||
this.buttonUpdateClient.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
|
||||||
this.buttonUpdateClient.Name = "buttonUpdateClient";
|
|
||||||
this.buttonUpdateClient.Size = new System.Drawing.Size(239, 29);
|
|
||||||
this.buttonUpdateClient.TabIndex = 18;
|
|
||||||
this.buttonUpdateClient.Text = "Обновить клиента";
|
|
||||||
this.buttonUpdateClient.UseVisualStyleBackColor = true;
|
|
||||||
this.buttonUpdateClient.Click += new System.EventHandler(this.buttonUpdateClient_Click);
|
|
||||||
//
|
|
||||||
// label1
|
|
||||||
//
|
|
||||||
this.label1.AutoSize = true;
|
|
||||||
this.label1.Location = new System.Drawing.Point(51, 15);
|
|
||||||
this.label1.Name = "label1";
|
|
||||||
this.label1.Size = new System.Drawing.Size(259, 15);
|
|
||||||
this.label1.TabIndex = 33;
|
|
||||||
this.label1.Text = "Выберите клиента, которого хотите обновить";
|
|
||||||
//
|
|
||||||
// comboBoxUpdateClient
|
|
||||||
//
|
|
||||||
this.comboBoxUpdateClient.FormattingEnabled = true;
|
|
||||||
this.comboBoxUpdateClient.Location = new System.Drawing.Point(10, 39);
|
|
||||||
this.comboBoxUpdateClient.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
|
||||||
this.comboBoxUpdateClient.Name = "comboBoxUpdateClient";
|
|
||||||
this.comboBoxUpdateClient.Size = new System.Drawing.Size(377, 23);
|
|
||||||
this.comboBoxUpdateClient.TabIndex = 34;
|
|
||||||
this.comboBoxUpdateClient.SelectedIndexChanged += new System.EventHandler(this.comboBoxUpdateClient_SelectedIndexChanged);
|
|
||||||
//
|
|
||||||
// textBoxDate
|
|
||||||
//
|
|
||||||
this.textBoxDate.Location = new System.Drawing.Point(79, 326);
|
|
||||||
this.textBoxDate.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
|
||||||
this.textBoxDate.Name = "textBoxDate";
|
|
||||||
this.textBoxDate.Size = new System.Drawing.Size(239, 23);
|
|
||||||
this.textBoxDate.TabIndex = 47;
|
|
||||||
//
|
|
||||||
// textBoxPhoneNumber
|
|
||||||
//
|
|
||||||
this.textBoxPhoneNumber.Location = new System.Drawing.Point(79, 276);
|
|
||||||
this.textBoxPhoneNumber.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
|
||||||
this.textBoxPhoneNumber.Name = "textBoxPhoneNumber";
|
|
||||||
this.textBoxPhoneNumber.Size = new System.Drawing.Size(239, 23);
|
|
||||||
this.textBoxPhoneNumber.TabIndex = 46;
|
|
||||||
//
|
|
||||||
// labelPhoneNumber
|
|
||||||
//
|
|
||||||
this.labelPhoneNumber.AutoSize = true;
|
|
||||||
this.labelPhoneNumber.Location = new System.Drawing.Point(79, 259);
|
|
||||||
this.labelPhoneNumber.Name = "labelPhoneNumber";
|
|
||||||
this.labelPhoneNumber.Size = new System.Drawing.Size(101, 15);
|
|
||||||
this.labelPhoneNumber.TabIndex = 45;
|
|
||||||
this.labelPhoneNumber.Text = "Номер телефона";
|
|
||||||
//
|
|
||||||
// labelDate
|
|
||||||
//
|
|
||||||
this.labelDate.AutoSize = true;
|
|
||||||
this.labelDate.Location = new System.Drawing.Point(79, 309);
|
|
||||||
this.labelDate.Name = "labelDate";
|
|
||||||
this.labelDate.Size = new System.Drawing.Size(105, 15);
|
|
||||||
this.labelDate.TabIndex = 43;
|
|
||||||
this.labelDate.Text = "Дата регистрации";
|
|
||||||
//
|
|
||||||
// textBoxEmail
|
|
||||||
//
|
|
||||||
this.textBoxEmail.Location = new System.Drawing.Point(79, 229);
|
|
||||||
this.textBoxEmail.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
|
||||||
this.textBoxEmail.Name = "textBoxEmail";
|
|
||||||
this.textBoxEmail.Size = new System.Drawing.Size(239, 23);
|
|
||||||
this.textBoxEmail.TabIndex = 42;
|
|
||||||
//
|
|
||||||
// labelEmail
|
|
||||||
//
|
|
||||||
this.labelEmail.AutoSize = true;
|
|
||||||
this.labelEmail.Location = new System.Drawing.Point(79, 211);
|
|
||||||
this.labelEmail.Name = "labelEmail";
|
|
||||||
this.labelEmail.Size = new System.Drawing.Size(41, 15);
|
|
||||||
this.labelEmail.TabIndex = 41;
|
|
||||||
this.labelEmail.Text = "Почта";
|
|
||||||
//
|
|
||||||
// textBoxPatronymic
|
|
||||||
//
|
|
||||||
this.textBoxPatronymic.Location = new System.Drawing.Point(79, 181);
|
|
||||||
this.textBoxPatronymic.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
|
||||||
this.textBoxPatronymic.Name = "textBoxPatronymic";
|
|
||||||
this.textBoxPatronymic.Size = new System.Drawing.Size(239, 23);
|
|
||||||
this.textBoxPatronymic.TabIndex = 40;
|
|
||||||
//
|
|
||||||
// labelPatronymic
|
|
||||||
//
|
|
||||||
this.labelPatronymic.AutoSize = true;
|
|
||||||
this.labelPatronymic.Location = new System.Drawing.Point(79, 164);
|
|
||||||
this.labelPatronymic.Name = "labelPatronymic";
|
|
||||||
this.labelPatronymic.Size = new System.Drawing.Size(58, 15);
|
|
||||||
this.labelPatronymic.TabIndex = 39;
|
|
||||||
this.labelPatronymic.Text = "Отчество";
|
|
||||||
//
|
|
||||||
// textBoxSurname
|
|
||||||
//
|
|
||||||
this.textBoxSurname.Location = new System.Drawing.Point(79, 135);
|
|
||||||
this.textBoxSurname.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
|
||||||
this.textBoxSurname.Name = "textBoxSurname";
|
|
||||||
this.textBoxSurname.Size = new System.Drawing.Size(239, 23);
|
|
||||||
this.textBoxSurname.TabIndex = 38;
|
|
||||||
//
|
|
||||||
// labelSurname
|
|
||||||
//
|
|
||||||
this.labelSurname.AutoSize = true;
|
|
||||||
this.labelSurname.Location = new System.Drawing.Point(79, 118);
|
|
||||||
this.labelSurname.Name = "labelSurname";
|
|
||||||
this.labelSurname.Size = new System.Drawing.Size(58, 15);
|
|
||||||
this.labelSurname.TabIndex = 37;
|
|
||||||
this.labelSurname.Text = "Фамилия";
|
|
||||||
//
|
|
||||||
// textBoxName
|
|
||||||
//
|
|
||||||
this.textBoxName.Location = new System.Drawing.Point(79, 89);
|
|
||||||
this.textBoxName.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
|
||||||
this.textBoxName.Name = "textBoxName";
|
|
||||||
this.textBoxName.Size = new System.Drawing.Size(239, 23);
|
|
||||||
this.textBoxName.TabIndex = 36;
|
|
||||||
//
|
|
||||||
// labelName
|
|
||||||
//
|
|
||||||
this.labelName.AutoSize = true;
|
|
||||||
this.labelName.Location = new System.Drawing.Point(79, 71);
|
|
||||||
this.labelName.Name = "labelName";
|
|
||||||
this.labelName.Size = new System.Drawing.Size(31, 15);
|
|
||||||
this.labelName.TabIndex = 35;
|
|
||||||
this.labelName.Text = "Имя";
|
|
||||||
//
|
|
||||||
// UpdateClientsForm
|
|
||||||
//
|
|
||||||
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
|
||||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
|
||||||
this.ClientSize = new System.Drawing.Size(397, 464);
|
|
||||||
this.Controls.Add(this.textBoxDate);
|
|
||||||
this.Controls.Add(this.textBoxPhoneNumber);
|
|
||||||
this.Controls.Add(this.labelPhoneNumber);
|
|
||||||
this.Controls.Add(this.labelDate);
|
|
||||||
this.Controls.Add(this.textBoxEmail);
|
|
||||||
this.Controls.Add(this.labelEmail);
|
|
||||||
this.Controls.Add(this.textBoxPatronymic);
|
|
||||||
this.Controls.Add(this.labelPatronymic);
|
|
||||||
this.Controls.Add(this.textBoxSurname);
|
|
||||||
this.Controls.Add(this.labelSurname);
|
|
||||||
this.Controls.Add(this.textBoxName);
|
|
||||||
this.Controls.Add(this.labelName);
|
|
||||||
this.Controls.Add(this.comboBoxUpdateClient);
|
|
||||||
this.Controls.Add(this.label1);
|
|
||||||
this.Controls.Add(this.buttonUpdateClient);
|
|
||||||
this.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
|
||||||
this.Name = "UpdateClientsForm";
|
|
||||||
this.Text = "Обновить клиента";
|
|
||||||
this.ResumeLayout(false);
|
|
||||||
this.PerformLayout();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
private Button buttonUpdateClient;
|
|
||||||
private Label label1;
|
|
||||||
private ComboBox comboBoxUpdateClient;
|
|
||||||
private TextBox textBoxDate;
|
|
||||||
private TextBox textBoxPhoneNumber;
|
|
||||||
private Label labelPhoneNumber;
|
|
||||||
private Label labelDate;
|
|
||||||
private TextBox textBoxEmail;
|
|
||||||
private Label labelEmail;
|
|
||||||
private TextBox textBoxPatronymic;
|
|
||||||
private Label labelPatronymic;
|
|
||||||
private TextBox textBoxSurname;
|
|
||||||
private Label labelSurname;
|
|
||||||
private TextBox textBoxName;
|
|
||||||
private Label labelName;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,110 +0,0 @@
|
|||||||
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 WebsiteForPlacingAds
|
|
||||||
{
|
|
||||||
public partial class UpdateClientsForm : Form
|
|
||||||
{
|
|
||||||
AbstractManagmentDatabase managmentDatabase;
|
|
||||||
public UpdateClientsForm(AbstractManagmentDatabase managmentDatabase)
|
|
||||||
{
|
|
||||||
InitializeComponent();
|
|
||||||
this.managmentDatabase = managmentDatabase;
|
|
||||||
LoadData();
|
|
||||||
}
|
|
||||||
public void LoadData()
|
|
||||||
{
|
|
||||||
comboBoxUpdateClient.Items.Clear();
|
|
||||||
DataTable result = managmentDatabase.getAllEntry("Clients");
|
|
||||||
string Clients = "";
|
|
||||||
for (int i = 0; i < result.Rows.Count; i++)
|
|
||||||
{
|
|
||||||
Clients = result.Rows[i]["clients_id"].ToString() + " | " +
|
|
||||||
(string)result.Rows[i]["name"] + " | " +
|
|
||||||
result.Rows[i]["surname"].ToString() + " | " +
|
|
||||||
(string)result.Rows[i]["patronymic"] + " | " +
|
|
||||||
result.Rows[i]["email"].ToString() + " | " +
|
|
||||||
result.Rows[i]["phone_number"].ToString() + " | " +
|
|
||||||
((DateTime)result.Rows[i]["registration_date"]).ToString("dd.MM.yyyy") + "\n";
|
|
||||||
comboBoxUpdateClient.Items.Add(Clients);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
private void buttonUpdateClient_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
string[] selectedClients = comboBoxUpdateClient.SelectedItem.ToString().Split("|");
|
|
||||||
int clients_id = int.Parse(selectedClients[0].Trim());
|
|
||||||
|
|
||||||
string query = $"UPDATE clients SET ";
|
|
||||||
int len = query.Length;
|
|
||||||
|
|
||||||
|
|
||||||
string oldName = managmentDatabase.getRowTableById("clients", "name", clients_id).ToString();
|
|
||||||
string oldSurname = managmentDatabase.getRowTableById("clients", "surname", clients_id).ToString();
|
|
||||||
string oldPatronymic = managmentDatabase.getRowTableById("clients", "patronymic", clients_id).ToString();
|
|
||||||
string oldEmail = managmentDatabase.getRowTableById("clients", "email", clients_id).ToString();
|
|
||||||
string oldPhoneNumber = managmentDatabase.getRowTableById("clients", "phone_number", clients_id).ToString();
|
|
||||||
string oldDate = ((DateTime)managmentDatabase.getRowTableById("clients", "registration_date", clients_id)).ToString("dd.MM.yyyy");
|
|
||||||
|
|
||||||
string newName = textBoxName.Text;
|
|
||||||
string newSurname = textBoxSurname.Text;
|
|
||||||
string newPatronymic = textBoxPatronymic.Text;
|
|
||||||
string newEmail = textBoxEmail.Text;
|
|
||||||
string newPhoneNumber = textBoxPhoneNumber.Text;
|
|
||||||
string newDate = textBoxDate.Text;
|
|
||||||
|
|
||||||
|
|
||||||
query = oldName == newName ? query : query + $"name = '{newName}', ";
|
|
||||||
query = oldSurname == newSurname ? query : query + $"surname = '{newSurname}', ";
|
|
||||||
query = oldPatronymic == newPatronymic ? query : query + $"patronymic = '{newPatronymic}', ";
|
|
||||||
query = oldEmail == newEmail ? query : query + $"email = '{newEmail}', ";
|
|
||||||
query = oldPhoneNumber == newPhoneNumber ? query : query + $"phone_number = {newPhoneNumber}, ";
|
|
||||||
query = oldDate == newDate ? query : query + $"registration_date = '{newDate}', ";
|
|
||||||
|
|
||||||
if (len != query.Length)
|
|
||||||
{
|
|
||||||
query = query.TrimEnd(' ');
|
|
||||||
query = query.TrimEnd(',');
|
|
||||||
query += $" WHERE Clients_ID = {clients_id};";
|
|
||||||
}
|
|
||||||
try
|
|
||||||
{
|
|
||||||
DateTime start = DateTime.Now;
|
|
||||||
|
|
||||||
managmentDatabase.ExecuteNonQuery(query);
|
|
||||||
|
|
||||||
DateTime end = DateTime.Now;
|
|
||||||
TimeSpan duration = end - start;
|
|
||||||
MessageBox.Show($"Данные успешно обновлены! Время выполнения: {duration.TotalMilliseconds} мс");
|
|
||||||
}
|
|
||||||
catch (Exception)
|
|
||||||
{
|
|
||||||
|
|
||||||
MessageBox.Show("Данные не обновились");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
public void LoadDataSelectedItem(int clients_id)
|
|
||||||
{
|
|
||||||
DataTable result = managmentDatabase.getEntryById("clients", clients_id);
|
|
||||||
textBoxName.Text = managmentDatabase.getRowTableById(result, "name", 0).ToString();
|
|
||||||
textBoxSurname.Text = managmentDatabase.getRowTableById(result, "surname", 0).ToString();
|
|
||||||
textBoxPatronymic.Text = managmentDatabase.getRowTableById(result, "patronymic", 0).ToString();
|
|
||||||
textBoxEmail.Text = managmentDatabase.getRowTableById(result, "email", 0).ToString();
|
|
||||||
textBoxPhoneNumber.Text = managmentDatabase.getRowTableById(result, "phone_number", 0).ToString();
|
|
||||||
textBoxDate.Text = ((DateTime)managmentDatabase.getRowTableById(result, "registration_date", 0)).ToString("dd.MM.yyyy");
|
|
||||||
}
|
|
||||||
|
|
||||||
private void comboBoxUpdateClient_SelectedIndexChanged(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
string[] selectedItems = comboBoxUpdateClient.SelectedItem.ToString().Split("|");
|
|
||||||
int clients_id = int.Parse(selectedItems[0].Trim());
|
|
||||||
LoadDataSelectedItem(clients_id);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,60 +0,0 @@
|
|||||||
<root>
|
|
||||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
|
||||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
|
||||||
<xsd:element name="root" msdata:IsDataSet="true">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:choice maxOccurs="unbounded">
|
|
||||||
<xsd:element name="metadata">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
|
||||||
<xsd:attribute name="type" type="xsd:string" />
|
|
||||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
|
||||||
<xsd:attribute ref="xml:space" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="assembly">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:attribute name="alias" type="xsd:string" />
|
|
||||||
<xsd:attribute name="name" type="xsd:string" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="data">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
|
||||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
|
||||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
|
||||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
|
||||||
<xsd:attribute ref="xml:space" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="resheader">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
</xsd:choice>
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
</xsd:schema>
|
|
||||||
<resheader name="resmimetype">
|
|
||||||
<value>text/microsoft-resx</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="version">
|
|
||||||
<value>2.0</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="reader">
|
|
||||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="writer">
|
|
||||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
|
||||||
</resheader>
|
|
||||||
</root>
|
|
127
BulletinBoard/BulletinBoard/FormAddReview.Designer.cs
generated
Normal file
127
BulletinBoard/BulletinBoard/FormAddReview.Designer.cs
generated
Normal file
@ -0,0 +1,127 @@
|
|||||||
|
namespace BulletinBoard
|
||||||
|
{
|
||||||
|
partial class FormAddReview
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Required designer variable.
|
||||||
|
/// </summary>
|
||||||
|
private System.ComponentModel.IContainer components = null;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Clean up any resources being used.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||||
|
protected override void Dispose(bool disposing)
|
||||||
|
{
|
||||||
|
if (disposing && (components != null))
|
||||||
|
{
|
||||||
|
components.Dispose();
|
||||||
|
}
|
||||||
|
base.Dispose(disposing);
|
||||||
|
}
|
||||||
|
|
||||||
|
#region Windows Form Designer generated code
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Required method for Designer support - do not modify
|
||||||
|
/// the contents of this method with the code editor.
|
||||||
|
/// </summary>
|
||||||
|
private void InitializeComponent()
|
||||||
|
{
|
||||||
|
this.label1 = new System.Windows.Forms.Label();
|
||||||
|
this.textBoxReviewText = new System.Windows.Forms.TextBox();
|
||||||
|
this.label2 = new System.Windows.Forms.Label();
|
||||||
|
this.numericUpDown = new System.Windows.Forms.NumericUpDown();
|
||||||
|
this.buttonAddReview = new System.Windows.Forms.Button();
|
||||||
|
this.buttonCancel = new System.Windows.Forms.Button();
|
||||||
|
((System.ComponentModel.ISupportInitialize)(this.numericUpDown)).BeginInit();
|
||||||
|
this.SuspendLayout();
|
||||||
|
//
|
||||||
|
// label1
|
||||||
|
//
|
||||||
|
this.label1.AutoSize = true;
|
||||||
|
this.label1.Location = new System.Drawing.Point(12, 9);
|
||||||
|
this.label1.Name = "label1";
|
||||||
|
this.label1.Size = new System.Drawing.Size(83, 15);
|
||||||
|
this.label1.TabIndex = 0;
|
||||||
|
this.label1.Text = "Новый отзыв:";
|
||||||
|
//
|
||||||
|
// textBoxReviewText
|
||||||
|
//
|
||||||
|
this.textBoxReviewText.Location = new System.Drawing.Point(12, 27);
|
||||||
|
this.textBoxReviewText.Multiline = true;
|
||||||
|
this.textBoxReviewText.Name = "textBoxReviewText";
|
||||||
|
this.textBoxReviewText.Size = new System.Drawing.Size(157, 116);
|
||||||
|
this.textBoxReviewText.TabIndex = 1;
|
||||||
|
//
|
||||||
|
// label2
|
||||||
|
//
|
||||||
|
this.label2.AutoSize = true;
|
||||||
|
this.label2.Location = new System.Drawing.Point(12, 146);
|
||||||
|
this.label2.Name = "label2";
|
||||||
|
this.label2.Size = new System.Drawing.Size(76, 15);
|
||||||
|
this.label2.TabIndex = 2;
|
||||||
|
this.label2.Text = "Оценка(1-5):";
|
||||||
|
//
|
||||||
|
// numericUpDown
|
||||||
|
//
|
||||||
|
this.numericUpDown.Location = new System.Drawing.Point(12, 164);
|
||||||
|
this.numericUpDown.Name = "numericUpDown";
|
||||||
|
this.numericUpDown.Size = new System.Drawing.Size(157, 23);
|
||||||
|
this.numericUpDown.TabIndex = 3;
|
||||||
|
this.numericUpDown.Value = new decimal(new int[] {
|
||||||
|
5,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0});
|
||||||
|
//
|
||||||
|
// buttonAddReview
|
||||||
|
//
|
||||||
|
this.buttonAddReview.Location = new System.Drawing.Point(12, 193);
|
||||||
|
this.buttonAddReview.Name = "buttonAddReview";
|
||||||
|
this.buttonAddReview.Size = new System.Drawing.Size(75, 23);
|
||||||
|
this.buttonAddReview.TabIndex = 4;
|
||||||
|
this.buttonAddReview.Text = "Добавить";
|
||||||
|
this.buttonAddReview.UseVisualStyleBackColor = true;
|
||||||
|
this.buttonAddReview.Click += new System.EventHandler(this.buttonAddReview_Click);
|
||||||
|
//
|
||||||
|
// buttonCancel
|
||||||
|
//
|
||||||
|
this.buttonCancel.Location = new System.Drawing.Point(94, 193);
|
||||||
|
this.buttonCancel.Name = "buttonCancel";
|
||||||
|
this.buttonCancel.Size = new System.Drawing.Size(75, 23);
|
||||||
|
this.buttonCancel.TabIndex = 5;
|
||||||
|
this.buttonCancel.Text = "Отмена";
|
||||||
|
this.buttonCancel.UseVisualStyleBackColor = true;
|
||||||
|
this.buttonCancel.Click += new System.EventHandler(this.buttonCancel_Click);
|
||||||
|
//
|
||||||
|
// FormAddReview
|
||||||
|
//
|
||||||
|
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
||||||
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
|
this.ClientSize = new System.Drawing.Size(179, 226);
|
||||||
|
this.Controls.Add(this.buttonCancel);
|
||||||
|
this.Controls.Add(this.buttonAddReview);
|
||||||
|
this.Controls.Add(this.numericUpDown);
|
||||||
|
this.Controls.Add(this.label2);
|
||||||
|
this.Controls.Add(this.textBoxReviewText);
|
||||||
|
this.Controls.Add(this.label1);
|
||||||
|
this.Name = "FormAddReview";
|
||||||
|
this.Text = "Новый отзыв";
|
||||||
|
this.Load += new System.EventHandler(this.FormAddReview_Load);
|
||||||
|
((System.ComponentModel.ISupportInitialize)(this.numericUpDown)).EndInit();
|
||||||
|
this.ResumeLayout(false);
|
||||||
|
this.PerformLayout();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private Label label1;
|
||||||
|
private TextBox textBoxReviewText;
|
||||||
|
private Label label2;
|
||||||
|
private NumericUpDown numericUpDown;
|
||||||
|
private Button buttonAddReview;
|
||||||
|
private Button buttonCancel;
|
||||||
|
}
|
||||||
|
}
|
143
BulletinBoard/BulletinBoard/FormAddReview.cs
Normal file
143
BulletinBoard/BulletinBoard/FormAddReview.cs
Normal file
@ -0,0 +1,143 @@
|
|||||||
|
using BulletinBoardContracts.BindingModels;
|
||||||
|
using BulletinBoardContracts.BusinessLogicContracts;
|
||||||
|
using BulletinBoardContracts.SearchModels;
|
||||||
|
using BulletinBoardContracts.ViewModels;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.Data;
|
||||||
|
using System.Drawing;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Reflection.Metadata.Ecma335;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Windows.Forms;
|
||||||
|
|
||||||
|
namespace BulletinBoard
|
||||||
|
{
|
||||||
|
public partial class FormAddReview : Form
|
||||||
|
{
|
||||||
|
private readonly IAnnouncementLogic _announcementLogic;
|
||||||
|
|
||||||
|
private int? _id;
|
||||||
|
public int Id { set { _id = value; } }
|
||||||
|
|
||||||
|
private string? _objectId;
|
||||||
|
public string ObjectId { set { _objectId = value; } }
|
||||||
|
|
||||||
|
public FormAddReview(IAnnouncementLogic announcementLogic)
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
|
||||||
|
_announcementLogic = announcementLogic;
|
||||||
|
|
||||||
|
numericUpDown.Value = 5;
|
||||||
|
numericUpDown.Maximum = 5;
|
||||||
|
numericUpDown.Minimum = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void FormAddReview_Load(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (_id.HasValue)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
AnnouncementViewModel view;
|
||||||
|
if (Program.CURRENT_DATABASE.Equals("PostgreSQL"))
|
||||||
|
{
|
||||||
|
view = _announcementLogic.ReadElement(new AnnouncementSearchModel { Id = _id.Value });
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
view = _announcementLogic.ReadElement(new AnnouncementSearchModel { ObjectId = _objectId });
|
||||||
|
}
|
||||||
|
|
||||||
|
if (view != null && (view.ReviewRating >= 1 || view.ReviewRating <= 5))
|
||||||
|
{
|
||||||
|
textBoxReviewText.Text = view.ReviewText;
|
||||||
|
numericUpDown.Value = Convert.ToDecimal(view.ReviewRating);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void buttonCancel_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
DialogResult = DialogResult.Cancel;
|
||||||
|
Close();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void buttonAddReview_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(textBoxReviewText.Text))
|
||||||
|
{
|
||||||
|
MessageBox.Show("Введите текст отзыва", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (numericUpDown.Value < 1 || numericUpDown.Value > 5)
|
||||||
|
{
|
||||||
|
MessageBox.Show("Укажите корректную оценку", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
AnnouncementBindingModel model;
|
||||||
|
if (Program.CURRENT_DATABASE.Equals("PostgreSQL"))
|
||||||
|
{
|
||||||
|
var announcement = _announcementLogic.ReadElement(new AnnouncementSearchModel { Id = _id });
|
||||||
|
model = new AnnouncementBindingModel
|
||||||
|
{
|
||||||
|
Id = _id ?? 0,
|
||||||
|
Title = announcement?.Title?.ToString(),
|
||||||
|
Description = announcement?.Description.ToString(),
|
||||||
|
ReviewRating = Convert.ToInt32(numericUpDown.Value),
|
||||||
|
ReviewText = textBoxReviewText.Text,
|
||||||
|
User = announcement?.User,
|
||||||
|
Region = announcement?.Region,
|
||||||
|
Category = announcement?.Category,
|
||||||
|
StartDate = announcement?.StartDate ?? DateTime.SpecifyKind(DateTime.MinValue, DateTimeKind.Utc),
|
||||||
|
|
||||||
|
};
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var announcement = _announcementLogic.ReadElement(new AnnouncementSearchModel { ObjectId = _objectId });
|
||||||
|
model = new AnnouncementBindingModel
|
||||||
|
{
|
||||||
|
ObjectId = _objectId ?? string.Empty,
|
||||||
|
Title = announcement?.Title?.ToString(),
|
||||||
|
Description = announcement?.Description.ToString(),
|
||||||
|
ReviewRating = Convert.ToInt32(numericUpDown.Value),
|
||||||
|
ReviewText = textBoxReviewText.Text,
|
||||||
|
User = announcement?.User,
|
||||||
|
Region = announcement?.Region,
|
||||||
|
Category = announcement?.Category,
|
||||||
|
StartDate = announcement?.StartDate ?? DateTime.SpecifyKind(DateTime.MinValue, DateTimeKind.Utc),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
var operationResult = _id.HasValue ? _announcementLogic.Update(model) : throw new Exception("Проблема с отзывом к объявлению");
|
||||||
|
|
||||||
|
if (!operationResult)
|
||||||
|
{
|
||||||
|
throw new Exception("Ошибка при сохранении.");
|
||||||
|
}
|
||||||
|
|
||||||
|
MessageBox.Show("Сохранение прошло успешно", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||||
|
DialogResult = DialogResult.OK;
|
||||||
|
|
||||||
|
Close();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
225
BulletinBoard/BulletinBoard/FormAnnouncements.Designer.cs
generated
Normal file
225
BulletinBoard/BulletinBoard/FormAnnouncements.Designer.cs
generated
Normal file
@ -0,0 +1,225 @@
|
|||||||
|
namespace BulletinBoard
|
||||||
|
{
|
||||||
|
partial class FormAnnouncements
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Required designer variable.
|
||||||
|
/// </summary>
|
||||||
|
private System.ComponentModel.IContainer components = null;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Clean up any resources being used.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||||
|
protected override void Dispose(bool disposing)
|
||||||
|
{
|
||||||
|
if (disposing && (components != null))
|
||||||
|
{
|
||||||
|
components.Dispose();
|
||||||
|
}
|
||||||
|
base.Dispose(disposing);
|
||||||
|
}
|
||||||
|
|
||||||
|
#region Windows Form Designer generated code
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Required method for Designer support - do not modify
|
||||||
|
/// the contents of this method with the code editor.
|
||||||
|
/// </summary>
|
||||||
|
private void InitializeComponent()
|
||||||
|
{
|
||||||
|
buttonUpdate = new Button();
|
||||||
|
buttonAdd = new Button();
|
||||||
|
dataGridView = new DataGridView();
|
||||||
|
menuStrip1 = new MenuStrip();
|
||||||
|
регионыToolStripMenuItem = new ToolStripMenuItem();
|
||||||
|
городаToolStripMenuItem = new ToolStripMenuItem();
|
||||||
|
пользователиToolStripMenuItem = new ToolStripMenuItem();
|
||||||
|
тестыToolStripMenuItem = new ToolStripMenuItem();
|
||||||
|
категорииToolStripMenuItem = new ToolStripMenuItem();
|
||||||
|
comboBoxUsersEmail = new ComboBox();
|
||||||
|
buttonAddReview = new Button();
|
||||||
|
buttonDelete = new Button();
|
||||||
|
buttonChange = new Button();
|
||||||
|
buttonAllClear = new Button();
|
||||||
|
buttonCopyFromPostgres = new Button();
|
||||||
|
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
|
||||||
|
menuStrip1.SuspendLayout();
|
||||||
|
SuspendLayout();
|
||||||
|
//
|
||||||
|
// buttonUpdate
|
||||||
|
//
|
||||||
|
buttonUpdate.Location = new Point(950, 91);
|
||||||
|
buttonUpdate.Name = "buttonUpdate";
|
||||||
|
buttonUpdate.Size = new Size(75, 23);
|
||||||
|
buttonUpdate.TabIndex = 13;
|
||||||
|
buttonUpdate.Text = "Обновить";
|
||||||
|
buttonUpdate.UseVisualStyleBackColor = true;
|
||||||
|
buttonUpdate.Click += buttonUpdate_Click;
|
||||||
|
//
|
||||||
|
// buttonAdd
|
||||||
|
//
|
||||||
|
buttonAdd.Location = new Point(950, 62);
|
||||||
|
buttonAdd.Name = "buttonAdd";
|
||||||
|
buttonAdd.Size = new Size(75, 23);
|
||||||
|
buttonAdd.TabIndex = 12;
|
||||||
|
buttonAdd.Text = "Создать";
|
||||||
|
buttonAdd.UseVisualStyleBackColor = true;
|
||||||
|
buttonAdd.Click += buttonAdd_Click;
|
||||||
|
//
|
||||||
|
// dataGridView
|
||||||
|
//
|
||||||
|
dataGridView.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
|
||||||
|
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||||
|
dataGridView.Location = new Point(12, 33);
|
||||||
|
dataGridView.Name = "dataGridView";
|
||||||
|
dataGridView.Size = new Size(912, 411);
|
||||||
|
dataGridView.TabIndex = 11;
|
||||||
|
//
|
||||||
|
// menuStrip1
|
||||||
|
//
|
||||||
|
menuStrip1.Items.AddRange(new ToolStripItem[] { регионыToolStripMenuItem, городаToolStripMenuItem, пользователиToolStripMenuItem, тестыToolStripMenuItem, категорииToolStripMenuItem });
|
||||||
|
menuStrip1.Location = new Point(0, 0);
|
||||||
|
menuStrip1.Name = "menuStrip1";
|
||||||
|
menuStrip1.Size = new Size(1060, 24);
|
||||||
|
menuStrip1.TabIndex = 10;
|
||||||
|
menuStrip1.Text = "menuStrip1";
|
||||||
|
//
|
||||||
|
// регионыToolStripMenuItem
|
||||||
|
//
|
||||||
|
регионыToolStripMenuItem.Name = "регионыToolStripMenuItem";
|
||||||
|
регионыToolStripMenuItem.Size = new Size(67, 20);
|
||||||
|
регионыToolStripMenuItem.Text = "Регионы";
|
||||||
|
регионыToolStripMenuItem.Click += регионыToolStripMenuItem_Click;
|
||||||
|
//
|
||||||
|
// городаToolStripMenuItem
|
||||||
|
//
|
||||||
|
городаToolStripMenuItem.Name = "городаToolStripMenuItem";
|
||||||
|
городаToolStripMenuItem.Size = new Size(58, 20);
|
||||||
|
городаToolStripMenuItem.Text = "Города";
|
||||||
|
городаToolStripMenuItem.Click += городаToolStripMenuItem_Click;
|
||||||
|
//
|
||||||
|
// пользователиToolStripMenuItem
|
||||||
|
//
|
||||||
|
пользователиToolStripMenuItem.Name = "пользователиToolStripMenuItem";
|
||||||
|
пользователиToolStripMenuItem.Size = new Size(67, 20);
|
||||||
|
пользователиToolStripMenuItem.Text = "Клиенты";
|
||||||
|
пользователиToolStripMenuItem.Click += пользователиToolStripMenuItem_Click;
|
||||||
|
//
|
||||||
|
// тестыToolStripMenuItem
|
||||||
|
//
|
||||||
|
тестыToolStripMenuItem.Name = "тестыToolStripMenuItem";
|
||||||
|
тестыToolStripMenuItem.Size = new Size(51, 20);
|
||||||
|
тестыToolStripMenuItem.Text = "Тесты";
|
||||||
|
тестыToolStripMenuItem.Click += testsToolStripMenuItem_Click;
|
||||||
|
//
|
||||||
|
// категорииToolStripMenuItem
|
||||||
|
//
|
||||||
|
категорииToolStripMenuItem.Name = "категорииToolStripMenuItem";
|
||||||
|
категорииToolStripMenuItem.Size = new Size(76, 20);
|
||||||
|
категорииToolStripMenuItem.Text = "Категории";
|
||||||
|
категорииToolStripMenuItem.Click += категорииToolStripMenuItem_Click;
|
||||||
|
//
|
||||||
|
// comboBoxUsersEmail
|
||||||
|
//
|
||||||
|
comboBoxUsersEmail.FormattingEnabled = true;
|
||||||
|
comboBoxUsersEmail.Location = new Point(930, 33);
|
||||||
|
comboBoxUsersEmail.Name = "comboBoxUsersEmail";
|
||||||
|
comboBoxUsersEmail.Size = new Size(121, 23);
|
||||||
|
comboBoxUsersEmail.TabIndex = 14;
|
||||||
|
comboBoxUsersEmail.SelectedIndexChanged += comboBoxUsersEmail_SelectedIndexChanged;
|
||||||
|
//
|
||||||
|
// buttonAddReview
|
||||||
|
//
|
||||||
|
buttonAddReview.Location = new Point(950, 193);
|
||||||
|
buttonAddReview.Name = "buttonAddReview";
|
||||||
|
buttonAddReview.Size = new Size(75, 44);
|
||||||
|
buttonAddReview.TabIndex = 15;
|
||||||
|
buttonAddReview.Text = "Добавить отзыв";
|
||||||
|
buttonAddReview.UseVisualStyleBackColor = true;
|
||||||
|
buttonAddReview.Click += buttonAddReview_Click;
|
||||||
|
//
|
||||||
|
// buttonDelete
|
||||||
|
//
|
||||||
|
buttonDelete.Location = new Point(950, 148);
|
||||||
|
buttonDelete.Name = "buttonDelete";
|
||||||
|
buttonDelete.Size = new Size(75, 23);
|
||||||
|
buttonDelete.TabIndex = 16;
|
||||||
|
buttonDelete.Text = "Удалить";
|
||||||
|
buttonDelete.UseVisualStyleBackColor = true;
|
||||||
|
buttonDelete.Click += buttonDelete_Click;
|
||||||
|
//
|
||||||
|
// buttonChange
|
||||||
|
//
|
||||||
|
buttonChange.Location = new Point(950, 119);
|
||||||
|
buttonChange.Name = "buttonChange";
|
||||||
|
buttonChange.Size = new Size(75, 23);
|
||||||
|
buttonChange.TabIndex = 17;
|
||||||
|
buttonChange.Text = "Изменить";
|
||||||
|
buttonChange.UseVisualStyleBackColor = true;
|
||||||
|
buttonChange.Click += buttonChange_Click;
|
||||||
|
//
|
||||||
|
// buttonAllClear
|
||||||
|
//
|
||||||
|
buttonAllClear.Location = new Point(930, 400);
|
||||||
|
buttonAllClear.Name = "buttonAllClear";
|
||||||
|
buttonAllClear.Size = new Size(121, 44);
|
||||||
|
buttonAllClear.TabIndex = 18;
|
||||||
|
buttonAllClear.Text = "Очистить все таблицы";
|
||||||
|
buttonAllClear.UseVisualStyleBackColor = true;
|
||||||
|
buttonAllClear.Click += buttonAllClear_Click;
|
||||||
|
//
|
||||||
|
// buttonCopyFromPostgres
|
||||||
|
//
|
||||||
|
buttonCopyFromPostgres.Location = new Point(930, 351);
|
||||||
|
buttonCopyFromPostgres.Name = "buttonCopyFromPostgres";
|
||||||
|
buttonCopyFromPostgres.Size = new Size(118, 43);
|
||||||
|
buttonCopyFromPostgres.TabIndex = 19;
|
||||||
|
buttonCopyFromPostgres.Text = "Перенос данных из PostgreSQL";
|
||||||
|
buttonCopyFromPostgres.UseVisualStyleBackColor = true;
|
||||||
|
buttonCopyFromPostgres.Click += buttonCopyFromPostgres_Click;
|
||||||
|
//
|
||||||
|
// FormAnnouncements
|
||||||
|
//
|
||||||
|
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||||
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
|
ClientSize = new Size(1060, 450);
|
||||||
|
Controls.Add(buttonCopyFromPostgres);
|
||||||
|
Controls.Add(buttonAllClear);
|
||||||
|
Controls.Add(buttonChange);
|
||||||
|
Controls.Add(buttonDelete);
|
||||||
|
Controls.Add(buttonAddReview);
|
||||||
|
Controls.Add(comboBoxUsersEmail);
|
||||||
|
Controls.Add(buttonUpdate);
|
||||||
|
Controls.Add(buttonAdd);
|
||||||
|
Controls.Add(dataGridView);
|
||||||
|
Controls.Add(menuStrip1);
|
||||||
|
Name = "FormAnnouncements";
|
||||||
|
Text = "Создание объявлений";
|
||||||
|
Load += FormAnnouncements_Load;
|
||||||
|
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
|
||||||
|
menuStrip1.ResumeLayout(false);
|
||||||
|
menuStrip1.PerformLayout();
|
||||||
|
ResumeLayout(false);
|
||||||
|
PerformLayout();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private Button buttonUpdate;
|
||||||
|
private Button buttonAdd;
|
||||||
|
private DataGridView dataGridView;
|
||||||
|
private MenuStrip menuStrip1;
|
||||||
|
private ToolStripMenuItem регионыToolStripMenuItem;
|
||||||
|
private ToolStripMenuItem городаToolStripMenuItem;
|
||||||
|
private ToolStripMenuItem пользователиToolStripMenuItem;
|
||||||
|
private ComboBox comboBoxUsersEmail;
|
||||||
|
private Button buttonAddReview;
|
||||||
|
private ToolStripMenuItem тестыToolStripMenuItem;
|
||||||
|
private Button buttonDelete;
|
||||||
|
private Button buttonChange;
|
||||||
|
private Button buttonAllClear;
|
||||||
|
private Button buttonCopyFromPostgres;
|
||||||
|
private ToolStripMenuItem категорииToolStripMenuItem;
|
||||||
|
}
|
||||||
|
}
|
261
BulletinBoard/BulletinBoard/FormAnnouncements.cs
Normal file
261
BulletinBoard/BulletinBoard/FormAnnouncements.cs
Normal file
@ -0,0 +1,261 @@
|
|||||||
|
using BulletinBoardContracts.BindingModels;
|
||||||
|
using BulletinBoardContracts.BusinessLogicContracts;
|
||||||
|
using BulletinBoardContracts.SearchModels;
|
||||||
|
using BulletinBoardMongoDB;
|
||||||
|
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 BulletinBoard
|
||||||
|
{
|
||||||
|
public partial class FormAnnouncements : Form
|
||||||
|
{
|
||||||
|
private readonly IAnnouncementLogic _announcementLogic;
|
||||||
|
private readonly IUserLogic _userLogic;
|
||||||
|
private readonly ICityLogic _cityLogic;
|
||||||
|
private readonly IRegionLogic _regionLogic;
|
||||||
|
private readonly ICategoryLogic _categoryLogic;
|
||||||
|
|
||||||
|
public FormAnnouncements(IAnnouncementLogic announcementLogic,
|
||||||
|
ICityLogic cityLogic,
|
||||||
|
IRegionLogic regionLogic,
|
||||||
|
ICategoryLogic categoryLogic,
|
||||||
|
IUserLogic userLogic)
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
|
||||||
|
_announcementLogic = announcementLogic;
|
||||||
|
_userLogic = userLogic;
|
||||||
|
_categoryLogic = categoryLogic;
|
||||||
|
_cityLogic = cityLogic;
|
||||||
|
_regionLogic = regionLogic;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void LoadData()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var list = _announcementLogic.ReadList(null);
|
||||||
|
|
||||||
|
var listUsers = _userLogic.ReadList(null);
|
||||||
|
|
||||||
|
if (listUsers != null)
|
||||||
|
{
|
||||||
|
comboBoxUsersEmail.DisplayMember = "Email";
|
||||||
|
if (Program.CURRENT_DATABASE.Equals("PostgreSQL"))
|
||||||
|
comboBoxUsersEmail.ValueMember = "Id";
|
||||||
|
else
|
||||||
|
comboBoxUsersEmail.ValueMember = "ObjectId";
|
||||||
|
comboBoxUsersEmail.DataSource = listUsers;
|
||||||
|
comboBoxUsersEmail.SelectedItem = null;
|
||||||
|
}
|
||||||
|
if (list != null)
|
||||||
|
{
|
||||||
|
dataGridView.DataSource = list;
|
||||||
|
dataGridView.Columns["UserId"].Visible = false;
|
||||||
|
dataGridView.Columns["User"].Visible = false;
|
||||||
|
dataGridView.Columns["CategoryId"].Visible = false;
|
||||||
|
dataGridView.Columns["Category"].Visible = false;
|
||||||
|
dataGridView.Columns["RegionId"].Visible = false;
|
||||||
|
dataGridView.Columns["Region"].Visible = false;
|
||||||
|
dataGridView.Columns["Id"].Visible = false;
|
||||||
|
dataGridView.Columns["ObjectId"].Visible = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
catch (Exception ex) { }
|
||||||
|
}
|
||||||
|
|
||||||
|
private void LoadData(int id)
|
||||||
|
{
|
||||||
|
var list = _announcementLogic.ReadList(new AnnouncementSearchModel
|
||||||
|
{
|
||||||
|
UserId = id,
|
||||||
|
});
|
||||||
|
|
||||||
|
dataGridView.DataSource = list;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void LoadData(string objectId)
|
||||||
|
{
|
||||||
|
var list = _announcementLogic.ReadList(new AnnouncementSearchModel
|
||||||
|
{
|
||||||
|
User = objectId,
|
||||||
|
});
|
||||||
|
|
||||||
|
dataGridView.DataSource = list;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void регионыToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
var service = Program.ServiceProvider?.GetService(typeof(FormRegions));
|
||||||
|
|
||||||
|
if (service is FormRegions form)
|
||||||
|
{
|
||||||
|
form.ShowDialog();
|
||||||
|
LoadData();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void городаToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
var service = Program.ServiceProvider?.GetService(typeof(FormCities));
|
||||||
|
|
||||||
|
if (service is FormCities form)
|
||||||
|
{
|
||||||
|
form.ShowDialog();
|
||||||
|
LoadData();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void пользователиToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
var service = Program.ServiceProvider?.GetService(typeof(FormUsers));
|
||||||
|
|
||||||
|
if (service is FormUsers form)
|
||||||
|
{
|
||||||
|
form.ShowDialog();
|
||||||
|
LoadData();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void buttonAdd_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
var service = Program.ServiceProvider?.GetService(typeof(FormCreateAnnouncements));
|
||||||
|
|
||||||
|
if (service is FormCreateAnnouncements form)
|
||||||
|
{
|
||||||
|
form.ShowDialog();
|
||||||
|
LoadData();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void buttonUpdate_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
LoadData();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void FormAnnouncements_Load(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
LoadData();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void buttonAddReview_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (dataGridView.SelectedRows.Count == 1)
|
||||||
|
{
|
||||||
|
var service = Program.ServiceProvider?.GetService(typeof(FormAddReview));
|
||||||
|
|
||||||
|
if (service is FormAddReview form)
|
||||||
|
{
|
||||||
|
form.Id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||||
|
form.ObjectId = dataGridView.SelectedRows[0].Cells["ObjectId"].Value.ToString() ?? string.Empty;
|
||||||
|
form.ShowDialog();
|
||||||
|
LoadData();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void testsToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
var service = Program.ServiceProvider?.GetService(typeof(FormTests));
|
||||||
|
|
||||||
|
if (service is FormTests form)
|
||||||
|
{
|
||||||
|
form.ShowDialog();
|
||||||
|
LoadData();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void comboBoxUsersEmail_SelectedIndexChanged(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (Program.CURRENT_DATABASE.Equals("PostgreSQL"))
|
||||||
|
LoadData(Convert.ToInt32(comboBoxUsersEmail.SelectedValue));
|
||||||
|
else
|
||||||
|
LoadData(comboBoxUsersEmail.SelectedValue?.ToString());
|
||||||
|
}
|
||||||
|
|
||||||
|
private void buttonChange_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (dataGridView.SelectedRows.Count == 1)
|
||||||
|
{
|
||||||
|
var service = Program.ServiceProvider?.GetService(typeof(FormCreateAnnouncements));
|
||||||
|
|
||||||
|
if (service is FormCreateAnnouncements form)
|
||||||
|
{
|
||||||
|
form.Id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||||
|
form.ObjectId = dataGridView.SelectedRows[0].Cells["ObjectId"].Value.ToString() ?? string.Empty;
|
||||||
|
|
||||||
|
if (form.ShowDialog() == DialogResult.OK)
|
||||||
|
{
|
||||||
|
LoadData();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void buttonDelete_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (dataGridView.SelectedRows.Count == 1)
|
||||||
|
{
|
||||||
|
if (MessageBox.Show("Удалить запись?", "Вопрос", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
|
||||||
|
{
|
||||||
|
int? id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||||
|
string? objectId = dataGridView.SelectedRows[0].Cells["ObjectId"].Value.ToString();
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (Program.CURRENT_DATABASE.Equals("PostgreSQL")
|
||||||
|
&& !_announcementLogic.Delete(new AnnouncementBindingModel { Id = id ?? 0 })
|
||||||
|
|| !_announcementLogic.Delete(new AnnouncementBindingModel { ObjectId = objectId ?? string.Empty }))
|
||||||
|
{
|
||||||
|
throw new Exception("Ошибка при удалении.");
|
||||||
|
}
|
||||||
|
|
||||||
|
LoadData();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void buttonAllClear_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_userLogic.ClearEntity();
|
||||||
|
_cityLogic.ClearEntity();
|
||||||
|
_regionLogic.ClearEntity();
|
||||||
|
_categoryLogic.ClearEntity();
|
||||||
|
_announcementLogic.ClearEntity();
|
||||||
|
LoadData();
|
||||||
|
}
|
||||||
|
catch (Exception) { }
|
||||||
|
}
|
||||||
|
|
||||||
|
private void buttonCopyFromPostgres_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
PostgreSQLToMongoDB.Start();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void категорииToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
var service = Program.ServiceProvider?.GetService(typeof(FormCategories));
|
||||||
|
|
||||||
|
if (service is FormCategories form)
|
||||||
|
{
|
||||||
|
form.ShowDialog();
|
||||||
|
LoadData();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
113
BulletinBoard/BulletinBoard/FormCategories.Designer.cs
generated
Normal file
113
BulletinBoard/BulletinBoard/FormCategories.Designer.cs
generated
Normal file
@ -0,0 +1,113 @@
|
|||||||
|
namespace BulletinBoard
|
||||||
|
{
|
||||||
|
partial class FormCategories
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Required designer variable.
|
||||||
|
/// </summary>
|
||||||
|
private System.ComponentModel.IContainer components = null;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Clean up any resources being used.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||||
|
protected override void Dispose(bool disposing)
|
||||||
|
{
|
||||||
|
if (disposing && (components != null))
|
||||||
|
{
|
||||||
|
components.Dispose();
|
||||||
|
}
|
||||||
|
base.Dispose(disposing);
|
||||||
|
}
|
||||||
|
|
||||||
|
#region Windows Form Designer generated code
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Required method for Designer support - do not modify
|
||||||
|
/// the contents of this method with the code editor.
|
||||||
|
/// </summary>
|
||||||
|
private void InitializeComponent()
|
||||||
|
{
|
||||||
|
buttonUpdate = new Button();
|
||||||
|
buttonDelete = new Button();
|
||||||
|
buttonChange = new Button();
|
||||||
|
buttonAdd = new Button();
|
||||||
|
dataGridView = new DataGridView();
|
||||||
|
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
|
||||||
|
SuspendLayout();
|
||||||
|
//
|
||||||
|
// buttonUpdate
|
||||||
|
//
|
||||||
|
buttonUpdate.Location = new Point(359, 195);
|
||||||
|
buttonUpdate.Name = "buttonUpdate";
|
||||||
|
buttonUpdate.Size = new Size(101, 48);
|
||||||
|
buttonUpdate.TabIndex = 9;
|
||||||
|
buttonUpdate.Text = "Обновить";
|
||||||
|
buttonUpdate.UseVisualStyleBackColor = true;
|
||||||
|
buttonUpdate.Click += buttonUpdate_Click;
|
||||||
|
//
|
||||||
|
// buttonDelete
|
||||||
|
//
|
||||||
|
buttonDelete.Location = new Point(359, 132);
|
||||||
|
buttonDelete.Name = "buttonDelete";
|
||||||
|
buttonDelete.Size = new Size(101, 41);
|
||||||
|
buttonDelete.TabIndex = 8;
|
||||||
|
buttonDelete.Text = "Удалить";
|
||||||
|
buttonDelete.UseVisualStyleBackColor = true;
|
||||||
|
buttonDelete.Click += buttonDelete_Click;
|
||||||
|
//
|
||||||
|
// buttonChange
|
||||||
|
//
|
||||||
|
buttonChange.Location = new Point(359, 70);
|
||||||
|
buttonChange.Name = "buttonChange";
|
||||||
|
buttonChange.Size = new Size(101, 42);
|
||||||
|
buttonChange.TabIndex = 7;
|
||||||
|
buttonChange.Text = "Изменить";
|
||||||
|
buttonChange.UseVisualStyleBackColor = true;
|
||||||
|
buttonChange.Click += buttonChange_Click;
|
||||||
|
//
|
||||||
|
// buttonAdd
|
||||||
|
//
|
||||||
|
buttonAdd.Location = new Point(359, 12);
|
||||||
|
buttonAdd.Name = "buttonAdd";
|
||||||
|
buttonAdd.Size = new Size(101, 40);
|
||||||
|
buttonAdd.TabIndex = 6;
|
||||||
|
buttonAdd.Text = "Создать";
|
||||||
|
buttonAdd.UseVisualStyleBackColor = true;
|
||||||
|
buttonAdd.Click += buttonAdd_Click;
|
||||||
|
//
|
||||||
|
// dataGridView
|
||||||
|
//
|
||||||
|
dataGridView.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
|
||||||
|
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||||
|
dataGridView.Location = new Point(12, 12);
|
||||||
|
dataGridView.Name = "dataGridView";
|
||||||
|
dataGridView.Size = new Size(328, 302);
|
||||||
|
dataGridView.TabIndex = 5;
|
||||||
|
//
|
||||||
|
// FormCategories
|
||||||
|
//
|
||||||
|
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||||
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
|
ClientSize = new Size(494, 340);
|
||||||
|
Controls.Add(buttonUpdate);
|
||||||
|
Controls.Add(buttonDelete);
|
||||||
|
Controls.Add(buttonChange);
|
||||||
|
Controls.Add(buttonAdd);
|
||||||
|
Controls.Add(dataGridView);
|
||||||
|
Name = "FormCategories";
|
||||||
|
Text = "Список категорий";
|
||||||
|
Load += FormCategories_Load;
|
||||||
|
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
|
||||||
|
ResumeLayout(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private Button buttonUpdate;
|
||||||
|
private Button buttonDelete;
|
||||||
|
private Button buttonChange;
|
||||||
|
private Button buttonAdd;
|
||||||
|
private DataGridView dataGridView;
|
||||||
|
}
|
||||||
|
}
|
112
BulletinBoard/BulletinBoard/FormCategories.cs
Normal file
112
BulletinBoard/BulletinBoard/FormCategories.cs
Normal file
@ -0,0 +1,112 @@
|
|||||||
|
using BulletinBoardContracts.BindingModels;
|
||||||
|
using BulletinBoardContracts.BusinessLogicContracts;
|
||||||
|
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 BulletinBoard
|
||||||
|
{
|
||||||
|
public partial class FormCategories : Form
|
||||||
|
{
|
||||||
|
private readonly ICategoryLogic _categoryLogic;
|
||||||
|
|
||||||
|
public FormCategories(ICategoryLogic categoryLogic)
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
|
||||||
|
_categoryLogic = categoryLogic;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void LoadData()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var list = _categoryLogic.ReadList(null);
|
||||||
|
|
||||||
|
if (list != null)
|
||||||
|
{
|
||||||
|
dataGridView.DataSource = list;
|
||||||
|
dataGridView.Columns["Id"].Visible = false;
|
||||||
|
dataGridView.Columns["ObjectId"].Visible = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex){ }
|
||||||
|
}
|
||||||
|
|
||||||
|
private void FormCategories_Load(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
LoadData();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void buttonAdd_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
var service = Program.ServiceProvider?.GetService(typeof(FormCreateCategory));
|
||||||
|
|
||||||
|
if (service is FormCreateCategory form)
|
||||||
|
{
|
||||||
|
if (form.ShowDialog() == DialogResult.OK)
|
||||||
|
{
|
||||||
|
LoadData();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void buttonChange_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (dataGridView.SelectedRows.Count == 1)
|
||||||
|
{
|
||||||
|
var service = Program.ServiceProvider?.GetService(typeof(FormCreateCategory));
|
||||||
|
|
||||||
|
if (service is FormCreateCategory form)
|
||||||
|
{
|
||||||
|
form.Id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||||
|
form.ObjectId = dataGridView.SelectedRows[0].Cells["ObjectId"].Value.ToString() ?? string.Empty;
|
||||||
|
|
||||||
|
if (form.ShowDialog() == DialogResult.OK)
|
||||||
|
{
|
||||||
|
LoadData();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void buttonDelete_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (dataGridView.SelectedRows.Count == 1)
|
||||||
|
{
|
||||||
|
if (MessageBox.Show("Удалить запись?", "Вопрос", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
|
||||||
|
{
|
||||||
|
int? id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||||
|
string? objectId = dataGridView.SelectedRows[0].Cells["ObjectId"].Value.ToString();
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (Program.CURRENT_DATABASE.Equals("PostgreSQL")
|
||||||
|
&& !_categoryLogic.Delete(new CategoryBindingModel{ Id = id ?? 0})
|
||||||
|
|| !_categoryLogic.Delete(new CategoryBindingModel { ObjectId = objectId ?? string.Empty }))
|
||||||
|
{
|
||||||
|
throw new Exception("Ошибка при удалении.");
|
||||||
|
}
|
||||||
|
|
||||||
|
LoadData();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void buttonUpdate_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
LoadData();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
112
BulletinBoard/BulletinBoard/FormCities.Designer.cs
generated
Normal file
112
BulletinBoard/BulletinBoard/FormCities.Designer.cs
generated
Normal file
@ -0,0 +1,112 @@
|
|||||||
|
namespace BulletinBoard
|
||||||
|
{
|
||||||
|
partial class FormCities
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Required designer variable.
|
||||||
|
/// </summary>
|
||||||
|
private System.ComponentModel.IContainer components = null;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Clean up any resources being used.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||||
|
protected override void Dispose(bool disposing)
|
||||||
|
{
|
||||||
|
if (disposing && (components != null))
|
||||||
|
{
|
||||||
|
components.Dispose();
|
||||||
|
}
|
||||||
|
base.Dispose(disposing);
|
||||||
|
}
|
||||||
|
|
||||||
|
#region Windows Form Designer generated code
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Required method for Designer support - do not modify
|
||||||
|
/// the contents of this method with the code editor.
|
||||||
|
/// </summary>
|
||||||
|
private void InitializeComponent()
|
||||||
|
{
|
||||||
|
buttonUpdate = new Button();
|
||||||
|
buttonDelete = new Button();
|
||||||
|
buttonChange = new Button();
|
||||||
|
buttonAdd = new Button();
|
||||||
|
dataGridView = new DataGridView();
|
||||||
|
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
|
||||||
|
SuspendLayout();
|
||||||
|
//
|
||||||
|
// buttonUpdate
|
||||||
|
//
|
||||||
|
buttonUpdate.Location = new Point(323, 190);
|
||||||
|
buttonUpdate.Name = "buttonUpdate";
|
||||||
|
buttonUpdate.Size = new Size(100, 41);
|
||||||
|
buttonUpdate.TabIndex = 9;
|
||||||
|
buttonUpdate.Text = "Обновить";
|
||||||
|
buttonUpdate.UseVisualStyleBackColor = true;
|
||||||
|
buttonUpdate.Click += buttonUpdate_Click;
|
||||||
|
//
|
||||||
|
// buttonDelete
|
||||||
|
//
|
||||||
|
buttonDelete.Location = new Point(323, 130);
|
||||||
|
buttonDelete.Name = "buttonDelete";
|
||||||
|
buttonDelete.Size = new Size(100, 38);
|
||||||
|
buttonDelete.TabIndex = 8;
|
||||||
|
buttonDelete.Text = "Удалить";
|
||||||
|
buttonDelete.UseVisualStyleBackColor = true;
|
||||||
|
buttonDelete.Click += buttonDelete_Click;
|
||||||
|
//
|
||||||
|
// buttonChange
|
||||||
|
//
|
||||||
|
buttonChange.Location = new Point(323, 70);
|
||||||
|
buttonChange.Name = "buttonChange";
|
||||||
|
buttonChange.Size = new Size(100, 41);
|
||||||
|
buttonChange.TabIndex = 7;
|
||||||
|
buttonChange.Text = "Изменить";
|
||||||
|
buttonChange.UseVisualStyleBackColor = true;
|
||||||
|
buttonChange.Click += buttonChange_Click;
|
||||||
|
//
|
||||||
|
// buttonAdd
|
||||||
|
//
|
||||||
|
buttonAdd.Location = new Point(323, 12);
|
||||||
|
buttonAdd.Name = "buttonAdd";
|
||||||
|
buttonAdd.Size = new Size(100, 42);
|
||||||
|
buttonAdd.TabIndex = 6;
|
||||||
|
buttonAdd.Text = "Создать";
|
||||||
|
buttonAdd.UseVisualStyleBackColor = true;
|
||||||
|
buttonAdd.Click += buttonAdd_Click;
|
||||||
|
//
|
||||||
|
// dataGridView
|
||||||
|
//
|
||||||
|
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||||
|
dataGridView.Location = new Point(12, 12);
|
||||||
|
dataGridView.Name = "dataGridView";
|
||||||
|
dataGridView.Size = new Size(290, 327);
|
||||||
|
dataGridView.TabIndex = 5;
|
||||||
|
//
|
||||||
|
// FormCities
|
||||||
|
//
|
||||||
|
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||||
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
|
ClientSize = new Size(456, 373);
|
||||||
|
Controls.Add(buttonUpdate);
|
||||||
|
Controls.Add(buttonDelete);
|
||||||
|
Controls.Add(buttonChange);
|
||||||
|
Controls.Add(buttonAdd);
|
||||||
|
Controls.Add(dataGridView);
|
||||||
|
Name = "FormCities";
|
||||||
|
Text = "Список городов";
|
||||||
|
Load += FormCities_Load;
|
||||||
|
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
|
||||||
|
ResumeLayout(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private Button buttonUpdate;
|
||||||
|
private Button buttonDelete;
|
||||||
|
private Button buttonChange;
|
||||||
|
private Button buttonAdd;
|
||||||
|
private DataGridView dataGridView;
|
||||||
|
}
|
||||||
|
}
|
112
BulletinBoard/BulletinBoard/FormCities.cs
Normal file
112
BulletinBoard/BulletinBoard/FormCities.cs
Normal file
@ -0,0 +1,112 @@
|
|||||||
|
using BulletinBoardContracts.BindingModels;
|
||||||
|
using BulletinBoardContracts.BusinessLogicContracts;
|
||||||
|
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 BulletinBoard
|
||||||
|
{
|
||||||
|
public partial class FormCities : Form
|
||||||
|
{
|
||||||
|
ICityLogic _citiesLogic;
|
||||||
|
|
||||||
|
public FormCities(ICityLogic citiesLogic)
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
|
||||||
|
_citiesLogic = citiesLogic;
|
||||||
|
}
|
||||||
|
private void LoadData()
|
||||||
|
{
|
||||||
|
/*try
|
||||||
|
{*/
|
||||||
|
var list = _citiesLogic.ReadList(null);
|
||||||
|
|
||||||
|
if (list != null)
|
||||||
|
{
|
||||||
|
dataGridView.DataSource = list;
|
||||||
|
dataGridView.Columns["Id"].Visible = false;
|
||||||
|
dataGridView.Columns["ObjectId"].Visible = false;
|
||||||
|
dataGridView.Columns["RegionId"].Visible = false;
|
||||||
|
dataGridView.Columns["RegionStringId"].Visible = false;
|
||||||
|
}
|
||||||
|
/*}
|
||||||
|
catch (Exception){ }*/
|
||||||
|
}
|
||||||
|
private void buttonAdd_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
var service = Program.ServiceProvider?.GetService(typeof(FormCreateCities));
|
||||||
|
|
||||||
|
if (service is FormCreateCities form)
|
||||||
|
{
|
||||||
|
if (form.ShowDialog() == DialogResult.OK)
|
||||||
|
{
|
||||||
|
LoadData();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void buttonChange_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (dataGridView.SelectedRows.Count == 1)
|
||||||
|
{
|
||||||
|
var service = Program.ServiceProvider?.GetService(typeof(FormCreateCities));
|
||||||
|
|
||||||
|
if (service is FormCreateCities form)
|
||||||
|
{
|
||||||
|
form.Id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||||
|
form.ObjectId = dataGridView.SelectedRows[0].Cells["ObjectId"].Value.ToString() ?? string.Empty;
|
||||||
|
|
||||||
|
if (form.ShowDialog() == DialogResult.OK)
|
||||||
|
{
|
||||||
|
LoadData();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void buttonDelete_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (dataGridView.SelectedRows.Count == 1)
|
||||||
|
{
|
||||||
|
if (MessageBox.Show("Удалить запись?", "Вопрос", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
|
||||||
|
{
|
||||||
|
int? id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||||
|
string? objectId = dataGridView.SelectedRows[0].Cells["ObjectId"].Value.ToString();
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (Program.CURRENT_DATABASE.Equals("PostgreSQL")
|
||||||
|
&& !_citiesLogic.Delete(new CityBindingModel { Id = id ?? 0 })
|
||||||
|
|| !_citiesLogic.Delete(new CityBindingModel { ObjectId = objectId ?? string.Empty }))
|
||||||
|
{
|
||||||
|
throw new Exception("Ошибка при удалении.");
|
||||||
|
}
|
||||||
|
|
||||||
|
LoadData();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void buttonUpdate_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
LoadData();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void FormCities_Load(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
LoadData();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
209
BulletinBoard/BulletinBoard/FormCreateAnnouncements.Designer.cs
generated
Normal file
209
BulletinBoard/BulletinBoard/FormCreateAnnouncements.Designer.cs
generated
Normal file
@ -0,0 +1,209 @@
|
|||||||
|
namespace BulletinBoard
|
||||||
|
{
|
||||||
|
partial class FormCreateAnnouncements
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Required designer variable.
|
||||||
|
/// </summary>
|
||||||
|
private System.ComponentModel.IContainer components = null;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Clean up any resources being used.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||||
|
protected override void Dispose(bool disposing)
|
||||||
|
{
|
||||||
|
if (disposing && (components != null))
|
||||||
|
{
|
||||||
|
components.Dispose();
|
||||||
|
}
|
||||||
|
base.Dispose(disposing);
|
||||||
|
}
|
||||||
|
|
||||||
|
#region Windows Form Designer generated code
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Required method for Designer support - do not modify
|
||||||
|
/// the contents of this method with the code editor.
|
||||||
|
/// </summary>
|
||||||
|
private void InitializeComponent()
|
||||||
|
{
|
||||||
|
comboBoxUser = new ComboBox();
|
||||||
|
label1 = new Label();
|
||||||
|
label2 = new Label();
|
||||||
|
comboBoxCategory = new ComboBox();
|
||||||
|
label3 = new Label();
|
||||||
|
dateTimePickerStart = new DateTimePicker();
|
||||||
|
label5 = new Label();
|
||||||
|
buttonCancel = new Button();
|
||||||
|
buttonAdd = new Button();
|
||||||
|
comboBoxRegion = new ComboBox();
|
||||||
|
textBoxName = new TextBox();
|
||||||
|
label4 = new Label();
|
||||||
|
textBox1 = new TextBox();
|
||||||
|
label6 = new Label();
|
||||||
|
SuspendLayout();
|
||||||
|
//
|
||||||
|
// comboBoxUser
|
||||||
|
//
|
||||||
|
comboBoxUser.FormattingEnabled = true;
|
||||||
|
comboBoxUser.Location = new Point(12, 235);
|
||||||
|
comboBoxUser.Name = "comboBoxUser";
|
||||||
|
comboBoxUser.Size = new Size(134, 23);
|
||||||
|
comboBoxUser.TabIndex = 0;
|
||||||
|
//
|
||||||
|
// label1
|
||||||
|
//
|
||||||
|
label1.AutoSize = true;
|
||||||
|
label1.Location = new Point(12, 9);
|
||||||
|
label1.Name = "label1";
|
||||||
|
label1.Size = new Size(68, 15);
|
||||||
|
label1.TabIndex = 1;
|
||||||
|
label1.Text = "Заголовок:";
|
||||||
|
//
|
||||||
|
// label2
|
||||||
|
//
|
||||||
|
label2.AutoSize = true;
|
||||||
|
label2.Location = new Point(12, 62);
|
||||||
|
label2.Name = "label2";
|
||||||
|
label2.Size = new Size(134, 15);
|
||||||
|
label2.TabIndex = 3;
|
||||||
|
label2.Text = "Описание объявления:";
|
||||||
|
//
|
||||||
|
// comboBoxCategory
|
||||||
|
//
|
||||||
|
comboBoxCategory.FormattingEnabled = true;
|
||||||
|
comboBoxCategory.Location = new Point(181, 235);
|
||||||
|
comboBoxCategory.Name = "comboBoxCategory";
|
||||||
|
comboBoxCategory.Size = new Size(121, 23);
|
||||||
|
comboBoxCategory.TabIndex = 2;
|
||||||
|
//
|
||||||
|
// label3
|
||||||
|
//
|
||||||
|
label3.AutoSize = true;
|
||||||
|
label3.Location = new Point(12, 116);
|
||||||
|
label3.Name = "label3";
|
||||||
|
label3.Size = new Size(105, 15);
|
||||||
|
label3.TabIndex = 5;
|
||||||
|
label3.Text = "Дата публикации:";
|
||||||
|
//
|
||||||
|
// dateTimePickerStart
|
||||||
|
//
|
||||||
|
dateTimePickerStart.Location = new Point(12, 134);
|
||||||
|
dateTimePickerStart.Name = "dateTimePickerStart";
|
||||||
|
dateTimePickerStart.Size = new Size(134, 23);
|
||||||
|
dateTimePickerStart.TabIndex = 6;
|
||||||
|
//
|
||||||
|
// label5
|
||||||
|
//
|
||||||
|
label5.AutoSize = true;
|
||||||
|
label5.Location = new Point(12, 217);
|
||||||
|
label5.Name = "label5";
|
||||||
|
label5.Size = new Size(87, 15);
|
||||||
|
label5.TabIndex = 10;
|
||||||
|
label5.Text = "Пользователь:";
|
||||||
|
//
|
||||||
|
// buttonCancel
|
||||||
|
//
|
||||||
|
buttonCancel.Location = new Point(203, 102);
|
||||||
|
buttonCancel.Name = "buttonCancel";
|
||||||
|
buttonCancel.Size = new Size(108, 43);
|
||||||
|
buttonCancel.TabIndex = 25;
|
||||||
|
buttonCancel.Text = "Отмена";
|
||||||
|
buttonCancel.UseVisualStyleBackColor = true;
|
||||||
|
buttonCancel.Click += buttonCancel_Click;
|
||||||
|
//
|
||||||
|
// buttonAdd
|
||||||
|
//
|
||||||
|
buttonAdd.Location = new Point(203, 30);
|
||||||
|
buttonAdd.Name = "buttonAdd";
|
||||||
|
buttonAdd.Size = new Size(108, 47);
|
||||||
|
buttonAdd.TabIndex = 24;
|
||||||
|
buttonAdd.Text = "Добавить";
|
||||||
|
buttonAdd.UseVisualStyleBackColor = true;
|
||||||
|
buttonAdd.Click += buttonAdd_Click;
|
||||||
|
//
|
||||||
|
// comboBoxRegion
|
||||||
|
//
|
||||||
|
comboBoxRegion.FormattingEnabled = true;
|
||||||
|
comboBoxRegion.Location = new Point(12, 185);
|
||||||
|
comboBoxRegion.Name = "comboBoxRegion";
|
||||||
|
comboBoxRegion.Size = new Size(134, 23);
|
||||||
|
comboBoxRegion.TabIndex = 26;
|
||||||
|
//
|
||||||
|
// textBoxName
|
||||||
|
//
|
||||||
|
textBoxName.Location = new Point(12, 27);
|
||||||
|
textBoxName.Name = "textBoxName";
|
||||||
|
textBoxName.Size = new Size(145, 23);
|
||||||
|
textBoxName.TabIndex = 28;
|
||||||
|
//
|
||||||
|
// label4
|
||||||
|
//
|
||||||
|
label4.AutoSize = true;
|
||||||
|
label4.Location = new Point(12, 167);
|
||||||
|
label4.Name = "label4";
|
||||||
|
label4.Size = new Size(49, 15);
|
||||||
|
label4.TabIndex = 27;
|
||||||
|
label4.Text = "Регион:";
|
||||||
|
//
|
||||||
|
// textBox1
|
||||||
|
//
|
||||||
|
textBox1.Location = new Point(12, 80);
|
||||||
|
textBox1.Name = "textBox1";
|
||||||
|
textBox1.Size = new Size(145, 23);
|
||||||
|
textBox1.TabIndex = 30;
|
||||||
|
//
|
||||||
|
// label6
|
||||||
|
//
|
||||||
|
label6.AutoSize = true;
|
||||||
|
label6.Location = new Point(181, 217);
|
||||||
|
label6.Name = "label6";
|
||||||
|
label6.Size = new Size(66, 15);
|
||||||
|
label6.TabIndex = 29;
|
||||||
|
label6.Text = "Категория:";
|
||||||
|
//
|
||||||
|
// FormCreateAnnouncements
|
||||||
|
//
|
||||||
|
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||||
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
|
ClientSize = new Size(332, 272);
|
||||||
|
Controls.Add(textBox1);
|
||||||
|
Controls.Add(label6);
|
||||||
|
Controls.Add(textBoxName);
|
||||||
|
Controls.Add(label4);
|
||||||
|
Controls.Add(comboBoxRegion);
|
||||||
|
Controls.Add(buttonCancel);
|
||||||
|
Controls.Add(buttonAdd);
|
||||||
|
Controls.Add(label5);
|
||||||
|
Controls.Add(dateTimePickerStart);
|
||||||
|
Controls.Add(label3);
|
||||||
|
Controls.Add(label2);
|
||||||
|
Controls.Add(comboBoxCategory);
|
||||||
|
Controls.Add(label1);
|
||||||
|
Controls.Add(comboBoxUser);
|
||||||
|
Name = "FormCreateAnnouncements";
|
||||||
|
Text = "Новое объявление";
|
||||||
|
Load += FormCreateAnnouncement_Load;
|
||||||
|
ResumeLayout(false);
|
||||||
|
PerformLayout();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private ComboBox comboBoxUser;
|
||||||
|
private Label label1;
|
||||||
|
private Label label2;
|
||||||
|
private ComboBox comboBoxCategory;
|
||||||
|
private Label label3;
|
||||||
|
private DateTimePicker dateTimePickerStart;
|
||||||
|
private Label label5;
|
||||||
|
private Button buttonCancel;
|
||||||
|
private Button buttonAdd;
|
||||||
|
private ComboBox comboBoxRegion;
|
||||||
|
private TextBox textBoxName;
|
||||||
|
private Label label4;
|
||||||
|
private TextBox textBox1;
|
||||||
|
private Label label6;
|
||||||
|
}
|
||||||
|
}
|
199
BulletinBoard/BulletinBoard/FormCreateAnnouncements.cs
Normal file
199
BulletinBoard/BulletinBoard/FormCreateAnnouncements.cs
Normal file
@ -0,0 +1,199 @@
|
|||||||
|
using BulletinBoardContracts.BindingModels;
|
||||||
|
using BulletinBoardContracts.BusinessLogicContracts;
|
||||||
|
using BulletinBoardContracts.SearchModels;
|
||||||
|
using BulletinBoardContracts.ViewModels;
|
||||||
|
using BulletinBoardLogic.BusinessLogics;
|
||||||
|
using Microsoft.EntityFrameworkCore.Metadata;
|
||||||
|
using Microsoft.EntityFrameworkCore.Metadata.Internal;
|
||||||
|
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 BulletinBoard
|
||||||
|
{
|
||||||
|
public partial class FormCreateAnnouncements : Form
|
||||||
|
{
|
||||||
|
private readonly ICategoryLogic _categoryLogic;
|
||||||
|
private readonly IUserLogic _userLogic;
|
||||||
|
private readonly IRegionLogic _regionLogic;
|
||||||
|
private readonly ICityLogic _cityLogic;
|
||||||
|
private readonly IAnnouncementLogic _announcementLogic;
|
||||||
|
|
||||||
|
private int? _id;
|
||||||
|
public int Id { set { _id = value; } }
|
||||||
|
|
||||||
|
private string? _objectId;
|
||||||
|
public string ObjectId { set { _objectId = value; } }
|
||||||
|
|
||||||
|
public FormCreateAnnouncements(ICategoryLogic categoryLogic, IUserLogic userLogic,
|
||||||
|
IRegionLogic regionLogic, ICityLogic cityLogic, IAnnouncementLogic announcementLogic)
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
|
||||||
|
_announcementLogic = announcementLogic;
|
||||||
|
_cityLogic = cityLogic;
|
||||||
|
_regionLogic = regionLogic;
|
||||||
|
_userLogic = userLogic;
|
||||||
|
_categoryLogic = categoryLogic;
|
||||||
|
|
||||||
|
dateTimePickerStart.Format = DateTimePickerFormat.Time;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void LoadData()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var listUsers = _userLogic.ReadList(null);
|
||||||
|
var listCategories = _categoryLogic.ReadList(null);
|
||||||
|
var listRegions = _regionLogic.ReadList(null);
|
||||||
|
|
||||||
|
if (listUsers != null)
|
||||||
|
{
|
||||||
|
comboBoxUser.DisplayMember = "Name";
|
||||||
|
if (Program.CURRENT_DATABASE.Equals("PostgreSQL"))
|
||||||
|
comboBoxUser.ValueMember = "Id";
|
||||||
|
else
|
||||||
|
comboBoxUser.ValueMember = "ObjectId";
|
||||||
|
comboBoxUser.DataSource = listUsers;
|
||||||
|
comboBoxUser.SelectedItem = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (listCategories != null)
|
||||||
|
{
|
||||||
|
comboBoxCategory.DisplayMember = "Name";
|
||||||
|
if (Program.CURRENT_DATABASE.Equals("PostgreSQL"))
|
||||||
|
comboBoxCategory.ValueMember = "Id";
|
||||||
|
else
|
||||||
|
comboBoxCategory.ValueMember = "ObjectId";
|
||||||
|
comboBoxCategory.DataSource = listCategories;
|
||||||
|
comboBoxCategory.SelectedItem = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (listRegions != null)
|
||||||
|
{
|
||||||
|
comboBoxRegion.DisplayMember = "RegionName";
|
||||||
|
if (Program.CURRENT_DATABASE.Equals("PostgreSQL"))
|
||||||
|
comboBoxRegion.ValueMember = "Id";
|
||||||
|
else
|
||||||
|
comboBoxRegion.ValueMember = "ObjectId";
|
||||||
|
comboBoxRegion.DataSource = listRegions;
|
||||||
|
comboBoxRegion.SelectedItem = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception) { }
|
||||||
|
}
|
||||||
|
private void buttonAdd_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(comboBoxCategory.Text))
|
||||||
|
{
|
||||||
|
MessageBox.Show("Выберите категорию", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (string.IsNullOrEmpty(comboBoxUser.Text))
|
||||||
|
{
|
||||||
|
MessageBox.Show("Выберите пользователя", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (string.IsNullOrEmpty(comboBoxRegion.Text))
|
||||||
|
{
|
||||||
|
MessageBox.Show("Выберите регион", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
AnnouncementBindingModel model;
|
||||||
|
if (Program.CURRENT_DATABASE.Equals("PostgreSQL"))
|
||||||
|
{
|
||||||
|
model = new AnnouncementBindingModel
|
||||||
|
{
|
||||||
|
Id = _id ?? 0,
|
||||||
|
Title = textBoxName.Text,
|
||||||
|
Description = textBox1.Text,
|
||||||
|
StartDate = DateTime.SpecifyKind(dateTimePickerStart.Value, DateTimeKind.Utc),
|
||||||
|
UserId = Convert.ToInt32(comboBoxUser.SelectedValue),
|
||||||
|
CategoryId = Convert.ToInt32(comboBoxCategory.SelectedValue),
|
||||||
|
RegionId = Convert.ToInt32(comboBoxRegion.SelectedValue),
|
||||||
|
ReviewText = null
|
||||||
|
};
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
model = new AnnouncementBindingModel
|
||||||
|
{
|
||||||
|
ObjectId = _objectId ?? string.Empty,
|
||||||
|
Title = textBoxName.Text,
|
||||||
|
Description = textBox1.Text,
|
||||||
|
StartDate = DateTime.SpecifyKind(dateTimePickerStart.Value, DateTimeKind.Utc),
|
||||||
|
User = comboBoxUser.SelectedValue.ToString(),
|
||||||
|
Category = comboBoxCategory.SelectedValue.ToString(),
|
||||||
|
Region = comboBoxRegion.SelectedValue.ToString(),
|
||||||
|
ReviewText = null
|
||||||
|
};
|
||||||
|
}
|
||||||
|
var operationResult = _id.HasValue ? _announcementLogic.Update(model) : _announcementLogic.Create(model);
|
||||||
|
|
||||||
|
if (!operationResult)
|
||||||
|
{
|
||||||
|
throw new Exception("Ошибка при сохранении.");
|
||||||
|
}
|
||||||
|
|
||||||
|
MessageBox.Show("Сохранение прошло успешно", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||||
|
DialogResult = DialogResult.OK;
|
||||||
|
|
||||||
|
Close();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void buttonCancel_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
DialogResult = DialogResult.Cancel;
|
||||||
|
Close();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void FormCreateAnnouncement_Load(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
LoadData();
|
||||||
|
if (_id.HasValue)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
AnnouncementViewModel? view;
|
||||||
|
if (Program.CURRENT_DATABASE.Equals("PostgreSQL"))
|
||||||
|
{
|
||||||
|
view = _announcementLogic.ReadElement(new AnnouncementSearchModel { Id = _id });
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
view = _announcementLogic.ReadElement(new AnnouncementSearchModel { ObjectId = _objectId });
|
||||||
|
}
|
||||||
|
|
||||||
|
if (view != null)
|
||||||
|
{
|
||||||
|
comboBoxUser.SelectedValue = view.User;
|
||||||
|
comboBoxCategory.SelectedValue = view.Category;
|
||||||
|
comboBoxRegion.SelectedValue = view.Region;
|
||||||
|
dateTimePickerStart.Value = view.StartDate;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
110
BulletinBoard/BulletinBoard/FormCreateCategory.Designer.cs
generated
Normal file
110
BulletinBoard/BulletinBoard/FormCreateCategory.Designer.cs
generated
Normal file
@ -0,0 +1,110 @@
|
|||||||
|
namespace BulletinBoard
|
||||||
|
{
|
||||||
|
partial class FormCreateCategory
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Required designer variable.
|
||||||
|
/// </summary>
|
||||||
|
private System.ComponentModel.IContainer components = null;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Clean up any resources being used.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||||
|
protected override void Dispose(bool disposing)
|
||||||
|
{
|
||||||
|
if (disposing && (components != null))
|
||||||
|
{
|
||||||
|
components.Dispose();
|
||||||
|
}
|
||||||
|
base.Dispose(disposing);
|
||||||
|
}
|
||||||
|
|
||||||
|
#region Windows Form Designer generated code
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Required method for Designer support - do not modify
|
||||||
|
/// the contents of this method with the code editor.
|
||||||
|
/// </summary>
|
||||||
|
private void InitializeComponent()
|
||||||
|
{
|
||||||
|
textBoxName = new TextBox();
|
||||||
|
label1 = new Label();
|
||||||
|
buttonCancel = new Button();
|
||||||
|
buttonAdd = new Button();
|
||||||
|
buttonTestAdd = new Button();
|
||||||
|
SuspendLayout();
|
||||||
|
//
|
||||||
|
// textBoxName
|
||||||
|
//
|
||||||
|
textBoxName.Location = new Point(12, 27);
|
||||||
|
textBoxName.Name = "textBoxName";
|
||||||
|
textBoxName.Size = new Size(145, 23);
|
||||||
|
textBoxName.TabIndex = 23;
|
||||||
|
//
|
||||||
|
// label1
|
||||||
|
//
|
||||||
|
label1.AutoSize = true;
|
||||||
|
label1.Location = new Point(12, 9);
|
||||||
|
label1.Name = "label1";
|
||||||
|
label1.Size = new Size(62, 15);
|
||||||
|
label1.TabIndex = 20;
|
||||||
|
label1.Text = "Название:";
|
||||||
|
//
|
||||||
|
// buttonCancel
|
||||||
|
//
|
||||||
|
buttonCancel.Location = new Point(12, 71);
|
||||||
|
buttonCancel.Name = "buttonCancel";
|
||||||
|
buttonCancel.Size = new Size(75, 23);
|
||||||
|
buttonCancel.TabIndex = 27;
|
||||||
|
buttonCancel.Text = "Отмена";
|
||||||
|
buttonCancel.UseVisualStyleBackColor = true;
|
||||||
|
buttonCancel.Click += buttonCancel_Click;
|
||||||
|
//
|
||||||
|
// buttonAdd
|
||||||
|
//
|
||||||
|
buttonAdd.Location = new Point(93, 71);
|
||||||
|
buttonAdd.Name = "buttonAdd";
|
||||||
|
buttonAdd.Size = new Size(75, 23);
|
||||||
|
buttonAdd.TabIndex = 26;
|
||||||
|
buttonAdd.Text = "Добавить";
|
||||||
|
buttonAdd.UseVisualStyleBackColor = true;
|
||||||
|
buttonAdd.Click += buttonAdd_Click;
|
||||||
|
//
|
||||||
|
// buttonTestAdd
|
||||||
|
//
|
||||||
|
buttonTestAdd.Location = new Point(176, 11);
|
||||||
|
buttonTestAdd.Name = "buttonTestAdd";
|
||||||
|
buttonTestAdd.Size = new Size(75, 54);
|
||||||
|
buttonTestAdd.TabIndex = 28;
|
||||||
|
buttonTestAdd.Text = "Добавить 1000 категории";
|
||||||
|
buttonTestAdd.UseVisualStyleBackColor = true;
|
||||||
|
buttonTestAdd.Click += buttonTestAdd_Click;
|
||||||
|
//
|
||||||
|
// FormCreateCategory
|
||||||
|
//
|
||||||
|
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||||
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
|
ClientSize = new Size(260, 106);
|
||||||
|
Controls.Add(buttonTestAdd);
|
||||||
|
Controls.Add(buttonCancel);
|
||||||
|
Controls.Add(buttonAdd);
|
||||||
|
Controls.Add(textBoxName);
|
||||||
|
Controls.Add(label1);
|
||||||
|
MaximizeBox = false;
|
||||||
|
MinimizeBox = false;
|
||||||
|
Name = "FormCreateCategory";
|
||||||
|
Text = "Добавление категории";
|
||||||
|
Load += FormCreateCategory_Load;
|
||||||
|
ResumeLayout(false);
|
||||||
|
PerformLayout();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
private TextBox textBoxName;
|
||||||
|
private Label label1;
|
||||||
|
private Button buttonCancel;
|
||||||
|
private Button buttonAdd;
|
||||||
|
private Button buttonTestAdd;
|
||||||
|
}
|
||||||
|
}
|
127
BulletinBoard/BulletinBoard/FormCreateCategory.cs
Normal file
127
BulletinBoard/BulletinBoard/FormCreateCategory.cs
Normal file
@ -0,0 +1,127 @@
|
|||||||
|
using BulletinBoardContracts.BindingModels;
|
||||||
|
using BulletinBoardContracts.BusinessLogicContracts;
|
||||||
|
using BulletinBoardContracts.SearchModels;
|
||||||
|
using BulletinBoardContracts.ViewModels;
|
||||||
|
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 BulletinBoard
|
||||||
|
{
|
||||||
|
public partial class FormCreateCategory : Form
|
||||||
|
{
|
||||||
|
private readonly ICategoryLogic _categoryLogic;
|
||||||
|
|
||||||
|
private int? _id;
|
||||||
|
public int Id { set { _id = value; } }
|
||||||
|
|
||||||
|
private string? _objectId;
|
||||||
|
public string ObjectId { set { _objectId = value; } }
|
||||||
|
|
||||||
|
public FormCreateCategory(ICategoryLogic categoryLogic)
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
|
||||||
|
_categoryLogic = categoryLogic;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void buttonAdd_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(textBoxName.Text))
|
||||||
|
{
|
||||||
|
MessageBox.Show("Введите название категории", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
CategoryBindingModel model;
|
||||||
|
if (Program.CURRENT_DATABASE.Equals("PostgreSQL"))
|
||||||
|
{
|
||||||
|
model = new CategoryBindingModel
|
||||||
|
{
|
||||||
|
Id = _id ?? 0,
|
||||||
|
Name = textBoxName.Text,
|
||||||
|
|
||||||
|
};
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
model = new CategoryBindingModel
|
||||||
|
{
|
||||||
|
ObjectId = _objectId ?? string.Empty,
|
||||||
|
Name = textBoxName.Text,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
var operationResult = _id.HasValue ? _categoryLogic.Update(model) : _categoryLogic.Create(model);
|
||||||
|
|
||||||
|
if (!operationResult)
|
||||||
|
{
|
||||||
|
throw new Exception("Ошибка при сохранении.");
|
||||||
|
}
|
||||||
|
|
||||||
|
MessageBox.Show("Сохранение прошло успешно", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||||
|
DialogResult = DialogResult.OK;
|
||||||
|
|
||||||
|
Close();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void buttonCancel_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
DialogResult = DialogResult.Cancel;
|
||||||
|
Close();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void FormCreateCategory_Load(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (_id.HasValue || !string.IsNullOrEmpty(_objectId))
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
CategoryViewModel? view;
|
||||||
|
if (Program.CURRENT_DATABASE.Equals("PostgreSQL"))
|
||||||
|
{
|
||||||
|
view = _categoryLogic.ReadElement(new CategorySearchModel { Id = _id });
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
view = _categoryLogic.ReadElement(new CategorySearchModel { ObjectId = _objectId });
|
||||||
|
}
|
||||||
|
|
||||||
|
if (view != null)
|
||||||
|
{
|
||||||
|
textBoxName.Text = view.Name;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void buttonTestAdd_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_categoryLogic.CategoryInsertList(1000);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
132
BulletinBoard/BulletinBoard/FormCreateCities.Designer.cs
generated
Normal file
132
BulletinBoard/BulletinBoard/FormCreateCities.Designer.cs
generated
Normal file
@ -0,0 +1,132 @@
|
|||||||
|
namespace BulletinBoard
|
||||||
|
{
|
||||||
|
partial class FormCreateCities
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Required designer variable.
|
||||||
|
/// </summary>
|
||||||
|
private System.ComponentModel.IContainer components = null;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Clean up any resources being used.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||||
|
protected override void Dispose(bool disposing)
|
||||||
|
{
|
||||||
|
if (disposing && (components != null))
|
||||||
|
{
|
||||||
|
components.Dispose();
|
||||||
|
}
|
||||||
|
base.Dispose(disposing);
|
||||||
|
}
|
||||||
|
|
||||||
|
#region Windows Form Designer generated code
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Required method for Designer support - do not modify
|
||||||
|
/// the contents of this method with the code editor.
|
||||||
|
/// </summary>
|
||||||
|
private void InitializeComponent()
|
||||||
|
{
|
||||||
|
label1 = new Label();
|
||||||
|
label7 = new Label();
|
||||||
|
textBoxCity = new TextBox();
|
||||||
|
comboBoxRegion = new ComboBox();
|
||||||
|
buttonAdd = new Button();
|
||||||
|
buttonCancel = new Button();
|
||||||
|
buttonTestAdd = new Button();
|
||||||
|
SuspendLayout();
|
||||||
|
//
|
||||||
|
// label1
|
||||||
|
//
|
||||||
|
label1.AutoSize = true;
|
||||||
|
label1.Location = new Point(12, 9);
|
||||||
|
label1.Name = "label1";
|
||||||
|
label1.Size = new Size(43, 15);
|
||||||
|
label1.TabIndex = 0;
|
||||||
|
label1.Text = "Город:";
|
||||||
|
//
|
||||||
|
// label7
|
||||||
|
//
|
||||||
|
label7.AutoSize = true;
|
||||||
|
label7.Location = new Point(12, 64);
|
||||||
|
label7.Name = "label7";
|
||||||
|
label7.Size = new Size(49, 15);
|
||||||
|
label7.TabIndex = 6;
|
||||||
|
label7.Text = "Регион:";
|
||||||
|
//
|
||||||
|
// textBoxCity
|
||||||
|
//
|
||||||
|
textBoxCity.Location = new Point(12, 27);
|
||||||
|
textBoxCity.Name = "textBoxCity";
|
||||||
|
textBoxCity.Size = new Size(145, 23);
|
||||||
|
textBoxCity.TabIndex = 7;
|
||||||
|
//
|
||||||
|
// comboBoxRegion
|
||||||
|
//
|
||||||
|
comboBoxRegion.FormattingEnabled = true;
|
||||||
|
comboBoxRegion.Location = new Point(12, 82);
|
||||||
|
comboBoxRegion.Name = "comboBoxRegion";
|
||||||
|
comboBoxRegion.Size = new Size(145, 23);
|
||||||
|
comboBoxRegion.TabIndex = 13;
|
||||||
|
//
|
||||||
|
// buttonAdd
|
||||||
|
//
|
||||||
|
buttonAdd.Location = new Point(110, 117);
|
||||||
|
buttonAdd.Name = "buttonAdd";
|
||||||
|
buttonAdd.Size = new Size(75, 23);
|
||||||
|
buttonAdd.TabIndex = 14;
|
||||||
|
buttonAdd.Text = "Добавить";
|
||||||
|
buttonAdd.UseVisualStyleBackColor = true;
|
||||||
|
buttonAdd.Click += buttonAdd_Click;
|
||||||
|
//
|
||||||
|
// buttonCancel
|
||||||
|
//
|
||||||
|
buttonCancel.Location = new Point(12, 117);
|
||||||
|
buttonCancel.Name = "buttonCancel";
|
||||||
|
buttonCancel.Size = new Size(75, 23);
|
||||||
|
buttonCancel.TabIndex = 15;
|
||||||
|
buttonCancel.Text = "Отмена";
|
||||||
|
buttonCancel.UseVisualStyleBackColor = true;
|
||||||
|
buttonCancel.Click += buttonCancel_Click;
|
||||||
|
//
|
||||||
|
// buttonTestAdd
|
||||||
|
//
|
||||||
|
buttonTestAdd.Location = new Point(180, 14);
|
||||||
|
buttonTestAdd.Name = "buttonTestAdd";
|
||||||
|
buttonTestAdd.Size = new Size(75, 54);
|
||||||
|
buttonTestAdd.TabIndex = 29;
|
||||||
|
buttonTestAdd.Text = "Добавить 1000 городов";
|
||||||
|
buttonTestAdd.UseVisualStyleBackColor = true;
|
||||||
|
buttonTestAdd.Click += buttonTestAdd_Click;
|
||||||
|
//
|
||||||
|
// FormCreateCities
|
||||||
|
//
|
||||||
|
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||||
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
|
ClientSize = new Size(266, 152);
|
||||||
|
Controls.Add(buttonTestAdd);
|
||||||
|
Controls.Add(buttonCancel);
|
||||||
|
Controls.Add(buttonAdd);
|
||||||
|
Controls.Add(comboBoxRegion);
|
||||||
|
Controls.Add(textBoxCity);
|
||||||
|
Controls.Add(label7);
|
||||||
|
Controls.Add(label1);
|
||||||
|
Name = "FormCreateCities";
|
||||||
|
Text = "Добавление города";
|
||||||
|
Load += FormCreateCity_Load;
|
||||||
|
ResumeLayout(false);
|
||||||
|
PerformLayout();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private Label label1;
|
||||||
|
private Label label7;
|
||||||
|
private TextBox textBoxCity;
|
||||||
|
private ComboBox comboBoxRegion;
|
||||||
|
private Button buttonAdd;
|
||||||
|
private Button buttonCancel;
|
||||||
|
private Button buttonTestAdd;
|
||||||
|
}
|
||||||
|
}
|
158
BulletinBoard/BulletinBoard/FormCreateCities.cs
Normal file
158
BulletinBoard/BulletinBoard/FormCreateCities.cs
Normal file
@ -0,0 +1,158 @@
|
|||||||
|
using BulletinBoardContracts.BindingModels;
|
||||||
|
using BulletinBoardContracts.BusinessLogicContracts;
|
||||||
|
using BulletinBoardContracts.SearchModels;
|
||||||
|
using BulletinBoardContracts.ViewModels;
|
||||||
|
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 BulletinBoard
|
||||||
|
{
|
||||||
|
public partial class FormCreateCities : Form
|
||||||
|
{
|
||||||
|
private readonly IRegionLogic _regionLogic;
|
||||||
|
private readonly ICityLogic _cityLogic;
|
||||||
|
|
||||||
|
private int? _id;
|
||||||
|
public int Id { set { _id = value; } }
|
||||||
|
|
||||||
|
private string? _objectId;
|
||||||
|
public string ObjectId { set { _objectId = value; } }
|
||||||
|
|
||||||
|
public FormCreateCities(IRegionLogic regionLogic, ICityLogic cityLogic)
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
|
||||||
|
_regionLogic = regionLogic;
|
||||||
|
_cityLogic = cityLogic;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void LoadData()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var listRegions = _regionLogic.ReadList(null);
|
||||||
|
|
||||||
|
if (listRegions != null)
|
||||||
|
{
|
||||||
|
comboBoxRegion.DisplayMember = "RegionName";
|
||||||
|
if (Program.CURRENT_DATABASE.Equals("PostgreSQL"))
|
||||||
|
comboBoxRegion.ValueMember = "Id";
|
||||||
|
else
|
||||||
|
comboBoxRegion.ValueMember = "ObjectId";
|
||||||
|
comboBoxRegion.DataSource = listRegions;
|
||||||
|
comboBoxRegion.SelectedItem = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception){ }
|
||||||
|
}
|
||||||
|
|
||||||
|
private void buttonAdd_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(textBoxCity.Text))
|
||||||
|
{
|
||||||
|
MessageBox.Show("Введите название города", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (string.IsNullOrEmpty(comboBoxRegion.Text))
|
||||||
|
{
|
||||||
|
MessageBox.Show("Выберите регион, в котором находится город", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
try
|
||||||
|
{
|
||||||
|
CityBindingModel model;
|
||||||
|
if (Program.CURRENT_DATABASE.Equals("PostgreSQL"))
|
||||||
|
{
|
||||||
|
model = new CityBindingModel
|
||||||
|
{
|
||||||
|
Id = _id ?? 0,
|
||||||
|
CityName = textBoxCity.Text,
|
||||||
|
RegionId = Convert.ToInt32(comboBoxRegion.SelectedValue),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
model = new CityBindingModel
|
||||||
|
{
|
||||||
|
ObjectId = _objectId ?? string.Empty,
|
||||||
|
CityName = textBoxCity.Text,
|
||||||
|
RegionStringId = comboBoxRegion.SelectedValue.ToString(),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
var operationResult = _id.HasValue || !string.IsNullOrEmpty(_objectId) ? _cityLogic.Update(model) : _cityLogic.Create(model);
|
||||||
|
|
||||||
|
if (!operationResult)
|
||||||
|
{
|
||||||
|
throw new Exception("Ошибка при сохранении.");
|
||||||
|
}
|
||||||
|
|
||||||
|
MessageBox.Show("Сохранение прошло успешно", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||||
|
DialogResult = DialogResult.OK;
|
||||||
|
|
||||||
|
Close();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void buttonCancel_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
DialogResult = DialogResult.Cancel;
|
||||||
|
Close();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void FormCreateCity_Load(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
LoadData();
|
||||||
|
if (_id.HasValue)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
CityViewModel? view;
|
||||||
|
if (Program.CURRENT_DATABASE.Equals("PostgreSQL"))
|
||||||
|
{
|
||||||
|
view = _cityLogic.ReadElement(new CitySearchModel { Id = _id });
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
view = _cityLogic.ReadElement(new CitySearchModel { ObjectId = _objectId });
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (view != null)
|
||||||
|
{
|
||||||
|
textBoxCity.Text = view.CityName;
|
||||||
|
comboBoxRegion.SelectedValue = view.RegionStringId;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void buttonTestAdd_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_cityLogic.CityInsertList(1000, _regionLogic.ReadList(null));
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
110
BulletinBoard/BulletinBoard/FormCreateRegions.Designer.cs
generated
Normal file
110
BulletinBoard/BulletinBoard/FormCreateRegions.Designer.cs
generated
Normal file
@ -0,0 +1,110 @@
|
|||||||
|
namespace BulletinBoard
|
||||||
|
{
|
||||||
|
partial class FormCreateRegions
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Required designer variable.
|
||||||
|
/// </summary>
|
||||||
|
private System.ComponentModel.IContainer components = null;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Clean up any resources being used.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||||
|
protected override void Dispose(bool disposing)
|
||||||
|
{
|
||||||
|
if (disposing && (components != null))
|
||||||
|
{
|
||||||
|
components.Dispose();
|
||||||
|
}
|
||||||
|
base.Dispose(disposing);
|
||||||
|
}
|
||||||
|
|
||||||
|
#region Windows Form Designer generated code
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Required method for Designer support - do not modify
|
||||||
|
/// the contents of this method with the code editor.
|
||||||
|
/// </summary>
|
||||||
|
private void InitializeComponent()
|
||||||
|
{
|
||||||
|
textBoxName = new TextBox();
|
||||||
|
label1 = new Label();
|
||||||
|
buttonCancel = new Button();
|
||||||
|
buttonAdd = new Button();
|
||||||
|
buttonTestAdd = new Button();
|
||||||
|
SuspendLayout();
|
||||||
|
//
|
||||||
|
// textBoxName
|
||||||
|
//
|
||||||
|
textBoxName.Location = new Point(12, 27);
|
||||||
|
textBoxName.Name = "textBoxName";
|
||||||
|
textBoxName.Size = new Size(145, 23);
|
||||||
|
textBoxName.TabIndex = 23;
|
||||||
|
//
|
||||||
|
// label1
|
||||||
|
//
|
||||||
|
label1.AutoSize = true;
|
||||||
|
label1.Location = new Point(12, 9);
|
||||||
|
label1.Name = "label1";
|
||||||
|
label1.Size = new Size(110, 15);
|
||||||
|
label1.TabIndex = 20;
|
||||||
|
label1.Text = "Название региона:";
|
||||||
|
//
|
||||||
|
// buttonCancel
|
||||||
|
//
|
||||||
|
buttonCancel.Location = new Point(12, 71);
|
||||||
|
buttonCancel.Name = "buttonCancel";
|
||||||
|
buttonCancel.Size = new Size(75, 23);
|
||||||
|
buttonCancel.TabIndex = 27;
|
||||||
|
buttonCancel.Text = "Отмена";
|
||||||
|
buttonCancel.UseVisualStyleBackColor = true;
|
||||||
|
buttonCancel.Click += buttonCancel_Click;
|
||||||
|
//
|
||||||
|
// buttonAdd
|
||||||
|
//
|
||||||
|
buttonAdd.Location = new Point(93, 71);
|
||||||
|
buttonAdd.Name = "buttonAdd";
|
||||||
|
buttonAdd.Size = new Size(75, 23);
|
||||||
|
buttonAdd.TabIndex = 26;
|
||||||
|
buttonAdd.Text = "Добавить";
|
||||||
|
buttonAdd.UseVisualStyleBackColor = true;
|
||||||
|
buttonAdd.Click += buttonAdd_Click;
|
||||||
|
//
|
||||||
|
// buttonTestAdd
|
||||||
|
//
|
||||||
|
buttonTestAdd.Location = new Point(176, 11);
|
||||||
|
buttonTestAdd.Name = "buttonTestAdd";
|
||||||
|
buttonTestAdd.Size = new Size(75, 54);
|
||||||
|
buttonTestAdd.TabIndex = 28;
|
||||||
|
buttonTestAdd.Text = "Добавить 1000 регионов";
|
||||||
|
buttonTestAdd.UseVisualStyleBackColor = true;
|
||||||
|
buttonTestAdd.Click += buttonTestAdd_Click;
|
||||||
|
//
|
||||||
|
// FormCreateRegions
|
||||||
|
//
|
||||||
|
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||||
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
|
ClientSize = new Size(264, 119);
|
||||||
|
Controls.Add(buttonTestAdd);
|
||||||
|
Controls.Add(buttonCancel);
|
||||||
|
Controls.Add(buttonAdd);
|
||||||
|
Controls.Add(textBoxName);
|
||||||
|
Controls.Add(label1);
|
||||||
|
MaximizeBox = false;
|
||||||
|
MinimizeBox = false;
|
||||||
|
Name = "FormCreateRegions";
|
||||||
|
Text = "Добавление региона";
|
||||||
|
Load += FormCreateRegion_Load;
|
||||||
|
ResumeLayout(false);
|
||||||
|
PerformLayout();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
private TextBox textBoxName;
|
||||||
|
private Label label1;
|
||||||
|
private Button buttonCancel;
|
||||||
|
private Button buttonAdd;
|
||||||
|
private Button buttonTestAdd;
|
||||||
|
}
|
||||||
|
}
|
127
BulletinBoard/BulletinBoard/FormCreateRegions.cs
Normal file
127
BulletinBoard/BulletinBoard/FormCreateRegions.cs
Normal file
@ -0,0 +1,127 @@
|
|||||||
|
using BulletinBoardContracts.BindingModels;
|
||||||
|
using BulletinBoardContracts.BusinessLogicContracts;
|
||||||
|
using BulletinBoardContracts.SearchModels;
|
||||||
|
using BulletinBoardContracts.ViewModels;
|
||||||
|
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 BulletinBoard
|
||||||
|
{
|
||||||
|
public partial class FormCreateRegions : Form
|
||||||
|
{
|
||||||
|
private readonly IRegionLogic _regionLogic;
|
||||||
|
|
||||||
|
private int? _id;
|
||||||
|
public int Id { set { _id = value; } }
|
||||||
|
|
||||||
|
private string? _objectId;
|
||||||
|
public string ObjectId { set { _objectId = value; } }
|
||||||
|
|
||||||
|
public FormCreateRegions(IRegionLogic regionLogic)
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
|
||||||
|
_regionLogic = regionLogic;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void buttonAdd_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(textBoxName.Text))
|
||||||
|
{
|
||||||
|
MessageBox.Show("Введите название региона", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
RegionBindingModel model;
|
||||||
|
if (Program.CURRENT_DATABASE.Equals("PostgreSQL"))
|
||||||
|
{
|
||||||
|
model = new RegionBindingModel
|
||||||
|
{
|
||||||
|
Id = _id ?? 0,
|
||||||
|
RegionName = textBoxName.Text,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
model = new RegionBindingModel
|
||||||
|
{
|
||||||
|
ObjectId = _objectId ?? string.Empty,
|
||||||
|
RegionName = textBoxName.Text,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
var operationResult = _id.HasValue ? _regionLogic.Update(model) : _regionLogic.Create(model);
|
||||||
|
|
||||||
|
if (!operationResult)
|
||||||
|
{
|
||||||
|
throw new Exception("Ошибка при сохранении.");
|
||||||
|
}
|
||||||
|
|
||||||
|
MessageBox.Show("Сохранение прошло успешно", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||||
|
DialogResult = DialogResult.OK;
|
||||||
|
|
||||||
|
Close();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void buttonCancel_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
DialogResult = DialogResult.Cancel;
|
||||||
|
Close();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void FormCreateRegion_Load(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (_id.HasValue || !string.IsNullOrEmpty(_objectId))
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
RegionViewModel? view;
|
||||||
|
if (Program.CURRENT_DATABASE.Equals("PostgreSQL"))
|
||||||
|
{
|
||||||
|
view = _regionLogic.ReadElement(new RegionSearchModel { Id = _id });
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
view = _regionLogic.ReadElement(new RegionSearchModel { ObjectId = _objectId });
|
||||||
|
}
|
||||||
|
|
||||||
|
if (view != null)
|
||||||
|
{
|
||||||
|
textBoxName.Text = view.RegionName;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void buttonTestAdd_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_regionLogic.RegionInsertList(1000);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
175
BulletinBoard/BulletinBoard/FormCreateUser.Designer.cs
generated
Normal file
175
BulletinBoard/BulletinBoard/FormCreateUser.Designer.cs
generated
Normal file
@ -0,0 +1,175 @@
|
|||||||
|
namespace BulletinBoard
|
||||||
|
{
|
||||||
|
partial class FormCreateUser
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Required designer variable.
|
||||||
|
/// </summary>
|
||||||
|
private System.ComponentModel.IContainer components = null;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Clean up any resources being used.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||||
|
protected override void Dispose(bool disposing)
|
||||||
|
{
|
||||||
|
if (disposing && (components != null))
|
||||||
|
{
|
||||||
|
components.Dispose();
|
||||||
|
}
|
||||||
|
base.Dispose(disposing);
|
||||||
|
}
|
||||||
|
|
||||||
|
#region Windows Form Designer generated code
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Required method for Designer support - do not modify
|
||||||
|
/// the contents of this method with the code editor.
|
||||||
|
/// </summary>
|
||||||
|
private void InitializeComponent()
|
||||||
|
{
|
||||||
|
textBoxEmail = new TextBox();
|
||||||
|
textBoxPhoneNumber = new TextBox();
|
||||||
|
textBoxSurname = new TextBox();
|
||||||
|
textBoxName = new TextBox();
|
||||||
|
label4 = new Label();
|
||||||
|
label3 = new Label();
|
||||||
|
label2 = new Label();
|
||||||
|
label1 = new Label();
|
||||||
|
buttonCancel = new Button();
|
||||||
|
buttonAdd = new Button();
|
||||||
|
buttonTestAdd = new Button();
|
||||||
|
SuspendLayout();
|
||||||
|
//
|
||||||
|
// textBoxEmail
|
||||||
|
//
|
||||||
|
textBoxEmail.Location = new Point(12, 159);
|
||||||
|
textBoxEmail.Name = "textBoxEmail";
|
||||||
|
textBoxEmail.Size = new Size(145, 23);
|
||||||
|
textBoxEmail.TabIndex = 20;
|
||||||
|
//
|
||||||
|
// textBoxPhoneNumber
|
||||||
|
//
|
||||||
|
textBoxPhoneNumber.Location = new Point(12, 115);
|
||||||
|
textBoxPhoneNumber.Name = "textBoxPhoneNumber";
|
||||||
|
textBoxPhoneNumber.Size = new Size(145, 23);
|
||||||
|
textBoxPhoneNumber.TabIndex = 19;
|
||||||
|
//
|
||||||
|
// textBoxSurname
|
||||||
|
//
|
||||||
|
textBoxSurname.Location = new Point(12, 71);
|
||||||
|
textBoxSurname.Name = "textBoxSurname";
|
||||||
|
textBoxSurname.Size = new Size(145, 23);
|
||||||
|
textBoxSurname.TabIndex = 18;
|
||||||
|
//
|
||||||
|
// textBoxName
|
||||||
|
//
|
||||||
|
textBoxName.Location = new Point(12, 27);
|
||||||
|
textBoxName.Name = "textBoxName";
|
||||||
|
textBoxName.Size = new Size(145, 23);
|
||||||
|
textBoxName.TabIndex = 17;
|
||||||
|
//
|
||||||
|
// label4
|
||||||
|
//
|
||||||
|
label4.AutoSize = true;
|
||||||
|
label4.Location = new Point(12, 141);
|
||||||
|
label4.Name = "label4";
|
||||||
|
label4.Size = new Size(44, 15);
|
||||||
|
label4.TabIndex = 15;
|
||||||
|
label4.Text = "E-mail:";
|
||||||
|
//
|
||||||
|
// label3
|
||||||
|
//
|
||||||
|
label3.AutoSize = true;
|
||||||
|
label3.Location = new Point(12, 97);
|
||||||
|
label3.Name = "label3";
|
||||||
|
label3.Size = new Size(104, 15);
|
||||||
|
label3.TabIndex = 14;
|
||||||
|
label3.Text = "Номер телефона:";
|
||||||
|
//
|
||||||
|
// label2
|
||||||
|
//
|
||||||
|
label2.AutoSize = true;
|
||||||
|
label2.Location = new Point(12, 53);
|
||||||
|
label2.Name = "label2";
|
||||||
|
label2.Size = new Size(61, 15);
|
||||||
|
label2.TabIndex = 13;
|
||||||
|
label2.Text = "Фамилия:";
|
||||||
|
//
|
||||||
|
// label1
|
||||||
|
//
|
||||||
|
label1.AutoSize = true;
|
||||||
|
label1.Location = new Point(12, 9);
|
||||||
|
label1.Name = "label1";
|
||||||
|
label1.Size = new Size(34, 15);
|
||||||
|
label1.TabIndex = 12;
|
||||||
|
label1.Text = "Имя:";
|
||||||
|
//
|
||||||
|
// buttonCancel
|
||||||
|
//
|
||||||
|
buttonCancel.Location = new Point(185, 151);
|
||||||
|
buttonCancel.Name = "buttonCancel";
|
||||||
|
buttonCancel.Size = new Size(75, 31);
|
||||||
|
buttonCancel.TabIndex = 23;
|
||||||
|
buttonCancel.Text = "Отмена";
|
||||||
|
buttonCancel.UseVisualStyleBackColor = true;
|
||||||
|
buttonCancel.Click += buttonCancel_Click;
|
||||||
|
//
|
||||||
|
// buttonAdd
|
||||||
|
//
|
||||||
|
buttonAdd.Location = new Point(185, 97);
|
||||||
|
buttonAdd.Name = "buttonAdd";
|
||||||
|
buttonAdd.Size = new Size(75, 38);
|
||||||
|
buttonAdd.TabIndex = 22;
|
||||||
|
buttonAdd.Text = "Добавить";
|
||||||
|
buttonAdd.UseVisualStyleBackColor = true;
|
||||||
|
buttonAdd.Click += buttonAdd_Click;
|
||||||
|
//
|
||||||
|
// buttonTestAdd
|
||||||
|
//
|
||||||
|
buttonTestAdd.Location = new Point(185, 27);
|
||||||
|
buttonTestAdd.Name = "buttonTestAdd";
|
||||||
|
buttonTestAdd.Size = new Size(75, 54);
|
||||||
|
buttonTestAdd.TabIndex = 30;
|
||||||
|
buttonTestAdd.Text = "Добавить 50 пользователей";
|
||||||
|
buttonTestAdd.UseVisualStyleBackColor = true;
|
||||||
|
buttonTestAdd.Click += buttonTestAdd_Click;
|
||||||
|
//
|
||||||
|
// FormCreateUser
|
||||||
|
//
|
||||||
|
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||||
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
|
ClientSize = new Size(281, 217);
|
||||||
|
Controls.Add(buttonTestAdd);
|
||||||
|
Controls.Add(buttonCancel);
|
||||||
|
Controls.Add(buttonAdd);
|
||||||
|
Controls.Add(textBoxEmail);
|
||||||
|
Controls.Add(textBoxPhoneNumber);
|
||||||
|
Controls.Add(textBoxSurname);
|
||||||
|
Controls.Add(textBoxName);
|
||||||
|
Controls.Add(label4);
|
||||||
|
Controls.Add(label3);
|
||||||
|
Controls.Add(label2);
|
||||||
|
Controls.Add(label1);
|
||||||
|
Name = "FormCreateUser";
|
||||||
|
Text = "Добавление пользователя";
|
||||||
|
Load += FormCreateUser_Load;
|
||||||
|
ResumeLayout(false);
|
||||||
|
PerformLayout();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
private TextBox textBoxSurname;
|
||||||
|
private TextBox textBoxName;
|
||||||
|
private TextBox textBoxEmail;
|
||||||
|
private TextBox textBoxPhoneNumber;
|
||||||
|
|
||||||
|
private Label label4;
|
||||||
|
private Label label3;
|
||||||
|
private Label label2;
|
||||||
|
private Label label1;
|
||||||
|
private Button buttonCancel;
|
||||||
|
private Button buttonAdd;
|
||||||
|
private Button buttonTestAdd;
|
||||||
|
}
|
||||||
|
}
|
152
BulletinBoard/BulletinBoard/FormCreateUser.cs
Normal file
152
BulletinBoard/BulletinBoard/FormCreateUser.cs
Normal file
@ -0,0 +1,152 @@
|
|||||||
|
using BulletinBoardContracts.BindingModels;
|
||||||
|
using BulletinBoardContracts.BusinessLogicContracts;
|
||||||
|
using BulletinBoardContracts.SearchModels;
|
||||||
|
using BulletinBoardContracts.ViewModels;
|
||||||
|
using Microsoft.EntityFrameworkCore.Metadata;
|
||||||
|
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 BulletinBoard
|
||||||
|
{
|
||||||
|
public partial class FormCreateUser : Form
|
||||||
|
{
|
||||||
|
private readonly IUserLogic _userLogic;
|
||||||
|
|
||||||
|
private int? _id;
|
||||||
|
public int Id { set { _id = value; } }
|
||||||
|
|
||||||
|
private string? _objectId;
|
||||||
|
public string ObjectId { set { _objectId = value; } }
|
||||||
|
|
||||||
|
public FormCreateUser(IUserLogic userLogic)
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
|
||||||
|
_userLogic = userLogic;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void buttonAdd_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(textBoxName.Text))
|
||||||
|
{
|
||||||
|
MessageBox.Show("Введите имя пользователя", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (string.IsNullOrEmpty(textBoxPhoneNumber.Text))
|
||||||
|
{
|
||||||
|
MessageBox.Show("Введите номер телефона пользователя", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (string.IsNullOrEmpty(textBoxSurname.Text))
|
||||||
|
{
|
||||||
|
MessageBox.Show("Введите фамилию пользователя", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (string.IsNullOrEmpty(textBoxEmail.Text))
|
||||||
|
{
|
||||||
|
MessageBox.Show("Введите E-mail пользователя", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{ UserBindingModel model;
|
||||||
|
if (Program.CURRENT_DATABASE.Equals("PostgreSQL"))
|
||||||
|
{
|
||||||
|
model = new UserBindingModel
|
||||||
|
{
|
||||||
|
Id = _id ?? 0,
|
||||||
|
Name = textBoxName.Text,
|
||||||
|
Surname = textBoxSurname.Text,
|
||||||
|
PhoneNumber = textBoxPhoneNumber.Text,
|
||||||
|
Email = textBoxEmail.Text,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
model = new UserBindingModel
|
||||||
|
{
|
||||||
|
ObjectId = _objectId ?? string.Empty,
|
||||||
|
Name = textBoxName.Text,
|
||||||
|
Surname = textBoxSurname.Text,
|
||||||
|
PhoneNumber = textBoxPhoneNumber.Text,
|
||||||
|
Email = textBoxEmail.Text,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
var operationResult = _id.HasValue ? _userLogic.Update(model) : _userLogic.Create(model);
|
||||||
|
|
||||||
|
if (!operationResult)
|
||||||
|
{
|
||||||
|
throw new Exception("Ошибка при сохранении.");
|
||||||
|
}
|
||||||
|
|
||||||
|
MessageBox.Show("Сохранение прошло успешно", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||||
|
DialogResult = DialogResult.OK;
|
||||||
|
|
||||||
|
Close();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void buttonCancel_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
DialogResult = DialogResult.Cancel;
|
||||||
|
Close();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void FormCreateUser_Load(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (_id.HasValue)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
UserViewModel? view;
|
||||||
|
if (Program.CURRENT_DATABASE.Equals("PostgreSQL"))
|
||||||
|
{
|
||||||
|
view = _userLogic.ReadElement(new UserSearchModel { Id = _id });
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
view = _userLogic.ReadElement(new UserSearchModel { ObjectId = _objectId });
|
||||||
|
}
|
||||||
|
|
||||||
|
if (view != null)
|
||||||
|
{
|
||||||
|
textBoxName.Text = view.Name;
|
||||||
|
textBoxSurname.Text = view.Surname;
|
||||||
|
textBoxPhoneNumber.Text = view.PhoneNumber;
|
||||||
|
textBoxEmail.Text = view.Email;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void buttonTestAdd_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_userLogic.UserInsertList(50);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
115
BulletinBoard/BulletinBoard/FormRegions.Designer.cs
generated
Normal file
115
BulletinBoard/BulletinBoard/FormRegions.Designer.cs
generated
Normal file
@ -0,0 +1,115 @@
|
|||||||
|
namespace BulletinBoard
|
||||||
|
{
|
||||||
|
partial class FormRegions
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Required designer variable.
|
||||||
|
/// </summary>
|
||||||
|
private System.ComponentModel.IContainer components = null;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Clean up any resources being used.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||||
|
protected override void Dispose(bool disposing)
|
||||||
|
{
|
||||||
|
if (disposing && (components != null))
|
||||||
|
{
|
||||||
|
components.Dispose();
|
||||||
|
}
|
||||||
|
base.Dispose(disposing);
|
||||||
|
}
|
||||||
|
|
||||||
|
#region Windows Form Designer generated code
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Required method for Designer support - do not modify
|
||||||
|
/// the contents of this method with the code editor.
|
||||||
|
/// </summary>
|
||||||
|
private void InitializeComponent()
|
||||||
|
{
|
||||||
|
this.buttonUpdate = new System.Windows.Forms.Button();
|
||||||
|
this.buttonDelete = new System.Windows.Forms.Button();
|
||||||
|
this.buttonChange = new System.Windows.Forms.Button();
|
||||||
|
this.buttonAdd = new System.Windows.Forms.Button();
|
||||||
|
this.dataGridView = new System.Windows.Forms.DataGridView();
|
||||||
|
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
|
||||||
|
this.SuspendLayout();
|
||||||
|
//
|
||||||
|
// buttonUpdate
|
||||||
|
//
|
||||||
|
this.buttonUpdate.Location = new System.Drawing.Point(592, 99);
|
||||||
|
this.buttonUpdate.Name = "buttonUpdate";
|
||||||
|
this.buttonUpdate.Size = new System.Drawing.Size(75, 23);
|
||||||
|
this.buttonUpdate.TabIndex = 9;
|
||||||
|
this.buttonUpdate.Text = "Обновить";
|
||||||
|
this.buttonUpdate.UseVisualStyleBackColor = true;
|
||||||
|
this.buttonUpdate.Click += new System.EventHandler(this.buttonUpdate_Click);
|
||||||
|
//
|
||||||
|
// buttonDelete
|
||||||
|
//
|
||||||
|
this.buttonDelete.Location = new System.Drawing.Point(592, 70);
|
||||||
|
this.buttonDelete.Name = "buttonDelete";
|
||||||
|
this.buttonDelete.Size = new System.Drawing.Size(75, 23);
|
||||||
|
this.buttonDelete.TabIndex = 8;
|
||||||
|
this.buttonDelete.Text = "Удалить";
|
||||||
|
this.buttonDelete.UseVisualStyleBackColor = true;
|
||||||
|
this.buttonDelete.Click += new System.EventHandler(this.buttonDelete_Click);
|
||||||
|
//
|
||||||
|
// buttonChange
|
||||||
|
//
|
||||||
|
this.buttonChange.Location = new System.Drawing.Point(592, 41);
|
||||||
|
this.buttonChange.Name = "buttonChange";
|
||||||
|
this.buttonChange.Size = new System.Drawing.Size(75, 23);
|
||||||
|
this.buttonChange.TabIndex = 7;
|
||||||
|
this.buttonChange.Text = "Изменить";
|
||||||
|
this.buttonChange.UseVisualStyleBackColor = true;
|
||||||
|
this.buttonChange.Click += new System.EventHandler(this.buttonChange_Click);
|
||||||
|
//
|
||||||
|
// buttonAdd
|
||||||
|
//
|
||||||
|
this.buttonAdd.Location = new System.Drawing.Point(592, 12);
|
||||||
|
this.buttonAdd.Name = "buttonAdd";
|
||||||
|
this.buttonAdd.Size = new System.Drawing.Size(75, 23);
|
||||||
|
this.buttonAdd.TabIndex = 6;
|
||||||
|
this.buttonAdd.Text = "Создать";
|
||||||
|
this.buttonAdd.UseVisualStyleBackColor = true;
|
||||||
|
this.buttonAdd.Click += new System.EventHandler(this.buttonAdd_Click);
|
||||||
|
//
|
||||||
|
// dataGridView
|
||||||
|
//
|
||||||
|
this.dataGridView.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill;
|
||||||
|
this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||||
|
this.dataGridView.Location = new System.Drawing.Point(12, 12);
|
||||||
|
this.dataGridView.Name = "dataGridView";
|
||||||
|
this.dataGridView.RowTemplate.Height = 25;
|
||||||
|
this.dataGridView.Size = new System.Drawing.Size(574, 426);
|
||||||
|
this.dataGridView.TabIndex = 5;
|
||||||
|
//
|
||||||
|
// FormRegions
|
||||||
|
//
|
||||||
|
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
||||||
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
|
this.ClientSize = new System.Drawing.Size(674, 450);
|
||||||
|
this.Controls.Add(this.buttonUpdate);
|
||||||
|
this.Controls.Add(this.buttonDelete);
|
||||||
|
this.Controls.Add(this.buttonChange);
|
||||||
|
this.Controls.Add(this.buttonAdd);
|
||||||
|
this.Controls.Add(this.dataGridView);
|
||||||
|
this.Name = "FormRegions";
|
||||||
|
this.Text = "Список регионов";
|
||||||
|
this.Load += new System.EventHandler(this.FormRegions_Load);
|
||||||
|
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit();
|
||||||
|
this.ResumeLayout(false);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private Button buttonUpdate;
|
||||||
|
private Button buttonDelete;
|
||||||
|
private Button buttonChange;
|
||||||
|
private Button buttonAdd;
|
||||||
|
private DataGridView dataGridView;
|
||||||
|
}
|
||||||
|
}
|
112
BulletinBoard/BulletinBoard/FormRegions.cs
Normal file
112
BulletinBoard/BulletinBoard/FormRegions.cs
Normal file
@ -0,0 +1,112 @@
|
|||||||
|
using BulletinBoardContracts.BindingModels;
|
||||||
|
using BulletinBoardContracts.BusinessLogicContracts;
|
||||||
|
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 BulletinBoard
|
||||||
|
{
|
||||||
|
public partial class FormRegions : Form
|
||||||
|
{
|
||||||
|
private readonly IRegionLogic _regionLogic;
|
||||||
|
|
||||||
|
public FormRegions(IRegionLogic regionLogic)
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
|
||||||
|
_regionLogic = regionLogic;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void LoadData()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var list = _regionLogic.ReadList(null);
|
||||||
|
|
||||||
|
if (list != null)
|
||||||
|
{
|
||||||
|
dataGridView.DataSource = list;
|
||||||
|
dataGridView.Columns["Id"].Visible = false;
|
||||||
|
dataGridView.Columns["ObjectId"].Visible = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex){ }
|
||||||
|
}
|
||||||
|
|
||||||
|
private void FormRegions_Load(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
LoadData();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void buttonAdd_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
var service = Program.ServiceProvider?.GetService(typeof(FormCreateRegions));
|
||||||
|
|
||||||
|
if (service is FormCreateRegions form)
|
||||||
|
{
|
||||||
|
if (form.ShowDialog() == DialogResult.OK)
|
||||||
|
{
|
||||||
|
LoadData();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void buttonChange_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (dataGridView.SelectedRows.Count == 1)
|
||||||
|
{
|
||||||
|
var service = Program.ServiceProvider?.GetService(typeof(FormCreateRegions));
|
||||||
|
|
||||||
|
if (service is FormCreateRegions form)
|
||||||
|
{
|
||||||
|
form.Id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||||
|
form.ObjectId = dataGridView.SelectedRows[0].Cells["ObjectId"].Value.ToString() ?? string.Empty;
|
||||||
|
|
||||||
|
if (form.ShowDialog() == DialogResult.OK)
|
||||||
|
{
|
||||||
|
LoadData();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void buttonDelete_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (dataGridView.SelectedRows.Count == 1)
|
||||||
|
{
|
||||||
|
if (MessageBox.Show("Удалить запись?", "Вопрос", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
|
||||||
|
{
|
||||||
|
int? id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||||
|
string? objectId = dataGridView.SelectedRows[0].Cells["ObjectId"].Value.ToString();
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (Program.CURRENT_DATABASE.Equals("PostgreSQL")
|
||||||
|
&& !_regionLogic.Delete(new RegionBindingModel{ Id = id ?? 0})
|
||||||
|
|| !_regionLogic.Delete(new RegionBindingModel { ObjectId = objectId ?? string.Empty }))
|
||||||
|
{
|
||||||
|
throw new Exception("Ошибка при удалении.");
|
||||||
|
}
|
||||||
|
|
||||||
|
LoadData();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void buttonUpdate_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
LoadData();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
228
BulletinBoard/BulletinBoard/FormTests.Designer.cs
generated
Normal file
228
BulletinBoard/BulletinBoard/FormTests.Designer.cs
generated
Normal file
@ -0,0 +1,228 @@
|
|||||||
|
namespace BulletinBoard
|
||||||
|
{
|
||||||
|
partial class FormTests
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Required designer variable.
|
||||||
|
/// </summary>
|
||||||
|
private System.ComponentModel.IContainer components = null;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Clean up any resources being used.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||||
|
protected override void Dispose(bool disposing)
|
||||||
|
{
|
||||||
|
if (disposing && (components != null))
|
||||||
|
{
|
||||||
|
components.Dispose();
|
||||||
|
}
|
||||||
|
base.Dispose(disposing);
|
||||||
|
}
|
||||||
|
|
||||||
|
#region Windows Form Designer generated code
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Required method for Designer support - do not modify
|
||||||
|
/// the contents of this method with the code editor.
|
||||||
|
/// </summary>
|
||||||
|
private void InitializeComponent()
|
||||||
|
{
|
||||||
|
this.buttonInsertTest = new System.Windows.Forms.Button();
|
||||||
|
this.label1 = new System.Windows.Forms.Label();
|
||||||
|
this.label2 = new System.Windows.Forms.Label();
|
||||||
|
this.textBoxInsertTime = new System.Windows.Forms.TextBox();
|
||||||
|
this.buttonReadTest = new System.Windows.Forms.Button();
|
||||||
|
this.textBoxReadTime = new System.Windows.Forms.TextBox();
|
||||||
|
this.label3 = new System.Windows.Forms.Label();
|
||||||
|
this.label4 = new System.Windows.Forms.Label();
|
||||||
|
this.numericUpDownInsert = new System.Windows.Forms.NumericUpDown();
|
||||||
|
this.numericUpDownRead = new System.Windows.Forms.NumericUpDown();
|
||||||
|
this.buttonJoinQuery = new System.Windows.Forms.Button();
|
||||||
|
this.numericUpDownJoin = new System.Windows.Forms.NumericUpDown();
|
||||||
|
this.textBoxJoin = new System.Windows.Forms.TextBox();
|
||||||
|
this.label5 = new System.Windows.Forms.Label();
|
||||||
|
this.label6 = new System.Windows.Forms.Label();
|
||||||
|
((System.ComponentModel.ISupportInitialize)(this.numericUpDownInsert)).BeginInit();
|
||||||
|
((System.ComponentModel.ISupportInitialize)(this.numericUpDownRead)).BeginInit();
|
||||||
|
((System.ComponentModel.ISupportInitialize)(this.numericUpDownJoin)).BeginInit();
|
||||||
|
this.SuspendLayout();
|
||||||
|
//
|
||||||
|
// buttonInsertTest
|
||||||
|
//
|
||||||
|
this.buttonInsertTest.Location = new System.Drawing.Point(12, 12);
|
||||||
|
this.buttonInsertTest.Name = "buttonInsertTest";
|
||||||
|
this.buttonInsertTest.Size = new System.Drawing.Size(75, 56);
|
||||||
|
this.buttonInsertTest.TabIndex = 0;
|
||||||
|
this.buttonInsertTest.Text = "Тест вставки заказов";
|
||||||
|
this.buttonInsertTest.UseVisualStyleBackColor = true;
|
||||||
|
this.buttonInsertTest.Click += new System.EventHandler(this.buttonInsertTest_Click);
|
||||||
|
//
|
||||||
|
// label1
|
||||||
|
//
|
||||||
|
this.label1.AutoSize = true;
|
||||||
|
this.label1.Location = new System.Drawing.Point(104, 12);
|
||||||
|
this.label1.Name = "label1";
|
||||||
|
this.label1.Size = new System.Drawing.Size(156, 15);
|
||||||
|
this.label1.TabIndex = 1;
|
||||||
|
this.label1.Text = "Введите кол-во элементов:";
|
||||||
|
//
|
||||||
|
// label2
|
||||||
|
//
|
||||||
|
this.label2.AutoSize = true;
|
||||||
|
this.label2.Location = new System.Drawing.Point(104, 53);
|
||||||
|
this.label2.Name = "label2";
|
||||||
|
this.label2.Size = new System.Drawing.Size(146, 15);
|
||||||
|
this.label2.TabIndex = 3;
|
||||||
|
this.label2.Text = "Итоговое время запроса:";
|
||||||
|
//
|
||||||
|
// textBoxInsertTime
|
||||||
|
//
|
||||||
|
this.textBoxInsertTime.Location = new System.Drawing.Point(266, 50);
|
||||||
|
this.textBoxInsertTime.Name = "textBoxInsertTime";
|
||||||
|
this.textBoxInsertTime.ReadOnly = true;
|
||||||
|
this.textBoxInsertTime.Size = new System.Drawing.Size(100, 23);
|
||||||
|
this.textBoxInsertTime.TabIndex = 4;
|
||||||
|
//
|
||||||
|
// buttonReadTest
|
||||||
|
//
|
||||||
|
this.buttonReadTest.Location = new System.Drawing.Point(12, 106);
|
||||||
|
this.buttonReadTest.Name = "buttonReadTest";
|
||||||
|
this.buttonReadTest.Size = new System.Drawing.Size(75, 56);
|
||||||
|
this.buttonReadTest.TabIndex = 5;
|
||||||
|
this.buttonReadTest.Text = "Тест чтения заказов";
|
||||||
|
this.buttonReadTest.UseVisualStyleBackColor = true;
|
||||||
|
this.buttonReadTest.Click += new System.EventHandler(this.buttonReadTest_Click);
|
||||||
|
//
|
||||||
|
// textBoxReadTime
|
||||||
|
//
|
||||||
|
this.textBoxReadTime.Location = new System.Drawing.Point(266, 144);
|
||||||
|
this.textBoxReadTime.Name = "textBoxReadTime";
|
||||||
|
this.textBoxReadTime.ReadOnly = true;
|
||||||
|
this.textBoxReadTime.Size = new System.Drawing.Size(100, 23);
|
||||||
|
this.textBoxReadTime.TabIndex = 9;
|
||||||
|
//
|
||||||
|
// label3
|
||||||
|
//
|
||||||
|
this.label3.AutoSize = true;
|
||||||
|
this.label3.Location = new System.Drawing.Point(104, 147);
|
||||||
|
this.label3.Name = "label3";
|
||||||
|
this.label3.Size = new System.Drawing.Size(146, 15);
|
||||||
|
this.label3.TabIndex = 8;
|
||||||
|
this.label3.Text = "Итоговое время запроса:";
|
||||||
|
//
|
||||||
|
// label4
|
||||||
|
//
|
||||||
|
this.label4.AutoSize = true;
|
||||||
|
this.label4.Location = new System.Drawing.Point(104, 106);
|
||||||
|
this.label4.Name = "label4";
|
||||||
|
this.label4.Size = new System.Drawing.Size(156, 15);
|
||||||
|
this.label4.TabIndex = 6;
|
||||||
|
this.label4.Text = "Введите кол-во элементов:";
|
||||||
|
//
|
||||||
|
// numericUpDownInsert
|
||||||
|
//
|
||||||
|
this.numericUpDownInsert.Location = new System.Drawing.Point(266, 10);
|
||||||
|
this.numericUpDownInsert.Name = "numericUpDownInsert";
|
||||||
|
this.numericUpDownInsert.Size = new System.Drawing.Size(100, 23);
|
||||||
|
this.numericUpDownInsert.TabIndex = 10;
|
||||||
|
//
|
||||||
|
// numericUpDownRead
|
||||||
|
//
|
||||||
|
this.numericUpDownRead.Location = new System.Drawing.Point(266, 104);
|
||||||
|
this.numericUpDownRead.Name = "numericUpDownRead";
|
||||||
|
this.numericUpDownRead.Size = new System.Drawing.Size(100, 23);
|
||||||
|
this.numericUpDownRead.TabIndex = 11;
|
||||||
|
//
|
||||||
|
// buttonJoinQuery
|
||||||
|
//
|
||||||
|
this.buttonJoinQuery.Location = new System.Drawing.Point(12, 197);
|
||||||
|
this.buttonJoinQuery.Name = "buttonJoinQuery";
|
||||||
|
this.buttonJoinQuery.Size = new System.Drawing.Size(75, 74);
|
||||||
|
this.buttonJoinQuery.TabIndex = 12;
|
||||||
|
this.buttonJoinQuery.Text = "Тест сложного чтения (Join)";
|
||||||
|
this.buttonJoinQuery.UseVisualStyleBackColor = true;
|
||||||
|
this.buttonJoinQuery.Click += new System.EventHandler(this.buttonJoinQuery_Click);
|
||||||
|
//
|
||||||
|
// numericUpDownJoin
|
||||||
|
//
|
||||||
|
this.numericUpDownJoin.Location = new System.Drawing.Point(266, 195);
|
||||||
|
this.numericUpDownJoin.Name = "numericUpDownJoin";
|
||||||
|
this.numericUpDownJoin.Size = new System.Drawing.Size(100, 23);
|
||||||
|
this.numericUpDownJoin.TabIndex = 16;
|
||||||
|
//
|
||||||
|
// textBoxJoin
|
||||||
|
//
|
||||||
|
this.textBoxJoin.Location = new System.Drawing.Point(266, 235);
|
||||||
|
this.textBoxJoin.Name = "textBoxJoin";
|
||||||
|
this.textBoxJoin.ReadOnly = true;
|
||||||
|
this.textBoxJoin.Size = new System.Drawing.Size(100, 23);
|
||||||
|
this.textBoxJoin.TabIndex = 15;
|
||||||
|
//
|
||||||
|
// label5
|
||||||
|
//
|
||||||
|
this.label5.AutoSize = true;
|
||||||
|
this.label5.Location = new System.Drawing.Point(104, 238);
|
||||||
|
this.label5.Name = "label5";
|
||||||
|
this.label5.Size = new System.Drawing.Size(146, 15);
|
||||||
|
this.label5.TabIndex = 14;
|
||||||
|
this.label5.Text = "Итоговое время запроса:";
|
||||||
|
//
|
||||||
|
// label6
|
||||||
|
//
|
||||||
|
this.label6.AutoSize = true;
|
||||||
|
this.label6.Location = new System.Drawing.Point(104, 197);
|
||||||
|
this.label6.Name = "label6";
|
||||||
|
this.label6.Size = new System.Drawing.Size(156, 15);
|
||||||
|
this.label6.TabIndex = 13;
|
||||||
|
this.label6.Text = "Введите кол-во элементов:";
|
||||||
|
//
|
||||||
|
// FormTests
|
||||||
|
//
|
||||||
|
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
||||||
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
|
this.ClientSize = new System.Drawing.Size(383, 286);
|
||||||
|
this.Controls.Add(this.numericUpDownJoin);
|
||||||
|
this.Controls.Add(this.textBoxJoin);
|
||||||
|
this.Controls.Add(this.label5);
|
||||||
|
this.Controls.Add(this.label6);
|
||||||
|
this.Controls.Add(this.buttonJoinQuery);
|
||||||
|
this.Controls.Add(this.numericUpDownRead);
|
||||||
|
this.Controls.Add(this.numericUpDownInsert);
|
||||||
|
this.Controls.Add(this.textBoxReadTime);
|
||||||
|
this.Controls.Add(this.label3);
|
||||||
|
this.Controls.Add(this.label4);
|
||||||
|
this.Controls.Add(this.buttonReadTest);
|
||||||
|
this.Controls.Add(this.textBoxInsertTime);
|
||||||
|
this.Controls.Add(this.label2);
|
||||||
|
this.Controls.Add(this.label1);
|
||||||
|
this.Controls.Add(this.buttonInsertTest);
|
||||||
|
this.Name = "FormTests";
|
||||||
|
this.Text = "Тесты запросов к бд";
|
||||||
|
((System.ComponentModel.ISupportInitialize)(this.numericUpDownInsert)).EndInit();
|
||||||
|
((System.ComponentModel.ISupportInitialize)(this.numericUpDownRead)).EndInit();
|
||||||
|
((System.ComponentModel.ISupportInitialize)(this.numericUpDownJoin)).EndInit();
|
||||||
|
this.ResumeLayout(false);
|
||||||
|
this.PerformLayout();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private Button buttonInsertTest;
|
||||||
|
private Label label1;
|
||||||
|
private Label label2;
|
||||||
|
private TextBox textBoxInsertTime;
|
||||||
|
private Button buttonReadTest;
|
||||||
|
private TextBox textBoxReadTime;
|
||||||
|
private Label label3;
|
||||||
|
private Label label4;
|
||||||
|
private NumericUpDown numericUpDownInsert;
|
||||||
|
private NumericUpDown numericUpDownRead;
|
||||||
|
private Button buttonJoinQuery;
|
||||||
|
private NumericUpDown numericUpDownJoin;
|
||||||
|
private TextBox textBoxJoin;
|
||||||
|
private Label label5;
|
||||||
|
private Label label6;
|
||||||
|
}
|
||||||
|
}
|
77
BulletinBoard/BulletinBoard/FormTests.cs
Normal file
77
BulletinBoard/BulletinBoard/FormTests.cs
Normal file
@ -0,0 +1,77 @@
|
|||||||
|
using BulletinBoardContracts.BusinessLogicContracts;
|
||||||
|
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 BulletinBoard
|
||||||
|
{
|
||||||
|
public partial class FormTests : Form
|
||||||
|
{
|
||||||
|
private readonly IAnnouncementLogic _annocementLogic;
|
||||||
|
private readonly IUserLogic _userLogic;
|
||||||
|
private readonly ICategoryLogic _categoryLogic;
|
||||||
|
|
||||||
|
public FormTests(IAnnouncementLogic annocementLogic,
|
||||||
|
IUserLogic userLogic,
|
||||||
|
ICategoryLogic categoryLogic)
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
|
||||||
|
_annocementLogic = annocementLogic;
|
||||||
|
_userLogic = userLogic;
|
||||||
|
_categoryLogic = categoryLogic;
|
||||||
|
numericUpDownInsert.Minimum = 0;
|
||||||
|
numericUpDownInsert.Maximum = 1000000;
|
||||||
|
numericUpDownRead.Minimum = 0;
|
||||||
|
numericUpDownRead.Maximum = 1000000;
|
||||||
|
numericUpDownJoin.Minimum = 0;
|
||||||
|
numericUpDownJoin.Maximum = 1000000;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void buttonInsertTest_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var result = _annocementLogic.TestInsertList(Convert.ToInt32(numericUpDownInsert.Value));
|
||||||
|
|
||||||
|
textBoxInsertTime.Text = result;
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void buttonReadTest_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var result = _annocementLogic.TestReadList(Convert.ToInt32(numericUpDownInsert.Value));
|
||||||
|
textBoxReadTime.Text = result;
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void buttonJoinQuery_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var result = _annocementLogic.TestJoinReadList(Convert.ToInt32(numericUpDownJoin.Value));
|
||||||
|
textBoxJoin.Text = result;
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
112
BulletinBoard/BulletinBoard/FormUsers.Designer.cs
generated
Normal file
112
BulletinBoard/BulletinBoard/FormUsers.Designer.cs
generated
Normal file
@ -0,0 +1,112 @@
|
|||||||
|
namespace BulletinBoard
|
||||||
|
{
|
||||||
|
partial class FormUsers
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Required designer variable.
|
||||||
|
/// </summary>
|
||||||
|
private System.ComponentModel.IContainer components = null;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Clean up any resources being used.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||||
|
protected override void Dispose(bool disposing)
|
||||||
|
{
|
||||||
|
if (disposing && (components != null))
|
||||||
|
{
|
||||||
|
components.Dispose();
|
||||||
|
}
|
||||||
|
base.Dispose(disposing);
|
||||||
|
}
|
||||||
|
|
||||||
|
#region Windows Form Designer generated code
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Required method for Designer support - do not modify
|
||||||
|
/// the contents of this method with the code editor.
|
||||||
|
/// </summary>
|
||||||
|
private void InitializeComponent()
|
||||||
|
{
|
||||||
|
dataGridView = new DataGridView();
|
||||||
|
buttonAdd = new Button();
|
||||||
|
buttonChange = new Button();
|
||||||
|
buttonDelete = new Button();
|
||||||
|
buttonUpdate = new Button();
|
||||||
|
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
|
||||||
|
SuspendLayout();
|
||||||
|
//
|
||||||
|
// dataGridView
|
||||||
|
//
|
||||||
|
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||||
|
dataGridView.Location = new Point(12, 12);
|
||||||
|
dataGridView.Name = "dataGridView";
|
||||||
|
dataGridView.Size = new Size(534, 398);
|
||||||
|
dataGridView.TabIndex = 0;
|
||||||
|
//
|
||||||
|
// buttonAdd
|
||||||
|
//
|
||||||
|
buttonAdd.Location = new Point(552, 12);
|
||||||
|
buttonAdd.Name = "buttonAdd";
|
||||||
|
buttonAdd.Size = new Size(88, 49);
|
||||||
|
buttonAdd.TabIndex = 1;
|
||||||
|
buttonAdd.Text = "Создать";
|
||||||
|
buttonAdd.UseVisualStyleBackColor = true;
|
||||||
|
buttonAdd.Click += buttonAdd_Click;
|
||||||
|
//
|
||||||
|
// buttonChange
|
||||||
|
//
|
||||||
|
buttonChange.Location = new Point(552, 72);
|
||||||
|
buttonChange.Name = "buttonChange";
|
||||||
|
buttonChange.Size = new Size(88, 46);
|
||||||
|
buttonChange.TabIndex = 2;
|
||||||
|
buttonChange.Text = "Изменить";
|
||||||
|
buttonChange.UseVisualStyleBackColor = true;
|
||||||
|
buttonChange.Click += buttonChange_Click;
|
||||||
|
//
|
||||||
|
// buttonDelete
|
||||||
|
//
|
||||||
|
buttonDelete.Location = new Point(552, 128);
|
||||||
|
buttonDelete.Name = "buttonDelete";
|
||||||
|
buttonDelete.Size = new Size(88, 41);
|
||||||
|
buttonDelete.TabIndex = 3;
|
||||||
|
buttonDelete.Text = "Удалить";
|
||||||
|
buttonDelete.UseVisualStyleBackColor = true;
|
||||||
|
buttonDelete.Click += buttonDelete_Click;
|
||||||
|
//
|
||||||
|
// buttonUpdate
|
||||||
|
//
|
||||||
|
buttonUpdate.Location = new Point(552, 179);
|
||||||
|
buttonUpdate.Name = "buttonUpdate";
|
||||||
|
buttonUpdate.Size = new Size(88, 44);
|
||||||
|
buttonUpdate.TabIndex = 4;
|
||||||
|
buttonUpdate.Text = "Обновить";
|
||||||
|
buttonUpdate.UseVisualStyleBackColor = true;
|
||||||
|
buttonUpdate.Click += buttonUpdate_Click;
|
||||||
|
//
|
||||||
|
// FormUsers
|
||||||
|
//
|
||||||
|
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||||
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
|
ClientSize = new Size(650, 426);
|
||||||
|
Controls.Add(buttonUpdate);
|
||||||
|
Controls.Add(buttonDelete);
|
||||||
|
Controls.Add(buttonChange);
|
||||||
|
Controls.Add(buttonAdd);
|
||||||
|
Controls.Add(dataGridView);
|
||||||
|
Name = "FormUsers";
|
||||||
|
Text = "Список пользователей";
|
||||||
|
Load += FormUsers_Load;
|
||||||
|
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
|
||||||
|
ResumeLayout(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private DataGridView dataGridView;
|
||||||
|
private Button buttonAdd;
|
||||||
|
private Button buttonChange;
|
||||||
|
private Button buttonDelete;
|
||||||
|
private Button buttonUpdate;
|
||||||
|
}
|
||||||
|
}
|
111
BulletinBoard/BulletinBoard/FormUsers.cs
Normal file
111
BulletinBoard/BulletinBoard/FormUsers.cs
Normal file
@ -0,0 +1,111 @@
|
|||||||
|
using BulletinBoardContracts.BindingModels;
|
||||||
|
using BulletinBoardContracts.BusinessLogicContracts;
|
||||||
|
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 BulletinBoard
|
||||||
|
{
|
||||||
|
public partial class FormUsers : Form
|
||||||
|
{
|
||||||
|
private readonly IUserLogic _userLogic;
|
||||||
|
|
||||||
|
public FormUsers(IUserLogic userLogic)
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
|
||||||
|
_userLogic = userLogic;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void LoadData()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var list = _userLogic.ReadList(null);
|
||||||
|
|
||||||
|
if (list != null)
|
||||||
|
{
|
||||||
|
dataGridView.DataSource = list;
|
||||||
|
dataGridView.Columns["Id"].Visible = false;
|
||||||
|
dataGridView.Columns["ObjectId"].Visible = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex) { }
|
||||||
|
}
|
||||||
|
|
||||||
|
private void FormUsers_Load(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
LoadData();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void buttonAdd_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
var service = Program.ServiceProvider?.GetService(typeof(FormCreateUser));
|
||||||
|
|
||||||
|
if (service is FormCreateUser form)
|
||||||
|
{
|
||||||
|
if (form.ShowDialog() == DialogResult.OK)
|
||||||
|
{
|
||||||
|
LoadData();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void buttonChange_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (dataGridView.SelectedRows.Count == 1)
|
||||||
|
{
|
||||||
|
var service = Program.ServiceProvider?.GetService(typeof(FormCreateUser));
|
||||||
|
|
||||||
|
if (service is FormCreateUser form)
|
||||||
|
{
|
||||||
|
form.Id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||||
|
form.ObjectId = dataGridView.SelectedRows[0].Cells["ObjectId"].Value.ToString() ?? string.Empty;
|
||||||
|
|
||||||
|
if (form.ShowDialog() == DialogResult.OK)
|
||||||
|
{
|
||||||
|
LoadData();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void buttonDelete_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (dataGridView.SelectedRows.Count == 1)
|
||||||
|
{
|
||||||
|
if (MessageBox.Show("Удалить запись?", "Вопрос", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
|
||||||
|
{
|
||||||
|
int? id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||||
|
string? objectId = dataGridView.SelectedRows[0].Cells["ObjectId"].Value.ToString();
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (Program.CURRENT_DATABASE.Equals("PostgreSQL")
|
||||||
|
&& !_userLogic.Delete(new UserBindingModel { Id = id ?? 0 })
|
||||||
|
|| !_userLogic.Delete(new UserBindingModel { ObjectId = objectId ?? string.Empty }))
|
||||||
|
{
|
||||||
|
throw new Exception("Ошибка при удалении.");
|
||||||
|
}
|
||||||
|
|
||||||
|
LoadData();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void buttonUpdate_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
LoadData();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
448
BulletinBoard/BulletinBoard/MainForm.Designer.cs
generated
448
BulletinBoard/BulletinBoard/MainForm.Designer.cs
generated
@ -1,448 +0,0 @@
|
|||||||
namespace WebsiteForPlacingAds
|
|
||||||
{
|
|
||||||
partial class MainForm
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Required designer variable.
|
|
||||||
/// </summary>
|
|
||||||
private System.ComponentModel.IContainer components = null;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Clean up any resources being used.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
|
||||||
protected override void Dispose(bool disposing)
|
|
||||||
{
|
|
||||||
if (disposing && (components != null))
|
|
||||||
{
|
|
||||||
components.Dispose();
|
|
||||||
}
|
|
||||||
base.Dispose(disposing);
|
|
||||||
}
|
|
||||||
|
|
||||||
#region Windows Form Designer generated code
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Required method for Designer support - do not modify
|
|
||||||
/// the contents of this method with the code editor.
|
|
||||||
/// </summary>
|
|
||||||
private void InitializeComponent()
|
|
||||||
{
|
|
||||||
menuStrip1 = new MenuStrip();
|
|
||||||
клиентыToolStripMenuItem = new ToolStripMenuItem();
|
|
||||||
создатьКлиентаToolStripMenuItem = new ToolStripMenuItem();
|
|
||||||
удалитьКлиентаToolStripMenuItem = new ToolStripMenuItem();
|
|
||||||
изменитьДанныеКлиентаToolStripMenuItem = new ToolStripMenuItem();
|
|
||||||
списокКлиентвToolStripMenuItem = new ToolStripMenuItem();
|
|
||||||
объявленияToolStripMenuItem = new ToolStripMenuItem();
|
|
||||||
создатьОбъявлениеToolStripMenuItem = new ToolStripMenuItem();
|
|
||||||
удалитьОбъявлениеToolStripMenuItem = new ToolStripMenuItem();
|
|
||||||
изменитьОбъявлениеэToolStripMenuItem = new ToolStripMenuItem();
|
|
||||||
списокОбъявленийToolStripMenuItem = new ToolStripMenuItem();
|
|
||||||
категорииToolStripMenuItem = new ToolStripMenuItem();
|
|
||||||
создатьКатегориюToolStripMenuItem = new ToolStripMenuItem();
|
|
||||||
удалитьКатегориюToolStripMenuItem = new ToolStripMenuItem();
|
|
||||||
изменитьКатегориюToolStripMenuItem = new ToolStripMenuItem();
|
|
||||||
списокКатегорийToolStripMenuItem = new ToolStripMenuItem();
|
|
||||||
подкатегорииToolStripMenuItem = new ToolStripMenuItem();
|
|
||||||
создатьПодкатеориюToolStripMenuItem = new ToolStripMenuItem();
|
|
||||||
удалитьПодкатегориюToolStripMenuItem = new ToolStripMenuItem();
|
|
||||||
изменитьПодкатегориюToolStripMenuItem = new ToolStripMenuItem();
|
|
||||||
списокПодкатегоийToolStripMenuItem = new ToolStripMenuItem();
|
|
||||||
toolStripMenuItem1 = new ToolStripMenuItem();
|
|
||||||
toolStripMenuItem2 = new ToolStripMenuItem();
|
|
||||||
toolStripMenuItem3 = new ToolStripMenuItem();
|
|
||||||
toolStripMenuItem4 = new ToolStripMenuItem();
|
|
||||||
toolStripMenuItem5 = new ToolStripMenuItem();
|
|
||||||
label1 = new Label();
|
|
||||||
button1 = new Button();
|
|
||||||
panel1 = new Panel();
|
|
||||||
panel2 = new Panel();
|
|
||||||
button2 = new Button();
|
|
||||||
label2 = new Label();
|
|
||||||
panel3 = new Panel();
|
|
||||||
button3 = new Button();
|
|
||||||
label3 = new Label();
|
|
||||||
toolStripMenuItem6 = new ToolStripMenuItem();
|
|
||||||
toolStripMenuItem7 = new ToolStripMenuItem();
|
|
||||||
toolStripMenuItem8 = new ToolStripMenuItem();
|
|
||||||
toolStripMenuItem9 = new ToolStripMenuItem();
|
|
||||||
toolStripMenuItem10 = new ToolStripMenuItem();
|
|
||||||
menuStrip1.SuspendLayout();
|
|
||||||
panel1.SuspendLayout();
|
|
||||||
panel2.SuspendLayout();
|
|
||||||
panel3.SuspendLayout();
|
|
||||||
SuspendLayout();
|
|
||||||
//
|
|
||||||
// menuStrip1
|
|
||||||
//
|
|
||||||
menuStrip1.ImageScalingSize = new Size(20, 20);
|
|
||||||
menuStrip1.Items.AddRange(new ToolStripItem[] { клиентыToolStripMenuItem, объявленияToolStripMenuItem, категорииToolStripMenuItem, подкатегорииToolStripMenuItem, toolStripMenuItem1, toolStripMenuItem6 });
|
|
||||||
menuStrip1.Location = new Point(0, 0);
|
|
||||||
menuStrip1.Name = "menuStrip1";
|
|
||||||
menuStrip1.Padding = new Padding(5, 2, 0, 2);
|
|
||||||
menuStrip1.Size = new Size(700, 24);
|
|
||||||
menuStrip1.TabIndex = 0;
|
|
||||||
menuStrip1.Text = "menuStrip1";
|
|
||||||
//
|
|
||||||
// клиентыToolStripMenuItem
|
|
||||||
//
|
|
||||||
клиентыToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { создатьКлиентаToolStripMenuItem, удалитьКлиентаToolStripMenuItem, изменитьДанныеКлиентаToolStripMenuItem, списокКлиентвToolStripMenuItem });
|
|
||||||
клиентыToolStripMenuItem.Name = "клиентыToolStripMenuItem";
|
|
||||||
клиентыToolStripMenuItem.Size = new Size(67, 20);
|
|
||||||
клиентыToolStripMenuItem.Text = "Клиенты";
|
|
||||||
//
|
|
||||||
// создатьКлиентаToolStripMenuItem
|
|
||||||
//
|
|
||||||
создатьКлиентаToolStripMenuItem.Name = "создатьКлиентаToolStripMenuItem";
|
|
||||||
создатьКлиентаToolStripMenuItem.Size = new Size(219, 22);
|
|
||||||
создатьКлиентаToolStripMenuItem.Text = "Создать клиента";
|
|
||||||
создатьКлиентаToolStripMenuItem.Click += создатьКлиентаToolStripMenuItem_Click;
|
|
||||||
//
|
|
||||||
// удалитьКлиентаToolStripMenuItem
|
|
||||||
//
|
|
||||||
удалитьКлиентаToolStripMenuItem.Name = "удалитьКлиентаToolStripMenuItem";
|
|
||||||
удалитьКлиентаToolStripMenuItem.Size = new Size(219, 22);
|
|
||||||
удалитьКлиентаToolStripMenuItem.Text = "Удалить клиента";
|
|
||||||
удалитьКлиентаToolStripMenuItem.Click += удалитьКлиентаToolStripMenuItem_Click;
|
|
||||||
//
|
|
||||||
// изменитьДанныеКлиентаToolStripMenuItem
|
|
||||||
//
|
|
||||||
изменитьДанныеКлиентаToolStripMenuItem.Name = "изменитьДанныеКлиентаToolStripMenuItem";
|
|
||||||
изменитьДанныеКлиентаToolStripMenuItem.Size = new Size(219, 22);
|
|
||||||
изменитьДанныеКлиентаToolStripMenuItem.Text = "Изменить данные клиента";
|
|
||||||
изменитьДанныеКлиентаToolStripMenuItem.Click += изменитьДанныеКлиентаToolStripMenuItem_Click;
|
|
||||||
//
|
|
||||||
// списокКлиентвToolStripMenuItem
|
|
||||||
//
|
|
||||||
списокКлиентвToolStripMenuItem.Name = "списокКлиентвToolStripMenuItem";
|
|
||||||
списокКлиентвToolStripMenuItem.Size = new Size(219, 22);
|
|
||||||
списокКлиентвToolStripMenuItem.Text = "Список клиентов";
|
|
||||||
списокКлиентвToolStripMenuItem.Click += списокКлиентвToolStripMenuItem_Click;
|
|
||||||
//
|
|
||||||
// объявленияToolStripMenuItem
|
|
||||||
//
|
|
||||||
объявленияToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { создатьОбъявлениеToolStripMenuItem, удалитьОбъявлениеToolStripMenuItem, изменитьОбъявлениеэToolStripMenuItem, списокОбъявленийToolStripMenuItem });
|
|
||||||
объявленияToolStripMenuItem.Name = "объявленияToolStripMenuItem";
|
|
||||||
объявленияToolStripMenuItem.Size = new Size(87, 20);
|
|
||||||
объявленияToolStripMenuItem.Text = "Объявления";
|
|
||||||
//
|
|
||||||
// создатьОбъявлениеToolStripMenuItem
|
|
||||||
//
|
|
||||||
создатьОбъявлениеToolStripMenuItem.Name = "создатьОбъявлениеToolStripMenuItem";
|
|
||||||
создатьОбъявлениеToolStripMenuItem.Size = new Size(197, 22);
|
|
||||||
создатьОбъявлениеToolStripMenuItem.Text = "Создать объявление";
|
|
||||||
создатьОбъявлениеToolStripMenuItem.Click += создатьОбъявлениеToolStripMenuItem_Click;
|
|
||||||
//
|
|
||||||
// удалитьОбъявлениеToolStripMenuItem
|
|
||||||
//
|
|
||||||
удалитьОбъявлениеToolStripMenuItem.Name = "удалитьОбъявлениеToolStripMenuItem";
|
|
||||||
удалитьОбъявлениеToolStripMenuItem.Size = new Size(197, 22);
|
|
||||||
удалитьОбъявлениеToolStripMenuItem.Text = "Удалить объявление";
|
|
||||||
удалитьОбъявлениеToolStripMenuItem.Click += удалитьОбъявлениеToolStripMenuItem_Click;
|
|
||||||
//
|
|
||||||
// изменитьОбъявлениеэToolStripMenuItem
|
|
||||||
//
|
|
||||||
изменитьОбъявлениеэToolStripMenuItem.Name = "изменитьОбъявлениеэToolStripMenuItem";
|
|
||||||
изменитьОбъявлениеэToolStripMenuItem.Size = new Size(197, 22);
|
|
||||||
изменитьОбъявлениеэToolStripMenuItem.Text = "Изменить объявление";
|
|
||||||
изменитьОбъявлениеэToolStripMenuItem.Click += изменитьОбъявлениеэToolStripMenuItem_Click;
|
|
||||||
//
|
|
||||||
// списокОбъявленийToolStripMenuItem
|
|
||||||
//
|
|
||||||
списокОбъявленийToolStripMenuItem.Name = "списокОбъявленийToolStripMenuItem";
|
|
||||||
списокОбъявленийToolStripMenuItem.Size = new Size(197, 22);
|
|
||||||
списокОбъявленийToolStripMenuItem.Text = "Список объявлений";
|
|
||||||
списокОбъявленийToolStripMenuItem.Click += списокОбъявленийToolStripMenuItem_Click;
|
|
||||||
//
|
|
||||||
// категорииToolStripMenuItem
|
|
||||||
//
|
|
||||||
категорииToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { создатьКатегориюToolStripMenuItem, удалитьКатегориюToolStripMenuItem, изменитьКатегориюToolStripMenuItem, списокКатегорийToolStripMenuItem });
|
|
||||||
категорииToolStripMenuItem.Name = "категорииToolStripMenuItem";
|
|
||||||
категорииToolStripMenuItem.Size = new Size(76, 20);
|
|
||||||
категорииToolStripMenuItem.Text = "Категории";
|
|
||||||
//
|
|
||||||
// создатьКатегориюToolStripMenuItem
|
|
||||||
//
|
|
||||||
создатьКатегориюToolStripMenuItem.Name = "создатьКатегориюToolStripMenuItem";
|
|
||||||
создатьКатегориюToolStripMenuItem.Size = new Size(190, 22);
|
|
||||||
создатьКатегориюToolStripMenuItem.Text = "Создать категорию";
|
|
||||||
создатьКатегориюToolStripMenuItem.Click += создатьКатегориюToolStripMenuItem_Click;
|
|
||||||
//
|
|
||||||
// удалитьКатегориюToolStripMenuItem
|
|
||||||
//
|
|
||||||
удалитьКатегориюToolStripMenuItem.Name = "удалитьКатегориюToolStripMenuItem";
|
|
||||||
удалитьКатегориюToolStripMenuItem.Size = new Size(190, 22);
|
|
||||||
удалитьКатегориюToolStripMenuItem.Text = "Удалить категорию";
|
|
||||||
удалитьКатегориюToolStripMenuItem.Click += удалитьКатегориюToolStripMenuItem_Click;
|
|
||||||
//
|
|
||||||
// изменитьКатегориюToolStripMenuItem
|
|
||||||
//
|
|
||||||
изменитьКатегориюToolStripMenuItem.Name = "изменитьКатегориюToolStripMenuItem";
|
|
||||||
изменитьКатегориюToolStripMenuItem.Size = new Size(190, 22);
|
|
||||||
изменитьКатегориюToolStripMenuItem.Text = "Изменить категорию";
|
|
||||||
изменитьКатегориюToolStripMenuItem.Click += изменитьКатегориюToolStripMenuItem_Click;
|
|
||||||
//
|
|
||||||
// списокКатегорийToolStripMenuItem
|
|
||||||
//
|
|
||||||
списокКатегорийToolStripMenuItem.Name = "списокКатегорийToolStripMenuItem";
|
|
||||||
списокКатегорийToolStripMenuItem.Size = new Size(190, 22);
|
|
||||||
списокКатегорийToolStripMenuItem.Text = "Список категорий";
|
|
||||||
списокКатегорийToolStripMenuItem.Click += списокКатегорийToolStripMenuItem_Click;
|
|
||||||
//
|
|
||||||
// подкатегорииToolStripMenuItem
|
|
||||||
//
|
|
||||||
подкатегорииToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { создатьПодкатеориюToolStripMenuItem, удалитьПодкатегориюToolStripMenuItem, изменитьПодкатегориюToolStripMenuItem, списокПодкатегоийToolStripMenuItem });
|
|
||||||
подкатегорииToolStripMenuItem.Name = "подкатегорииToolStripMenuItem";
|
|
||||||
подкатегорииToolStripMenuItem.Size = new Size(97, 20);
|
|
||||||
подкатегорииToolStripMenuItem.Text = "Подкатегории";
|
|
||||||
//
|
|
||||||
// создатьПодкатеориюToolStripMenuItem
|
|
||||||
//
|
|
||||||
создатьПодкатеориюToolStripMenuItem.Name = "создатьПодкатеориюToolStripMenuItem";
|
|
||||||
создатьПодкатеориюToolStripMenuItem.Size = new Size(210, 22);
|
|
||||||
создатьПодкатеориюToolStripMenuItem.Text = "Создать подкатегорию";
|
|
||||||
создатьПодкатеориюToolStripMenuItem.Click += создатьПодкатеориюToolStripMenuItem_Click;
|
|
||||||
//
|
|
||||||
// удалитьПодкатегориюToolStripMenuItem
|
|
||||||
//
|
|
||||||
удалитьПодкатегориюToolStripMenuItem.Name = "удалитьПодкатегориюToolStripMenuItem";
|
|
||||||
удалитьПодкатегориюToolStripMenuItem.Size = new Size(210, 22);
|
|
||||||
удалитьПодкатегориюToolStripMenuItem.Text = "Удалить подкатегорию";
|
|
||||||
удалитьПодкатегориюToolStripMenuItem.Click += удалитьПодкатегориюToolStripMenuItem_Click;
|
|
||||||
//
|
|
||||||
// изменитьПодкатегориюToolStripMenuItem
|
|
||||||
//
|
|
||||||
изменитьПодкатегориюToolStripMenuItem.Name = "изменитьПодкатегориюToolStripMenuItem";
|
|
||||||
изменитьПодкатегориюToolStripMenuItem.Size = new Size(210, 22);
|
|
||||||
изменитьПодкатегориюToolStripMenuItem.Text = "Изменить подкатегорию";
|
|
||||||
изменитьПодкатегориюToolStripMenuItem.Click += изменитьПодкатегориюToolStripMenuItem_Click;
|
|
||||||
//
|
|
||||||
// списокПодкатегоийToolStripMenuItem
|
|
||||||
//
|
|
||||||
списокПодкатегоийToolStripMenuItem.Name = "списокПодкатегоийToolStripMenuItem";
|
|
||||||
списокПодкатегоийToolStripMenuItem.Size = new Size(210, 22);
|
|
||||||
списокПодкатегоийToolStripMenuItem.Text = "Список подкатегорий";
|
|
||||||
списокПодкатегоийToolStripMenuItem.Click += списокПодкатегоийToolStripMenuItem_Click;
|
|
||||||
//
|
|
||||||
// toolStripMenuItem1
|
|
||||||
//
|
|
||||||
toolStripMenuItem1.DropDownItems.AddRange(new ToolStripItem[] { toolStripMenuItem2, toolStripMenuItem3, toolStripMenuItem4, toolStripMenuItem5 });
|
|
||||||
toolStripMenuItem1.Name = "toolStripMenuItem1";
|
|
||||||
toolStripMenuItem1.Size = new Size(67, 20);
|
|
||||||
toolStripMenuItem1.Text = "Регионы";
|
|
||||||
//
|
|
||||||
// toolStripMenuItem2
|
|
||||||
//
|
|
||||||
toolStripMenuItem2.Name = "toolStripMenuItem2";
|
|
||||||
toolStripMenuItem2.Size = new Size(180, 22);
|
|
||||||
toolStripMenuItem2.Text = "Создать регион";
|
|
||||||
toolStripMenuItem2.Click += создатьРегионToolStripMenuItem_Click;
|
|
||||||
//
|
|
||||||
// toolStripMenuItem3
|
|
||||||
//
|
|
||||||
toolStripMenuItem3.Name = "toolStripMenuItem3";
|
|
||||||
toolStripMenuItem3.Size = new Size(180, 22);
|
|
||||||
toolStripMenuItem3.Text = "Удалить регион";
|
|
||||||
toolStripMenuItem3.Click += удалитьРегионToolStripMenuItem_Click;
|
|
||||||
//
|
|
||||||
// toolStripMenuItem4
|
|
||||||
//
|
|
||||||
toolStripMenuItem4.Name = "toolStripMenuItem4";
|
|
||||||
toolStripMenuItem4.Size = new Size(180, 22);
|
|
||||||
toolStripMenuItem4.Text = "Изменить регион";
|
|
||||||
toolStripMenuItem4.Click += изменитьРегионToolStripMenuItem_Click;
|
|
||||||
//
|
|
||||||
// toolStripMenuItem5
|
|
||||||
//
|
|
||||||
toolStripMenuItem5.Name = "toolStripMenuItem5";
|
|
||||||
toolStripMenuItem5.Size = new Size(180, 22);
|
|
||||||
toolStripMenuItem5.Text = "Список регион";
|
|
||||||
toolStripMenuItem5.Click += списокРегионToolStripMenuItem_Click;
|
|
||||||
//
|
|
||||||
// label1
|
|
||||||
//
|
|
||||||
label1.AutoSize = true;
|
|
||||||
label1.Location = new Point(3, 11);
|
|
||||||
label1.Name = "label1";
|
|
||||||
label1.Size = new Size(225, 15);
|
|
||||||
label1.TabIndex = 1;
|
|
||||||
label1.Text = "Сценарий 1: Добавление 1000 клиентов";
|
|
||||||
//
|
|
||||||
// button1
|
|
||||||
//
|
|
||||||
button1.Location = new Point(63, 66);
|
|
||||||
button1.Name = "button1";
|
|
||||||
button1.Size = new Size(95, 33);
|
|
||||||
button1.TabIndex = 2;
|
|
||||||
button1.Text = "Старт";
|
|
||||||
button1.UseVisualStyleBackColor = true;
|
|
||||||
button1.Click += button1_Click;
|
|
||||||
//
|
|
||||||
// panel1
|
|
||||||
//
|
|
||||||
panel1.Controls.Add(button1);
|
|
||||||
panel1.Controls.Add(label1);
|
|
||||||
panel1.Location = new Point(12, 83);
|
|
||||||
panel1.Name = "panel1";
|
|
||||||
panel1.Size = new Size(222, 102);
|
|
||||||
panel1.TabIndex = 3;
|
|
||||||
//
|
|
||||||
// panel2
|
|
||||||
//
|
|
||||||
panel2.Controls.Add(button2);
|
|
||||||
panel2.Controls.Add(label2);
|
|
||||||
panel2.Location = new Point(240, 83);
|
|
||||||
panel2.Name = "panel2";
|
|
||||||
panel2.Size = new Size(222, 102);
|
|
||||||
panel2.TabIndex = 4;
|
|
||||||
//
|
|
||||||
// button2
|
|
||||||
//
|
|
||||||
button2.Location = new Point(63, 66);
|
|
||||||
button2.Name = "button2";
|
|
||||||
button2.Size = new Size(95, 33);
|
|
||||||
button2.TabIndex = 2;
|
|
||||||
button2.Text = "Старт";
|
|
||||||
button2.UseVisualStyleBackColor = true;
|
|
||||||
button2.Click += button2_Click;
|
|
||||||
//
|
|
||||||
// label2
|
|
||||||
//
|
|
||||||
label2.AutoSize = true;
|
|
||||||
label2.Location = new Point(3, 11);
|
|
||||||
label2.Name = "label2";
|
|
||||||
label2.Size = new Size(210, 15);
|
|
||||||
label2.TabIndex = 1;
|
|
||||||
label2.Text = "Сценарий 2: Удаление 1000 клиентов";
|
|
||||||
//
|
|
||||||
// panel3
|
|
||||||
//
|
|
||||||
panel3.Controls.Add(button3);
|
|
||||||
panel3.Controls.Add(label3);
|
|
||||||
panel3.Location = new Point(468, 83);
|
|
||||||
panel3.Name = "panel3";
|
|
||||||
panel3.Size = new Size(222, 102);
|
|
||||||
panel3.TabIndex = 5;
|
|
||||||
//
|
|
||||||
// button3
|
|
||||||
//
|
|
||||||
button3.Location = new Point(63, 66);
|
|
||||||
button3.Name = "button3";
|
|
||||||
button3.Size = new Size(95, 33);
|
|
||||||
button3.TabIndex = 2;
|
|
||||||
button3.Text = "Старт";
|
|
||||||
button3.UseVisualStyleBackColor = true;
|
|
||||||
button3.Click += button3_Click;
|
|
||||||
//
|
|
||||||
// label3
|
|
||||||
//
|
|
||||||
label3.Location = new Point(7, 11);
|
|
||||||
label3.Name = "label3";
|
|
||||||
label3.Size = new Size(213, 44);
|
|
||||||
label3.TabIndex = 1;
|
|
||||||
label3.Text = "Сценарий 3: Изменение фамилий 1000 клиентов на \"surname2\"";
|
|
||||||
//
|
|
||||||
// toolStripMenuItem6
|
|
||||||
//
|
|
||||||
toolStripMenuItem6.DropDownItems.AddRange(new ToolStripItem[] { toolStripMenuItem7, toolStripMenuItem8, toolStripMenuItem9, toolStripMenuItem10 });
|
|
||||||
toolStripMenuItem6.Name = "toolStripMenuItem6";
|
|
||||||
toolStripMenuItem6.Size = new Size(58, 20);
|
|
||||||
toolStripMenuItem6.Text = "Города";
|
|
||||||
//
|
|
||||||
// toolStripMenuItem7
|
|
||||||
//
|
|
||||||
toolStripMenuItem7.Name = "toolStripMenuItem7";
|
|
||||||
toolStripMenuItem7.Size = new Size(180, 22);
|
|
||||||
toolStripMenuItem7.Text = "Создать город";
|
|
||||||
toolStripMenuItem7.Click += создатьГородToolStripMenuItem_Click;
|
|
||||||
//
|
|
||||||
// toolStripMenuItem8
|
|
||||||
//
|
|
||||||
toolStripMenuItem8.Name = "toolStripMenuItem8";
|
|
||||||
toolStripMenuItem8.Size = new Size(180, 22);
|
|
||||||
toolStripMenuItem8.Text = "Удалить город";
|
|
||||||
toolStripMenuItem8.Click += удалитьГородToolStripMenuItem_Click;
|
|
||||||
//
|
|
||||||
// toolStripMenuItem9
|
|
||||||
//
|
|
||||||
toolStripMenuItem9.Name = "toolStripMenuItem9";
|
|
||||||
toolStripMenuItem9.Size = new Size(180, 22);
|
|
||||||
toolStripMenuItem9.Text = "Изменить город";
|
|
||||||
toolStripMenuItem9.Click += изменитьГородToolStripMenuItem_Click;
|
|
||||||
//
|
|
||||||
// toolStripMenuItem10
|
|
||||||
//
|
|
||||||
toolStripMenuItem10.Name = "toolStripMenuItem10";
|
|
||||||
toolStripMenuItem10.Size = new Size(180, 22);
|
|
||||||
toolStripMenuItem10.Text = "Список город";
|
|
||||||
toolStripMenuItem10.Click += списокГородToolStripMenuItem_Click;
|
|
||||||
//
|
|
||||||
// MainForm
|
|
||||||
//
|
|
||||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
|
||||||
AutoScaleMode = AutoScaleMode.Font;
|
|
||||||
ClientSize = new Size(700, 338);
|
|
||||||
Controls.Add(panel3);
|
|
||||||
Controls.Add(panel2);
|
|
||||||
Controls.Add(panel1);
|
|
||||||
Controls.Add(menuStrip1);
|
|
||||||
MainMenuStrip = menuStrip1;
|
|
||||||
Margin = new Padding(3, 2, 3, 2);
|
|
||||||
Name = "MainForm";
|
|
||||||
Text = "MainForm";
|
|
||||||
menuStrip1.ResumeLayout(false);
|
|
||||||
menuStrip1.PerformLayout();
|
|
||||||
panel1.ResumeLayout(false);
|
|
||||||
panel1.PerformLayout();
|
|
||||||
panel2.ResumeLayout(false);
|
|
||||||
panel2.PerformLayout();
|
|
||||||
panel3.ResumeLayout(false);
|
|
||||||
ResumeLayout(false);
|
|
||||||
PerformLayout();
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
private MenuStrip menuStrip1;
|
|
||||||
private ToolStripMenuItem клиентыToolStripMenuItem;
|
|
||||||
private ToolStripMenuItem создатьКлиентаToolStripMenuItem;
|
|
||||||
private ToolStripMenuItem удалитьКлиентаToolStripMenuItem;
|
|
||||||
private ToolStripMenuItem изменитьДанныеКлиентаToolStripMenuItem;
|
|
||||||
private ToolStripMenuItem списокКлиентвToolStripMenuItem;
|
|
||||||
private ToolStripMenuItem объявленияToolStripMenuItem;
|
|
||||||
private ToolStripMenuItem создатьОбъявлениеToolStripMenuItem;
|
|
||||||
private ToolStripMenuItem категорииToolStripMenuItem;
|
|
||||||
private ToolStripMenuItem подкатегорииToolStripMenuItem;
|
|
||||||
private ToolStripMenuItem удалитьОбъявлениеToolStripMenuItem;
|
|
||||||
private ToolStripMenuItem изменитьОбъявлениеэToolStripMenuItem;
|
|
||||||
private ToolStripMenuItem списокОбъявленийToolStripMenuItem;
|
|
||||||
private ToolStripMenuItem создатьКатегориюToolStripMenuItem;
|
|
||||||
private ToolStripMenuItem удалитьКатегориюToolStripMenuItem;
|
|
||||||
private ToolStripMenuItem изменитьКатегориюToolStripMenuItem;
|
|
||||||
private ToolStripMenuItem списокКатегорийToolStripMenuItem;
|
|
||||||
private ToolStripMenuItem создатьПодкатеориюToolStripMenuItem;
|
|
||||||
private ToolStripMenuItem удалитьПодкатегориюToolStripMenuItem;
|
|
||||||
private ToolStripMenuItem изменитьПодкатегориюToolStripMenuItem;
|
|
||||||
private ToolStripMenuItem списокПодкатегоийToolStripMenuItem;
|
|
||||||
private Label label1;
|
|
||||||
private Button button1;
|
|
||||||
private Panel panel1;
|
|
||||||
private Panel panel2;
|
|
||||||
private Button button2;
|
|
||||||
private Label label2;
|
|
||||||
private Panel panel3;
|
|
||||||
private Button button3;
|
|
||||||
private Label label3;
|
|
||||||
private ToolStripMenuItem toolStripMenuItem1;
|
|
||||||
private ToolStripMenuItem toolStripMenuItem2;
|
|
||||||
private ToolStripMenuItem toolStripMenuItem3;
|
|
||||||
private ToolStripMenuItem toolStripMenuItem4;
|
|
||||||
private ToolStripMenuItem toolStripMenuItem5;
|
|
||||||
private ToolStripMenuItem toolStripMenuItem6;
|
|
||||||
private ToolStripMenuItem toolStripMenuItem7;
|
|
||||||
private ToolStripMenuItem toolStripMenuItem8;
|
|
||||||
private ToolStripMenuItem toolStripMenuItem9;
|
|
||||||
private ToolStripMenuItem toolStripMenuItem10;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,205 +0,0 @@
|
|||||||
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 WebsiteForPlacingAds
|
|
||||||
{
|
|
||||||
public partial class MainForm : Form
|
|
||||||
{
|
|
||||||
AbstractManagmentDatabase managmentDatabase;
|
|
||||||
|
|
||||||
|
|
||||||
public MainForm()
|
|
||||||
{
|
|
||||||
InitializeComponent();
|
|
||||||
managmentDatabase = new ManagmentDatabase("Server=192.168.56.101;Port=5432;User Id=postgres;Password=postgres;Database=lab4;");
|
|
||||||
}
|
|
||||||
|
|
||||||
private void создатьКатегориюToolStripMenuItem_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
CreateCategoriesForm ccf = new CreateCategoriesForm(managmentDatabase);
|
|
||||||
ccf.Show();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void удалитьКатегориюToolStripMenuItem_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
DeleteCategoriesForm dcf = new DeleteCategoriesForm(managmentDatabase);
|
|
||||||
dcf.Show();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void изменитьКатегориюToolStripMenuItem_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
UpdateCategoriesForm ucf = new UpdateCategoriesForm(managmentDatabase);
|
|
||||||
ucf.Show();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void списокКатегорийToolStripMenuItem_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
ListCategoriesForm lcf = new ListCategoriesForm(managmentDatabase);
|
|
||||||
lcf.Show();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void создатьРегионToolStripMenuItem_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
CreateRegionsForm crf = new CreateRegionsForm(managmentDatabase);
|
|
||||||
crf.Show();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void удалитьРегионToolStripMenuItem_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
DeleteRegionsForm drf = new DeleteRegionsForm(managmentDatabase);
|
|
||||||
drf.Show();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void изменитьРегионToolStripMenuItem_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
UpdateRegionsForm urf = new UpdateRegionsForm(managmentDatabase);
|
|
||||||
urf.Show();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void списокРегионToolStripMenuItem_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
ListRegionsForm lrf = new ListRegionsForm(managmentDatabase);
|
|
||||||
lrf.Show();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void создатьГородToolStripMenuItem_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
CreateCitiesForm crf = new CreateCitiesForm(managmentDatabase);
|
|
||||||
crf.Show();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void удалитьГородToolStripMenuItem_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
DeleteCitiesForm drf = new DeleteCitiesForm(managmentDatabase);
|
|
||||||
drf.Show();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void изменитьГородToolStripMenuItem_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
UpdateCitiesForm urf = new UpdateCitiesForm(managmentDatabase);
|
|
||||||
urf.Show();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void списокГородToolStripMenuItem_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
ListCitiesForm lrf = new ListCitiesForm(managmentDatabase);
|
|
||||||
lrf.Show();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void создатьОбъявлениеToolStripMenuItem_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
CreateAdsForm caf = new CreateAdsForm(managmentDatabase);
|
|
||||||
caf.Show();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void удалитьОбъявлениеToolStripMenuItem_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
DeleteAdsForm uaf = new DeleteAdsForm(managmentDatabase);
|
|
||||||
uaf.Show();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void изменитьОбъявлениеэToolStripMenuItem_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
UpdateAdsForm daf = new UpdateAdsForm(managmentDatabase);
|
|
||||||
daf.Show();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void списокОбъявленийToolStripMenuItem_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
ListAdsForm laf = new ListAdsForm(managmentDatabase);
|
|
||||||
laf.Show();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void создатьКлиентаToolStripMenuItem_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
CreateClientsForm ccf = new CreateClientsForm(managmentDatabase);
|
|
||||||
ccf.Show();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void удалитьКлиентаToolStripMenuItem_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
DeleteClientsForm dcf = new DeleteClientsForm(managmentDatabase);
|
|
||||||
dcf.Show();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void изменитьДанныеКлиентаToolStripMenuItem_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
UpdateClientsForm ucf = new UpdateClientsForm(managmentDatabase);
|
|
||||||
ucf.Show();
|
|
||||||
}
|
|
||||||
private void списокКлиентвToolStripMenuItem_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
ListClientsForm lcf = new ListClientsForm(managmentDatabase);
|
|
||||||
lcf.Show();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void создатьПодкатеориюToolStripMenuItem_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
CreateSubcategoriesForm csf = new CreateSubcategoriesForm(managmentDatabase);
|
|
||||||
csf.Show();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void удалитьПодкатегориюToolStripMenuItem_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
DeleteSubcategoriesForm dsf = new DeleteSubcategoriesForm(managmentDatabase);
|
|
||||||
dsf.Show();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void изменитьПодкатегориюToolStripMenuItem_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
UpdateSubcategoriesForm usf = new UpdateSubcategoriesForm(managmentDatabase);
|
|
||||||
usf.Show();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void списокПодкатегоийToolStripMenuItem_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
ListSubcategoriesForm lsf = new ListSubcategoriesForm(managmentDatabase);
|
|
||||||
lsf.Show();
|
|
||||||
}
|
|
||||||
private void button1_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
DateTime start = DateTime.Now;
|
|
||||||
|
|
||||||
for (int i = 0; i < 1000; i++)
|
|
||||||
{
|
|
||||||
managmentDatabase.insertInto("clients", "'name'", "'surname'", "'patronymic'", "'email@mail.ru'", $"{89372511129}", "'20.01.2022'");
|
|
||||||
}
|
|
||||||
|
|
||||||
DateTime end = DateTime.Now;
|
|
||||||
TimeSpan duration = end - start;
|
|
||||||
MessageBox.Show($"Сценарий 1 завершен! Время выполнения: {duration.TotalMilliseconds} мс");
|
|
||||||
}
|
|
||||||
|
|
||||||
private void button2_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
DateTime start = DateTime.Now;
|
|
||||||
|
|
||||||
for (int i = 0; i < 1000; i++)
|
|
||||||
{
|
|
||||||
managmentDatabase.deleteEntry("clients", "name");
|
|
||||||
}
|
|
||||||
|
|
||||||
DateTime end = DateTime.Now;
|
|
||||||
TimeSpan duration = end - start;
|
|
||||||
MessageBox.Show($"Сценарий 2 завершен! Время выполнения: {duration.TotalMilliseconds} мс");
|
|
||||||
}
|
|
||||||
|
|
||||||
private void button3_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
DateTime start = DateTime.Now;
|
|
||||||
|
|
||||||
managmentDatabase.ExecuteNonQuery("Update clients Set surname = 'surname2' where surname = 'surname'");
|
|
||||||
|
|
||||||
DateTime end = DateTime.Now;
|
|
||||||
TimeSpan duration = end - start;
|
|
||||||
MessageBox.Show($"Сценарий 3 завершен! Время выполнения: {duration.TotalMilliseconds} мс");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,85 +0,0 @@
|
|||||||
using Npgsql;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Data;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace WebsiteForPlacingAds
|
|
||||||
{
|
|
||||||
public class ManagmentDatabase : AbstractManagmentDatabase
|
|
||||||
{
|
|
||||||
protected NpgsqlConnection connection;
|
|
||||||
|
|
||||||
public ManagmentDatabase(String connectionString)
|
|
||||||
{
|
|
||||||
connection = new NpgsqlConnection(connectionString);
|
|
||||||
}
|
|
||||||
|
|
||||||
public override Object getRowTableById(string tableName, string columnName, int id)
|
|
||||||
{
|
|
||||||
return ExecuteQuery($"SELECT {columnName} FROM {tableName} WHERE {tableName}_id = {id}").Rows[0][$"{columnName}"];
|
|
||||||
}
|
|
||||||
|
|
||||||
public override Object getRowTableById(DataTable table, string columnName, int i)
|
|
||||||
{
|
|
||||||
return table.Rows[i][columnName];
|
|
||||||
}
|
|
||||||
|
|
||||||
public override DataTable getEntryById(string tableName, int id)
|
|
||||||
{
|
|
||||||
return ExecuteQuery($"SELECT * FROM {tableName} WHERE {tableName}_id = {id}");
|
|
||||||
}
|
|
||||||
|
|
||||||
public override DataTable getAllEntry(string tableName)
|
|
||||||
{
|
|
||||||
return ExecuteQuery($"SELECT * FROM {tableName}");
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void insertInto(string tableName, params string[] values)
|
|
||||||
{
|
|
||||||
string query = $"INSERT INTO {tableName} VALUES (nextval('seq_{tableName.ToLower()}'), "; // seq_{tableName.}
|
|
||||||
for (int i = 0; i < values.Length; i++)
|
|
||||||
{
|
|
||||||
if (i < values.Length - 1) query += $"{values[i]}, ";
|
|
||||||
else query += $"{values[i]})";
|
|
||||||
}
|
|
||||||
ExecuteNonQuery(query);
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void deleteEntry(string tableName, int id)
|
|
||||||
{
|
|
||||||
ExecuteNonQuery($"DELETE FROM {tableName} WHERE {tableName}_id = {id}");
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void deleteEntry(string tableName, string name)
|
|
||||||
{
|
|
||||||
ExecuteNonQuery($"DELETE FROM {tableName} WHERE name = '{name}'");
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void reduceSeq(string seq, int currval)
|
|
||||||
{
|
|
||||||
ExecuteNonQuery($"SELECT setval('{seq}', {currval});");
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void ExecuteNonQuery(string query)
|
|
||||||
{
|
|
||||||
connection.Open();
|
|
||||||
NpgsqlCommand command = new NpgsqlCommand(query, connection);
|
|
||||||
command.ExecuteNonQuery();
|
|
||||||
connection.Close();
|
|
||||||
}
|
|
||||||
|
|
||||||
public override DataTable ExecuteQuery(string query)
|
|
||||||
{
|
|
||||||
connection.Open();
|
|
||||||
NpgsqlCommand command = new NpgsqlCommand(query, connection);
|
|
||||||
NpgsqlDataAdapter adapter = new NpgsqlDataAdapter(command);
|
|
||||||
DataTable result = new DataTable();
|
|
||||||
adapter.Fill(result);
|
|
||||||
connection.Close();
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,7 +1,19 @@
|
|||||||
namespace WebsiteForPlacingAds
|
using BulletinBoardBusinessLogic.BusinessLogics;
|
||||||
|
using BulletinBoardContracts.BusinessLogicContracts;
|
||||||
|
using BulletinBoardContracts.StoragesContracts;
|
||||||
|
using BulletinBoardLogic.BusinessLogics;
|
||||||
|
using BulletinBoardMongoDB.Implements;
|
||||||
|
//using BulletinBoardDatabase.Implements;
|
||||||
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
|
using System;
|
||||||
|
|
||||||
|
namespace BulletinBoard
|
||||||
{
|
{
|
||||||
internal static class Program
|
internal static class Program
|
||||||
{
|
{
|
||||||
|
public static string CURRENT_DATABASE = "MongoDB";
|
||||||
|
private static ServiceProvider? _serviceProvider;
|
||||||
|
public static ServiceProvider? ServiceProvider => _serviceProvider;
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The main entry point for the application.
|
/// The main entry point for the application.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -11,7 +23,38 @@ namespace WebsiteForPlacingAds
|
|||||||
// 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 MainForm());
|
var services = new ServiceCollection();
|
||||||
|
ConfigureServices(services);
|
||||||
|
_serviceProvider = services.BuildServiceProvider();
|
||||||
|
Application.Run(_serviceProvider.GetRequiredService<FormAnnouncements>());
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void ConfigureServices(ServiceCollection services)
|
||||||
|
{
|
||||||
|
services.AddTransient<ICityStorage, CityStorage>();
|
||||||
|
services.AddTransient<IRegionStorage, RegionStorage>();
|
||||||
|
services.AddTransient<IUserStorage, UserStorage>();
|
||||||
|
services.AddTransient<ICategoryStorage, CategoryStorage>();
|
||||||
|
services.AddTransient<IAnnouncementStorage, AnnouncementStorage>();
|
||||||
|
|
||||||
|
services.AddTransient<ICityLogic, CityLogic>();
|
||||||
|
services.AddTransient<IRegionLogic, RegionLogic>();
|
||||||
|
services.AddTransient<ICategoryLogic, CategoryLogic>();
|
||||||
|
services.AddTransient<IUserLogic, UserLogic>();
|
||||||
|
services.AddTransient<IAnnouncementLogic, AnnouncementLogic>();
|
||||||
|
|
||||||
|
services.AddTransient<FormAnnouncements>();
|
||||||
|
services.AddTransient<FormRegions>();
|
||||||
|
services.AddTransient<FormCities>();
|
||||||
|
services.AddTransient<FormCategories>();
|
||||||
|
services.AddTransient<FormUsers>();
|
||||||
|
services.AddTransient<FormCreateAnnouncements>();
|
||||||
|
services.AddTransient<FormCreateCities>();
|
||||||
|
services.AddTransient<FormCreateRegions>();
|
||||||
|
services.AddTransient<FormCreateCategory>();
|
||||||
|
services.AddTransient<FormCreateUser>();
|
||||||
|
services.AddTransient<FormAddReview>();
|
||||||
|
services.AddTransient<FormTests>();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,82 +0,0 @@
|
|||||||
namespace WebsiteForPlacingAds
|
|
||||||
{
|
|
||||||
partial class CreateRegionsForm
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Required designer variable.
|
|
||||||
/// </summary>
|
|
||||||
private System.ComponentModel.IContainer components = null;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Clean up any resources being used.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
|
||||||
protected override void Dispose(bool disposing)
|
|
||||||
{
|
|
||||||
if (disposing && (components != null))
|
|
||||||
{
|
|
||||||
components.Dispose();
|
|
||||||
}
|
|
||||||
base.Dispose(disposing);
|
|
||||||
}
|
|
||||||
|
|
||||||
#region Windows Form Designer generated code
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Required method for Designer support - do not modify
|
|
||||||
/// the contents of this method with the code editor.
|
|
||||||
/// </summary>
|
|
||||||
private void InitializeComponent()
|
|
||||||
{
|
|
||||||
buttonCreateCity = new Button();
|
|
||||||
labelName = new Label();
|
|
||||||
textBoxName = new TextBox();
|
|
||||||
SuspendLayout();
|
|
||||||
//
|
|
||||||
// buttonCreateCity
|
|
||||||
//
|
|
||||||
buttonCreateCity.Location = new Point(49, 93);
|
|
||||||
buttonCreateCity.Name = "buttonCreateCity";
|
|
||||||
buttonCreateCity.Size = new Size(273, 39);
|
|
||||||
buttonCreateCity.TabIndex = 0;
|
|
||||||
buttonCreateCity.Text = "Добавить город";
|
|
||||||
buttonCreateCity.UseVisualStyleBackColor = true;
|
|
||||||
buttonCreateCity.Click += buttonCreateCity_Click;
|
|
||||||
//
|
|
||||||
// labelName
|
|
||||||
//
|
|
||||||
labelName.AutoSize = true;
|
|
||||||
labelName.Location = new Point(49, 11);
|
|
||||||
labelName.Name = "labelName";
|
|
||||||
labelName.Size = new Size(77, 20);
|
|
||||||
labelName.TabIndex = 1;
|
|
||||||
labelName.Text = "Название";
|
|
||||||
//
|
|
||||||
// textBoxName
|
|
||||||
//
|
|
||||||
textBoxName.Location = new Point(49, 35);
|
|
||||||
textBoxName.Name = "textBoxName";
|
|
||||||
textBoxName.Size = new Size(273, 27);
|
|
||||||
textBoxName.TabIndex = 2;
|
|
||||||
//
|
|
||||||
// CreateRegionsForm
|
|
||||||
//
|
|
||||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
|
||||||
AutoScaleMode = AutoScaleMode.Font;
|
|
||||||
ClientSize = new Size(370, 157);
|
|
||||||
Controls.Add(textBoxName);
|
|
||||||
Controls.Add(labelName);
|
|
||||||
Controls.Add(buttonCreateCity);
|
|
||||||
Name = "CreateRegionsForm";
|
|
||||||
Text = "Добавить Город";
|
|
||||||
ResumeLayout(false);
|
|
||||||
PerformLayout();
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
private Button buttonCreateCity;
|
|
||||||
private Label labelName;
|
|
||||||
private TextBox textBoxName;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,40 +0,0 @@
|
|||||||
using System.Data;
|
|
||||||
|
|
||||||
namespace WebsiteForPlacingAds
|
|
||||||
{
|
|
||||||
public partial class CreateRegionsForm : Form
|
|
||||||
{
|
|
||||||
AbstractManagmentDatabase managmentDatabase;
|
|
||||||
public CreateRegionsForm(AbstractManagmentDatabase managmentDatabase)
|
|
||||||
{
|
|
||||||
InitializeComponent();
|
|
||||||
this.managmentDatabase = managmentDatabase;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void buttonCreateCity_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
string name = textBoxName.Text;
|
|
||||||
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
DateTime start = DateTime.Now;
|
|
||||||
|
|
||||||
managmentDatabase.insertInto("regions", $"'{name}'");
|
|
||||||
MessageBox.Show("Äîáàâëåíî!");
|
|
||||||
|
|
||||||
DateTime end = DateTime.Now;
|
|
||||||
TimeSpan duration = end - start;
|
|
||||||
MessageBox.Show($"Äîáàâëåíî! Âðåìÿ âûïîëíåíèÿ: {duration.TotalMilliseconds} ìñ");
|
|
||||||
|
|
||||||
// Çàêðûòü òåêóùóþ ôîðìó ïîñëå âûïîëíåíèÿ äåéñòâèé
|
|
||||||
this.Close();
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
MessageBox.Show("Íå óäàëîñü äîáàâèòü");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,86 +0,0 @@
|
|||||||
namespace WebsiteForPlacingAds
|
|
||||||
{
|
|
||||||
partial class DeleteRegionsForm
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Required designer variable.
|
|
||||||
/// </summary>
|
|
||||||
private System.ComponentModel.IContainer components = null;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Clean up any resources being used.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
|
||||||
protected override void Dispose(bool disposing)
|
|
||||||
{
|
|
||||||
if (disposing && (components != null))
|
|
||||||
{
|
|
||||||
components.Dispose();
|
|
||||||
}
|
|
||||||
base.Dispose(disposing);
|
|
||||||
}
|
|
||||||
|
|
||||||
#region Windows Form Designer generated code
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Required method for Designer support - do not modify
|
|
||||||
/// the contents of this method with the code editor.
|
|
||||||
/// </summary>
|
|
||||||
private void InitializeComponent()
|
|
||||||
{
|
|
||||||
label1 = new Label();
|
|
||||||
buttonDeleteRegion = new Button();
|
|
||||||
comboBoxDeleteRegions = new ComboBox();
|
|
||||||
SuspendLayout();
|
|
||||||
//
|
|
||||||
// label1
|
|
||||||
//
|
|
||||||
label1.AutoSize = true;
|
|
||||||
label1.Location = new Point(70, 16);
|
|
||||||
label1.Name = "label1";
|
|
||||||
label1.Size = new Size(242, 15);
|
|
||||||
label1.TabIndex = 0;
|
|
||||||
label1.Text = "Выберите регион, которую хотите удалить";
|
|
||||||
//
|
|
||||||
// buttonDeleteRegion
|
|
||||||
//
|
|
||||||
buttonDeleteRegion.Location = new Point(132, 85);
|
|
||||||
buttonDeleteRegion.Margin = new Padding(3, 2, 3, 2);
|
|
||||||
buttonDeleteRegion.Name = "buttonDeleteRegion";
|
|
||||||
buttonDeleteRegion.Size = new Size(163, 28);
|
|
||||||
buttonDeleteRegion.TabIndex = 1;
|
|
||||||
buttonDeleteRegion.Text = "Удалить";
|
|
||||||
buttonDeleteRegion.UseVisualStyleBackColor = true;
|
|
||||||
buttonDeleteRegion.Click += buttonDeleteRegion_Click;
|
|
||||||
//
|
|
||||||
// comboBoxDeleteRegions
|
|
||||||
//
|
|
||||||
comboBoxDeleteRegions.FormattingEnabled = true;
|
|
||||||
comboBoxDeleteRegions.Location = new Point(35, 48);
|
|
||||||
comboBoxDeleteRegions.Margin = new Padding(3, 2, 3, 2);
|
|
||||||
comboBoxDeleteRegions.Name = "comboBoxDeleteRegions";
|
|
||||||
comboBoxDeleteRegions.Size = new Size(367, 23);
|
|
||||||
comboBoxDeleteRegions.TabIndex = 2;
|
|
||||||
//
|
|
||||||
// DeleteRegionsForm
|
|
||||||
//
|
|
||||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
|
||||||
AutoScaleMode = AutoScaleMode.Font;
|
|
||||||
ClientSize = new Size(442, 131);
|
|
||||||
Controls.Add(comboBoxDeleteRegions);
|
|
||||||
Controls.Add(buttonDeleteRegion);
|
|
||||||
Controls.Add(label1);
|
|
||||||
Margin = new Padding(3, 2, 3, 2);
|
|
||||||
Name = "DeleteRegionsForm";
|
|
||||||
Text = "Удалить регион";
|
|
||||||
ResumeLayout(false);
|
|
||||||
PerformLayout();
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
private Label label1;
|
|
||||||
private Button buttonDeleteRegion;
|
|
||||||
private ComboBox comboBoxDeleteRegions;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,61 +0,0 @@
|
|||||||
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 WebsiteForPlacingAds
|
|
||||||
{
|
|
||||||
public partial class DeleteRegionsForm : Form
|
|
||||||
{
|
|
||||||
AbstractManagmentDatabase managmentDatabase;
|
|
||||||
private int setval_seq;
|
|
||||||
public DeleteRegionsForm(AbstractManagmentDatabase managmentDatabase)
|
|
||||||
{
|
|
||||||
InitializeComponent();
|
|
||||||
this.managmentDatabase = managmentDatabase;
|
|
||||||
LoadData();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void buttonDeleteRegion_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
string[] categories = comboBoxDeleteRegions.SelectedItem.ToString().Split("|");
|
|
||||||
string category_id = categories[0].Trim();
|
|
||||||
try
|
|
||||||
{
|
|
||||||
DateTime start = DateTime.Now;
|
|
||||||
|
|
||||||
managmentDatabase.deleteEntry("regions", int.Parse(category_id));
|
|
||||||
LoadData();
|
|
||||||
if (setval_seq > 0) managmentDatabase.reduceSeq("seq_regions", setval_seq);
|
|
||||||
MessageBox.Show("Удалено!");
|
|
||||||
|
|
||||||
DateTime end = DateTime.Now;
|
|
||||||
TimeSpan duration = end - start;
|
|
||||||
MessageBox.Show($"Добавлено! Время выполнения: {duration.TotalMilliseconds} мс");
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
MessageBox.Show("Не удалось удалить");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
public void LoadData()
|
|
||||||
{
|
|
||||||
comboBoxDeleteRegions.Items.Clear();
|
|
||||||
DataTable result = managmentDatabase.getAllEntry("Regions");
|
|
||||||
setval_seq = result.Rows.Count;
|
|
||||||
string Regions = "";
|
|
||||||
for (int i = 0; i < result.Rows.Count; i++)
|
|
||||||
{
|
|
||||||
setval_seq = Math.Max(Convert.ToInt32(managmentDatabase.getRowTableById(result, "regions_id", i)), setval_seq);
|
|
||||||
Regions = managmentDatabase.getRowTableById(result, "regions_id", i).ToString() + " | " +
|
|
||||||
managmentDatabase.getRowTableById(result, "name", i).ToString() + "\n";
|
|
||||||
comboBoxDeleteRegions.Items.Add(Regions);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,74 +0,0 @@
|
|||||||
namespace WebsiteForPlacingAds
|
|
||||||
{
|
|
||||||
partial class ListRegionsForm
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Required designer variable.
|
|
||||||
/// </summary>
|
|
||||||
private System.ComponentModel.IContainer components = null;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Clean up any resources being used.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
|
||||||
protected override void Dispose(bool disposing)
|
|
||||||
{
|
|
||||||
if (disposing && (components != null))
|
|
||||||
{
|
|
||||||
components.Dispose();
|
|
||||||
}
|
|
||||||
base.Dispose(disposing);
|
|
||||||
}
|
|
||||||
|
|
||||||
#region Windows Form Designer generated code
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Required method for Designer support - do not modify
|
|
||||||
/// the contents of this method with the code editor.
|
|
||||||
/// </summary>
|
|
||||||
private void InitializeComponent()
|
|
||||||
{
|
|
||||||
label1 = new Label();
|
|
||||||
labelListRegions = new Label();
|
|
||||||
SuspendLayout();
|
|
||||||
//
|
|
||||||
// label1
|
|
||||||
//
|
|
||||||
label1.AutoSize = true;
|
|
||||||
label1.BackColor = SystemColors.Control;
|
|
||||||
label1.Font = new Font("Segoe UI", 11F, FontStyle.Regular, GraphicsUnit.Point);
|
|
||||||
label1.Location = new Point(10, 7);
|
|
||||||
label1.Name = "label1";
|
|
||||||
label1.Size = new Size(130, 20);
|
|
||||||
label1.TabIndex = 0;
|
|
||||||
label1.Text = "Список регионов";
|
|
||||||
//
|
|
||||||
// labelListRegions
|
|
||||||
//
|
|
||||||
labelListRegions.AutoSize = true;
|
|
||||||
labelListRegions.Font = new Font("Segoe UI", 10F, FontStyle.Regular, GraphicsUnit.Point);
|
|
||||||
labelListRegions.Location = new Point(10, 35);
|
|
||||||
labelListRegions.Name = "labelListRegions";
|
|
||||||
labelListRegions.Size = new Size(0, 19);
|
|
||||||
labelListRegions.TabIndex = 1;
|
|
||||||
//
|
|
||||||
// ListRegionsForm
|
|
||||||
//
|
|
||||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
|
||||||
AutoScaleMode = AutoScaleMode.Font;
|
|
||||||
ClientSize = new Size(700, 338);
|
|
||||||
Controls.Add(labelListRegions);
|
|
||||||
Controls.Add(label1);
|
|
||||||
Margin = new Padding(3, 2, 3, 2);
|
|
||||||
Name = "ListRegionsForm";
|
|
||||||
Text = "Список регионов";
|
|
||||||
ResumeLayout(false);
|
|
||||||
PerformLayout();
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
private Label label1;
|
|
||||||
private Label labelListRegions;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,42 +0,0 @@
|
|||||||
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 System.Windows.Forms.VisualStyles;
|
|
||||||
|
|
||||||
namespace WebsiteForPlacingAds
|
|
||||||
{
|
|
||||||
public partial class ListRegionsForm : Form
|
|
||||||
{
|
|
||||||
AbstractManagmentDatabase managmentDatabase;
|
|
||||||
public ListRegionsForm(AbstractManagmentDatabase managmentDatabase)
|
|
||||||
{
|
|
||||||
InitializeComponent();
|
|
||||||
this.managmentDatabase = managmentDatabase;
|
|
||||||
LoadData();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void LoadData()
|
|
||||||
{
|
|
||||||
DateTime start = DateTime.Now;
|
|
||||||
|
|
||||||
DataTable result = managmentDatabase.getAllEntry("Regions");
|
|
||||||
string listRegions = "";
|
|
||||||
for (int i = 0; i < result.Rows.Count; i++)
|
|
||||||
{
|
|
||||||
listRegions += managmentDatabase.getRowTableById(result, "regions_id", i).ToString() + " | " +
|
|
||||||
managmentDatabase.getRowTableById(result, "name", i).ToString() + "\n";
|
|
||||||
}
|
|
||||||
labelListRegions.Text = listRegions;
|
|
||||||
|
|
||||||
DateTime end = DateTime.Now;
|
|
||||||
TimeSpan duration = end - start;
|
|
||||||
MessageBox.Show($"Добавлено! Время выполнения: {duration.TotalMilliseconds} мс");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,120 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<root>
|
|
||||||
<!--
|
|
||||||
Microsoft ResX Schema
|
|
||||||
|
|
||||||
Version 2.0
|
|
||||||
|
|
||||||
The primary goals of this format is to allow a simple XML format
|
|
||||||
that is mostly human readable. The generation and parsing of the
|
|
||||||
various data types are done through the TypeConverter classes
|
|
||||||
associated with the data types.
|
|
||||||
|
|
||||||
Example:
|
|
||||||
|
|
||||||
... ado.net/XML headers & schema ...
|
|
||||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
|
||||||
<resheader name="version">2.0</resheader>
|
|
||||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
|
||||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
|
||||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
|
||||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
|
||||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
|
||||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
|
||||||
</data>
|
|
||||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
|
||||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
|
||||||
<comment>This is a comment</comment>
|
|
||||||
</data>
|
|
||||||
|
|
||||||
There are any number of "resheader" rows that contain simple
|
|
||||||
name/value pairs.
|
|
||||||
|
|
||||||
Each data row contains a name, and value. The row also contains a
|
|
||||||
type or mimetype. Type corresponds to a .NET class that support
|
|
||||||
text/value conversion through the TypeConverter architecture.
|
|
||||||
Classes that don't support this are serialized and stored with the
|
|
||||||
mimetype set.
|
|
||||||
|
|
||||||
The mimetype is used for serialized objects, and tells the
|
|
||||||
ResXResourceReader how to depersist the object. This is currently not
|
|
||||||
extensible. For a given mimetype the value must be set accordingly:
|
|
||||||
|
|
||||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
|
||||||
that the ResXResourceWriter will generate, however the reader can
|
|
||||||
read any of the formats listed below.
|
|
||||||
|
|
||||||
mimetype: application/x-microsoft.net.object.binary.base64
|
|
||||||
value : The object must be serialized with
|
|
||||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
|
||||||
: and then encoded with base64 encoding.
|
|
||||||
|
|
||||||
mimetype: application/x-microsoft.net.object.soap.base64
|
|
||||||
value : The object must be serialized with
|
|
||||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
|
||||||
: and then encoded with base64 encoding.
|
|
||||||
|
|
||||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
|
||||||
value : The object must be serialized into a byte array
|
|
||||||
: using a System.ComponentModel.TypeConverter
|
|
||||||
: and then encoded with base64 encoding.
|
|
||||||
-->
|
|
||||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
|
||||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
|
||||||
<xsd:element name="root" msdata:IsDataSet="true">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:choice maxOccurs="unbounded">
|
|
||||||
<xsd:element name="metadata">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
|
||||||
<xsd:attribute name="type" type="xsd:string" />
|
|
||||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
|
||||||
<xsd:attribute ref="xml:space" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="assembly">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:attribute name="alias" type="xsd:string" />
|
|
||||||
<xsd:attribute name="name" type="xsd:string" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="data">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
|
||||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
|
||||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
|
||||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
|
||||||
<xsd:attribute ref="xml:space" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="resheader">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
</xsd:choice>
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
</xsd:schema>
|
|
||||||
<resheader name="resmimetype">
|
|
||||||
<value>text/microsoft-resx</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="version">
|
|
||||||
<value>2.0</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="reader">
|
|
||||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="writer">
|
|
||||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
|
||||||
</resheader>
|
|
||||||
</root>
|
|
@ -1,109 +0,0 @@
|
|||||||
namespace WebsiteForPlacingAds
|
|
||||||
{
|
|
||||||
partial class UpdateRegionsForm
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Required designer variable.
|
|
||||||
/// </summary>
|
|
||||||
private System.ComponentModel.IContainer components = null;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Clean up any resources being used.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
|
||||||
protected override void Dispose(bool disposing)
|
|
||||||
{
|
|
||||||
if (disposing && (components != null))
|
|
||||||
{
|
|
||||||
components.Dispose();
|
|
||||||
}
|
|
||||||
base.Dispose(disposing);
|
|
||||||
}
|
|
||||||
|
|
||||||
#region Windows Form Designer generated code
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Required method for Designer support - do not modify
|
|
||||||
/// the contents of this method with the code editor.
|
|
||||||
/// </summary>
|
|
||||||
private void InitializeComponent()
|
|
||||||
{
|
|
||||||
label1 = new Label();
|
|
||||||
comboBoxUpdateRegion = new ComboBox();
|
|
||||||
textBoxName = new TextBox();
|
|
||||||
labelName = new Label();
|
|
||||||
buttonUpdateRegion = new Button();
|
|
||||||
SuspendLayout();
|
|
||||||
//
|
|
||||||
// label1
|
|
||||||
//
|
|
||||||
label1.AutoSize = true;
|
|
||||||
label1.Location = new Point(51, 15);
|
|
||||||
label1.Name = "label1";
|
|
||||||
label1.Size = new Size(251, 15);
|
|
||||||
label1.TabIndex = 33;
|
|
||||||
label1.Text = "Выберите регион, которую хотите обновить";
|
|
||||||
//
|
|
||||||
// comboBoxUpdateRegion
|
|
||||||
//
|
|
||||||
comboBoxUpdateRegion.FormattingEnabled = true;
|
|
||||||
comboBoxUpdateRegion.Location = new Point(10, 39);
|
|
||||||
comboBoxUpdateRegion.Margin = new Padding(3, 2, 3, 2);
|
|
||||||
comboBoxUpdateRegion.Name = "comboBoxUpdateRegion";
|
|
||||||
comboBoxUpdateRegion.Size = new Size(377, 23);
|
|
||||||
comboBoxUpdateRegion.TabIndex = 34;
|
|
||||||
comboBoxUpdateRegion.SelectedIndexChanged += comboBoxUpdateRegion_SelectedIndexChanged;
|
|
||||||
//
|
|
||||||
// textBoxName
|
|
||||||
//
|
|
||||||
textBoxName.Location = new Point(78, 96);
|
|
||||||
textBoxName.Margin = new Padding(3, 2, 3, 2);
|
|
||||||
textBoxName.Name = "textBoxName";
|
|
||||||
textBoxName.Size = new Size(239, 23);
|
|
||||||
textBoxName.TabIndex = 37;
|
|
||||||
//
|
|
||||||
// labelName
|
|
||||||
//
|
|
||||||
labelName.AutoSize = true;
|
|
||||||
labelName.Location = new Point(78, 78);
|
|
||||||
labelName.Name = "labelName";
|
|
||||||
labelName.Size = new Size(59, 15);
|
|
||||||
labelName.TabIndex = 36;
|
|
||||||
labelName.Text = "Название";
|
|
||||||
//
|
|
||||||
// buttonUpdateRegion
|
|
||||||
//
|
|
||||||
buttonUpdateRegion.Location = new Point(78, 140);
|
|
||||||
buttonUpdateRegion.Margin = new Padding(3, 2, 3, 2);
|
|
||||||
buttonUpdateRegion.Name = "buttonUpdateRegion";
|
|
||||||
buttonUpdateRegion.Size = new Size(239, 29);
|
|
||||||
buttonUpdateRegion.TabIndex = 35;
|
|
||||||
buttonUpdateRegion.Text = "Обновить регион";
|
|
||||||
buttonUpdateRegion.UseVisualStyleBackColor = true;
|
|
||||||
buttonUpdateRegion.Click += buttonUpdateRegion_Click_1;
|
|
||||||
//
|
|
||||||
// UpdateRegionsForm
|
|
||||||
//
|
|
||||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
|
||||||
AutoScaleMode = AutoScaleMode.Font;
|
|
||||||
ClientSize = new Size(397, 190);
|
|
||||||
Controls.Add(textBoxName);
|
|
||||||
Controls.Add(labelName);
|
|
||||||
Controls.Add(buttonUpdateRegion);
|
|
||||||
Controls.Add(comboBoxUpdateRegion);
|
|
||||||
Controls.Add(label1);
|
|
||||||
Margin = new Padding(3, 2, 3, 2);
|
|
||||||
Name = "UpdateRegionsForm";
|
|
||||||
Text = "Обновить регион";
|
|
||||||
ResumeLayout(false);
|
|
||||||
PerformLayout();
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
private Label label1;
|
|
||||||
private ComboBox comboBoxUpdateRegion;
|
|
||||||
private TextBox textBoxName;
|
|
||||||
private Label labelName;
|
|
||||||
private Button buttonUpdateRegion;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,86 +0,0 @@
|
|||||||
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 WebsiteForPlacingAds
|
|
||||||
{
|
|
||||||
public partial class UpdateRegionsForm : Form
|
|
||||||
{
|
|
||||||
AbstractManagmentDatabase managmentDatabase;
|
|
||||||
public UpdateRegionsForm(AbstractManagmentDatabase managmentDatabase)
|
|
||||||
{
|
|
||||||
InitializeComponent();
|
|
||||||
this.managmentDatabase = managmentDatabase;
|
|
||||||
LoadData();
|
|
||||||
}
|
|
||||||
public void LoadData()
|
|
||||||
{
|
|
||||||
comboBoxUpdateRegion.Items.Clear();
|
|
||||||
DataTable result = managmentDatabase.getAllEntry("Regions");
|
|
||||||
string Regions = "";
|
|
||||||
for (int i = 0; i < result.Rows.Count; i++)
|
|
||||||
{
|
|
||||||
Regions = result.Rows[i]["regions_id"].ToString() + " | " +
|
|
||||||
(string)result.Rows[i]["name"] + "\n";
|
|
||||||
comboBoxUpdateRegion.Items.Add(Regions);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
public void LoadDataSelectedItem(int regions_id)
|
|
||||||
{
|
|
||||||
DataTable result = managmentDatabase.getEntryById("regions", regions_id);
|
|
||||||
textBoxName.Text = managmentDatabase.getRowTableById(result, "name", 0).ToString();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void comboBoxUpdateRegion_SelectedIndexChanged(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
string[] selectedItems = comboBoxUpdateRegion.SelectedItem.ToString().Split("|");
|
|
||||||
int region_id = int.Parse(selectedItems[0].Trim());
|
|
||||||
LoadDataSelectedItem(region_id);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void buttonUpdateRegion_Click_1(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
string[] selectedCategory = comboBoxUpdateRegion.SelectedItem.ToString().Split("|");
|
|
||||||
int region_id = int.Parse(selectedCategory[0].Trim());
|
|
||||||
|
|
||||||
string query = $"UPDATE Regions SET ";
|
|
||||||
int len = query.Length;
|
|
||||||
|
|
||||||
|
|
||||||
string oldName = managmentDatabase.getRowTableById("regions", "name", region_id).ToString();
|
|
||||||
|
|
||||||
string newName = textBoxName.Text;
|
|
||||||
|
|
||||||
|
|
||||||
query = oldName == newName ? query : query + $"name = '{newName}', ";
|
|
||||||
if (len != query.Length)
|
|
||||||
{
|
|
||||||
query = query.TrimEnd(' ');
|
|
||||||
query = query.TrimEnd(',');
|
|
||||||
query += $" WHERE Regions_ID = {region_id};";
|
|
||||||
}
|
|
||||||
try
|
|
||||||
{
|
|
||||||
DateTime start = DateTime.Now;
|
|
||||||
|
|
||||||
managmentDatabase.ExecuteNonQuery(query);
|
|
||||||
MessageBox.Show("Данные успешно обновлены!");
|
|
||||||
|
|
||||||
DateTime end = DateTime.Now;
|
|
||||||
TimeSpan duration = end - start;
|
|
||||||
MessageBox.Show($"Добавлено! Время выполнения: {duration.TotalMilliseconds} мс");
|
|
||||||
}
|
|
||||||
catch (Exception)
|
|
||||||
{
|
|
||||||
|
|
||||||
MessageBox.Show("Данные не обновились");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,120 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<root>
|
|
||||||
<!--
|
|
||||||
Microsoft ResX Schema
|
|
||||||
|
|
||||||
Version 2.0
|
|
||||||
|
|
||||||
The primary goals of this format is to allow a simple XML format
|
|
||||||
that is mostly human readable. The generation and parsing of the
|
|
||||||
various data types are done through the TypeConverter classes
|
|
||||||
associated with the data types.
|
|
||||||
|
|
||||||
Example:
|
|
||||||
|
|
||||||
... ado.net/XML headers & schema ...
|
|
||||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
|
||||||
<resheader name="version">2.0</resheader>
|
|
||||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
|
||||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
|
||||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
|
||||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
|
||||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
|
||||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
|
||||||
</data>
|
|
||||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
|
||||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
|
||||||
<comment>This is a comment</comment>
|
|
||||||
</data>
|
|
||||||
|
|
||||||
There are any number of "resheader" rows that contain simple
|
|
||||||
name/value pairs.
|
|
||||||
|
|
||||||
Each data row contains a name, and value. The row also contains a
|
|
||||||
type or mimetype. Type corresponds to a .NET class that support
|
|
||||||
text/value conversion through the TypeConverter architecture.
|
|
||||||
Classes that don't support this are serialized and stored with the
|
|
||||||
mimetype set.
|
|
||||||
|
|
||||||
The mimetype is used for serialized objects, and tells the
|
|
||||||
ResXResourceReader how to depersist the object. This is currently not
|
|
||||||
extensible. For a given mimetype the value must be set accordingly:
|
|
||||||
|
|
||||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
|
||||||
that the ResXResourceWriter will generate, however the reader can
|
|
||||||
read any of the formats listed below.
|
|
||||||
|
|
||||||
mimetype: application/x-microsoft.net.object.binary.base64
|
|
||||||
value : The object must be serialized with
|
|
||||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
|
||||||
: and then encoded with base64 encoding.
|
|
||||||
|
|
||||||
mimetype: application/x-microsoft.net.object.soap.base64
|
|
||||||
value : The object must be serialized with
|
|
||||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
|
||||||
: and then encoded with base64 encoding.
|
|
||||||
|
|
||||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
|
||||||
value : The object must be serialized into a byte array
|
|
||||||
: using a System.ComponentModel.TypeConverter
|
|
||||||
: and then encoded with base64 encoding.
|
|
||||||
-->
|
|
||||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
|
||||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
|
||||||
<xsd:element name="root" msdata:IsDataSet="true">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:choice maxOccurs="unbounded">
|
|
||||||
<xsd:element name="metadata">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
|
||||||
<xsd:attribute name="type" type="xsd:string" />
|
|
||||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
|
||||||
<xsd:attribute ref="xml:space" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="assembly">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:attribute name="alias" type="xsd:string" />
|
|
||||||
<xsd:attribute name="name" type="xsd:string" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="data">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
|
||||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
|
||||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
|
||||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
|
||||||
<xsd:attribute ref="xml:space" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="resheader">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
</xsd:choice>
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
</xsd:schema>
|
|
||||||
<resheader name="resmimetype">
|
|
||||||
<value>text/microsoft-resx</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="version">
|
|
||||||
<value>2.0</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="reader">
|
|
||||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="writer">
|
|
||||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
|
||||||
</resheader>
|
|
||||||
</root>
|
|
@ -1,109 +0,0 @@
|
|||||||
namespace WebsiteForPlacingAds
|
|
||||||
{
|
|
||||||
partial class CreateSubcategoriesForm
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Required designer variable.
|
|
||||||
/// </summary>
|
|
||||||
private System.ComponentModel.IContainer components = null;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Clean up any resources being used.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
|
||||||
protected override void Dispose(bool disposing)
|
|
||||||
{
|
|
||||||
if (disposing && (components != null))
|
|
||||||
{
|
|
||||||
components.Dispose();
|
|
||||||
}
|
|
||||||
base.Dispose(disposing);
|
|
||||||
}
|
|
||||||
|
|
||||||
#region Windows Form Designer generated code
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Required method for Designer support - do not modify
|
|
||||||
/// the contents of this method with the code editor.
|
|
||||||
/// </summary>
|
|
||||||
private void InitializeComponent()
|
|
||||||
{
|
|
||||||
textBoxName = new TextBox();
|
|
||||||
labelName = new Label();
|
|
||||||
buttonCreateSubcategory = new Button();
|
|
||||||
comboBoxCategory = new ComboBox();
|
|
||||||
labelCategory = new Label();
|
|
||||||
SuspendLayout();
|
|
||||||
//
|
|
||||||
// textBoxName
|
|
||||||
//
|
|
||||||
textBoxName.Location = new Point(37, 35);
|
|
||||||
textBoxName.Margin = new Padding(3, 2, 3, 2);
|
|
||||||
textBoxName.Name = "textBoxName";
|
|
||||||
textBoxName.Size = new Size(239, 23);
|
|
||||||
textBoxName.TabIndex = 5;
|
|
||||||
//
|
|
||||||
// labelName
|
|
||||||
//
|
|
||||||
labelName.AutoSize = true;
|
|
||||||
labelName.Location = new Point(37, 17);
|
|
||||||
labelName.Name = "labelName";
|
|
||||||
labelName.Size = new Size(59, 15);
|
|
||||||
labelName.TabIndex = 4;
|
|
||||||
labelName.Text = "Название";
|
|
||||||
//
|
|
||||||
// buttonCreateSubcategory
|
|
||||||
//
|
|
||||||
buttonCreateSubcategory.Location = new Point(37, 118);
|
|
||||||
buttonCreateSubcategory.Margin = new Padding(3, 2, 3, 2);
|
|
||||||
buttonCreateSubcategory.Name = "buttonCreateSubcategory";
|
|
||||||
buttonCreateSubcategory.Size = new Size(239, 29);
|
|
||||||
buttonCreateSubcategory.TabIndex = 3;
|
|
||||||
buttonCreateSubcategory.Text = "Добавить подкатегорию";
|
|
||||||
buttonCreateSubcategory.UseVisualStyleBackColor = true;
|
|
||||||
buttonCreateSubcategory.Click += buttonCreateSubcategory_Click_1;
|
|
||||||
//
|
|
||||||
// comboBoxCategory
|
|
||||||
//
|
|
||||||
comboBoxCategory.FormattingEnabled = true;
|
|
||||||
comboBoxCategory.Location = new Point(37, 83);
|
|
||||||
comboBoxCategory.Margin = new Padding(3, 2, 3, 2);
|
|
||||||
comboBoxCategory.Name = "comboBoxCategory";
|
|
||||||
comboBoxCategory.Size = new Size(239, 23);
|
|
||||||
comboBoxCategory.TabIndex = 17;
|
|
||||||
//
|
|
||||||
// labelCategory
|
|
||||||
//
|
|
||||||
labelCategory.AutoSize = true;
|
|
||||||
labelCategory.Location = new Point(37, 67);
|
|
||||||
labelCategory.Name = "labelCategory";
|
|
||||||
labelCategory.Size = new Size(63, 15);
|
|
||||||
labelCategory.TabIndex = 18;
|
|
||||||
labelCategory.Text = "Категория";
|
|
||||||
//
|
|
||||||
// CreateSubcategoriesForm
|
|
||||||
//
|
|
||||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
|
||||||
AutoScaleMode = AutoScaleMode.Font;
|
|
||||||
ClientSize = new Size(324, 158);
|
|
||||||
Controls.Add(labelCategory);
|
|
||||||
Controls.Add(comboBoxCategory);
|
|
||||||
Controls.Add(textBoxName);
|
|
||||||
Controls.Add(labelName);
|
|
||||||
Controls.Add(buttonCreateSubcategory);
|
|
||||||
Margin = new Padding(3, 2, 3, 2);
|
|
||||||
Name = "CreateSubcategoriesForm";
|
|
||||||
Text = "Подкатегория";
|
|
||||||
ResumeLayout(false);
|
|
||||||
PerformLayout();
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
private TextBox textBoxName;
|
|
||||||
private Label labelName;
|
|
||||||
private Button buttonCreateSubcategory;
|
|
||||||
private ComboBox comboBoxCategory;
|
|
||||||
private Label labelCategory;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,56 +0,0 @@
|
|||||||
using System.Data;
|
|
||||||
|
|
||||||
namespace WebsiteForPlacingAds
|
|
||||||
{
|
|
||||||
public partial class CreateSubcategoriesForm : Form
|
|
||||||
{
|
|
||||||
AbstractManagmentDatabase managmentDatabase;
|
|
||||||
public CreateSubcategoriesForm(AbstractManagmentDatabase managmentDatabase)
|
|
||||||
{
|
|
||||||
InitializeComponent();
|
|
||||||
this.managmentDatabase = managmentDatabase;
|
|
||||||
LoadData();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void buttonCreateSubcategory_Click_1(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
string name = textBoxName.Text;
|
|
||||||
string[] category = comboBoxCategory.SelectedItem.ToString().Split(" ");
|
|
||||||
|
|
||||||
string category_id = category[0];
|
|
||||||
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
DateTime start = DateTime.Now;
|
|
||||||
|
|
||||||
managmentDatabase.insertInto("subcategories", $"'{name}'", category_id);
|
|
||||||
MessageBox.Show("Äîáàâëåíî!");
|
|
||||||
LoadData();
|
|
||||||
|
|
||||||
DateTime end = DateTime.Now;
|
|
||||||
TimeSpan duration = end - start;
|
|
||||||
MessageBox.Show($"Äîáàâëåíî! Âðåìÿ âûïîëíåíèÿ: {duration.TotalMilliseconds} ìñ");
|
|
||||||
|
|
||||||
// Çàêðûòü òåêóùóþ ôîðìó ïîñëå âûïîëíåíèÿ äåéñòâèé
|
|
||||||
this.Close();
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
MessageBox.Show("Íå óäàëîñü äîáàâèòü");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void LoadData()
|
|
||||||
{
|
|
||||||
comboBoxCategory.Items.Clear();
|
|
||||||
DataTable result = managmentDatabase.getAllEntry("CATEGORIES");
|
|
||||||
string[] id_names = new string[result.Rows.Count];
|
|
||||||
for (int i = 0; i < result.Rows.Count; i++)
|
|
||||||
{
|
|
||||||
id_names[i] = managmentDatabase.getRowTableById(result, "categories_id", i).ToString() + ". " + managmentDatabase.getRowTableById(result, "name", i).ToString();
|
|
||||||
comboBoxCategory.Items.Add(id_names[i]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,120 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<root>
|
|
||||||
<!--
|
|
||||||
Microsoft ResX Schema
|
|
||||||
|
|
||||||
Version 2.0
|
|
||||||
|
|
||||||
The primary goals of this format is to allow a simple XML format
|
|
||||||
that is mostly human readable. The generation and parsing of the
|
|
||||||
various data types are done through the TypeConverter classes
|
|
||||||
associated with the data types.
|
|
||||||
|
|
||||||
Example:
|
|
||||||
|
|
||||||
... ado.net/XML headers & schema ...
|
|
||||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
|
||||||
<resheader name="version">2.0</resheader>
|
|
||||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
|
||||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
|
||||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
|
||||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
|
||||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
|
||||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
|
||||||
</data>
|
|
||||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
|
||||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
|
||||||
<comment>This is a comment</comment>
|
|
||||||
</data>
|
|
||||||
|
|
||||||
There are any number of "resheader" rows that contain simple
|
|
||||||
name/value pairs.
|
|
||||||
|
|
||||||
Each data row contains a name, and value. The row also contains a
|
|
||||||
type or mimetype. Type corresponds to a .NET class that support
|
|
||||||
text/value conversion through the TypeConverter architecture.
|
|
||||||
Classes that don't support this are serialized and stored with the
|
|
||||||
mimetype set.
|
|
||||||
|
|
||||||
The mimetype is used for serialized objects, and tells the
|
|
||||||
ResXResourceReader how to depersist the object. This is currently not
|
|
||||||
extensible. For a given mimetype the value must be set accordingly:
|
|
||||||
|
|
||||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
|
||||||
that the ResXResourceWriter will generate, however the reader can
|
|
||||||
read any of the formats listed below.
|
|
||||||
|
|
||||||
mimetype: application/x-microsoft.net.object.binary.base64
|
|
||||||
value : The object must be serialized with
|
|
||||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
|
||||||
: and then encoded with base64 encoding.
|
|
||||||
|
|
||||||
mimetype: application/x-microsoft.net.object.soap.base64
|
|
||||||
value : The object must be serialized with
|
|
||||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
|
||||||
: and then encoded with base64 encoding.
|
|
||||||
|
|
||||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
|
||||||
value : The object must be serialized into a byte array
|
|
||||||
: using a System.ComponentModel.TypeConverter
|
|
||||||
: and then encoded with base64 encoding.
|
|
||||||
-->
|
|
||||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
|
||||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
|
||||||
<xsd:element name="root" msdata:IsDataSet="true">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:choice maxOccurs="unbounded">
|
|
||||||
<xsd:element name="metadata">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
|
||||||
<xsd:attribute name="type" type="xsd:string" />
|
|
||||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
|
||||||
<xsd:attribute ref="xml:space" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="assembly">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:attribute name="alias" type="xsd:string" />
|
|
||||||
<xsd:attribute name="name" type="xsd:string" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="data">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
|
||||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
|
||||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
|
||||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
|
||||||
<xsd:attribute ref="xml:space" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="resheader">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
</xsd:choice>
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
</xsd:schema>
|
|
||||||
<resheader name="resmimetype">
|
|
||||||
<value>text/microsoft-resx</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="version">
|
|
||||||
<value>2.0</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="reader">
|
|
||||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="writer">
|
|
||||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
|
||||||
</resheader>
|
|
||||||
</root>
|
|
@ -1,87 +0,0 @@
|
|||||||
namespace WebsiteForPlacingAds
|
|
||||||
{
|
|
||||||
partial class DeleteSubcategoriesForm
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Required designer variable.
|
|
||||||
/// </summary>
|
|
||||||
private System.ComponentModel.IContainer components = null;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Clean up any resources being used.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
|
||||||
protected override void Dispose(bool disposing)
|
|
||||||
{
|
|
||||||
if (disposing && (components != null))
|
|
||||||
{
|
|
||||||
components.Dispose();
|
|
||||||
}
|
|
||||||
base.Dispose(disposing);
|
|
||||||
}
|
|
||||||
|
|
||||||
#region Windows Form Designer generated code
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Required method for Designer support - do not modify
|
|
||||||
/// the contents of this method with the code editor.
|
|
||||||
/// </summary>
|
|
||||||
private void InitializeComponent()
|
|
||||||
{
|
|
||||||
this.comboBoxDeleteSubcategories = new System.Windows.Forms.ComboBox();
|
|
||||||
this.buttonDeleteSubcategory = new System.Windows.Forms.Button();
|
|
||||||
this.label1 = new System.Windows.Forms.Label();
|
|
||||||
this.SuspendLayout();
|
|
||||||
//
|
|
||||||
// comboBoxDeleteSubcategories
|
|
||||||
//
|
|
||||||
this.comboBoxDeleteSubcategories.FormattingEnabled = true;
|
|
||||||
this.comboBoxDeleteSubcategories.Location = new System.Drawing.Point(38, 49);
|
|
||||||
this.comboBoxDeleteSubcategories.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
|
||||||
this.comboBoxDeleteSubcategories.Name = "comboBoxDeleteSubcategories";
|
|
||||||
this.comboBoxDeleteSubcategories.Size = new System.Drawing.Size(367, 23);
|
|
||||||
this.comboBoxDeleteSubcategories.TabIndex = 5;
|
|
||||||
//
|
|
||||||
// buttonDeleteSubcategory
|
|
||||||
//
|
|
||||||
this.buttonDeleteSubcategory.Location = new System.Drawing.Point(135, 86);
|
|
||||||
this.buttonDeleteSubcategory.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
|
||||||
this.buttonDeleteSubcategory.Name = "buttonDeleteSubcategory";
|
|
||||||
this.buttonDeleteSubcategory.Size = new System.Drawing.Size(163, 28);
|
|
||||||
this.buttonDeleteSubcategory.TabIndex = 4;
|
|
||||||
this.buttonDeleteSubcategory.Text = "Удалить";
|
|
||||||
this.buttonDeleteSubcategory.UseVisualStyleBackColor = true;
|
|
||||||
this.buttonDeleteSubcategory.Click += new System.EventHandler(this.buttonDeleteSubcategory_Click_1);
|
|
||||||
//
|
|
||||||
// label1
|
|
||||||
//
|
|
||||||
this.label1.AutoSize = true;
|
|
||||||
this.label1.Location = new System.Drawing.Point(73, 17);
|
|
||||||
this.label1.Name = "label1";
|
|
||||||
this.label1.Size = new System.Drawing.Size(282, 15);
|
|
||||||
this.label1.TabIndex = 3;
|
|
||||||
this.label1.Text = "Выберите подкатегорию, которую хотите удалить";
|
|
||||||
//
|
|
||||||
// DeleteSubcategoriesForm
|
|
||||||
//
|
|
||||||
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
|
||||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
|
||||||
this.ClientSize = new System.Drawing.Size(442, 131);
|
|
||||||
this.Controls.Add(this.comboBoxDeleteSubcategories);
|
|
||||||
this.Controls.Add(this.buttonDeleteSubcategory);
|
|
||||||
this.Controls.Add(this.label1);
|
|
||||||
this.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
|
||||||
this.Name = "DeleteSubcategoriesForm";
|
|
||||||
this.Text = "Удалить подкатегорию";
|
|
||||||
this.ResumeLayout(false);
|
|
||||||
this.PerformLayout();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
private ComboBox comboBoxDeleteSubcategories;
|
|
||||||
private Button buttonDeleteSubcategory;
|
|
||||||
private Label label1;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,61 +0,0 @@
|
|||||||
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 WebsiteForPlacingAds
|
|
||||||
{
|
|
||||||
public partial class DeleteSubcategoriesForm : Form
|
|
||||||
{
|
|
||||||
AbstractManagmentDatabase managmentDatabase;
|
|
||||||
private int setval_seq;
|
|
||||||
public DeleteSubcategoriesForm(AbstractManagmentDatabase managmentDatabase)
|
|
||||||
{
|
|
||||||
InitializeComponent();
|
|
||||||
this.managmentDatabase = managmentDatabase;
|
|
||||||
LoadData();
|
|
||||||
}
|
|
||||||
public void LoadData()
|
|
||||||
{
|
|
||||||
comboBoxDeleteSubcategories.Items.Clear();
|
|
||||||
DataTable result = managmentDatabase.getAllEntry("Subcategories");
|
|
||||||
setval_seq = result.Rows.Count;
|
|
||||||
string Subcategories = "";
|
|
||||||
for (int i = 0; i < result.Rows.Count; i++)
|
|
||||||
{
|
|
||||||
setval_seq = Math.Max(Convert.ToInt32(managmentDatabase.getRowTableById(result, "subcategories_id", i)), setval_seq);
|
|
||||||
Subcategories = managmentDatabase.getRowTableById(result, "subcategories_id", i).ToString() + " | " +
|
|
||||||
managmentDatabase.getRowTableById(result, "name", i).ToString() + "\n";
|
|
||||||
comboBoxDeleteSubcategories.Items.Add(Subcategories);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void buttonDeleteSubcategory_Click_1(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
string[] subcategories = comboBoxDeleteSubcategories.SelectedItem.ToString().Split("|");
|
|
||||||
string subcategory_id = subcategories[0].Trim();
|
|
||||||
try
|
|
||||||
{
|
|
||||||
DateTime start = DateTime.Now;
|
|
||||||
|
|
||||||
managmentDatabase.deleteEntry("subcategories", int.Parse(subcategory_id));
|
|
||||||
LoadData();
|
|
||||||
if (setval_seq > 0) managmentDatabase.reduceSeq("seq_subcategories", setval_seq);
|
|
||||||
MessageBox.Show("Удалено!");
|
|
||||||
|
|
||||||
DateTime end = DateTime.Now;
|
|
||||||
TimeSpan duration = end - start;
|
|
||||||
MessageBox.Show($"Добавлено! Время выполнения: {duration.TotalMilliseconds} мс");
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
MessageBox.Show("Не удалось удалить");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,60 +0,0 @@
|
|||||||
<root>
|
|
||||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
|
||||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
|
||||||
<xsd:element name="root" msdata:IsDataSet="true">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:choice maxOccurs="unbounded">
|
|
||||||
<xsd:element name="metadata">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
|
||||||
<xsd:attribute name="type" type="xsd:string" />
|
|
||||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
|
||||||
<xsd:attribute ref="xml:space" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="assembly">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:attribute name="alias" type="xsd:string" />
|
|
||||||
<xsd:attribute name="name" type="xsd:string" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="data">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
|
||||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
|
||||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
|
||||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
|
||||||
<xsd:attribute ref="xml:space" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="resheader">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
</xsd:choice>
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
</xsd:schema>
|
|
||||||
<resheader name="resmimetype">
|
|
||||||
<value>text/microsoft-resx</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="version">
|
|
||||||
<value>2.0</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="reader">
|
|
||||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="writer">
|
|
||||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
|
||||||
</resheader>
|
|
||||||
</root>
|
|
@ -1,75 +0,0 @@
|
|||||||
namespace WebsiteForPlacingAds
|
|
||||||
{
|
|
||||||
partial class ListSubcategoriesForm
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Required designer variable.
|
|
||||||
/// </summary>
|
|
||||||
private System.ComponentModel.IContainer components = null;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Clean up any resources being used.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
|
||||||
protected override void Dispose(bool disposing)
|
|
||||||
{
|
|
||||||
if (disposing && (components != null))
|
|
||||||
{
|
|
||||||
components.Dispose();
|
|
||||||
}
|
|
||||||
base.Dispose(disposing);
|
|
||||||
}
|
|
||||||
|
|
||||||
#region Windows Form Designer generated code
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Required method for Designer support - do not modify
|
|
||||||
/// the contents of this method with the code editor.
|
|
||||||
/// </summary>
|
|
||||||
private void InitializeComponent()
|
|
||||||
{
|
|
||||||
this.label1 = new System.Windows.Forms.Label();
|
|
||||||
this.labelListSubcategories = new System.Windows.Forms.Label();
|
|
||||||
this.SuspendLayout();
|
|
||||||
//
|
|
||||||
// label1
|
|
||||||
//
|
|
||||||
this.label1.AutoSize = true;
|
|
||||||
this.label1.BackColor = System.Drawing.SystemColors.Control;
|
|
||||||
this.label1.Font = new System.Drawing.Font("Segoe UI", 11F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
|
|
||||||
this.label1.Location = new System.Drawing.Point(10, 7);
|
|
||||||
this.label1.Name = "label1";
|
|
||||||
this.label1.Size = new System.Drawing.Size(160, 20);
|
|
||||||
this.label1.TabIndex = 0;
|
|
||||||
this.label1.Text = "Список подкатегорий";
|
|
||||||
//
|
|
||||||
// labelListSubcategories
|
|
||||||
//
|
|
||||||
this.labelListSubcategories.AutoSize = true;
|
|
||||||
this.labelListSubcategories.Font = new System.Drawing.Font("Segoe UI", 10F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
|
|
||||||
this.labelListSubcategories.Location = new System.Drawing.Point(10, 35);
|
|
||||||
this.labelListSubcategories.Name = "labelListSubcategories";
|
|
||||||
this.labelListSubcategories.Size = new System.Drawing.Size(0, 19);
|
|
||||||
this.labelListSubcategories.TabIndex = 1;
|
|
||||||
//
|
|
||||||
// ListSubcategoriesForm
|
|
||||||
//
|
|
||||||
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
|
||||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
|
||||||
this.ClientSize = new System.Drawing.Size(700, 338);
|
|
||||||
this.Controls.Add(this.labelListSubcategories);
|
|
||||||
this.Controls.Add(this.label1);
|
|
||||||
this.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
|
||||||
this.Name = "ListSubcategoriesForm";
|
|
||||||
this.Text = "Список подкатегорий";
|
|
||||||
this.ResumeLayout(false);
|
|
||||||
this.PerformLayout();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
private Label label1;
|
|
||||||
private Label labelListSubcategories;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,42 +0,0 @@
|
|||||||
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 System.Windows.Forms.VisualStyles;
|
|
||||||
|
|
||||||
namespace WebsiteForPlacingAds
|
|
||||||
{
|
|
||||||
public partial class ListSubcategoriesForm : Form
|
|
||||||
{
|
|
||||||
AbstractManagmentDatabase managmentDatabase;
|
|
||||||
public ListSubcategoriesForm(AbstractManagmentDatabase managmentDatabase)
|
|
||||||
{
|
|
||||||
InitializeComponent();
|
|
||||||
this.managmentDatabase = managmentDatabase;
|
|
||||||
LoadData();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void LoadData()
|
|
||||||
{
|
|
||||||
DateTime start = DateTime.Now;
|
|
||||||
|
|
||||||
DataTable result = managmentDatabase.getAllEntry("Subcategories");
|
|
||||||
string listSubcategories = "";
|
|
||||||
for (int i = 0; i < result.Rows.Count; i++)
|
|
||||||
{
|
|
||||||
listSubcategories += managmentDatabase.getRowTableById(result, "subcategories_id", i).ToString() + " | " +
|
|
||||||
managmentDatabase.getRowTableById(result, "name", i).ToString() + "\n";
|
|
||||||
}
|
|
||||||
labelListSubcategories.Text = listSubcategories;
|
|
||||||
|
|
||||||
DateTime end = DateTime.Now;
|
|
||||||
TimeSpan duration = end - start;
|
|
||||||
MessageBox.Show($"Добавлено! Время выполнения: {duration.TotalMilliseconds} мс");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user