Реализована работа со всеми сущностями

This commit is contained in:
Алина Батылкина 2023-03-29 23:06:23 +04:00
parent 4f5adc07dc
commit 4d16f07d68
54 changed files with 3004 additions and 175 deletions

View File

@ -4,11 +4,11 @@ namespace WebsiteForPlacingAds
{ {
public partial class CreateAdsForm : Form public partial class CreateAdsForm : Form
{ {
PostgreSqlDatabase psd; IDatabaseLogic databaseLogic;
public CreateAdsForm(PostgreSqlDatabase psd) public CreateAdsForm(IDatabaseLogic databaseLogic)
{ {
InitializeComponent(); InitializeComponent();
this.psd = psd; this.databaseLogic = databaseLogic;
LoadData(); LoadData();
} }
@ -26,11 +26,9 @@ namespace WebsiteForPlacingAds
string category_id = category[0]; string category_id = category[0];
string subcategory_id = subcategory[0]; string subcategory_id = subcategory[0];
string query = $"INSERT INTO ads VALUES (nextval('seq_ads'), '{heading}', {price}, '{date}', '{status}', {client_id}, {category_id}, {subcategory_id})";
try try
{ {
databaseLogic.insertInto("ads", $"'{heading}'", price, $"'{date}'", $"'{status}'", client_id, category_id, subcategory_id);
psd.ExecuteNonQuery(query);
MessageBox.Show("Äîáàâëåíî!"); MessageBox.Show("Äîáàâëåíî!");
LoadData(); LoadData();
} }
@ -45,25 +43,25 @@ namespace WebsiteForPlacingAds
comboBoxCategory.Items.Clear(); comboBoxCategory.Items.Clear();
comboBoxSubcategory.Items.Clear(); comboBoxSubcategory.Items.Clear();
comboBoxClient.Items.Clear(); comboBoxClient.Items.Clear();
DataTable result = psd.ExecuteQuery("SELECT * FROM CATEGORIES"); DataTable result = databaseLogic.getAllEntry("CATEGORIES");
string[] id_names = new string[result.Rows.Count]; string[] id_names = new string[result.Rows.Count];
for (int i = 0; i < result.Rows.Count; i++) for (int i = 0; i < result.Rows.Count; i++)
{ {
id_names[i] = result.Rows[i]["categories_id"].ToString() + ". " + (string)result.Rows[i]["name"]; id_names[i] = databaseLogic.getRowTableById(result, "categories_id", i).ToString() + ". " + databaseLogic.getRowTableById(result, "name", i).ToString();
comboBoxCategory.Items.Add(id_names[i]); comboBoxCategory.Items.Add(id_names[i]);
} }
result = psd.ExecuteQuery("SELECT * FROM SUBCATEGORIES"); result = databaseLogic.getAllEntry("SUBCATEGORIES");
id_names = new string[result.Rows.Count]; id_names = new string[result.Rows.Count];
for (int i = 0; i < result.Rows.Count; i++) for (int i = 0; i < result.Rows.Count; i++)
{ {
id_names[i] = result.Rows[i]["subcategories_id"].ToString() + ". " + (string)result.Rows[i]["name"]; id_names[i] = databaseLogic.getRowTableById(result, "subcategories_id", i).ToString() + ". " + databaseLogic.getRowTableById(result, "name", i).ToString();
comboBoxSubcategory.Items.Add(id_names[i]); comboBoxSubcategory.Items.Add(id_names[i]);
} }
result = psd.ExecuteQuery("SELECT * FROM CLIENTS"); result = databaseLogic.getAllEntry("CLIENTS");
string[] id_names_surnames = new string[result.Rows.Count]; string[] id_names_surnames = new string[result.Rows.Count];
for (int i = 0; i < result.Rows.Count; i++) 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(); id_names_surnames[i] = databaseLogic.getRowTableById(result, "clients_id", i).ToString().Trim() + ". " + databaseLogic.getRowTableById(result, "name", i).ToString().Trim() + " " + databaseLogic.getRowTableById(result, "surname", i).ToString().Trim();
comboBoxClient.Items.Add(id_names_surnames[i]); comboBoxClient.Items.Add(id_names_surnames[i]);
} }
} }

View File

@ -12,12 +12,12 @@ namespace WebsiteForPlacingAds
{ {
public partial class DeleteAdsForm : Form public partial class DeleteAdsForm : Form
{ {
PostgreSqlDatabase psd; IDatabaseLogic databaseLogic;
private int setval_seq; private int setval_seq;
public DeleteAdsForm(PostgreSqlDatabase psd) public DeleteAdsForm(IDatabaseLogic databaseLogic)
{ {
InitializeComponent(); InitializeComponent();
this.psd = psd; this.databaseLogic = databaseLogic;
LoadData(); LoadData();
} }
@ -29,9 +29,8 @@ namespace WebsiteForPlacingAds
string query_seq_reduction = $"SELECT setval('seq_ads', {setval_seq - 1});"; string query_seq_reduction = $"SELECT setval('seq_ads', {setval_seq - 1});";
try try
{ {
databaseLogic.deleteEntry("ads", int.Parse(ad_id));
psd.ExecuteNonQuery(query); databaseLogic.reduceSeq("seq_ads", setval_seq);
psd.ExecuteNonQuery(query_seq_reduction);
MessageBox.Show("Удалено!"); MessageBox.Show("Удалено!");
LoadData(); LoadData();
} }
@ -43,19 +42,20 @@ namespace WebsiteForPlacingAds
public void LoadData() public void LoadData()
{ {
comboBoxDeleteAds.Items.Clear(); comboBoxDeleteAds.Items.Clear();
DataTable result = psd.ExecuteQuery("SELECT * FROM ADS"); DataTable result = databaseLogic.getAllEntry("ADS");
setval_seq = result.Rows.Count; setval_seq = result.Rows.Count;
string Ads = ""; string Ads = "";
for (int i = 0; i < result.Rows.Count; i++) for (int i = 0; i < result.Rows.Count; i++)
{ {
Ads = result.Rows[i]["ads_id"].ToString() + " | " + if (i == result.Rows.Count - 1) setval_seq = Convert.ToInt32(databaseLogic.getRowTableById(result, "ads_id", i));
(string)result.Rows[i]["heading"] + " | " + Ads = databaseLogic.getRowTableById(result, "ads_id", i).ToString() + " | " +
result.Rows[i]["price"].ToString() + " | " + databaseLogic.getRowTableById(result, "heading", i).ToString() + " | " +
((DateTime)result.Rows[i]["date_of_placement"]).ToString("d") + " | " + databaseLogic.getRowTableById(result, "price", i).ToString() + " | " +
(string)result.Rows[i]["status"] + " | " + ((DateTime)databaseLogic.getRowTableById(result, "date_of_placement", i)).ToString("dd.MM.yyy") + " | " +
result.Rows[i]["id_client"].ToString() + " | " + databaseLogic.getRowTableById(result, "status", i).ToString() + " | " +
result.Rows[i]["id_category"].ToString() + " | " + databaseLogic.getRowTableById(result, "id_client", i).ToString() + " | " +
result.Rows[i]["id_subcategory"].ToString() + "\n"; databaseLogic.getRowTableById(result, "id_category", i).ToString() + " | " +
databaseLogic.getRowTableById(result, "id_subcategory", i).ToString() + "\n";
comboBoxDeleteAds.Items.Add(Ads); comboBoxDeleteAds.Items.Add(Ads);
} }
} }

View File

@ -0,0 +1,42 @@
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
{
IDatabaseLogic databaseLogic;
public ListAdsForm(IDatabaseLogic databaseLogic)
{
InitializeComponent();
this.databaseLogic = databaseLogic;
LoadData();
}
private void LoadData()
{
DataTable result = databaseLogic.getAllEntry("ADS");
string listAds = "";
for (int i = 0; i < result.Rows.Count; i++)
{
listAds += databaseLogic.getRowTableById(result, "ads_id", i).ToString() + " | " +
databaseLogic.getRowTableById(result, "heading", i).ToString() + " | " +
databaseLogic.getRowTableById(result, "price", i).ToString() + " | " +
((DateTime)databaseLogic.getRowTableById(result, "date_of_placement", i)).ToString("dd.MM.yyy") + " | " +
databaseLogic.getRowTableById(result, "status", i).ToString() + " | " +
databaseLogic.getRowTableById(result, "id_client", i).ToString() + " | " +
databaseLogic.getRowTableById(result, "id_category", i).ToString() + " | " +
databaseLogic.getRowTableById(result, "id_subcategory", i).ToString() + "\n";
}
labelListAds.Text = listAds;
}
}
}

View File

@ -0,0 +1,86 @@
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;
}
}

View File

@ -0,0 +1,29 @@
using System.Data;
namespace WebsiteForPlacingAds
{
public partial class CreateCategoriesForm : Form
{
IDatabaseLogic databaseLogic;
public CreateCategoriesForm(IDatabaseLogic databaseLogic)
{
InitializeComponent();
this.databaseLogic = databaseLogic;
}
private void buttonCreateCategory_Click(object sender, EventArgs e)
{
string name = textBoxName.Text;
try
{
databaseLogic.insertInto("categories", $"'{name}'");
MessageBox.Show("Äîáàâëåíî!");
}
catch (Exception ex)
{
MessageBox.Show("Íå óäàëîñü äîáàâèòü");
}
}
}
}

View File

@ -0,0 +1,60 @@
<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>

View File

@ -0,0 +1,87 @@
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;
}
}

