diff --git a/WebsiteForPlacingAds/WebsiteForPlacingAds/AbstractDatabase.cs b/WebsiteForPlacingAds/WebsiteForPlacingAds/AbstractDatabase.cs new file mode 100644 index 0000000..d14cb69 --- /dev/null +++ b/WebsiteForPlacingAds/WebsiteForPlacingAds/AbstractDatabase.cs @@ -0,0 +1,39 @@ +using Npgsql; +using System; +using System.Collections.Generic; +using System.Data; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace WebsiteForPlacingAds +{ + public abstract class AbstractDatabase + { + private NpgsqlConnection connection; + + public AbstractDatabase(string connectionString) + { + connection = new NpgsqlConnection(connectionString); + } + + protected 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; + } + + protected void ExecuteNonQuery(string query) + { + connection.Open(); + NpgsqlCommand command = new NpgsqlCommand(query, connection); + command.ExecuteNonQuery(); + connection.Close(); + } + } +} diff --git a/WebsiteForPlacingAds/WebsiteForPlacingAds/ConnectionSingleton.cs b/WebsiteForPlacingAds/WebsiteForPlacingAds/ConnectionSingleton.cs new file mode 100644 index 0000000..7cf0f10 --- /dev/null +++ b/WebsiteForPlacingAds/WebsiteForPlacingAds/ConnectionSingleton.cs @@ -0,0 +1,23 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace WebsiteForPlacingAds +{ + public class ConnectionSingleton + { + private static PostgreSqlDatabase postgreSqlDatabase; + + private ConnectionSingleton() + { } + + public static PostgreSqlDatabase getPostgreSqlDatabase(string connectionString) + { + if (postgreSqlDatabase == null) + postgreSqlDatabase = new PostgreSqlDatabase(connectionString); + return postgreSqlDatabase; + } + } +} diff --git a/WebsiteForPlacingAds/WebsiteForPlacingAds/CreateAdsForm.Designer.cs b/WebsiteForPlacingAds/WebsiteForPlacingAds/CreateAdsForm.Designer.cs new file mode 100644 index 0000000..74f7a6f --- /dev/null +++ b/WebsiteForPlacingAds/WebsiteForPlacingAds/CreateAdsForm.Designer.cs @@ -0,0 +1,218 @@ +namespace WebsiteForPlacingAds +{ + partial class CreateAdsForm + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.button1 = new System.Windows.Forms.Button(); + this.labelHeading = new System.Windows.Forms.Label(); + this.textBoxHeading = new System.Windows.Forms.TextBox(); + this.textBoxPrice = new System.Windows.Forms.TextBox(); + this.labelPrice = new System.Windows.Forms.Label(); + this.textBoxDate = new System.Windows.Forms.TextBox(); + this.labelDate = new System.Windows.Forms.Label(); + this.labelSubcategory = new System.Windows.Forms.Label(); + this.labelCategory = new System.Windows.Forms.Label(); + this.textBoxStatus = new System.Windows.Forms.TextBox(); + this.labelStatus = new System.Windows.Forms.Label(); + this.labelClient = new System.Windows.Forms.Label(); + this.comboBoxSubcategory = new System.Windows.Forms.ComboBox(); + this.comboBoxCategory = new System.Windows.Forms.ComboBox(); + this.comboBoxClient = new System.Windows.Forms.ComboBox(); + this.SuspendLayout(); + // + // button1 + // + this.button1.Location = new System.Drawing.Point(49, 456); + this.button1.Name = "button1"; + this.button1.Size = new System.Drawing.Size(125, 67); + this.button1.TabIndex = 0; + this.button1.Text = "Разместить объявление"; + this.button1.UseVisualStyleBackColor = true; + this.button1.Click += new System.EventHandler(this.button1_Click); + // + // labelHeading + // + this.labelHeading.AutoSize = true; + this.labelHeading.Location = new System.Drawing.Point(49, 11); + this.labelHeading.Name = "labelHeading"; + this.labelHeading.Size = new System.Drawing.Size(81, 20); + this.labelHeading.TabIndex = 1; + this.labelHeading.Text = "Заголовок"; + // + // textBoxHeading + // + this.textBoxHeading.Location = new System.Drawing.Point(49, 34); + this.textBoxHeading.Name = "textBoxHeading"; + this.textBoxHeading.Size = new System.Drawing.Size(125, 27); + this.textBoxHeading.TabIndex = 2; + // + // textBoxPrice + // + this.textBoxPrice.Location = new System.Drawing.Point(49, 96); + this.textBoxPrice.Name = "textBoxPrice"; + this.textBoxPrice.Size = new System.Drawing.Size(125, 27); + this.textBoxPrice.TabIndex = 4; + // + // labelPrice + // + this.labelPrice.AutoSize = true; + this.labelPrice.Location = new System.Drawing.Point(49, 73); + this.labelPrice.Name = "labelPrice"; + this.labelPrice.Size = new System.Drawing.Size(45, 20); + this.labelPrice.TabIndex = 3; + this.labelPrice.Text = "Цена"; + // + // textBoxDate + // + this.textBoxDate.Location = new System.Drawing.Point(49, 158); + this.textBoxDate.Name = "textBoxDate"; + this.textBoxDate.Size = new System.Drawing.Size(125, 27); + this.textBoxDate.TabIndex = 6; + // + // labelDate + // + this.labelDate.AutoSize = true; + this.labelDate.Location = new System.Drawing.Point(49, 135); + this.labelDate.Name = "labelDate"; + this.labelDate.Size = new System.Drawing.Size(134, 20); + this.labelDate.TabIndex = 5; + this.labelDate.Text = "Дата размещения"; + // + // labelSubcategory + // + this.labelSubcategory.AutoSize = true; + this.labelSubcategory.Location = new System.Drawing.Point(49, 390); + this.labelSubcategory.Name = "labelSubcategory"; + this.labelSubcategory.Size = new System.Drawing.Size(107, 20); + this.labelSubcategory.TabIndex = 11; + this.labelSubcategory.Text = "Подкатегория"; + // + // labelCategory + // + this.labelCategory.AutoSize = true; + this.labelCategory.Location = new System.Drawing.Point(49, 328); + this.labelCategory.Name = "labelCategory"; + this.labelCategory.Size = new System.Drawing.Size(81, 20); + this.labelCategory.TabIndex = 9; + this.labelCategory.Text = "Категория"; + // + // textBoxStatus + // + this.textBoxStatus.Location = new System.Drawing.Point(49, 221); + this.textBoxStatus.Name = "textBoxStatus"; + this.textBoxStatus.Size = new System.Drawing.Size(125, 27); + this.textBoxStatus.TabIndex = 8; + // + // labelStatus + // + this.labelStatus.AutoSize = true; + this.labelStatus.Location = new System.Drawing.Point(49, 198); + this.labelStatus.Name = "labelStatus"; + this.labelStatus.Size = new System.Drawing.Size(52, 20); + this.labelStatus.TabIndex = 7; + this.labelStatus.Text = "Статус"; + // + // labelClient + // + this.labelClient.AutoSize = true; + this.labelClient.Location = new System.Drawing.Point(49, 261); + this.labelClient.Name = "labelClient"; + this.labelClient.Size = new System.Drawing.Size(58, 20); + this.labelClient.TabIndex = 13; + this.labelClient.Text = "Клиент"; + // + // comboBoxSubcategory + // + this.comboBoxSubcategory.FormattingEnabled = true; + this.comboBoxSubcategory.Location = new System.Drawing.Point(49, 413); + this.comboBoxSubcategory.Name = "comboBoxSubcategory"; + this.comboBoxSubcategory.Size = new System.Drawing.Size(125, 28); + this.comboBoxSubcategory.TabIndex = 15; + // + // comboBoxCategory + // + this.comboBoxCategory.FormattingEnabled = true; + this.comboBoxCategory.Location = new System.Drawing.Point(49, 351); + this.comboBoxCategory.Name = "comboBoxCategory"; + this.comboBoxCategory.Size = new System.Drawing.Size(125, 28); + this.comboBoxCategory.TabIndex = 16; + // + // comboBoxClient + // + this.comboBoxClient.FormattingEnabled = true; + this.comboBoxClient.Location = new System.Drawing.Point(49, 284); + this.comboBoxClient.Name = "comboBoxClient"; + this.comboBoxClient.Size = new System.Drawing.Size(125, 28); + this.comboBoxClient.TabIndex = 17; + // + // CreateAdsForm + // + this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(228, 558); + this.Controls.Add(this.comboBoxClient); + this.Controls.Add(this.comboBoxCategory); + this.Controls.Add(this.comboBoxSubcategory); + this.Controls.Add(this.labelClient); + this.Controls.Add(this.labelSubcategory); + this.Controls.Add(this.labelCategory); + this.Controls.Add(this.textBoxStatus); + this.Controls.Add(this.labelStatus); + this.Controls.Add(this.textBoxDate); + this.Controls.Add(this.labelDate); + this.Controls.Add(this.textBoxPrice); + this.Controls.Add(this.labelPrice); + this.Controls.Add(this.textBoxHeading); + this.Controls.Add(this.labelHeading); + this.Controls.Add(this.button1); + this.Name = "CreateAdsForm"; + this.Text = "Объявления"; + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private Button button1; + 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; + } +} \ No newline at end of file diff --git a/WebsiteForPlacingAds/WebsiteForPlacingAds/CreateAdsForm.cs b/WebsiteForPlacingAds/WebsiteForPlacingAds/CreateAdsForm.cs new file mode 100644 index 0000000..39784da --- /dev/null +++ b/WebsiteForPlacingAds/WebsiteForPlacingAds/CreateAdsForm.cs @@ -0,0 +1,49 @@ +using System.Data; + +namespace WebsiteForPlacingAds +{ + public partial class CreateAdsForm : Form + { + PostgreSqlDatabase psd; + public CreateAdsForm(PostgreSqlDatabase psd) + { + InitializeComponent(); + this.psd = psd; + FillComboBox(); + } + + private void button1_Click(object sender, EventArgs e) + { + string[] client = comboBoxClient.SelectedItem.ToString().Split(" "); + string[] category = comboBoxCategory.SelectedItem.ToString().Split(" "); + string[] subcategory = comboBoxSubcategory.SelectedItem.ToString().Split(" "); + + psd.addAd(textBoxHeading.Text, int.Parse(textBoxPrice.Text), textBoxDate.Text, textBoxStatus.Text, int.Parse(client[0]), int.Parse(category[0]), int.Parse(subcategory[0])); + } + + private void FillComboBox() + { + DataTable result = psd.getAllCategories(); + string[] id_names = new string[result.Rows.Count]; + for (int i = 0; i < result.Rows.Count; i++) + { + id_names[i] = result.Rows[i]["category_id"].ToString() + " " + (string)result.Rows[i]["name"]; + comboBoxCategory.Items.Add(id_names[i]); + } + result = psd.getAllSubcategories(); + id_names = new string[result.Rows.Count]; + for (int i = 0; i < result.Rows.Count; i++) + { + id_names[i] = result.Rows[i]["subcategory_id"].ToString() + " " + (string)result.Rows[i]["name"]; + comboBoxSubcategory.Items.Add(id_names[i]); + } + result = psd.getAllClients(); + 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]["client_id"].ToString() + " " +(string)result.Rows[i]["name"] + " " + (string)result.Rows[i]["surname"]; + comboBoxClient.Items.Add(id_names_surnames[i]); + } + } + } +} \ No newline at end of file diff --git a/WebsiteForPlacingAds/WebsiteForPlacingAds/CreateAdsForm.resx b/WebsiteForPlacingAds/WebsiteForPlacingAds/CreateAdsForm.resx new file mode 100644 index 0000000..f298a7b --- /dev/null +++ b/WebsiteForPlacingAds/WebsiteForPlacingAds/CreateAdsForm.resx @@ -0,0 +1,60 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/WebsiteForPlacingAds/WebsiteForPlacingAds/DeleteAdsForm.Designer.cs b/WebsiteForPlacingAds/WebsiteForPlacingAds/DeleteAdsForm.Designer.cs new file mode 100644 index 0000000..977a0f2 --- /dev/null +++ b/WebsiteForPlacingAds/WebsiteForPlacingAds/DeleteAdsForm.Designer.cs @@ -0,0 +1,83 @@ +namespace WebsiteForPlacingAds +{ + partial class DeleteAdsForm + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.label1 = new System.Windows.Forms.Label(); + this.button1 = new System.Windows.Forms.Button(); + this.comboBox1 = new System.Windows.Forms.ComboBox(); + this.SuspendLayout(); + // + // label1 + // + this.label1.AutoSize = true; + this.label1.Location = new System.Drawing.Point(40, 23); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(338, 20); + this.label1.TabIndex = 0; + this.label1.Text = "Выберите объявление, которое хотите удалить"; + // + // button1 + // + this.button1.Location = new System.Drawing.Point(136, 117); + this.button1.Name = "button1"; + this.button1.Size = new System.Drawing.Size(132, 55); + this.button1.TabIndex = 1; + this.button1.Text = "Удалить"; + this.button1.UseVisualStyleBackColor = true; + // + // comboBox1 + // + this.comboBox1.FormattingEnabled = true; + this.comboBox1.Location = new System.Drawing.Point(40, 64); + this.comboBox1.Name = "comboBox1"; + this.comboBox1.Size = new System.Drawing.Size(338, 28); + this.comboBox1.TabIndex = 2; + // + // UpdateAdsForm + // + this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(415, 216); + this.Controls.Add(this.comboBox1); + this.Controls.Add(this.button1); + this.Controls.Add(this.label1); + this.Name = "UpdateAdsForm"; + this.Text = "UpdateAdsForm"; + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private Label label1; + private Button button1; + private ComboBox comboBox1; + } +} \ No newline at end of file diff --git a/WebsiteForPlacingAds/WebsiteForPlacingAds/DeleteAdsForm.cs b/WebsiteForPlacingAds/WebsiteForPlacingAds/DeleteAdsForm.cs new file mode 100644 index 0000000..7a6eaa0 --- /dev/null +++ b/WebsiteForPlacingAds/WebsiteForPlacingAds/DeleteAdsForm.cs @@ -0,0 +1,20 @@ +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 + { + public DeleteAdsForm() + { + InitializeComponent(); + } + } +} diff --git a/WebsiteForPlacingAds/WebsiteForPlacingAds/DeleteAdsForm.resx b/WebsiteForPlacingAds/WebsiteForPlacingAds/DeleteAdsForm.resx new file mode 100644 index 0000000..f298a7b --- /dev/null +++ b/WebsiteForPlacingAds/WebsiteForPlacingAds/DeleteAdsForm.resx @@ -0,0 +1,60 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/WebsiteForPlacingAds/WebsiteForPlacingAds/Form1.cs b/WebsiteForPlacingAds/WebsiteForPlacingAds/Form1.cs deleted file mode 100644 index 1de243e..0000000 --- a/WebsiteForPlacingAds/WebsiteForPlacingAds/Form1.cs +++ /dev/null @@ -1,10 +0,0 @@ -namespace WebsiteForPlacingAds -{ - public partial class Form1 : Form - { - public Form1() - { - InitializeComponent(); - } - } -} \ No newline at end of file diff --git a/WebsiteForPlacingAds/WebsiteForPlacingAds/Form1.resx b/WebsiteForPlacingAds/WebsiteForPlacingAds/Form1.resx deleted file mode 100644 index 1af7de1..0000000 --- a/WebsiteForPlacingAds/WebsiteForPlacingAds/Form1.resx +++ /dev/null @@ -1,120 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - \ No newline at end of file diff --git a/WebsiteForPlacingAds/WebsiteForPlacingAds/ListAdsForm.Designer.cs b/WebsiteForPlacingAds/WebsiteForPlacingAds/ListAdsForm.Designer.cs new file mode 100644 index 0000000..2cd8502 --- /dev/null +++ b/WebsiteForPlacingAds/WebsiteForPlacingAds/ListAdsForm.Designer.cs @@ -0,0 +1,72 @@ +namespace WebsiteForPlacingAds +{ + partial class ListAdsForm + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.label1 = new System.Windows.Forms.Label(); + this.label2 = new System.Windows.Forms.Label(); + 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(149, 20); + this.label1.TabIndex = 0; + this.label1.Text = "Список объявлений"; + // + // label2 + // + this.label2.AutoSize = true; + this.label2.Location = new System.Drawing.Point(12, 47); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(0, 20); + this.label2.TabIndex = 1; + this.label2.Click += new System.EventHandler(this.label2_Click); + // + // 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.label2); + this.Controls.Add(this.label1); + this.Name = "ListAdsForm"; + this.Text = "ListAdsForm"; + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private Label label1; + private Label label2; + } +} \ No newline at end of file diff --git a/WebsiteForPlacingAds/WebsiteForPlacingAds/ListAdsForm.cs b/WebsiteForPlacingAds/WebsiteForPlacingAds/ListAdsForm.cs new file mode 100644 index 0000000..530e4a3 --- /dev/null +++ b/WebsiteForPlacingAds/WebsiteForPlacingAds/ListAdsForm.cs @@ -0,0 +1,26 @@ +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 ListAdsForm : Form + { + public ListAdsForm() + { + InitializeComponent(); + } + + private void label2_Click(object sender, EventArgs e) + { + string s = "Первое объявление\nВторое объявление"; + label2.Text = s; + } + } +} diff --git a/WebsiteForPlacingAds/WebsiteForPlacingAds/ListAdsForm.resx b/WebsiteForPlacingAds/WebsiteForPlacingAds/ListAdsForm.resx new file mode 100644 index 0000000..f298a7b --- /dev/null +++ b/WebsiteForPlacingAds/WebsiteForPlacingAds/ListAdsForm.resx @@ -0,0 +1,60 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/WebsiteForPlacingAds/WebsiteForPlacingAds/MainForm.Designer.cs b/WebsiteForPlacingAds/WebsiteForPlacingAds/MainForm.Designer.cs new file mode 100644 index 0000000..38f65a0 --- /dev/null +++ b/WebsiteForPlacingAds/WebsiteForPlacingAds/MainForm.Designer.cs @@ -0,0 +1,256 @@ +namespace WebsiteForPlacingAds +{ + partial class MainForm + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.menuStrip1 = new System.Windows.Forms.MenuStrip(); + this.клиентыToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.объявленияToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.категорииToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.подкатегорииToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.создатьКлиентаToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.удалитьКлиентаToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.изменитьДанныеКлиентаToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.создатьОбъявлениеToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.списокКлиентвToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.удалитьОбъявлениеToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.изменитьОбъявлениеэToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.списокОбъявленийToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.создатьКатегориюToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.удалитьКатегориюToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.изменитьКатегориюToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.списокКатегорийToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.создатьПодкатеориюToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.удалитьПодкатегориюToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.изменитьПодкатегориюToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.списокПодкатегоийToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.menuStrip1.SuspendLayout(); + this.SuspendLayout(); + // + // menuStrip1 + // + this.menuStrip1.ImageScalingSize = new System.Drawing.Size(20, 20); + this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.клиентыToolStripMenuItem, + this.объявленияToolStripMenuItem, + this.категорииToolStripMenuItem, + this.подкатегорииToolStripMenuItem}); + this.menuStrip1.Location = new System.Drawing.Point(0, 0); + this.menuStrip1.Name = "menuStrip1"; + this.menuStrip1.Size = new System.Drawing.Size(800, 28); + this.menuStrip1.TabIndex = 0; + this.menuStrip1.Text = "menuStrip1"; + // + // клиентыToolStripMenuItem + // + this.клиентыToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.создатьКлиентаToolStripMenuItem, + this.удалитьКлиентаToolStripMenuItem, + this.изменитьДанныеКлиентаToolStripMenuItem, + this.списокКлиентвToolStripMenuItem}); + this.клиентыToolStripMenuItem.Name = "клиентыToolStripMenuItem"; + this.клиентыToolStripMenuItem.Size = new System.Drawing.Size(83, 24); + this.клиентыToolStripMenuItem.Text = "Клиенты"; + // + // объявленияToolStripMenuItem + // + this.объявленияToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.создатьОбъявлениеToolStripMenuItem, + this.удалитьОбъявлениеToolStripMenuItem, + this.изменитьОбъявлениеэToolStripMenuItem, + this.списокОбъявленийToolStripMenuItem}); + this.объявленияToolStripMenuItem.Name = "объявленияToolStripMenuItem"; + this.объявленияToolStripMenuItem.Size = new System.Drawing.Size(110, 24); + this.объявленияToolStripMenuItem.Text = "Объявления"; + // + // категорииToolStripMenuItem + // + this.категорииToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.создатьКатегориюToolStripMenuItem, + this.удалитьКатегориюToolStripMenuItem, + this.изменитьКатегориюToolStripMenuItem, + this.списокКатегорийToolStripMenuItem}); + this.категорииToolStripMenuItem.Name = "категорииToolStripMenuItem"; + this.категорииToolStripMenuItem.Size = new System.Drawing.Size(96, 24); + this.категорииToolStripMenuItem.Text = "Категории"; + // + // подкатегорииToolStripMenuItem + // + this.подкатегорииToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.создатьПодкатеориюToolStripMenuItem, + this.удалитьПодкатегориюToolStripMenuItem, + this.изменитьПодкатегориюToolStripMenuItem, + this.списокПодкатегоийToolStripMenuItem}); + this.подкатегорииToolStripMenuItem.Name = "подкатегорииToolStripMenuItem"; + this.подкатегорииToolStripMenuItem.Size = new System.Drawing.Size(122, 24); + this.подкатегорииToolStripMenuItem.Text = "Подкатегории"; + // + // создатьКлиентаToolStripMenuItem + // + this.создатьКлиентаToolStripMenuItem.Name = "создатьКлиентаToolStripMenuItem"; + this.создатьКлиентаToolStripMenuItem.Size = new System.Drawing.Size(277, 26); + this.создатьКлиентаToolStripMenuItem.Text = "Создать клиента"; + // + // удалитьКлиентаToolStripMenuItem + // + this.удалитьКлиентаToolStripMenuItem.Name = "удалитьКлиентаToolStripMenuItem"; + this.удалитьКлиентаToolStripMenuItem.Size = new System.Drawing.Size(277, 26); + this.удалитьКлиентаToolStripMenuItem.Text = "Удалить клиента"; + // + // изменитьДанныеКлиентаToolStripMenuItem + // + this.изменитьДанныеКлиентаToolStripMenuItem.Name = "изменитьДанныеКлиентаToolStripMenuItem"; + this.изменитьДанныеКлиентаToolStripMenuItem.Size = new System.Drawing.Size(277, 26); + this.изменитьДанныеКлиентаToolStripMenuItem.Text = "Изменить данные клиента"; + // + // создатьОбъявлениеToolStripMenuItem + // + this.создатьОбъявлениеToolStripMenuItem.Name = "создатьОбъявлениеToolStripMenuItem"; + this.создатьОбъявлениеToolStripMenuItem.Size = new System.Drawing.Size(250, 26); + this.создатьОбъявлениеToolStripMenuItem.Text = "Создать объявление"; + this.создатьОбъявлениеToolStripMenuItem.Click += new System.EventHandler(this.создатьОбъявлениеToolStripMenuItem_Click); + // + // списокКлиентвToolStripMenuItem + // + this.списокКлиентвToolStripMenuItem.Name = "списокКлиентвToolStripMenuItem"; + this.списокКлиентвToolStripMenuItem.Size = new System.Drawing.Size(277, 26); + this.списокКлиентвToolStripMenuItem.Text = "Список клиентов"; + this.списокКлиентвToolStripMenuItem.Click += new System.EventHandler(this.списокКлиентвToolStripMenuItem_Click); + // + // удалитьОбъявлениеToolStripMenuItem + // + this.удалитьОбъявлениеToolStripMenuItem.Name = "удалитьОбъявлениеToolStripMenuItem"; + this.удалитьОбъявлениеToolStripMenuItem.Size = new System.Drawing.Size(250, 26); + this.удалитьОбъявлениеToolStripMenuItem.Text = "Удалить объявление"; + this.удалитьОбъявлениеToolStripMenuItem.Click += new System.EventHandler(this.удалитьОбъявлениеToolStripMenuItem_Click); + // + // изменитьОбъявлениеэToolStripMenuItem + // + this.изменитьОбъявлениеэToolStripMenuItem.Name = "изменитьОбъявлениеэToolStripMenuItem"; + this.изменитьОбъявлениеэToolStripMenuItem.Size = new System.Drawing.Size(250, 26); + this.изменитьОбъявлениеэToolStripMenuItem.Text = "Изменить объявление"; + this.изменитьОбъявлениеэToolStripMenuItem.Click += new System.EventHandler(this.изменитьОбъявлениеэToolStripMenuItem_Click); + // + // списокОбъявленийToolStripMenuItem + // + this.списокОбъявленийToolStripMenuItem.Name = "списокОбъявленийToolStripMenuItem"; + this.списокОбъявленийToolStripMenuItem.Size = new System.Drawing.Size(250, 26); + this.списокОбъявленийToolStripMenuItem.Text = "Список объявлений"; + this.списокОбъявленийToolStripMenuItem.Click += new System.EventHandler(this.списокОбъявленийToolStripMenuItem_Click); + // + // создатьКатегориюToolStripMenuItem + // + this.создатьКатегориюToolStripMenuItem.Name = "создатьКатегориюToolStripMenuItem"; + this.создатьКатегориюToolStripMenuItem.Size = new System.Drawing.Size(239, 26); + this.создатьКатегориюToolStripMenuItem.Text = "Создать категорию"; + this.создатьКатегориюToolStripMenuItem.Click += new System.EventHandler(this.создатьКатегориюToolStripMenuItem_Click); + // + // удалитьКатегориюToolStripMenuItem + // + this.удалитьКатегориюToolStripMenuItem.Name = "удалитьКатегориюToolStripMenuItem"; + this.удалитьКатегориюToolStripMenuItem.Size = new System.Drawing.Size(239, 26); + this.удалитьКатегориюToolStripMenuItem.Text = "Удалить категорию"; + this.удалитьКатегориюToolStripMenuItem.Click += new System.EventHandler(this.удалитьКатегориюToolStripMenuItem_Click); + // + // изменитьКатегориюToolStripMenuItem + // + this.изменитьКатегориюToolStripMenuItem.Name = "изменитьКатегориюToolStripMenuItem"; + this.изменитьКатегориюToolStripMenuItem.Size = new System.Drawing.Size(239, 26); + this.изменитьКатегориюToolStripMenuItem.Text = "Изменить категорию"; + // + // списокКатегорийToolStripMenuItem + // + this.списокКатегорийToolStripMenuItem.Name = "списокКатегорийToolStripMenuItem"; + this.списокКатегорийToolStripMenuItem.Size = new System.Drawing.Size(239, 26); + this.списокКатегорийToolStripMenuItem.Text = "Список категорий"; + // + // создатьПодкатеориюToolStripMenuItem + // + this.создатьПодкатеориюToolStripMenuItem.Name = "создатьПодкатеориюToolStripMenuItem"; + this.создатьПодкатеориюToolStripMenuItem.Size = new System.Drawing.Size(265, 26); + this.создатьПодкатеориюToolStripMenuItem.Text = "Создать подкатегорию"; + // + // удалитьПодкатегориюToolStripMenuItem + // + this.удалитьПодкатегориюToolStripMenuItem.Name = "удалитьПодкатегориюToolStripMenuItem"; + this.удалитьПодкатегориюToolStripMenuItem.Size = new System.Drawing.Size(265, 26); + this.удалитьПодкатегориюToolStripMenuItem.Text = "Удалить подкатегорию"; + // + // изменитьПодкатегориюToolStripMenuItem + // + this.изменитьПодкатегориюToolStripMenuItem.Name = "изменитьПодкатегориюToolStripMenuItem"; + this.изменитьПодкатегориюToolStripMenuItem.Size = new System.Drawing.Size(265, 26); + this.изменитьПодкатегориюToolStripMenuItem.Text = "Изменить подкатегорию"; + // + // списокПодкатегоийToolStripMenuItem + // + this.списокПодкатегоийToolStripMenuItem.Name = "списокПодкатегоийToolStripMenuItem"; + this.списокПодкатегоийToolStripMenuItem.Size = new System.Drawing.Size(265, 26); + this.списокПодкатегоийToolStripMenuItem.Text = "Список подкатегорий"; + // + // MainForm + // + 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.menuStrip1); + this.MainMenuStrip = this.menuStrip1; + this.Name = "MainForm"; + this.Text = "MainForm"; + this.menuStrip1.ResumeLayout(false); + this.menuStrip1.PerformLayout(); + this.ResumeLayout(false); + this.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; + } +} \ No newline at end of file diff --git a/WebsiteForPlacingAds/WebsiteForPlacingAds/MainForm.cs b/WebsiteForPlacingAds/WebsiteForPlacingAds/MainForm.cs new file mode 100644 index 0000000..7190b94 --- /dev/null +++ b/WebsiteForPlacingAds/WebsiteForPlacingAds/MainForm.cs @@ -0,0 +1,61 @@ +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 + { + PostgreSqlDatabase psd; + public MainForm() + { + InitializeComponent(); + psd = new PostgreSqlDatabase("Server=localhost;Port=5432;User Id=postgres;Password=aswdqq;Database=alina_refactor;"); + } + + private void списокКлиентвToolStripMenuItem_Click(object sender, EventArgs e) + { + + } + + private void создатьКатегориюToolStripMenuItem_Click(object sender, EventArgs e) + { + + } + + private void удалитьКатегориюToolStripMenuItem_Click(object sender, EventArgs e) + { + + } + + private void создатьОбъявлениеToolStripMenuItem_Click(object sender, EventArgs e) + { + CreateAdsForm caf = new CreateAdsForm(psd); + caf.Show(); + } + + private void удалитьОбъявлениеToolStripMenuItem_Click(object sender, EventArgs e) + { + UpdateAdsForm daf = new UpdateAdsForm(); + daf.Show(); + } + + private void изменитьОбъявлениеэToolStripMenuItem_Click(object sender, EventArgs e) + { + DeleteAdsForm uaf = new DeleteAdsForm(); + uaf.Show(); + } + + private void списокОбъявленийToolStripMenuItem_Click(object sender, EventArgs e) + { + ListAdsForm laf = new ListAdsForm(); + laf.Show(); + } + } +} diff --git a/WebsiteForPlacingAds/WebsiteForPlacingAds/MainForm.resx b/WebsiteForPlacingAds/WebsiteForPlacingAds/MainForm.resx new file mode 100644 index 0000000..938108a --- /dev/null +++ b/WebsiteForPlacingAds/WebsiteForPlacingAds/MainForm.resx @@ -0,0 +1,63 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 17, 17 + + \ No newline at end of file diff --git a/WebsiteForPlacingAds/WebsiteForPlacingAds/PostgreSqlDatabase.cs b/WebsiteForPlacingAds/WebsiteForPlacingAds/PostgreSqlDatabase.cs new file mode 100644 index 0000000..272d0f5 --- /dev/null +++ b/WebsiteForPlacingAds/WebsiteForPlacingAds/PostgreSqlDatabase.cs @@ -0,0 +1,62 @@ +using System; +using System.Collections.Generic; +using System.Data; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace WebsiteForPlacingAds +{ + public class PostgreSqlDatabase : AbstractDatabase + { + public PostgreSqlDatabase(string connectionString) : base(connectionString) + { + } + + public void addAd(string heading, int price, string date, string status, int id_client, int id_category, int id_subcategory) + { + string query = String.Format("INSERT INTO ads VALUES (nextval('seq_ads'), '{0}', {1}, '{2}', '{3}', {4}, {5}, {6})", heading, price, date, status, id_client, id_category, id_subcategory); + ExecuteNonQuery(query); + } + public void addClient(string name, string surname, string patronymic, string email, string phone_number, string registration_date, int client_rating) + { + string query = String.Format($"INSERT INTO clients VALUES (nextval('seq_clients'), {name}', '{surname}', '{patronymic}', '{email}', '{phone_number}', '{registration_date}', '{client_rating}')"); + ExecuteNonQuery(query); + } + public void addClientsRating(int number_of_reviews, int number_of_sales, int number_of_subscribers, float average_rating) + { + string query = String.Format($"INSERT INTO clients_rating VALUES (nextval('seq_user_rating'), {number_of_reviews}', '{number_of_sales}', '{number_of_subscribers}', '{average_rating}')"); + ExecuteNonQuery(query); + } + public void addSubcategory(string name) + { + string query = String.Format($"INSERT INTO subcategories VALUES (nextval('seq_subcategory'), {name}')"); + ExecuteNonQuery(query); + } + public void addCategory(string name) + { + string query = String.Format($"INSERT INTO categories VALUES (nextval('seq_category'), {name}')"); + ExecuteNonQuery(query); + } + public DataTable getAllCategories() + { + string query = "SELECT category_id, name FROM categories"; + return ExecuteQuery(query); + } + public DataTable getAllSubcategories() + { + string query = "SELECT subcategory_id, name FROM subcategories"; + return ExecuteQuery(query); + } + public DataTable getAllClients() + { + string query = "SELECT client_id, name, surname FROM clients"; + return ExecuteQuery(query); + } + public DataTable getClient(int id_client) + { + string query = $"SELECT * FROM clients where id = {id_client}"; + return ExecuteQuery(query); + } + } +} diff --git a/WebsiteForPlacingAds/WebsiteForPlacingAds/Program.cs b/WebsiteForPlacingAds/WebsiteForPlacingAds/Program.cs index 6679ef6..4a9f366 100644 --- a/WebsiteForPlacingAds/WebsiteForPlacingAds/Program.cs +++ b/WebsiteForPlacingAds/WebsiteForPlacingAds/Program.cs @@ -11,7 +11,7 @@ namespace WebsiteForPlacingAds // To customize application configuration such as set high DPI settings or default font, // see https://aka.ms/applicationconfiguration. ApplicationConfiguration.Initialize(); - Application.Run(new Form1()); + Application.Run(new MainForm()); } } } \ No newline at end of file diff --git a/WebsiteForPlacingAds/WebsiteForPlacingAds/Form1.Designer.cs b/WebsiteForPlacingAds/WebsiteForPlacingAds/UpdateAdsForm.Designer.cs similarity index 76% rename from WebsiteForPlacingAds/WebsiteForPlacingAds/Form1.Designer.cs rename to WebsiteForPlacingAds/WebsiteForPlacingAds/UpdateAdsForm.Designer.cs index 24fbf75..e497e06 100644 --- a/WebsiteForPlacingAds/WebsiteForPlacingAds/Form1.Designer.cs +++ b/WebsiteForPlacingAds/WebsiteForPlacingAds/UpdateAdsForm.Designer.cs @@ -1,14 +1,14 @@ namespace WebsiteForPlacingAds { - partial class Form1 + partial class UpdateAdsForm { /// - /// Required designer variable. + /// Required designer variable. /// private System.ComponentModel.IContainer components = null; /// - /// Clean up any resources being used. + /// Clean up any resources being used. /// /// true if managed resources should be disposed; otherwise, false. protected override void Dispose(bool disposing) @@ -23,15 +23,15 @@ #region Windows Form Designer generated code /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. /// private void InitializeComponent() { this.components = new System.ComponentModel.Container(); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(800, 450); - this.Text = "Form1"; + this.Text = "DeleteAdsForm"; } #endregion diff --git a/WebsiteForPlacingAds/WebsiteForPlacingAds/UpdateAdsForm.cs b/WebsiteForPlacingAds/WebsiteForPlacingAds/UpdateAdsForm.cs new file mode 100644 index 0000000..bbd7aa6 --- /dev/null +++ b/WebsiteForPlacingAds/WebsiteForPlacingAds/UpdateAdsForm.cs @@ -0,0 +1,20 @@ +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 + { + public UpdateAdsForm() + { + InitializeComponent(); + } + } +} diff --git a/WebsiteForPlacingAds/WebsiteForPlacingAds/UpdateAdsForm.resx b/WebsiteForPlacingAds/WebsiteForPlacingAds/UpdateAdsForm.resx new file mode 100644 index 0000000..f298a7b --- /dev/null +++ b/WebsiteForPlacingAds/WebsiteForPlacingAds/UpdateAdsForm.resx @@ -0,0 +1,60 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/WebsiteForPlacingAds/WebsiteForPlacingAds/WebsiteForPlacingAds.csproj b/WebsiteForPlacingAds/WebsiteForPlacingAds/WebsiteForPlacingAds.csproj index b57c89e..9acf6fb 100644 --- a/WebsiteForPlacingAds/WebsiteForPlacingAds/WebsiteForPlacingAds.csproj +++ b/WebsiteForPlacingAds/WebsiteForPlacingAds/WebsiteForPlacingAds.csproj @@ -8,4 +8,8 @@ enable + + + + \ No newline at end of file