View File

@ -0,0 +1,55 @@
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
{
IDatabaseLogic databaseLogic;
private int setval_seq;
public DeleteCategoriesForm(IDatabaseLogic databaseLogic)
{
InitializeComponent();
this.databaseLogic = databaseLogic;
LoadData();
}
private void buttonDeleteCategory_Click(object sender, EventArgs e)
{
string[] categories = comboBoxDeleteCategories.SelectedItem.ToString().Split("|");
string category_id = categories[0].Trim();
try
{
databaseLogic.deleteEntry("categories", int.Parse(category_id));
LoadData();
databaseLogic.reduceSeq("seq_categories", setval_seq);
MessageBox.Show("Удалено!");
}
catch (Exception ex)
{
MessageBox.Show("Не удалось удалить");
}
}
public void LoadData()
{
comboBoxDeleteCategories.Items.Clear();
DataTable result = databaseLogic.getAllEntry("Categories");
setval_seq = result.Rows.Count;
string Categories = "";
for (int i = 0; i < result.Rows.Count; i++)
{
if (i == result.Rows.Count - 1) setval_seq = Convert.ToInt32(databaseLogic.getRowTableById(result, "categories_id", i));
Categories = databaseLogic.getRowTableById(result, "categories_id", i).ToString() + " | " +
databaseLogic.getRowTableById(result, "name", i).ToString() + "\n";
comboBoxDeleteCategories.Items.Add(Categories);
}
}
}
}

View File

@ -0,0 +1,60 @@
<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>

View File

@ -0,0 +1,75 @@
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;
}
}

View File

@ -0,0 +1,36 @@
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
{
IDatabaseLogic databaseLogic;
public ListCategoriesForm(IDatabaseLogic databaseLogic)
{
InitializeComponent();
this.databaseLogic = databaseLogic;
LoadData();
}
private void LoadData()
{
DataTable result = databaseLogic.getAllEntry("Categories");
string listCategories = "";
for (int i = 0; i < result.Rows.Count; i++)
{
listCategories += databaseLogic.getRowTableById(result, "categories_id", i).ToString() + " | " +
databaseLogic.getRowTableById(result, "name", i).ToString() + "\n";
}
labelListCategories.Text = listCategories;
}
}
}

View File

@ -0,0 +1,60 @@
<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>

View File

@ -0,0 +1,110 @@
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;
}
}

View File

@ -0,0 +1,80 @@
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
{
IDatabaseLogic databaseLogic;
public UpdateCategoriesForm(IDatabaseLogic databaseLogic)
{
InitializeComponent();
this.databaseLogic = databaseLogic;
LoadData();
}
public void LoadData()
{
comboBoxUpdateCategory.Items.Clear();
DataTable result = databaseLogic.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 = databaseLogic.getEntryById("categories", categories_id);
textBoxName.Text = databaseLogic.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 = databaseLogic.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
{
databaseLogic.ExecuteNonQuery(query);
MessageBox.Show("Данные успешно обновлены!");
}
catch (Exception)
{
MessageBox.Show("Данные не обновились");
}
}
}
}

View File

@ -0,0 +1,60 @@
<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>

View File

@ -0,0 +1,224 @@
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.labelRating = 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.textBoxRating = 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 = "Отчество";
//
// labelRating
//
this.labelRating.AutoSize = true;
this.labelRating.Location = new System.Drawing.Point(43, 291);
this.labelRating.Name = "labelRating";
this.labelRating.Size = new System.Drawing.Size(51, 15);
this.labelRating.TabIndex = 11;
this.labelRating.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;
//
// textBoxRating
//
this.textBoxRating.Location = new System.Drawing.Point(43, 308);
this.textBoxRating.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.textBoxRating.Name = "textBoxRating";
this.textBoxRating.Size = new System.Drawing.Size(239, 23);
this.textBoxRating.TabIndex = 16;
//
// 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.textBoxRating);
this.Controls.Add(this.textBoxDate);
this.Controls.Add(this.textBoxPhoneNumber);
this.Controls.Add(this.labelPhoneNumber);
this.Controls.Add(this.labelRating);
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 labelRating;
private Label labelDate;
private TextBox textBoxEmail;
private Label labelEmail;
private Label labelPhoneNumber;
private TextBox textBoxPhoneNumber;
private TextBox textBoxDate;
private TextBox textBoxRating;
}
}

View File

@ -0,0 +1,37 @@
using System.Data;
namespace WebsiteForPlacingAds
{
public partial class CreateClientsForm : Form
{
//PostgreSqlDatabase psd;
IDatabaseLogic databaseLogic;
public CreateClientsForm(IDatabaseLogic databaseLogic)
{
InitializeComponent();
this.databaseLogic = databaseLogic;
}
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;
string rating = textBoxRating.Text;
try
{
if (patronymic != null) databaseLogic.insertInto("clients", $"'{name}'", $"'{surname}'", $"'{patronymic}'", $"'{email}'", $"{phoneNumber}", $"'{date}'", $"{rating}");
else databaseLogic.insertInto("clients", $"'{name}'", $"'{surname}'", $"{patronymic}", $"'{email}'", $"{phoneNumber}", $"'{date}'", $"{rating}");
MessageBox.Show("Äîáàâëåíî!");
}
catch (Exception ex)
{
MessageBox.Show("Íå óäàëîñü äîáàâèòü");
}
}
}
}

View File

@ -0,0 +1,60 @@
<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>

View File

@ -0,0 +1,87 @@
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;
}
}

View File

@ -0,0 +1,63 @@
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
{
IDatabaseLogic databaseLogic;
private int setval_seq;
public DeleteClientsForm(IDatabaseLogic databaseLogic)
{
InitializeComponent();
this.databaseLogic = databaseLogic;
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
{
databaseLogic.deleteEntry("clients", int.Parse(client_id));
LoadData();
databaseLogic.reduceSeq("seq_clients", setval_seq);
MessageBox.Show("Удалено!");
}
catch (Exception ex)
{
MessageBox.Show("Не удалось удалить");
}
}
public void LoadData()
{
comboBoxDeleteClients.Items.Clear();
DataTable result = databaseLogic.getAllEntry("Clients");
setval_seq = result.Rows.Count;
string Clients = "";
for (int i = 0; i < result.Rows.Count; i++)
{
if (i == result.Rows.Count - 1) setval_seq = Convert.ToInt32(databaseLogic.getRowTableById(result, "clients_id", i));
Clients = databaseLogic.getRowTableById(result, "clients_id", i).ToString() + " | " +
databaseLogic.getRowTableById(result, "name", i).ToString() + " | " +
databaseLogic.getRowTableById(result, "surname", i).ToString() + " | " +
databaseLogic.getRowTableById(result, "patronymic", i).ToString() + " | " +
databaseLogic.getRowTableById(result, "email", i).ToString() + " | " +
databaseLogic.getRowTableById(result, "phone_number", i).ToString() + " | " +
((DateTime)databaseLogic.getRowTableById(result, "registration_date", i)).ToString("dd.MM.yyy") + " | " +
databaseLogic.getRowTableById(result, "rating", i).ToString() + "\n";
comboBoxDeleteClients.Items.Add(Clients);
}
}
}
}

View File

@ -0,0 +1,60 @@
<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>

View File

@ -0,0 +1,75 @@
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;
}
}

View File

@ -0,0 +1,42 @@
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
{
IDatabaseLogic databaseLogic;
public ListClientsForm(IDatabaseLogic databaseLogic)
{
InitializeComponent();
this.databaseLogic = databaseLogic;
LoadData();
}
private void LoadData()
{
DataTable result = databaseLogic.getAllEntry("clients");
string listClients = "";
for (int i = 0; i < result.Rows.Count; i++)
{
listClients += databaseLogic.getRowTableById(result, "clients_id", i).ToString() + " | " +
databaseLogic.getRowTableById(result, "name", i).ToString() + " | " +
databaseLogic.getRowTableById(result, "surname", i).ToString() + " | " +
databaseLogic.getRowTableById(result, "patronymic", i).ToString() + " | " +
databaseLogic.getRowTableById(result, "email", i).ToString() + " | " +
databaseLogic.getRowTableById(result, "phone_number", i).ToString() + " | " +
((DateTime)databaseLogic.getRowTableById(result, "registration_date", i)).ToString("dd.MM.yyy") + " | " +
databaseLogic.getRowTableById(result, "rating", i).ToString() + "\n";
}
labelListClients.Text = listClients;
}
}
}

View File

@ -0,0 +1,60 @@
<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>

View File

@ -0,0 +1,248 @@
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.textBoxRating = new System.Windows.Forms.TextBox();
this.textBoxDate = new System.Windows.Forms.TextBox();
this.textBoxPhoneNumber = new System.Windows.Forms.TextBox();
this.labelPhoneNumber = new System.Windows.Forms.Label();
this.labelRating = 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 = "Выберите клиента, которого хотите обновить";
//
// comboBoxUpdateAd
//
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 = "comboBoxUpdateAd";
this.comboBoxUpdateClient.Size = new System.Drawing.Size(377, 23);
this.comboBoxUpdateClient.TabIndex = 34;
this.comboBoxUpdateClient.SelectedIndexChanged += new System.EventHandler(this.comboBoxUpdateClient_SelectedIndexChanged);
//
// textBoxRating
//
this.textBoxRating.Location = new System.Drawing.Point(79, 371);
this.textBoxRating.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.textBoxRating.Name = "textBoxRating";
this.textBoxRating.Size = new System.Drawing.Size(239, 23);
this.textBoxRating.TabIndex = 48;
//
// 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 = "Номер телефона";
//
// labelRating
//
this.labelRating.AutoSize = true;
this.labelRating.Location = new System.Drawing.Point(79, 354);
this.labelRating.Name = "labelRating";
this.labelRating.Size = new System.Drawing.Size(51, 15);
this.labelRating.TabIndex = 44;
this.labelRating.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.textBoxRating);
this.Controls.Add(this.textBoxDate);
this.Controls.Add(this.textBoxPhoneNumber);
this.Controls.Add(this.labelPhoneNumber);
this.Controls.Add(this.labelRating);
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 textBoxRating;
private TextBox textBoxDate;
private TextBox textBoxPhoneNumber;
private Label labelPhoneNumber;
private Label labelRating;
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;
}
}

View File

@ -0,0 +1,110 @@
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
{
IDatabaseLogic databaseLogic;
public UpdateClientsForm(IDatabaseLogic databaseLogic)
{
InitializeComponent();
this.databaseLogic = databaseLogic;
LoadData();
}
public void LoadData()
{
comboBoxUpdateClient.Items.Clear();
DataTable result = databaseLogic.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") + " | " +
result.Rows[i]["rating"].ToString() + "\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 = databaseLogic.getRowTableById("clients", "name", clients_id).ToString();
string oldSurname = databaseLogic.getRowTableById("clients", "surname", clients_id).ToString();
string oldPatronymic = databaseLogic.getRowTableById("clients", "patronymic", clients_id).ToString();
string oldEmail = databaseLogic.getRowTableById("clients", "email", clients_id).ToString();
string oldPhoneNumber = databaseLogic.getRowTableById("clients", "phone_number", clients_id).ToString();
string oldDate = ((DateTime)databaseLogic.getRowTableById("clients", "registration_date", clients_id)).ToString("dd.MM.yyyy");
string oldRating = databaseLogic.getRowTableById("clients", "rating", clients_id).ToString();
string newName = textBoxName.Text;
string newSurname = textBoxSurname.Text;
string newPatronymic = textBoxPatronymic.Text;
string newEmail = textBoxEmail.Text;
string newPhoneNumber = textBoxPhoneNumber.Text;
string newDate = textBoxDate.Text;
string newRating = textBoxRating.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}', ";
query = oldRating == newRating ? query : query + $"rating = {newRating}, ";
if (len != query.Length)
{
query = query.TrimEnd(' ');
query = query.TrimEnd(',');
query += $" WHERE Clients_ID = {clients_id};";
}
try
{
databaseLogic.ExecuteNonQuery(query);
MessageBox.Show("Данные успешно обновлены!");
}
catch (Exception)
{
MessageBox.Show("Данные не обновились");
}
}
public void LoadDataSelectedItem(int clients_id)
{
DataTable result = databaseLogic.getEntryById("clients", clients_id);
textBoxName.Text = databaseLogic.getRowTableById(result, "name", 0).ToString();
textBoxSurname.Text = databaseLogic.getRowTableById(result, "surname", 0).ToString();
textBoxPatronymic.Text = databaseLogic.getRowTableById(result, "patronymic", 0).ToString();
textBoxEmail.Text = databaseLogic.getRowTableById(result, "email", 0).ToString();
textBoxPhoneNumber.Text = databaseLogic.getRowTableById(result, "phone_number", 0).ToString();
textBoxDate.Text = ((DateTime)databaseLogic.getRowTableById(result, "registration_date", 0)).ToString("dd.MM.yyyy");
textBoxRating.Text = databaseLogic.getRowTableById(result, "rating", 0).ToString();
}
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);
}
}
}

View File

@ -0,0 +1,60 @@
<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>

View File

@ -15,12 +15,14 @@ namespace WebsiteForPlacingAds
{ {
this.database = database; this.database = database;
} }
public Object getRowTableById(string tableName, string columnName, int id) public Object getRowTableById(string tableName, string columnName, int id)
{ {
return database.ExecuteQuery($"SELECT {columnName} FROM {tableName} WHERE {tableName}_id = {id}").Rows[0][$"{columnName}"]; return database.ExecuteQuery($"SELECT {columnName} FROM {tableName} WHERE {tableName}_id = {id}").Rows[0][$"{columnName}"];
} }
public Object getRowTableById(DataTable table, string columnName, int i)
{
return table.Rows[i][columnName];
}
public DataTable getEntryById(string tableName, int id) public DataTable getEntryById(string tableName, int id)
{ {
return database.ExecuteQuery($"SELECT * FROM {tableName} WHERE {tableName}_id = {id}"); return database.ExecuteQuery($"SELECT * FROM {tableName} WHERE {tableName}_id = {id}");
@ -37,5 +39,23 @@ namespace WebsiteForPlacingAds
{ {
return database.ExecuteQuery($"SELECT * FROM {tableName}"); return database.ExecuteQuery($"SELECT * FROM {tableName}");
} }
public void insertInto(string tableName, params string[] values)
{
string query = $"INSERT INTO {tableName} VALUES (nextval('seq_{tableName.ToLower()}'), ";
for (int i = 0; i < values.Length; i++)
{
if (i < values.Length - 1) query += $"{values[i]}, ";
else query += $"{values[i]})";
}
database.ExecuteNonQuery(query);
}
public void deleteEntry(string tableName, int id)
{
database.ExecuteNonQuery($"DELETE FROM {tableName} WHERE {tableName}_id = {id}");
}
public void reduceSeq(string seq, int currval)
{
database.ExecuteNonQuery($"SELECT setval('{seq}', {currval});");
}
} }
} }

View File

@ -11,8 +11,12 @@ namespace WebsiteForPlacingAds
{ {
public DataTable getEntryById(string tableName, int id); public DataTable getEntryById(string tableName, int id);
public Object getRowTableById(string tableName, string columnName, int id); public Object getRowTableById(string tableName, string columnName, int id);
public Object getRowTableById(DataTable table, string columnName, int i);
public DataTable ExecuteQuery(string query); public DataTable ExecuteQuery(string query);
public void ExecuteNonQuery(string query); public void ExecuteNonQuery(string query);
DataTable getAllEntry(string tableName); DataTable getAllEntry(string tableName);
public void insertInto(string tableName, params string[] values);
public void deleteEntry(string tableName, int id);
public void reduceSeq(string seq, int currval);
} }
} }

View File

@ -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 ListAdsForm : Form
{
PostgreSqlDatabase psd;
public ListAdsForm(PostgreSqlDatabase psd)
{
InitializeComponent();
this.psd = psd;
LoadData();
}
private void LoadData()
{
DataTable result = psd.ExecuteQuery("SELECT * FROM ADS");
string listAds = "";
for (int i = 0; i < result.Rows.Count; i++)
{
listAds += result.Rows[i]["ads_id"].ToString() + " | " +
(string)result.Rows[i]["heading"] + " | " +
result.Rows[i]["price"].ToString() + " | " +
((DateTime)result.Rows[i]["date_of_placement"]).ToString("d") + " | " +
(string)result.Rows[i]["status"] + " | " +
result.Rows[i]["id_client"].ToString() + " | " +
result.Rows[i]["id_category"].ToString() + " | " +
result.Rows[i]["id_subcategory"].ToString() + "\n";
}
labelListAds.Text = listAds;
}
}
}

View File

@ -30,21 +30,21 @@
{ {
this.menuStrip1 = new System.Windows.Forms.MenuStrip(); 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.списокОбъявлений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();
@ -62,7 +62,8 @@
this.подкатегорииToolStripMenuItem}); this.подкатегорииToolStripMenuItem});
this.menuStrip1.Location = new System.Drawing.Point(0, 0); this.menuStrip1.Location = new System.Drawing.Point(0, 0);
this.menuStrip1.Name = "menuStrip1"; this.menuStrip1.Name = "menuStrip1";
this.menuStrip1.Size = new System.Drawing.Size(800, 28); this.menuStrip1.Padding = new System.Windows.Forms.Padding(5, 2, 0, 2);
this.menuStrip1.Size = new System.Drawing.Size(700, 24);
this.menuStrip1.TabIndex = 0; this.menuStrip1.TabIndex = 0;
this.menuStrip1.Text = "menuStrip1"; this.menuStrip1.Text = "menuStrip1";
// //
@ -74,9 +75,37 @@
this.изменитьДанныеКлиентаToolStripMenuItem, this.изменитьДанныеКлиентаToolStripMenuItem,
this.списокКлиентвToolStripMenuItem}); this.списокКлиентвToolStripMenuItem});
this.клиентыToolStripMenuItem.Name = "клиентыToolStripMenuItem"; this.клиентыToolStripMenuItem.Name = "клиентыToolStripMenuItem";
this.клиентыToolStripMenuItem.Size = new System.Drawing.Size(83, 24); this.клиентыToolStripMenuItem.Size = new System.Drawing.Size(67, 20);
this.клиентыToolStripMenuItem.Text = "Клиенты"; this.клиентыToolStripMenuItem.Text = "Клиенты";
// //
// создатьКлиентаToolStripMenuItem
//
this.создатьКлиентаToolStripMenuItem.Name = "создатьКлиентаToolStripMenuItem";
this.создатьКлиентаToolStripMenuItem.Size = new System.Drawing.Size(219, 22);
this.создатьКлиентаToolStripMenuItem.Text = "Создать клиента";
this.создатьКлиентаToolStripMenuItem.Click += new System.EventHandler(this.создатьКлиентаToolStripMenuItem_Click);
//
// удалитьКлиентаToolStripMenuItem
//
this.удалитьКлиентаToolStripMenuItem.Name = "удалитьКлиентаToolStripMenuItem";
this.удалитьКлиентаToolStripMenuItem.Size = new System.Drawing.Size(219, 22);
this.удалитьКлиентаToolStripMenuItem.Text = "Удалить клиента";
this.удалитьКлиентаToolStripMenuItem.Click += new System.EventHandler(this.удалитьКлиентаToolStripMenuItem_Click);
//
// изменитьДанныеКлиентаToolStripMenuItem
//
this.изменитьДанныеКлиентаToolStripMenuItem.Name = "изменитьДанныеКлиентаToolStripMenuItem";
this.изменитьДанныеКлиентаToolStripMenuItem.Size = new System.Drawing.Size(219, 22);
this.изменитьДанныеКлиентаToolStripMenuItem.Text = "Изменить данные клиента";
this.изменитьДанныеКлиентаToolStripMenuItem.Click += new System.EventHandler(this.изменитьДанныеКлиентаToolStripMenuItem_Click);
//
// списокКлиентвToolStripMenuItem
//
this.списокКлиентвToolStripMenuItem.Name = "списокКлиентвToolStripMenuItem";
this.списокКлиентвToolStripMenuItem.Size = new System.Drawing.Size(219, 22);
this.списокКлиентвToolStripMenuItem.Text = "Список клиентов";
this.списокКлиентвToolStripMenuItem.Click += new System.EventHandler(this.списокКлиентвToolStripMenuItem_Click);
//
// объявленияToolStripMenuItem // объявленияToolStripMenuItem
// //
this.объявленияToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { this.объявленияToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
@ -85,9 +114,37 @@
this.изменитьОбъявлениеэToolStripMenuItem, this.изменитьОбъявлениеэToolStripMenuItem,
this.списокОбъявленийToolStripMenuItem}); this.списокОбъявленийToolStripMenuItem});
this.объявленияToolStripMenuItem.Name = "объявленияToolStripMenuItem"; this.объявленияToolStripMenuItem.Name = "объявленияToolStripMenuItem";
this.объявленияToolStripMenuItem.Size = new System.Drawing.Size(110, 24); this.объявленияToolStripMenuItem.Size = new System.Drawing.Size(87, 20);
this.объявленияToolStripMenuItem.Text = "Объявления"; this.объявленияToolStripMenuItem.Text = "Объявления";
// //
// создатьОбъявлениеToolStripMenuItem
//
this.создатьОбъявлениеToolStripMenuItem.Name = "создатьОбъявлениеToolStripMenuItem";
this.создатьОбъявлениеToolStripMenuItem.Size = new System.Drawing.Size(197, 22);
this.создатьОбъявлениеToolStripMenuItem.Text = "Создать объявление";
this.создатьОбъявлениеToolStripMenuItem.Click += new System.EventHandler(this.создатьОбъявлениеToolStripMenuItem_Click);
//
// удалитьОбъявлениеToolStripMenuItem
//
this.удалитьОбъявлениеToolStripMenuItem.Name = "удалитьОбъявлениеToolStripMenuItem";
this.удалитьОбъявлениеToolStripMenuItem.Size = new System.Drawing.Size(197, 22);
this.удалитьОбъявлениеToolStripMenuItem.Text = "Удалить объявление";
this.удалитьОбъявлениеToolStripMenuItem.Click += new System.EventHandler(this.удалитьОбъявлениеToolStripMenuItem_Click);
//
// изменитьОбъявлениеэToolStripMenuItem
//
this.изменитьОбъявлениеэToolStripMenuItem.Name = "изменитьОбъявлениеэToolStripMenuItem";
this.изменитьОбъявлениеэToolStripMenuItem.Size = new System.Drawing.Size(197, 22);
this.изменитьОбъявлениеэToolStripMenuItem.Text = "Изменить объявление";
this.изменитьОбъявлениеэToolStripMenuItem.Click += new System.EventHandler(this.изменитьОбъявлениеэToolStripMenuItem_Click);
//
// списокОбъявленийToolStripMenuItem
//
this.списокОбъявленийToolStripMenuItem.Name = "списокОбъявленийToolStripMenuItem";
this.списокОбъявленийToolStripMenuItem.Size = new System.Drawing.Size(197, 22);
this.списокОбъявленийToolStripMenuItem.Text = "Список объявлений";
this.списокОбъявленийToolStripMenuItem.Click += new System.EventHandler(this.списокОбъявленийToolStripMenuItem_Click);
//
// категорииToolStripMenuItem // категорииToolStripMenuItem
// //
this.категорииToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { this.категорииToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
@ -96,9 +153,37 @@
this.изменитьКатегориюToolStripMenuItem, this.изменитьКатегориюToolStripMenuItem,
this.списокКатегорийToolStripMenuItem}); this.списокКатегорийToolStripMenuItem});
this.категорииToolStripMenuItem.Name = атегорииToolStripMenuItem"; this.категорииToolStripMenuItem.Name = атегорииToolStripMenuItem";
this.категорииToolStripMenuItem.Size = new System.Drawing.Size(96, 24); this.категорииToolStripMenuItem.Size = new System.Drawing.Size(76, 20);
this.категорииToolStripMenuItem.Text = "Категории"; this.категорииToolStripMenuItem.Text = "Категории";
// //
// создатьКатегориюToolStripMenuItem
//
this.создатьКатегориюToolStripMenuItem.Name = "создатьКатегориюToolStripMenuItem";
this.создатьКатегориюToolStripMenuItem.Size = new System.Drawing.Size(190, 22);
this.создатьКатегориюToolStripMenuItem.Text = "Создать категорию";
this.создатьКатегориюToolStripMenuItem.Click += new System.EventHandler(this.создатьКатегориюToolStripMenuItem_Click);
//
// удалитьКатегориюToolStripMenuItem
//
this.удалитьКатегориюToolStripMenuItem.Name = "удалитьКатегориюToolStripMenuItem";
this.удалитьКатегориюToolStripMenuItem.Size = new System.Drawing.Size(190, 22);
this.удалитьКатегориюToolStripMenuItem.Text = "Удалить категорию";
this.удалитьКатегориюToolStripMenuItem.Click += new System.EventHandler(this.удалитьКатегориюToolStripMenuItem_Click);
//
// изменитьКатегориюToolStripMenuItem
//
this.изменитьКатегориюToolStripMenuItem.Name = "изменитьКатегориюToolStripMenuItem";
this.изменитьКатегориюToolStripMenuItem.Size = new System.Drawing.Size(190, 22);
this.изменитьКатегориюToolStripMenuItem.Text = "Изменить категорию";
this.изменитьКатегориюToolStripMenuItem.Click += new System.EventHandler(this.изменитьКатегориюToolStripMenuItem_Click);
//
// списокКатегорийToolStripMenuItem
//
this.списокКатегорийToolStripMenuItem.Name = "списокКатегорийToolStripMenuItem";
this.списокКатегорийToolStripMenuItem.Size = new System.Drawing.Size(190, 22);
this.списокКатегорийToolStripMenuItem.Text = "Список категорий";
this.списокКатегорийToolStripMenuItem.Click += new System.EventHandler(this.списокКатегорийToolStripMenuItem_Click);
//
// подкатегорииToolStripMenuItem // подкатегорииToolStripMenuItem
// //
this.подкатегорииToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { this.подкатегорииToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
@ -107,119 +192,45 @@
this.изменитьПодкатегориюToolStripMenuItem, this.изменитьПодкатегориюToolStripMenuItem,
this.списокПодкатегоийToolStripMenuItem}); this.списокПодкатегоийToolStripMenuItem});
this.подкатегорииToolStripMenuItem.Name = "подкатегорииToolStripMenuItem"; this.подкатегорииToolStripMenuItem.Name = "подкатегорииToolStripMenuItem";
this.подкатегорииToolStripMenuItem.Size = new System.Drawing.Size(122, 24); this.подкатегорииToolStripMenuItem.Size = new System.Drawing.Size(97, 20);
this.подкатегорииToolStripMenuItem.Text = "Подкатегории"; 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 // создатьПодкатеориюToolStripMenuItem
// //
this.создатьПодкатеориюToolStripMenuItem.Name = "создатьПодкатеориюToolStripMenuItem"; this.создатьПодкатеориюToolStripMenuItem.Name = "создатьПодкатеориюToolStripMenuItem";
this.создатьПодкатеориюToolStripMenuItem.Size = new System.Drawing.Size(265, 26); this.создатьПодкатеориюToolStripMenuItem.Size = new System.Drawing.Size(210, 22);
this.создатьПодкатеориюToolStripMenuItem.Text = "Создать подкатегорию"; this.создатьПодкатеориюToolStripMenuItem.Text = "Создать подкатегорию";
this.создатьПодкатеориюToolStripMenuItem.Click += new System.EventHandler(this.создатьПодкатеориюToolStripMenuItem_Click);
// //
// удалитьПодкатегориюToolStripMenuItem // удалитьПодкатегориюToolStripMenuItem
// //
this.удалитьПодкатегориюToolStripMenuItem.Name = "удалитьПодкатегориюToolStripMenuItem"; this.удалитьПодкатегориюToolStripMenuItem.Name = "удалитьПодкатегориюToolStripMenuItem";
this.удалитьПодкатегориюToolStripMenuItem.Size = new System.Drawing.Size(265, 26); this.удалитьПодкатегориюToolStripMenuItem.Size = new System.Drawing.Size(210, 22);
this.удалитьПодкатегориюToolStripMenuItem.Text = "Удалить подкатегорию"; this.удалитьПодкатегориюToolStripMenuItem.Text = "Удалить подкатегорию";
this.удалитьПодкатегориюToolStripMenuItem.Click += new System.EventHandler(this.удалитьПодкатегориюToolStripMenuItem_Click);
// //
// изменитьПодкатегориюToolStripMenuItem // изменитьПодкатегориюToolStripMenuItem
// //
this.изменитьПодкатегориюToolStripMenuItem.Name = "изменитьПодкатегориюToolStripMenuItem"; this.изменитьПодкатегориюToolStripMenuItem.Name = "изменитьПодкатегориюToolStripMenuItem";
this.изменитьПодкатегориюToolStripMenuItem.Size = new System.Drawing.Size(265, 26); this.изменитьПодкатегориюToolStripMenuItem.Size = new System.Drawing.Size(210, 22);
this.изменитьПодкатегориюToolStripMenuItem.Text = "Изменить подкатегорию"; this.изменитьПодкатегориюToolStripMenuItem.Text = "Изменить подкатегорию";
this.изменитьПодкатегориюToolStripMenuItem.Click += new System.EventHandler(this.изменитьПодкатегориюToolStripMenuItem_Click);
// //
// списокПодкатегоийToolStripMenuItem // списокПодкатегоийToolStripMenuItem
// //
this.списокПодкатегоийToolStripMenuItem.Name = "списокПодкатегоийToolStripMenuItem"; this.списокПодкатегоийToolStripMenuItem.Name = "списокПодкатегоийToolStripMenuItem";
this.списокПодкатегоийToolStripMenuItem.Size = new System.Drawing.Size(265, 26); this.списокПодкатегоийToolStripMenuItem.Size = new System.Drawing.Size(210, 22);
this.списокПодкатегоийToolStripMenuItem.Text = "Список подкатегорий"; this.списокПодкатегоийToolStripMenuItem.Text = "Список подкатегорий";
this.списокПодкатегоийToolStripMenuItem.Click += new System.EventHandler(this.списокПодкатегоийToolStripMenuItem_Click);
// //
// MainForm // MainForm
// //
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F); this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(800, 450); this.ClientSize = new System.Drawing.Size(700, 338);
this.Controls.Add(this.menuStrip1); this.Controls.Add(this.menuStrip1);
this.MainMenuStrip = this.menuStrip1; this.MainMenuStrip = this.menuStrip1;
this.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.Name = "MainForm"; this.Name = "MainForm";
this.Text = "MainForm"; this.Text = "MainForm";
this.menuStrip1.ResumeLayout(false); this.menuStrip1.ResumeLayout(false);

View File

@ -22,30 +22,27 @@ namespace WebsiteForPlacingAds
databaseLogic = new DatabaseLogic(psd); databaseLogic = new DatabaseLogic(psd);
} }
private void списокКлиентвToolStripMenuItem_Click(object sender, EventArgs e)
{
}
private void создатьКатегориюToolStripMenuItem_Click(object sender, EventArgs e) private void создатьКатегориюToolStripMenuItem_Click(object sender, EventArgs e)
{ {
CreateCategoriesForm ccf = new CreateCategoriesForm(databaseLogic);
ccf.Show();
} }
private void удалитьКатегориюToolStripMenuItem_Click(object sender, EventArgs e) private void удалитьКатегориюToolStripMenuItem_Click(object sender, EventArgs e)
{ {
DeleteCategoriesForm dcf = new DeleteCategoriesForm(databaseLogic);
dcf.Show();
} }
private void создатьОбъявлениеToolStripMenuItem_Click(object sender, EventArgs e) private void создатьОбъявлениеToolStripMenuItem_Click(object sender, EventArgs e)
{ {
CreateAdsForm caf = new CreateAdsForm((PostgreSqlDatabase)psd); CreateAdsForm caf = new CreateAdsForm(databaseLogic);
caf.Show(); caf.Show();
} }
private void удалитьОбъявлениеToolStripMenuItem_Click(object sender, EventArgs e) private void удалитьОбъявлениеToolStripMenuItem_Click(object sender, EventArgs e)
{ {
DeleteAdsForm uaf = new DeleteAdsForm((PostgreSqlDatabase)psd); DeleteAdsForm uaf = new DeleteAdsForm(databaseLogic);
uaf.Show(); uaf.Show();
} }
@ -57,8 +54,67 @@ namespace WebsiteForPlacingAds
private void списокОбъявленийToolStripMenuItem_Click(object sender, EventArgs e) private void списокОбъявленийToolStripMenuItem_Click(object sender, EventArgs e)
{ {
ListAdsForm laf = new ListAdsForm((PostgreSqlDatabase)psd); ListAdsForm laf = new ListAdsForm(databaseLogic);
laf.Show(); laf.Show();
} }
private void создатьКлиентаToolStripMenuItem_Click(object sender, EventArgs e)
{
CreateClientsForm ccf = new CreateClientsForm(databaseLogic);
ccf.Show();
}
private void удалитьКлиентаToolStripMenuItem_Click(object sender, EventArgs e)
{
DeleteClientsForm dcf = new DeleteClientsForm(databaseLogic);
dcf.Show();
}
private void изменитьДанныеКлиентаToolStripMenuItem_Click(object sender, EventArgs e)
{
UpdateClientsForm ucf = new UpdateClientsForm(databaseLogic);
ucf.Show();
}
private void списокКлиентвToolStripMenuItem_Click(object sender, EventArgs e)
{
ListClientsForm lcf = new ListClientsForm(databaseLogic);
lcf.Show();
}
private void изменитьКатегориюToolStripMenuItem_Click(object sender, EventArgs e)
{
UpdateCategoriesForm ucf = new UpdateCategoriesForm(databaseLogic);
ucf.Show();
}
private void списокКатегорийToolStripMenuItem_Click(object sender, EventArgs e)
{
ListCategoriesForm lcf = new ListCategoriesForm(databaseLogic);
lcf.Show();
}
private void создатьПодкатеориюToolStripMenuItem_Click(object sender, EventArgs e)
{
CreateSubcategoriesForm csf = new CreateSubcategoriesForm(databaseLogic);
csf.Show();
}
private void удалитьПодкатегориюToolStripMenuItem_Click(object sender, EventArgs e)
{
DeleteSubcategoriesForm dsf = new DeleteSubcategoriesForm(databaseLogic);
dsf.Show();
}
private void изменитьПодкатегориюToolStripMenuItem_Click(object sender, EventArgs e)
{
UpdateSubcategoriesForm usf = new UpdateSubcategoriesForm(databaseLogic);
usf.Show();
}
private void списокПодкатегоийToolStripMenuItem_Click(object sender, EventArgs e)
{
ListSubcategoriesForm lsf = new ListSubcategoriesForm(databaseLogic);
lsf.Show();
}
} }
} }

View File

@ -0,0 +1,86 @@
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()
{
this.textBoxName = new System.Windows.Forms.TextBox();
this.labelName = new System.Windows.Forms.Label();
this.buttonCreateSubcategory = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// textBoxName
//
this.textBoxName.Location = new System.Drawing.Point(37, 35);
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 = 5;
//
// labelName
//
this.labelName.AutoSize = true;
this.labelName.Location = new System.Drawing.Point(37, 17);
this.labelName.Name = "labelName";
this.labelName.Size = new System.Drawing.Size(59, 15);
this.labelName.TabIndex = 4;
this.labelName.Text = "Название";
//
// buttonCreateSubcategory
//
this.buttonCreateSubcategory.Location = new System.Drawing.Point(37, 79);
this.buttonCreateSubcategory.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.buttonCreateSubcategory.Name = "buttonCreateSubcategory";
this.buttonCreateSubcategory.Size = new System.Drawing.Size(239, 29);
this.buttonCreateSubcategory.TabIndex = 3;
this.buttonCreateSubcategory.Text = "Добавить подкатегорию";
this.buttonCreateSubcategory.UseVisualStyleBackColor = true;
this.buttonCreateSubcategory.Click += new System.EventHandler(this.buttonCreateSubcategory_Click_1);
//
// CreateSubcategoriesForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(324, 122);
this.Controls.Add(this.textBoxName);
this.Controls.Add(this.labelName);
this.Controls.Add(this.buttonCreateSubcategory);
this.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.Name = "CreateSubcategoriesForm";
this.Text = "Подкатегория";
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private TextBox textBoxName;
private Label labelName;
private Button buttonCreateSubcategory;
}
}

View File

@ -0,0 +1,29 @@
using System.Data;
namespace WebsiteForPlacingAds
{
public partial class CreateSubcategoriesForm : Form
{
IDatabaseLogic databaseLogic;
public CreateSubcategoriesForm(IDatabaseLogic databaseLogic)
{
InitializeComponent();
this.databaseLogic = databaseLogic;
}
private void buttonCreateSubcategory_Click_1(object sender, EventArgs e)
{
string name = textBoxName.Text;
try
{
databaseLogic.insertInto("subcategories", $"'{name}'");
MessageBox.Show("Äîáàâëåíî!");
}
catch (Exception ex)
{
MessageBox.Show("Íå óäàëîñü äîáàâèòü");
}
}
}
}

View File

@ -0,0 +1,60 @@
<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>

View File

@ -0,0 +1,87 @@
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;
}
}

View File

@ -0,0 +1,55 @@
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
{
IDatabaseLogic databaseLogic;
private int setval_seq;
public DeleteSubcategoriesForm(IDatabaseLogic databaseLogic)
{
InitializeComponent();
this.databaseLogic = databaseLogic;
LoadData();
}
public void LoadData()
{
comboBoxDeleteSubcategories.Items.Clear();
DataTable result = databaseLogic.getAllEntry("Subcategories");
setval_seq = result.Rows.Count;
string Subcategories = "";
for (int i = 0; i < result.Rows.Count; i++)
{
if (i == result.Rows.Count - 1) setval_seq = Convert.ToInt32(databaseLogic.getRowTableById(result, "subcategories_id", i));
Subcategories = databaseLogic.getRowTableById(result, "subcategories_id", i).ToString() + " | " +
databaseLogic.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
{
databaseLogic.deleteEntry("subcategories", int.Parse(subcategory_id));
LoadData();
databaseLogic.reduceSeq("seq_subcategories", setval_seq);
MessageBox.Show("Удалено!");
}
catch (Exception ex)
{
MessageBox.Show("Не удалось удалить");
}
}
}
}

View File

@ -0,0 +1,60 @@
<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>

View File

@ -0,0 +1,75 @@
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;
}
}

View File

@ -0,0 +1,36 @@
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
{
IDatabaseLogic databaseLogic;
public ListSubcategoriesForm(IDatabaseLogic databaseLogic)
{
InitializeComponent();
this.databaseLogic = databaseLogic;
LoadData();
}
private void LoadData()
{
DataTable result = databaseLogic.getAllEntry("Subcategories");
string listSubcategories = "";
for (int i = 0; i < result.Rows.Count; i++)
{
listSubcategories += databaseLogic.getRowTableById(result, "subcategories_id", i).ToString() + " | " +
databaseLogic.getRowTableById(result, "name", i).ToString() + "\n";
}
labelListSubcategories.Text = listSubcategories;
}
}
}

View File

@ -0,0 +1,60 @@
<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>

View File

@ -0,0 +1,111 @@
namespace WebsiteForPlacingAds
{
partial class UpdateSubcategoriesForm
{
/// <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.textBoxName = new System.Windows.Forms.TextBox();
this.labelName = new System.Windows.Forms.Label();
this.buttonUpdateSubcategory = new System.Windows.Forms.Button();
this.comboBoxUpdateSubcategory = new System.Windows.Forms.ComboBox();
this.label1 = new System.Windows.Forms.Label();
this.SuspendLayout();
//
// textBoxName
//
this.textBoxName.Location = new System.Drawing.Point(80, 104);
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 = 42;
//
// labelName
//
this.labelName.AutoSize = true;
this.labelName.Location = new System.Drawing.Point(80, 86);
this.labelName.Name = "labelName";
this.labelName.Size = new System.Drawing.Size(59, 15);
this.labelName.TabIndex = 41;
this.labelName.Text = "Название";
//
// buttonUpdateSubcategory
//
this.buttonUpdateSubcategory.Location = new System.Drawing.Point(80, 148);
this.buttonUpdateSubcategory.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.buttonUpdateSubcategory.Name = "buttonUpdateSubcategory";
this.buttonUpdateSubcategory.Size = new System.Drawing.Size(239, 29);
this.buttonUpdateSubcategory.TabIndex = 40;
this.buttonUpdateSubcategory.Text = "Обновить категорию";
this.buttonUpdateSubcategory.UseVisualStyleBackColor = true;
this.buttonUpdateSubcategory.Click += new System.EventHandler(this.buttonUpdateSubcategory_Click);
//
// comboBoxUpdateSubcategory
//
this.comboBoxUpdateSubcategory.FormattingEnabled = true;
this.comboBoxUpdateSubcategory.Location = new System.Drawing.Point(12, 47);
this.comboBoxUpdateSubcategory.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.comboBoxUpdateSubcategory.Name = "comboBoxUpdateSubcategory";
this.comboBoxUpdateSubcategory.Size = new System.Drawing.Size(377, 23);
this.comboBoxUpdateSubcategory.TabIndex = 39;
this.comboBoxUpdateSubcategory.SelectedIndexChanged += new System.EventHandler(this.comboBoxUpdateSubcategory_SelectedIndexChanged_1);
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(53, 23);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(291, 15);
this.label1.TabIndex = 38;
this.label1.Text = "Выберите подкатегорию, которую хотите обновить";
//
// UpdateSubcategoriesForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(397, 195);
this.Controls.Add(this.textBoxName);
this.Controls.Add(this.labelName);
this.Controls.Add(this.buttonUpdateSubcategory);
this.Controls.Add(this.comboBoxUpdateSubcategory);
this.Controls.Add(this.label1);
this.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.Name = "UpdateSubcategoriesForm";
this.Text = "Обновить подкатегорию";
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private TextBox textBoxName;
private Label labelName;
private Button buttonUpdateSubcategory;
private ComboBox comboBoxUpdateSubcategory;
private Label label1;
}
}

View File

@ -0,0 +1,82 @@
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 UpdateSubcategoriesForm : Form
{
IDatabaseLogic databaseLogic;
public UpdateSubcategoriesForm(IDatabaseLogic databaseLogic)
{
InitializeComponent();
this.databaseLogic = databaseLogic;
LoadData();
}
public void LoadData()
{
comboBoxUpdateSubcategory.Items.Clear();
DataTable result = databaseLogic.getAllEntry("Subcategories");
string Subcategories = "";
for (int i = 0; i < result.Rows.Count; i++)
{
Subcategories = result.Rows[i]["subcategories_id"].ToString() + " | " +
(string)result.Rows[i]["name"] + "\n";
comboBoxUpdateSubcategory.Items.Add(Subcategories);
}
}
public void LoadDataSelectedItem(int subcategories_id)
{
DataTable result = databaseLogic.getEntryById("subcategories", subcategories_id);
textBoxName.Text = databaseLogic.getRowTableById(result, "name", 0).ToString();
}
private void buttonUpdateSubcategory_Click(object sender, EventArgs e)
{
string[] selectedSubcategory = comboBoxUpdateSubcategory.SelectedItem.ToString().Split("|");
int subcategory_id = int.Parse(selectedSubcategory[0].Trim());
string query = $"UPDATE Subcategories SET ";
int len = query.Length;
string oldName = databaseLogic.getRowTableById("subcategories", "name", subcategory_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 Subcategories_ID = {subcategory_id};";
}
try
{
databaseLogic.ExecuteNonQuery(query);
MessageBox.Show("Данные успешно обновлены!");
}
catch (Exception)
{
MessageBox.Show("Данные не обновились");
}
}
private void comboBoxUpdateSubcategory_SelectedIndexChanged_1(object sender, EventArgs e)
{
string[] selectedItems = comboBoxUpdateSubcategory.SelectedItem.ToString().Split("|");
int subcategory_id = int.Parse(selectedItems[0].Trim());
LoadDataSelectedItem(subcategory_id);
}
}
}

View File

@ -0,0 +1,60 @@
<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>

View File

@ -12,4 +12,19 @@
<PackageReference Include="Npgsql" Version="7.0.2" /> <PackageReference Include="Npgsql" Version="7.0.2" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<Compile Update="ClientsForm\CreateClientsForm.cs">
<SubType>Form</SubType>
</Compile>
<Compile Update="ClientsForm\DeleteClientsForm.cs">
<SubType>Form</SubType>
</Compile>
<Compile Update="ClientsForm\ListClientsForm.cs">
<SubType>Form</SubType>
</Compile>
<Compile Update="ClientsForm\UpdateClientsForm.cs">
<SubType>Form</SubType>
</Compile>
</ItemGroup>
</Project> </Project>