3 lab ready
This commit is contained in:
parent
d398882215
commit
c25cbeed77
@ -23,7 +23,7 @@ namespace ClientRecordBuisinessLogic.BuisinessLogic
|
|||||||
|
|
||||||
public bool Delete(ClientBindingModel model)
|
public bool Delete(ClientBindingModel model)
|
||||||
{
|
{
|
||||||
CheckModel(model);
|
CheckModel(model,false);
|
||||||
return _clientStorage.Delete(model) != null;
|
return _clientStorage.Delete(model) != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -7,7 +7,7 @@ namespace ClientRecordContracts.BindingModels
|
|||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
public string? Reviews { get; set; }
|
public string? Reviews { get; set; }
|
||||||
public string ClientFIO { get; set; } = string.Empty;
|
public string ClientFIO { get; set; } = string.Empty;
|
||||||
public double? Amount { get; set; }
|
public int? Amount { get; set; }
|
||||||
public int StatusId { get; set; }
|
public int StatusId { get; set; }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -11,7 +11,7 @@ namespace ClientRecordContracts.ViewModels
|
|||||||
[DisplayName("Отзывы")]
|
[DisplayName("Отзывы")]
|
||||||
public string? Reviews { get; set; }
|
public string? Reviews { get; set; }
|
||||||
[DisplayName("Сумма покупок")]
|
[DisplayName("Сумма покупок")]
|
||||||
public double? Amount { get; set; }
|
public int? Amount { get; set; }
|
||||||
|
|
||||||
public int StatusId { get; set; }
|
public int StatusId { get; set; }
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
{
|
{
|
||||||
string ClientFIO{ get; }
|
string ClientFIO{ get; }
|
||||||
string? Reviews{ get; }
|
string? Reviews{ get; }
|
||||||
double? Amount{ get; }
|
int? Amount{ get; }
|
||||||
int StatusId{ get; }
|
int StatusId{ get; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,7 @@ namespace ClientRecordDatabaseImplement
|
|||||||
{
|
{
|
||||||
if (optionsBuilder.IsConfigured == false)
|
if (optionsBuilder.IsConfigured == false)
|
||||||
{
|
{
|
||||||
optionsBuilder.UseNpgsql(@"Host=localhost;Database=Factory;Username=postgres;Password=postgres");
|
optionsBuilder.UseNpgsql(@"Host=localhost;Database=COP;Username=postgres;Password=postgres");
|
||||||
}
|
}
|
||||||
base.OnConfiguring(optionsBuilder);
|
base.OnConfiguring(optionsBuilder);
|
||||||
|
|
||||||
|
@ -12,7 +12,7 @@ using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
|||||||
namespace ClientRecordDatabaseImplement.Migrations
|
namespace ClientRecordDatabaseImplement.Migrations
|
||||||
{
|
{
|
||||||
[DbContext(typeof(ClientRecordDatabase))]
|
[DbContext(typeof(ClientRecordDatabase))]
|
||||||
[Migration("20241029151814_init")]
|
[Migration("20241030093837_init")]
|
||||||
partial class init
|
partial class init
|
||||||
{
|
{
|
||||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||||
@ -32,8 +32,8 @@ namespace ClientRecordDatabaseImplement.Migrations
|
|||||||
|
|
||||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
b.Property<double?>("Amount")
|
b.Property<int?>("Amount")
|
||||||
.HasColumnType("double precision");
|
.HasColumnType("integer");
|
||||||
|
|
||||||
b.Property<string>("ClientFIO")
|
b.Property<string>("ClientFIO")
|
||||||
.IsRequired()
|
.IsRequired()
|
@ -32,7 +32,7 @@ namespace ClientRecordDatabaseImplement.Migrations
|
|||||||
StatusId = table.Column<int>(type: "integer", nullable: false),
|
StatusId = table.Column<int>(type: "integer", nullable: false),
|
||||||
ClientId = table.Column<int>(type: "integer", nullable: false),
|
ClientId = table.Column<int>(type: "integer", nullable: false),
|
||||||
Reviews = table.Column<string>(type: "text", nullable: true),
|
Reviews = table.Column<string>(type: "text", nullable: true),
|
||||||
Amount = table.Column<double>(type: "double precision", nullable: true)
|
Amount = table.Column<int>(type: "integer", nullable: true)
|
||||||
},
|
},
|
||||||
constraints: table =>
|
constraints: table =>
|
||||||
{
|
{
|
90
ClientRecordDatabaseImplement/Migrations/20241030102017_fix.Designer.cs
generated
Normal file
90
ClientRecordDatabaseImplement/Migrations/20241030102017_fix.Designer.cs
generated
Normal file
@ -0,0 +1,90 @@
|
|||||||
|
// <auto-generated />
|
||||||
|
using System;
|
||||||
|
using ClientRecordDatabaseImplement;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||||
|
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace ClientRecordDatabaseImplement.Migrations
|
||||||
|
{
|
||||||
|
[DbContext(typeof(ClientRecordDatabase))]
|
||||||
|
[Migration("20241030102017_fix")]
|
||||||
|
partial class fix
|
||||||
|
{
|
||||||
|
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||||
|
{
|
||||||
|
#pragma warning disable 612, 618
|
||||||
|
modelBuilder
|
||||||
|
.HasAnnotation("ProductVersion", "6.0.35")
|
||||||
|
.HasAnnotation("Relational:MaxIdentifierLength", 63);
|
||||||
|
|
||||||
|
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
|
||||||
|
|
||||||
|
modelBuilder.Entity("ClientRecordDatabaseImplement.Models.Client", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
|
b.Property<int?>("Amount")
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
b.Property<string>("ClientFIO")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("Reviews")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<int>("StatusId")
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("StatusId");
|
||||||
|
|
||||||
|
b.ToTable("Clients");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("ClientRecordDatabaseImplement.Models.Status", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
|
b.Property<string>("Name")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("Statuses");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("ClientRecordDatabaseImplement.Models.Client", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("ClientRecordDatabaseImplement.Models.Status", "Status")
|
||||||
|
.WithMany("Clients")
|
||||||
|
.HasForeignKey("StatusId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.Navigation("Status");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("ClientRecordDatabaseImplement.Models.Status", b =>
|
||||||
|
{
|
||||||
|
b.Navigation("Clients");
|
||||||
|
});
|
||||||
|
#pragma warning restore 612, 618
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,68 @@
|
|||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace ClientRecordDatabaseImplement.Migrations
|
||||||
|
{
|
||||||
|
public partial class fix : Migration
|
||||||
|
{
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.DropForeignKey(
|
||||||
|
name: "FK_Clients_Statuses_ClientId",
|
||||||
|
table: "Clients");
|
||||||
|
|
||||||
|
migrationBuilder.DropIndex(
|
||||||
|
name: "IX_Clients_ClientId",
|
||||||
|
table: "Clients");
|
||||||
|
|
||||||
|
migrationBuilder.DropColumn(
|
||||||
|
name: "ClientId",
|
||||||
|
table: "Clients");
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "IX_Clients_StatusId",
|
||||||
|
table: "Clients",
|
||||||
|
column: "StatusId");
|
||||||
|
|
||||||
|
migrationBuilder.AddForeignKey(
|
||||||
|
name: "FK_Clients_Statuses_StatusId",
|
||||||
|
table: "Clients",
|
||||||
|
column: "StatusId",
|
||||||
|
principalTable: "Statuses",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.DropForeignKey(
|
||||||
|
name: "FK_Clients_Statuses_StatusId",
|
||||||
|
table: "Clients");
|
||||||
|
|
||||||
|
migrationBuilder.DropIndex(
|
||||||
|
name: "IX_Clients_StatusId",
|
||||||
|
table: "Clients");
|
||||||
|
|
||||||
|
migrationBuilder.AddColumn<int>(
|
||||||
|
name: "ClientId",
|
||||||
|
table: "Clients",
|
||||||
|
type: "integer",
|
||||||
|
nullable: false,
|
||||||
|
defaultValue: 0);
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "IX_Clients_ClientId",
|
||||||
|
table: "Clients",
|
||||||
|
column: "ClientId");
|
||||||
|
|
||||||
|
migrationBuilder.AddForeignKey(
|
||||||
|
name: "FK_Clients_Statuses_ClientId",
|
||||||
|
table: "Clients",
|
||||||
|
column: "ClientId",
|
||||||
|
principalTable: "Statuses",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -30,16 +30,13 @@ namespace ClientRecordDatabaseImplement.Migrations
|
|||||||
|
|
||||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
b.Property<double?>("Amount")
|
b.Property<int?>("Amount")
|
||||||
.HasColumnType("double precision");
|
.HasColumnType("integer");
|
||||||
|
|
||||||
b.Property<string>("ClientFIO")
|
b.Property<string>("ClientFIO")
|
||||||
.IsRequired()
|
.IsRequired()
|
||||||
.HasColumnType("text");
|
.HasColumnType("text");
|
||||||
|
|
||||||
b.Property<int>("ClientId")
|
|
||||||
.HasColumnType("integer");
|
|
||||||
|
|
||||||
b.Property<string>("Reviews")
|
b.Property<string>("Reviews")
|
||||||
.HasColumnType("text");
|
.HasColumnType("text");
|
||||||
|
|
||||||
@ -48,7 +45,7 @@ namespace ClientRecordDatabaseImplement.Migrations
|
|||||||
|
|
||||||
b.HasKey("Id");
|
b.HasKey("Id");
|
||||||
|
|
||||||
b.HasIndex("ClientId");
|
b.HasIndex("StatusId");
|
||||||
|
|
||||||
b.ToTable("Clients");
|
b.ToTable("Clients");
|
||||||
});
|
});
|
||||||
@ -74,7 +71,7 @@ namespace ClientRecordDatabaseImplement.Migrations
|
|||||||
{
|
{
|
||||||
b.HasOne("ClientRecordDatabaseImplement.Models.Status", "Status")
|
b.HasOne("ClientRecordDatabaseImplement.Models.Status", "Status")
|
||||||
.WithMany("Clients")
|
.WithMany("Clients")
|
||||||
.HasForeignKey("ClientId")
|
.HasForeignKey("StatusId")
|
||||||
.OnDelete(DeleteBehavior.Cascade)
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
.IsRequired();
|
.IsRequired();
|
||||||
|
|
||||||
|
@ -15,7 +15,7 @@ namespace ClientRecordDatabaseImplement.Models
|
|||||||
public int StatusId { get; set; }
|
public int StatusId { get; set; }
|
||||||
public virtual Status Status { get; set; }
|
public virtual Status Status { get; set; }
|
||||||
public string? Reviews { get; set; }
|
public string? Reviews { get; set; }
|
||||||
public double? Amount { get; set; }
|
public int? Amount { get; set; }
|
||||||
|
|
||||||
public static Client? Create(ClientBindingModel model)
|
public static Client? Create(ClientBindingModel model)
|
||||||
{
|
{
|
||||||
|
@ -14,7 +14,7 @@ namespace ClientRecordDatabaseImplement.Models
|
|||||||
|
|
||||||
[Required]
|
[Required]
|
||||||
public string Name { get; private set; } = string.Empty;
|
public string Name { get; private set; } = string.Empty;
|
||||||
[ForeignKey("ClientId")]
|
[ForeignKey("StatusId")]
|
||||||
public virtual List<Client> Clients { get; set; } = new();
|
public virtual List<Client> Clients { get; set; } = new();
|
||||||
|
|
||||||
public static Status? Create(StatusBindingModel model)
|
public static Status? Create(StatusBindingModel model)
|
||||||
|
@ -2,13 +2,16 @@
|
|||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<OutputType>WinExe</OutputType>
|
<OutputType>WinExe</OutputType>
|
||||||
<TargetFramework>net6.0-windows</TargetFramework>
|
<TargetFramework>net7.0-windows</TargetFramework>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
<UseWindowsForms>true</UseWindowsForms>
|
<UseWindowsForms>true</UseWindowsForms>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<PackageReference Include="Components" Version="1.0.0" />
|
||||||
|
<PackageReference Include="ComponentsLibraryNet60" Version="1.0.0" />
|
||||||
|
<PackageReference Include="ControlsLibraryNet60" Version="1.0.0" />
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="6.0.35">
|
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="6.0.35">
|
||||||
<PrivateAssets>all</PrivateAssets>
|
<PrivateAssets>all</PrivateAssets>
|
||||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
|
157
ClientRecordView/FormClient.Designer.cs
generated
157
ClientRecordView/FormClient.Designer.cs
generated
@ -28,12 +28,163 @@
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
private void InitializeComponent()
|
private void InitializeComponent()
|
||||||
{
|
{
|
||||||
this.components = new System.ComponentModel.Container();
|
this.buttonCancel = new System.Windows.Forms.Button();
|
||||||
|
this.labelStatus = new System.Windows.Forms.Label();
|
||||||
|
this.labelAmount = new System.Windows.Forms.Label();
|
||||||
|
this.labelReviews = new System.Windows.Forms.Label();
|
||||||
|
this.labelFIO = new System.Windows.Forms.Label();
|
||||||
|
this.buttonSave = new System.Windows.Forms.Button();
|
||||||
|
this.textBoxReviews = new System.Windows.Forms.TextBox();
|
||||||
|
this.textBoxFIO = new System.Windows.Forms.TextBox();
|
||||||
|
this.userControlIntegerInput = new Components.UserControlIntegerInput();
|
||||||
|
this.dropDownList = new WinFormsLibrary.DropDownList();
|
||||||
|
this.SuspendLayout();
|
||||||
|
//
|
||||||
|
// buttonCancel
|
||||||
|
//
|
||||||
|
this.buttonCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
|
||||||
|
| System.Windows.Forms.AnchorStyles.Left)
|
||||||
|
| System.Windows.Forms.AnchorStyles.Right)));
|
||||||
|
this.buttonCancel.Location = new System.Drawing.Point(258, 392);
|
||||||
|
this.buttonCancel.Margin = new System.Windows.Forms.Padding(4);
|
||||||
|
this.buttonCancel.Name = "buttonCancel";
|
||||||
|
this.buttonCancel.Size = new System.Drawing.Size(131, 45);
|
||||||
|
this.buttonCancel.TabIndex = 17;
|
||||||
|
this.buttonCancel.Text = "Отмена";
|
||||||
|
this.buttonCancel.UseVisualStyleBackColor = true;
|
||||||
|
this.buttonCancel.Click += new System.EventHandler(this.buttonCancel_Click);
|
||||||
|
//
|
||||||
|
// labelStatus
|
||||||
|
//
|
||||||
|
this.labelStatus.AutoSize = true;
|
||||||
|
this.labelStatus.Location = new System.Drawing.Point(13, 9);
|
||||||
|
this.labelStatus.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
|
||||||
|
this.labelStatus.Name = "labelStatus";
|
||||||
|
this.labelStatus.Size = new System.Drawing.Size(63, 25);
|
||||||
|
this.labelStatus.TabIndex = 15;
|
||||||
|
this.labelStatus.Text = "Статус";
|
||||||
|
//
|
||||||
|
// labelAmount
|
||||||
|
//
|
||||||
|
this.labelAmount.AutoSize = true;
|
||||||
|
this.labelAmount.Location = new System.Drawing.Point(20, 283);
|
||||||
|
this.labelAmount.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
|
||||||
|
this.labelAmount.Name = "labelAmount";
|
||||||
|
this.labelAmount.Size = new System.Drawing.Size(141, 25);
|
||||||
|
this.labelAmount.TabIndex = 14;
|
||||||
|
this.labelAmount.Text = "Сумма покупок";
|
||||||
|
//
|
||||||
|
// labelReviews
|
||||||
|
//
|
||||||
|
this.labelReviews.AutoSize = true;
|
||||||
|
this.labelReviews.Location = new System.Drawing.Point(13, 193);
|
||||||
|
this.labelReviews.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
|
||||||
|
this.labelReviews.Name = "labelReviews";
|
||||||
|
this.labelReviews.Size = new System.Drawing.Size(77, 25);
|
||||||
|
this.labelReviews.TabIndex = 13;
|
||||||
|
this.labelReviews.Text = "Отзывы";
|
||||||
|
//
|
||||||
|
// labelFIO
|
||||||
|
//
|
||||||
|
this.labelFIO.AutoSize = true;
|
||||||
|
this.labelFIO.Location = new System.Drawing.Point(13, 99);
|
||||||
|
this.labelFIO.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
|
||||||
|
this.labelFIO.Name = "labelFIO";
|
||||||
|
this.labelFIO.Size = new System.Drawing.Size(52, 25);
|
||||||
|
this.labelFIO.TabIndex = 12;
|
||||||
|
this.labelFIO.Text = "ФИО";
|
||||||
|
//
|
||||||
|
// buttonSave
|
||||||
|
//
|
||||||
|
this.buttonSave.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
|
||||||
|
| System.Windows.Forms.AnchorStyles.Left)
|
||||||
|
| System.Windows.Forms.AnchorStyles.Right)));
|
||||||
|
this.buttonSave.Location = new System.Drawing.Point(13, 392);
|
||||||
|
this.buttonSave.Margin = new System.Windows.Forms.Padding(4);
|
||||||
|
this.buttonSave.Name = "buttonSave";
|
||||||
|
this.buttonSave.Size = new System.Drawing.Size(131, 45);
|
||||||
|
this.buttonSave.TabIndex = 16;
|
||||||
|
this.buttonSave.Text = "Сохранить";
|
||||||
|
this.buttonSave.UseVisualStyleBackColor = true;
|
||||||
|
this.buttonSave.Click += new System.EventHandler(this.buttonSave_Click);
|
||||||
|
//
|
||||||
|
// textBoxReviews
|
||||||
|
//
|
||||||
|
this.textBoxReviews.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
|
||||||
|
| System.Windows.Forms.AnchorStyles.Right)));
|
||||||
|
this.textBoxReviews.Location = new System.Drawing.Point(13, 232);
|
||||||
|
this.textBoxReviews.Margin = new System.Windows.Forms.Padding(4);
|
||||||
|
this.textBoxReviews.Name = "textBoxReviews";
|
||||||
|
this.textBoxReviews.Size = new System.Drawing.Size(376, 31);
|
||||||
|
this.textBoxReviews.TabIndex = 11;
|
||||||
|
this.textBoxReviews.TextChanged += new System.EventHandler(this.textBoxReviews_TextChanged);
|
||||||
|
//
|
||||||
|
// textBoxFIO
|
||||||
|
//
|
||||||
|
this.textBoxFIO.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
|
||||||
|
| System.Windows.Forms.AnchorStyles.Right)));
|
||||||
|
this.textBoxFIO.Location = new System.Drawing.Point(13, 137);
|
||||||
|
this.textBoxFIO.Margin = new System.Windows.Forms.Padding(4);
|
||||||
|
this.textBoxFIO.Name = "textBoxFIO";
|
||||||
|
this.textBoxFIO.Size = new System.Drawing.Size(376, 31);
|
||||||
|
this.textBoxFIO.TabIndex = 10;
|
||||||
|
this.textBoxFIO.TextChanged += new System.EventHandler(this.textBoxFIO_TextChanged);
|
||||||
|
//
|
||||||
|
// userControlIntegerInput
|
||||||
|
//
|
||||||
|
this.userControlIntegerInput.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
|
||||||
|
| System.Windows.Forms.AnchorStyles.Right)));
|
||||||
|
this.userControlIntegerInput.Location = new System.Drawing.Point(13, 324);
|
||||||
|
this.userControlIntegerInput.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
|
||||||
|
this.userControlIntegerInput.Name = "userControlIntegerInput";
|
||||||
|
this.userControlIntegerInput.Size = new System.Drawing.Size(384, 75);
|
||||||
|
this.userControlIntegerInput.TabIndex = 19;
|
||||||
|
//
|
||||||
|
// dropDownList
|
||||||
|
//
|
||||||
|
this.dropDownList.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
|
||||||
|
| System.Windows.Forms.AnchorStyles.Right)));
|
||||||
|
this.dropDownList.Location = new System.Drawing.Point(13, 37);
|
||||||
|
this.dropDownList.Name = "dropDownList";
|
||||||
|
this.dropDownList.Selected = "";
|
||||||
|
this.dropDownList.Size = new System.Drawing.Size(376, 51);
|
||||||
|
this.dropDownList.TabIndex = 20;
|
||||||
|
//
|
||||||
|
// FormClient
|
||||||
|
//
|
||||||
|
this.AutoScaleDimensions = new System.Drawing.SizeF(10F, 25F);
|
||||||
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(402, 450);
|
||||||
this.Text = "Form1";
|
this.Controls.Add(this.dropDownList);
|
||||||
|
this.Controls.Add(this.buttonCancel);
|
||||||
|
this.Controls.Add(this.labelStatus);
|
||||||
|
this.Controls.Add(this.labelAmount);
|
||||||
|
this.Controls.Add(this.labelReviews);
|
||||||
|
this.Controls.Add(this.labelFIO);
|
||||||
|
this.Controls.Add(this.buttonSave);
|
||||||
|
this.Controls.Add(this.textBoxReviews);
|
||||||
|
this.Controls.Add(this.textBoxFIO);
|
||||||
|
this.Controls.Add(this.userControlIntegerInput);
|
||||||
|
this.Name = "FormClient";
|
||||||
|
this.Text = "Клиент";
|
||||||
|
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.FormClient_FormClosing);
|
||||||
|
this.Load += new System.EventHandler(this.FormClient_Load);
|
||||||
|
this.ResumeLayout(false);
|
||||||
|
this.PerformLayout();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
private Button buttonCancel;
|
||||||
|
private Label labelStatus;
|
||||||
|
private Label labelAmount;
|
||||||
|
private Label labelReviews;
|
||||||
|
private Label labelFIO;
|
||||||
|
private Button buttonSave;
|
||||||
|
private TextBox textBoxReviews;
|
||||||
|
private TextBox textBoxFIO;
|
||||||
|
private Components.UserControlIntegerInput userControlIntegerInput;
|
||||||
|
private WinFormsLibrary.DropDownList dropDownList;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,10 +1,125 @@
|
|||||||
|
using ClientRecordContracts.BindingModels;
|
||||||
|
using ClientRecordContracts.BusinessLogicContracts;
|
||||||
|
using ClientRecordContracts.SearchModels;
|
||||||
|
using ClientRecordContracts.ViewModels;
|
||||||
|
using DocumentFormat.OpenXml.Vml.Office;
|
||||||
|
|
||||||
namespace ClientRecordView
|
namespace ClientRecordView
|
||||||
{
|
{
|
||||||
public partial class FormClient : Form
|
public partial class FormClient : Form
|
||||||
{
|
{
|
||||||
public FormClient()
|
private int? _id;
|
||||||
|
|
||||||
|
private bool _isModified = false;
|
||||||
|
|
||||||
|
private readonly IClientLogic _clientlogic;
|
||||||
|
|
||||||
|
private readonly IStatusLogic _statusLogic;
|
||||||
|
|
||||||
|
private List<StatusViewModel> _statuses;
|
||||||
|
public int Id { set { _id = value; } }
|
||||||
|
public FormClient(IClientLogic logic, IStatusLogic statusLogic)
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
_clientlogic = logic;
|
||||||
|
_statusLogic = statusLogic;
|
||||||
|
_statuses = new List<StatusViewModel>();
|
||||||
|
dropDownList.ValueChanged += (_, _) => _isModified = true;
|
||||||
|
userControlIntegerInput.ElementChanged += (_, _) => _isModified = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void FormClient_Load(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
_statuses = _statusLogic.ReadList(null) ?? throw new Exception("Íå óäàëîñü ïîëó÷èòü ñïèñîê ñòàòóñîâ");
|
||||||
|
dropDownList.LoadValues(_statuses.Select(x => x.Name).ToList());
|
||||||
|
if (_id.HasValue)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var client = _clientlogic.ReadElement(new ClientSearchModel { Id = _id.Value });
|
||||||
|
if (client != null)
|
||||||
|
{
|
||||||
|
textBoxFIO.Text = client.ClientFIO;
|
||||||
|
textBoxReviews.Text = client.Reviews;
|
||||||
|
userControlIntegerInput.InputtedInteger = client.Amount;
|
||||||
|
dropDownList.Selected = client.Status;
|
||||||
|
_isModified = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message, "Îøèáêà", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void buttonSave_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(textBoxFIO.Text))
|
||||||
|
{
|
||||||
|
MessageBox.Show("Çàïîëíèòå ÔÈÎ", "Îøèáêà", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (string.IsNullOrEmpty(dropDownList.Selected))
|
||||||
|
{
|
||||||
|
MessageBox.Show("Âûáåðèòå ñòàòóñ", "Îøèáêà", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var model = new ClientBindingModel
|
||||||
|
{
|
||||||
|
Id = _id ?? 0,
|
||||||
|
ClientFIO = textBoxFIO.Text,
|
||||||
|
Reviews = textBoxReviews.Text,
|
||||||
|
Amount = userControlIntegerInput.InputtedInteger,
|
||||||
|
StatusId = _statuses.First(x => x.Name == dropDownList.Selected).Id,
|
||||||
|
};
|
||||||
|
var operationResult = _id.HasValue ? _clientlogic.Update(model) : _clientlogic.Create(model);
|
||||||
|
if (!operationResult)
|
||||||
|
{
|
||||||
|
throw new Exception("Îøèáêà ïðè ñîõðàíåíèè");
|
||||||
|
}
|
||||||
|
MessageBox.Show("Ñîõðàíåíèå ïðîøëî óñïåøíî", "Ñîîáùåíèå", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||||
|
DialogResult = DialogResult.OK;
|
||||||
|
Close();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message, "Îøèáêà", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void buttonCancel_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
DialogResult = DialogResult.Cancel;
|
||||||
|
Close();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void textBoxFIO_TextChanged(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
_isModified = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void textBoxReviews_TextChanged(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
_isModified = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void FormClient_FormClosing(object sender, FormClosingEventArgs e)
|
||||||
|
{
|
||||||
|
if (!_isModified || DialogResult == DialogResult.OK)
|
||||||
|
return;
|
||||||
|
|
||||||
|
var result = MessageBox.Show(
|
||||||
|
"Ó âàñ åñòü íåñîõðàí¸ííûå èçìåíåíèÿ. Âû äåéñòâèòåëüíî õîòèòå çàêðûòü ôîðìó?",
|
||||||
|
"Ïðåäóïðåæäåíèå",
|
||||||
|
MessageBoxButtons.YesNo,
|
||||||
|
MessageBoxIcon.Warning
|
||||||
|
);
|
||||||
|
|
||||||
|
if (result == DialogResult.No)
|
||||||
|
e.Cancel = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,64 +1,4 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<root>
|
||||||
<root>
|
|
||||||
<!--
|
|
||||||
Microsoft ResX Schema
|
|
||||||
|
|
||||||
Version 2.0
|
|
||||||
|
|
||||||
The primary goals of this format is to allow a simple XML format
|
|
||||||
that is mostly human readable. The generation and parsing of the
|
|
||||||
various data types are done through the TypeConverter classes
|
|
||||||
associated with the data types.
|
|
||||||
|
|
||||||
Example:
|
|
||||||
|
|
||||||
... ado.net/XML headers & schema ...
|
|
||||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
|
||||||
<resheader name="version">2.0</resheader>
|
|
||||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
|
||||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
|
||||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
|
||||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
|
||||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
|
||||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
|
||||||
</data>
|
|
||||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
|
||||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
|
||||||
<comment>This is a comment</comment>
|
|
||||||
</data>
|
|
||||||
|
|
||||||
There are any number of "resheader" rows that contain simple
|
|
||||||
name/value pairs.
|
|
||||||
|
|
||||||
Each data row contains a name, and value. The row also contains a
|
|
||||||
type or mimetype. Type corresponds to a .NET class that support
|
|
||||||
text/value conversion through the TypeConverter architecture.
|
|
||||||
Classes that don't support this are serialized and stored with the
|
|
||||||
mimetype set.
|
|
||||||
|
|
||||||
The mimetype is used for serialized objects, and tells the
|
|
||||||
ResXResourceReader how to depersist the object. This is currently not
|
|
||||||
extensible. For a given mimetype the value must be set accordingly:
|
|
||||||
|
|
||||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
|
||||||
that the ResXResourceWriter will generate, however the reader can
|
|
||||||
read any of the formats listed below.
|
|
||||||
|
|
||||||
mimetype: application/x-microsoft.net.object.binary.base64
|
|
||||||
value : The object must be serialized with
|
|
||||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
|
||||||
: and then encoded with base64 encoding.
|
|
||||||
|
|
||||||
mimetype: application/x-microsoft.net.object.soap.base64
|
|
||||||
value : The object must be serialized with
|
|
||||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
|
||||||
: and then encoded with base64 encoding.
|
|
||||||
|
|
||||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
|
||||||
value : The object must be serialized into a byte array
|
|
||||||
: using a System.ComponentModel.TypeConverter
|
|
||||||
: and then encoded with base64 encoding.
|
|
||||||
-->
|
|
||||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
<xsd: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:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||||
<xsd:element name="root" msdata:IsDataSet="true">
|
<xsd:element name="root" msdata:IsDataSet="true">
|
||||||
|
144
ClientRecordView/FormMain.Designer.cs
generated
144
ClientRecordView/FormMain.Designer.cs
generated
@ -29,11 +29,153 @@
|
|||||||
private void InitializeComponent()
|
private void InitializeComponent()
|
||||||
{
|
{
|
||||||
this.components = new System.ComponentModel.Container();
|
this.components = new System.ComponentModel.Container();
|
||||||
|
this.menuStrip = 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.ОтчетпоклиентамExcelToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||||
|
this.отчетСДиаграммойToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||||
|
this.статусыToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||||
|
this.componentDocumentWithChartPieExcel = new ComponentsLibraryNet60.DocumentWithChart.ComponentDocumentWithChartPieExcel(this.components);
|
||||||
|
this.wordText = new WinFormsLibrary.WordText(this.components);
|
||||||
|
this.controlDataTreeTable = new ControlsLibraryNet60.Data.ControlDataTreeTable();
|
||||||
|
this.userControlConfigurableTableDocument = new Components.Nonvisual.UserControlConfigurableTableDocument(this.components);
|
||||||
|
this.menuStrip.SuspendLayout();
|
||||||
|
this.SuspendLayout();
|
||||||
|
//
|
||||||
|
// menuStrip
|
||||||
|
//
|
||||||
|
this.menuStrip.ImageScalingSize = new System.Drawing.Size(24, 24);
|
||||||
|
this.menuStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||||
|
this.клиентыToolStripMenuItem,
|
||||||
|
this.отчетыToolStripMenuItem,
|
||||||
|
this.статусыToolStripMenuItem});
|
||||||
|
this.menuStrip.Location = new System.Drawing.Point(0, 0);
|
||||||
|
this.menuStrip.Name = "menuStrip";
|
||||||
|
this.menuStrip.Size = new System.Drawing.Size(800, 33);
|
||||||
|
this.menuStrip.TabIndex = 0;
|
||||||
|
this.menuStrip.Text = "menuStrip";
|
||||||
|
//
|
||||||
|
// клиентыToolStripMenuItem
|
||||||
|
//
|
||||||
|
this.клиентыToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||||
|
this.СозданиеToolStripMenuItem,
|
||||||
|
this.редToolStripMenuItem,
|
||||||
|
this.удалениеToolStripMenuItem});
|
||||||
|
this.клиентыToolStripMenuItem.Name = "клиентыToolStripMenuItem";
|
||||||
|
this.клиентыToolStripMenuItem.Size = new System.Drawing.Size(96, 29);
|
||||||
|
this.клиентыToolStripMenuItem.Text = "Клиенты";
|
||||||
|
//
|
||||||
|
// СозданиеToolStripMenuItem
|
||||||
|
//
|
||||||
|
this.СозданиеToolStripMenuItem.Name = "СозданиеToolStripMenuItem";
|
||||||
|
this.СозданиеToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.A)));
|
||||||
|
this.СозданиеToolStripMenuItem.Size = new System.Drawing.Size(311, 34);
|
||||||
|
this.СозданиеToolStripMenuItem.Text = "Создание";
|
||||||
|
this.СозданиеToolStripMenuItem.Click += new System.EventHandler(this.СозданиеToolStripMenuItem_Click);
|
||||||
|
//
|
||||||
|
// редToolStripMenuItem
|
||||||
|
//
|
||||||
|
this.редToolStripMenuItem.Name = "редToolStripMenuItem";
|
||||||
|
this.редToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.U)));
|
||||||
|
this.редToolStripMenuItem.Size = new System.Drawing.Size(311, 34);
|
||||||
|
this.редToolStripMenuItem.Text = "Редактирование";
|
||||||
|
this.редToolStripMenuItem.Click += new System.EventHandler(this.редToolStripMenuItem_Click);
|
||||||
|
//
|
||||||
|
// удалениеToolStripMenuItem
|
||||||
|
//
|
||||||
|
this.удалениеToolStripMenuItem.Name = "удалениеToolStripMenuItem";
|
||||||
|
this.удалениеToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.D)));
|
||||||
|
this.удалениеToolStripMenuItem.Size = new System.Drawing.Size(311, 34);
|
||||||
|
this.удалениеToolStripMenuItem.Text = "Удаление";
|
||||||
|
this.удалениеToolStripMenuItem.Click += new System.EventHandler(this.удалениеToolStripMenuItem_Click);
|
||||||
|
//
|
||||||
|
// отчетыToolStripMenuItem
|
||||||
|
//
|
||||||
|
this.отчетыToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||||
|
this.ОтзывыToolStripMenuItem,
|
||||||
|
this.ОтчетпоклиентамExcelToolStripMenuItem,
|
||||||
|
this.отчетСДиаграммойToolStripMenuItem});
|
||||||
|
this.отчетыToolStripMenuItem.Name = "отчетыToolStripMenuItem";
|
||||||
|
this.отчетыToolStripMenuItem.Size = new System.Drawing.Size(88, 29);
|
||||||
|
this.отчетыToolStripMenuItem.Text = "Отчеты";
|
||||||
|
//
|
||||||
|
// ОтзывыToolStripMenuItem
|
||||||
|
//
|
||||||
|
this.ОтзывыToolStripMenuItem.Name = "ОтзывыToolStripMenuItem";
|
||||||
|
this.ОтзывыToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.S)));
|
||||||
|
this.ОтзывыToolStripMenuItem.Size = new System.Drawing.Size(344, 34);
|
||||||
|
this.ОтзывыToolStripMenuItem.Text = "Отзывы о покупках";
|
||||||
|
this.ОтзывыToolStripMenuItem.Click += new System.EventHandler(this.ОтзывыToolStripMenuItem_Click);
|
||||||
|
//
|
||||||
|
// ОтчетпоклиентамExcelToolStripMenuItem
|
||||||
|
//
|
||||||
|
this.ОтчетпоклиентамExcelToolStripMenuItem.Name = "ОтчетпоклиентамExcelToolStripMenuItem";
|
||||||
|
this.ОтчетпоклиентамExcelToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.T)));
|
||||||
|
this.ОтчетпоклиентамExcelToolStripMenuItem.Size = new System.Drawing.Size(344, 34);
|
||||||
|
this.ОтчетпоклиентамExcelToolStripMenuItem.Text = "Отчет по клиентам";
|
||||||
|
this.ОтчетпоклиентамExcelToolStripMenuItem.Click += new System.EventHandler(this.ОтчетпоклиентамExcelToolStripMenuItem_Click);
|
||||||
|
//
|
||||||
|
// отчетСДиаграммойToolStripMenuItem
|
||||||
|
//
|
||||||
|
this.отчетСДиаграммойToolStripMenuItem.Name = "отчетСДиаграммойToolStripMenuItem";
|
||||||
|
this.отчетСДиаграммойToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.C)));
|
||||||
|
this.отчетСДиаграммойToolStripMenuItem.Size = new System.Drawing.Size(344, 34);
|
||||||
|
this.отчетСДиаграммойToolStripMenuItem.Text = "Отчет с диаграммой";
|
||||||
|
this.отчетСДиаграммойToolStripMenuItem.Click += new System.EventHandler(this.отчетСДиаграммойToolStripMenuItem_Click);
|
||||||
|
//
|
||||||
|
// статусыToolStripMenuItem
|
||||||
|
//
|
||||||
|
this.статусыToolStripMenuItem.Name = "статусыToolStripMenuItem";
|
||||||
|
this.статусыToolStripMenuItem.Size = new System.Drawing.Size(92, 29);
|
||||||
|
this.статусыToolStripMenuItem.Text = "Статусы";
|
||||||
|
this.статусыToolStripMenuItem.Click += new System.EventHandler(this.статусыToolStripMenuItem_Click);
|
||||||
|
//
|
||||||
|
// controlDataTreeTable
|
||||||
|
//
|
||||||
|
this.controlDataTreeTable.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||||
|
this.controlDataTreeTable.Location = new System.Drawing.Point(0, 33);
|
||||||
|
this.controlDataTreeTable.Margin = new System.Windows.Forms.Padding(5, 6, 5, 6);
|
||||||
|
this.controlDataTreeTable.Name = "controlDataTreeTable";
|
||||||
|
this.controlDataTreeTable.Size = new System.Drawing.Size(800, 417);
|
||||||
|
this.controlDataTreeTable.TabIndex = 1;
|
||||||
|
//
|
||||||
|
// FormMain
|
||||||
|
//
|
||||||
|
this.AutoScaleDimensions = new System.Drawing.SizeF(10F, 25F);
|
||||||
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(800, 450);
|
||||||
this.Text = "FormMain";
|
this.Controls.Add(this.controlDataTreeTable);
|
||||||
|
this.Controls.Add(this.menuStrip);
|
||||||
|
this.MainMenuStrip = this.menuStrip;
|
||||||
|
this.Name = "FormMain";
|
||||||
|
this.Text = "Основная форма";
|
||||||
|
this.Load += new System.EventHandler(this.FormMain_Load);
|
||||||
|
this.menuStrip.ResumeLayout(false);
|
||||||
|
this.menuStrip.PerformLayout();
|
||||||
|
this.ResumeLayout(false);
|
||||||
|
this.PerformLayout();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
private MenuStrip menuStrip;
|
||||||
|
private ToolStripMenuItem клиентыToolStripMenuItem;
|
||||||
|
private ToolStripMenuItem СозданиеToolStripMenuItem;
|
||||||
|
private ToolStripMenuItem редToolStripMenuItem;
|
||||||
|
private ToolStripMenuItem удалениеToolStripMenuItem;
|
||||||
|
private ToolStripMenuItem отчетыToolStripMenuItem;
|
||||||
|
private ToolStripMenuItem ОтзывыToolStripMenuItem;
|
||||||
|
private ToolStripMenuItem ОтчетпоклиентамExcelToolStripMenuItem;
|
||||||
|
private ToolStripMenuItem отчетСДиаграммойToolStripMenuItem;
|
||||||
|
private ToolStripMenuItem статусыToolStripMenuItem;
|
||||||
|
private ComponentsLibraryNet60.DocumentWithChart.ComponentDocumentWithChartPieExcel componentDocumentWithChartPieExcel;
|
||||||
|
private WinFormsLibrary.WordText wordText;
|
||||||
|
private ControlsLibraryNet60.Data.ControlDataTreeTable controlDataTreeTable;
|
||||||
|
private Components.Nonvisual.UserControlConfigurableTableDocument userControlConfigurableTableDocument;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,20 +1,219 @@
|
|||||||
using System;
|
using ClientRecordContracts.BindingModels;
|
||||||
using System.Collections.Generic;
|
using ClientRecordContracts.BusinessLogicContracts;
|
||||||
using System.ComponentModel;
|
using ClientRecordContracts.ViewModels;
|
||||||
using System.Data;
|
using ComponentsLibraryNet60.DocumentWithTable;
|
||||||
using System.Drawing;
|
using ComponentsLibraryNet60.Models;
|
||||||
using System.Linq;
|
using ControlsLibraryNet60.Data;
|
||||||
|
using ControlsLibraryNet60.Models;
|
||||||
|
using DocumentFormat.OpenXml.Spreadsheet;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using WinFormsLibrary.NonVisualComponents.Helpers;
|
||||||
using System.Windows.Forms;
|
|
||||||
|
|
||||||
namespace ClientRecordView
|
namespace ClientRecordView
|
||||||
{
|
{
|
||||||
public partial class FormMain : Form
|
public partial class FormMain : Form
|
||||||
{
|
{
|
||||||
public FormMain()
|
private readonly IClientLogic _logic;
|
||||||
|
public FormMain(IClientLogic clientLogic)
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
_logic = clientLogic;
|
||||||
|
|
||||||
|
var nodeNames = new Queue<string>();
|
||||||
|
nodeNames.Enqueue("Status");
|
||||||
|
nodeNames.Enqueue("AmountString");
|
||||||
|
nodeNames.Enqueue("Id");
|
||||||
|
nodeNames.Enqueue("ClientFIO");
|
||||||
|
controlDataTreeTable.LoadConfig(new DataTreeNodeConfig { NodeNames = nodeNames});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void LoadData()
|
||||||
|
{
|
||||||
|
controlDataTreeTable.Clear();
|
||||||
|
var clients = _logic.ReadList(null);
|
||||||
|
if (clients != null)
|
||||||
|
{
|
||||||
|
foreach (var client in clients)
|
||||||
|
{
|
||||||
|
client.AmountString = client.Amount?.ToString() ?? "Нет";
|
||||||
|
}
|
||||||
|
controlDataTreeTable.AddTable(clients);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void СозданиеToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
var service = Program.ServiceProvider?.GetService(typeof(FormClient));
|
||||||
|
if (service is FormClient form)
|
||||||
|
{
|
||||||
|
if (form.ShowDialog() == DialogResult.OK)
|
||||||
|
{
|
||||||
|
LoadData();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void редToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
var service = Program.ServiceProvider?.GetService(typeof(FormClient));
|
||||||
|
if (service is FormClient form)
|
||||||
|
{
|
||||||
|
var selected = controlDataTreeTable.GetSelectedObject<ClientViewModel>();
|
||||||
|
if (selected == null)
|
||||||
|
return;
|
||||||
|
form.Id = selected.Id;
|
||||||
|
if (form.ShowDialog() == DialogResult.OK)
|
||||||
|
{
|
||||||
|
LoadData();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void удалениеToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
var selected = controlDataTreeTable.GetSelectedObject<ClientViewModel>();
|
||||||
|
if (selected == null)
|
||||||
|
return;
|
||||||
|
if (MessageBox.Show("Удалить запись?", "", MessageBoxButtons.YesNo) == DialogResult.Yes)
|
||||||
|
{
|
||||||
|
if (_logic.Delete(new ClientBindingModel { Id = selected.Id }))
|
||||||
|
{
|
||||||
|
LoadData();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ОтзывыToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
using var dialog = new SaveFileDialog
|
||||||
|
{
|
||||||
|
Filter = "docx|*.docx"
|
||||||
|
};
|
||||||
|
if (dialog.ShowDialog() == DialogResult.OK)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var clients = _logic.ReadList(null) ?? throw new Exception("Не удалось получить список клиентов");
|
||||||
|
List<string> paragraphs = new();
|
||||||
|
foreach (var client in clients)
|
||||||
|
{
|
||||||
|
if (client.Amount != null)
|
||||||
|
{
|
||||||
|
paragraphs.Add($"{client.ClientFIO}: {(string.IsNullOrWhiteSpace(client.ClientFIO) ? "Отзывы отсутствуют" : client.Reviews)}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
wordText.CreateWordText(new LongWordInfo()
|
||||||
|
{
|
||||||
|
Path = dialog.FileName,
|
||||||
|
Title = "Клиенты, совершашие покупки",
|
||||||
|
Paragraphs = paragraphs.ToArray()
|
||||||
|
});
|
||||||
|
MessageBox.Show("Готово!");
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show("Произошла ошибка: " + ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ОтчетпоклиентамExcelToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
|
||||||
|
using var dialog = new SaveFileDialog
|
||||||
|
{
|
||||||
|
Filter = "PDF Files|*.pdf"
|
||||||
|
};
|
||||||
|
if (dialog.ShowDialog() == DialogResult.OK)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var clients = _logic.ReadList(null) ?? throw new Exception("Не удалось получить список аккаунтов");
|
||||||
|
foreach (var account in clients)
|
||||||
|
{
|
||||||
|
account.AmountString = account.Amount?.ToString() ?? "нет";
|
||||||
|
}
|
||||||
|
userControlConfigurableTableDocument.SaveToDocument(
|
||||||
|
dialog.FileName,
|
||||||
|
"Учет клиентов",
|
||||||
|
new List<(double , string Header, string PropertyName)>
|
||||||
|
{
|
||||||
|
(1, "Id", "Id"),
|
||||||
|
(3, "ФИО", "ClientFIO"),
|
||||||
|
(2, "Статус", "Status"),
|
||||||
|
(3, "Сумма", "AmountString")
|
||||||
|
},
|
||||||
|
2,
|
||||||
|
2,
|
||||||
|
clients.OrderBy(x => x.Id).ToList()
|
||||||
|
);
|
||||||
|
MessageBox.Show("Готово!");
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show("Произошла ошибка: " + ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void отчетСДиаграммойToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
using var dialog = new SaveFileDialog
|
||||||
|
{
|
||||||
|
Filter = "Excel Files|*.xlsx"
|
||||||
|
};
|
||||||
|
if (dialog.ShowDialog() == DialogResult.OK)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var clients = _logic.ReadList(null) ?? throw new Exception("Не удалось получить список клиентов");
|
||||||
|
var statusMapping = new List<string>();
|
||||||
|
var data = new Dictionary<string, List<(int Date, double Value)>>
|
||||||
|
{
|
||||||
|
{
|
||||||
|
"Клиенты",
|
||||||
|
clients
|
||||||
|
.Where(x => x.Status != null)
|
||||||
|
.GroupBy(x => x.Status)
|
||||||
|
.Select((group, index) =>
|
||||||
|
{
|
||||||
|
statusMapping.Add($"{group.Key} - {index + 1}");
|
||||||
|
|
||||||
|
return (Date: index + 1, Value: (double)group.Count());
|
||||||
|
})
|
||||||
|
.ToList()
|
||||||
|
}
|
||||||
|
};
|
||||||
|
componentDocumentWithChartPieExcel.CreateDoc(new ComponentDocumentWithChartConfig
|
||||||
|
{
|
||||||
|
FilePath = dialog.FileName,
|
||||||
|
Header = $"Клиенты, совершавшие покупки, по статусам ({string.Join(", ", statusMapping)})",
|
||||||
|
ChartTitle = "Круговая диаграмма",
|
||||||
|
LegendLocation = ComponentsLibraryNet60.Models.Location.Bottom,
|
||||||
|
Data = data
|
||||||
|
});
|
||||||
|
MessageBox.Show("Готово!");
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show("Произошла ошибка: " + ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void статусыToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
var service = Program.ServiceProvider?.GetService(typeof(FormStatuses));
|
||||||
|
if (service is FormStatuses form)
|
||||||
|
{
|
||||||
|
form.ShowDialog();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void FormMain_Load(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
LoadData();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,64 +1,4 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<root>
|
||||||
<root>
|
|
||||||
<!--
|
|
||||||
Microsoft ResX Schema
|
|
||||||
|
|
||||||
Version 2.0
|
|
||||||
|
|
||||||
The primary goals of this format is to allow a simple XML format
|
|
||||||
that is mostly human readable. The generation and parsing of the
|
|
||||||
various data types are done through the TypeConverter classes
|
|
||||||
associated with the data types.
|
|
||||||
|
|
||||||
Example:
|
|
||||||
|
|
||||||
... ado.net/XML headers & schema ...
|
|
||||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
|
||||||
<resheader name="version">2.0</resheader>
|
|
||||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
|
||||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
|
||||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
|
||||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
|
||||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
|
||||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
|
||||||
</data>
|
|
||||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
|
||||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
|
||||||
<comment>This is a comment</comment>
|
|
||||||
</data>
|
|
||||||
|
|
||||||
There are any number of "resheader" rows that contain simple
|
|
||||||
name/value pairs.
|
|
||||||
|
|
||||||
Each data row contains a name, and value. The row also contains a
|
|
||||||
type or mimetype. Type corresponds to a .NET class that support
|
|
||||||
text/value conversion through the TypeConverter architecture.
|
|
||||||
Classes that don't support this are serialized and stored with the
|
|
||||||
mimetype set.
|
|
||||||
|
|
||||||
The mimetype is used for serialized objects, and tells the
|
|
||||||
ResXResourceReader how to depersist the object. This is currently not
|
|
||||||
extensible. For a given mimetype the value must be set accordingly:
|
|
||||||
|
|
||||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
|
||||||
that the ResXResourceWriter will generate, however the reader can
|
|
||||||
read any of the formats listed below.
|
|
||||||
|
|
||||||
mimetype: application/x-microsoft.net.object.binary.base64
|
|
||||||
value : The object must be serialized with
|
|
||||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
|
||||||
: and then encoded with base64 encoding.
|
|
||||||
|
|
||||||
mimetype: application/x-microsoft.net.object.soap.base64
|
|
||||||
value : The object must be serialized with
|
|
||||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
|
||||||
: and then encoded with base64 encoding.
|
|
||||||
|
|
||||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
|
||||||
value : The object must be serialized into a byte array
|
|
||||||
: using a System.ComponentModel.TypeConverter
|
|
||||||
: and then encoded with base64 encoding.
|
|
||||||
-->
|
|
||||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
<xsd: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:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||||
<xsd:element name="root" msdata:IsDataSet="true">
|
<xsd:element name="root" msdata:IsDataSet="true">
|
||||||
@ -117,4 +57,19 @@
|
|||||||
<resheader name="writer">
|
<resheader name="writer">
|
||||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
</resheader>
|
</resheader>
|
||||||
|
<metadata name="menuStrip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||||
|
<value>17, 17</value>
|
||||||
|
</metadata>
|
||||||
|
<metadata name="componentDocumentWithChartPieExcel.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||||
|
<value>302, 17</value>
|
||||||
|
</metadata>
|
||||||
|
<metadata name="wordText.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||||
|
<value>295, 49</value>
|
||||||
|
</metadata>
|
||||||
|
<metadata name="userControlConfigurableTableDocument.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||||
|
<value>424, 49</value>
|
||||||
|
</metadata>
|
||||||
|
<metadata name="$this.TrayHeight" type="System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
|
<value>112</value>
|
||||||
|
</metadata>
|
||||||
</root>
|
</root>
|
57
ClientRecordView/FormStatuses.Designer.cs
generated
57
ClientRecordView/FormStatuses.Designer.cs
generated
@ -28,12 +28,65 @@
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
private void InitializeComponent()
|
private void InitializeComponent()
|
||||||
{
|
{
|
||||||
this.components = new System.ComponentModel.Container();
|
this.dataGridView = new System.Windows.Forms.DataGridView();
|
||||||
|
this.NameCol = new System.Windows.Forms.DataGridViewTextBoxColumn();
|
||||||
|
this.Id = new System.Windows.Forms.DataGridViewTextBoxColumn();
|
||||||
|
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
|
||||||
|
this.SuspendLayout();
|
||||||
|
//
|
||||||
|
// dataGridView
|
||||||
|
//
|
||||||
|
this.dataGridView.BackgroundColor = System.Drawing.SystemColors.ControlLightLight;
|
||||||
|
this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||||
|
this.dataGridView.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
|
||||||
|
this.NameCol,
|
||||||
|
this.Id});
|
||||||
|
this.dataGridView.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||||
|
this.dataGridView.Location = new System.Drawing.Point(0, 0);
|
||||||
|
this.dataGridView.Margin = new System.Windows.Forms.Padding(4);
|
||||||
|
this.dataGridView.Name = "dataGridView";
|
||||||
|
this.dataGridView.RowHeadersWidth = 51;
|
||||||
|
this.dataGridView.RowTemplate.Height = 29;
|
||||||
|
this.dataGridView.Size = new System.Drawing.Size(800, 450);
|
||||||
|
this.dataGridView.TabIndex = 1;
|
||||||
|
this.dataGridView.CellValueChanged += new System.Windows.Forms.DataGridViewCellEventHandler(this.dataGridView_CellValueChanged);
|
||||||
|
this.dataGridView.UserDeletingRow += new System.Windows.Forms.DataGridViewRowCancelEventHandler(this.dataGridView_UserDeletingRow);
|
||||||
|
this.dataGridView.KeyDown += new System.Windows.Forms.KeyEventHandler(this.dataGridView_KeyDown);
|
||||||
|
this.dataGridView.KeyUp += new System.Windows.Forms.KeyEventHandler(this.dataGridView_KeyUp);
|
||||||
|
//
|
||||||
|
// NameCol
|
||||||
|
//
|
||||||
|
this.NameCol.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
|
||||||
|
this.NameCol.HeaderText = "Название";
|
||||||
|
this.NameCol.MinimumWidth = 6;
|
||||||
|
this.NameCol.Name = "NameCol";
|
||||||
|
//
|
||||||
|
// Id
|
||||||
|
//
|
||||||
|
this.Id.HeaderText = "Id";
|
||||||
|
this.Id.MinimumWidth = 6;
|
||||||
|
this.Id.Name = "Id";
|
||||||
|
this.Id.Visible = false;
|
||||||
|
this.Id.Width = 6;
|
||||||
|
//
|
||||||
|
// FormStatuses
|
||||||
|
//
|
||||||
|
this.AutoScaleDimensions = new System.Drawing.SizeF(10F, 25F);
|
||||||
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(800, 450);
|
||||||
this.Text = "FormStatuse";
|
this.Controls.Add(this.dataGridView);
|
||||||
|
this.Name = "FormStatuses";
|
||||||
|
this.Text = "Статусы";
|
||||||
|
this.Load += new System.EventHandler(this.FormStatuses_Load);
|
||||||
|
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit();
|
||||||
|
this.ResumeLayout(false);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
private DataGridView dataGridView;
|
||||||
|
private DataGridViewTextBoxColumn NameCol;
|
||||||
|
private DataGridViewTextBoxColumn Id;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,20 +1,109 @@
|
|||||||
using System;
|
using ClientRecordContracts.BindingModels;
|
||||||
using System.Collections.Generic;
|
using ClientRecordContracts.BusinessLogicContracts;
|
||||||
using System.ComponentModel;
|
using ClientRecordContracts.SearchModels;
|
||||||
using System.Data;
|
|
||||||
using System.Drawing;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using System.Windows.Forms;
|
|
||||||
|
|
||||||
namespace ClientRecordView
|
namespace ClientRecordView
|
||||||
{
|
{
|
||||||
public partial class FormStatuses : Form
|
public partial class FormStatuses : Form
|
||||||
{
|
{
|
||||||
public FormStatuses()
|
private readonly IStatusLogic _logic;
|
||||||
|
|
||||||
|
private bool dataLoading = false;
|
||||||
|
public FormStatuses(IStatusLogic statusLogic)
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
_logic = statusLogic;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void FormStatuses_Load(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
LoadData();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void LoadData()
|
||||||
|
{
|
||||||
|
dataLoading = true;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var list = _logic.ReadList(null);
|
||||||
|
if (list != null)
|
||||||
|
{
|
||||||
|
foreach (var role in list)
|
||||||
|
{
|
||||||
|
int rowIndex = dataGridView.Rows.Add();
|
||||||
|
dataGridView.Rows[rowIndex].Cells[0].Value = role.Name;
|
||||||
|
dataGridView.Rows[rowIndex].Cells[1].Value = role.Id;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
dataLoading = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void dataGridView_CellValueChanged(object sender, DataGridViewCellEventArgs e)
|
||||||
|
{
|
||||||
|
if (dataLoading || e.RowIndex < 0 || e.ColumnIndex != 0)
|
||||||
|
return;
|
||||||
|
if (dataGridView.Rows[e.RowIndex].Cells[1].Value != null)
|
||||||
|
{
|
||||||
|
var name = dataGridView.Rows[e.RowIndex].Cells[0].Value?.ToString()
|
||||||
|
?? throw new Exception("Не заполнено название статуса");
|
||||||
|
_logic.Update(new StatusBindingModel { Id = Convert.ToInt32(dataGridView.Rows[e.RowIndex].Cells[1].Value), Name = name });
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var name = dataGridView.Rows[e.RowIndex].Cells[0].Value?.ToString()
|
||||||
|
?? throw new Exception("Не заполнено название статуса");
|
||||||
|
_logic.Create(new StatusBindingModel { Id = 0, Name = name });
|
||||||
|
var list = _logic.ReadList(null) ?? throw new Exception("Не удалось получить список статусов");
|
||||||
|
int newRoleId = list.Last().Id;
|
||||||
|
dataGridView.Rows[e.RowIndex].Cells[1].Value = newRoleId;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void dataGridView_KeyUp(object sender, KeyEventArgs e)
|
||||||
|
{
|
||||||
|
switch (e.KeyCode)
|
||||||
|
{
|
||||||
|
case Keys.Insert:
|
||||||
|
dataGridView.Rows.Add();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void DeleteRows(DataGridViewSelectedRowCollection rows)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < rows.Count; i++)
|
||||||
|
{
|
||||||
|
DataGridViewRow row = rows[i];
|
||||||
|
if (row.IsNewRow)
|
||||||
|
continue;
|
||||||
|
if (row.Cells[1].Value != null && !_logic.Delete(new StatusBindingModel { Id = Convert.ToInt32(row.Cells[1].Value), Name = row.Cells[0].Value?.ToString() }))
|
||||||
|
throw new Exception($"Ошибка удаления строки: {row.Cells[0].Value}");
|
||||||
|
dataGridView.Rows.Remove(row);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void dataGridView_UserDeletingRow(object sender, DataGridViewRowCancelEventArgs e)
|
||||||
|
{
|
||||||
|
e.Cancel = true;
|
||||||
|
if (dataGridView.SelectedRows == null)
|
||||||
|
return;
|
||||||
|
if (MessageBox.Show("Удалить записи?", "Подтвердите действие", MessageBoxButtons.YesNo) == DialogResult.No)
|
||||||
|
return;
|
||||||
|
DeleteRows(dataGridView.SelectedRows);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void dataGridView_KeyDown(object sender, KeyEventArgs e)
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,64 +1,4 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<root>
|
||||||
<root>
|
|
||||||
<!--
|
|
||||||
Microsoft ResX Schema
|
|
||||||
|
|
||||||
Version 2.0
|
|
||||||
|
|
||||||
The primary goals of this format is to allow a simple XML format
|
|
||||||
that is mostly human readable. The generation and parsing of the
|
|
||||||
various data types are done through the TypeConverter classes
|
|
||||||
associated with the data types.
|
|
||||||
|
|
||||||
Example:
|
|
||||||
|
|
||||||
... ado.net/XML headers & schema ...
|
|
||||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
|
||||||
<resheader name="version">2.0</resheader>
|
|
||||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
|
||||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
|
||||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
|
||||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
|
||||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
|
||||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
|
||||||
</data>
|
|
||||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
|
||||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
|
||||||
<comment>This is a comment</comment>
|
|
||||||
</data>
|
|
||||||
|
|
||||||
There are any number of "resheader" rows that contain simple
|
|
||||||
name/value pairs.
|
|
||||||
|
|
||||||
Each data row contains a name, and value. The row also contains a
|
|
||||||
type or mimetype. Type corresponds to a .NET class that support
|
|
||||||
text/value conversion through the TypeConverter architecture.
|
|
||||||
Classes that don't support this are serialized and stored with the
|
|
||||||
mimetype set.
|
|
||||||
|
|
||||||
The mimetype is used for serialized objects, and tells the
|
|
||||||
ResXResourceReader how to depersist the object. This is currently not
|
|
||||||
extensible. For a given mimetype the value must be set accordingly:
|
|
||||||
|
|
||||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
|
||||||
that the ResXResourceWriter will generate, however the reader can
|
|
||||||
read any of the formats listed below.
|
|
||||||
|
|
||||||
mimetype: application/x-microsoft.net.object.binary.base64
|
|
||||||
value : The object must be serialized with
|
|
||||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
|
||||||
: and then encoded with base64 encoding.
|
|
||||||
|
|
||||||
mimetype: application/x-microsoft.net.object.soap.base64
|
|
||||||
value : The object must be serialized with
|
|
||||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
|
||||||
: and then encoded with base64 encoding.
|
|
||||||
|
|
||||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
|
||||||
value : The object must be serialized into a byte array
|
|
||||||
: using a System.ComponentModel.TypeConverter
|
|
||||||
: and then encoded with base64 encoding.
|
|
||||||
-->
|
|
||||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
<xsd: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:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||||
<xsd:element name="root" msdata:IsDataSet="true">
|
<xsd:element name="root" msdata:IsDataSet="true">
|
||||||
@ -117,4 +57,7 @@
|
|||||||
<resheader name="writer">
|
<resheader name="writer">
|
||||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
</resheader>
|
</resheader>
|
||||||
|
<metadata name="Id.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
|
<value>True</value>
|
||||||
|
</metadata>
|
||||||
</root>
|
</root>
|
@ -29,43 +29,31 @@
|
|||||||
private void InitializeComponent()
|
private void InitializeComponent()
|
||||||
{
|
{
|
||||||
this.comboBox = new System.Windows.Forms.ComboBox();
|
this.comboBox = new System.Windows.Forms.ComboBox();
|
||||||
this.labelDropDownList = new System.Windows.Forms.Label();
|
|
||||||
this.SuspendLayout();
|
this.SuspendLayout();
|
||||||
//
|
//
|
||||||
// comboBox
|
// comboBox
|
||||||
//
|
//
|
||||||
this.comboBox.FormattingEnabled = true;
|
this.comboBox.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||||
this.comboBox.Location = new System.Drawing.Point(3, 60);
|
this.comboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||||
|
this.comboBox.Location = new System.Drawing.Point(0, 0);
|
||||||
this.comboBox.Name = "comboBox";
|
this.comboBox.Name = "comboBox";
|
||||||
this.comboBox.Size = new System.Drawing.Size(182, 33);
|
this.comboBox.Size = new System.Drawing.Size(199, 33);
|
||||||
this.comboBox.TabIndex = 0;
|
this.comboBox.TabIndex = 0;
|
||||||
this.comboBox.SelectedIndexChanged += new System.EventHandler(this.comboBox_SelectedIndexChanged);
|
this.comboBox.SelectedIndexChanged += new System.EventHandler(this.comboBox_SelectedIndexChanged);
|
||||||
//
|
//
|
||||||
// labelDropDownList
|
|
||||||
//
|
|
||||||
this.labelDropDownList.AutoSize = true;
|
|
||||||
this.labelDropDownList.Location = new System.Drawing.Point(3, 12);
|
|
||||||
this.labelDropDownList.Name = "labelDropDownList";
|
|
||||||
this.labelDropDownList.Size = new System.Drawing.Size(184, 25);
|
|
||||||
this.labelDropDownList.TabIndex = 1;
|
|
||||||
this.labelDropDownList.Text = "Выпадающий список";
|
|
||||||
//
|
|
||||||
// DropDownList
|
// DropDownList
|
||||||
//
|
//
|
||||||
this.AutoScaleDimensions = new System.Drawing.SizeF(10F, 25F);
|
this.AutoScaleDimensions = new System.Drawing.SizeF(10F, 25F);
|
||||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
this.Controls.Add(this.labelDropDownList);
|
|
||||||
this.Controls.Add(this.comboBox);
|
this.Controls.Add(this.comboBox);
|
||||||
this.Name = "DropDownList";
|
this.Name = "DropDownList";
|
||||||
this.Size = new System.Drawing.Size(199, 105);
|
this.Size = new System.Drawing.Size(199, 34);
|
||||||
this.ResumeLayout(false);
|
this.ResumeLayout(false);
|
||||||
this.PerformLayout();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
private ComboBox comboBox;
|
private ComboBox comboBox;
|
||||||
private Label labelDropDownList;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -38,7 +38,7 @@
|
|||||||
//
|
//
|
||||||
this.textBoxEmail.Location = new System.Drawing.Point(0, 55);
|
this.textBoxEmail.Location = new System.Drawing.Point(0, 55);
|
||||||
this.textBoxEmail.Name = "textBoxEmail";
|
this.textBoxEmail.Name = "textBoxEmail";
|
||||||
this.textBoxEmail.Size = new System.Drawing.Size(181, 31);
|
this.textBoxEmail.Size = new System.Drawing.Size(209, 31);
|
||||||
this.textBoxEmail.TabIndex = 0;
|
this.textBoxEmail.TabIndex = 0;
|
||||||
this.textBoxEmail.TextChanged += new System.EventHandler(this.textBoxEmail_TextChanged);
|
this.textBoxEmail.TextChanged += new System.EventHandler(this.textBoxEmail_TextChanged);
|
||||||
this.textBoxEmail.MouseEnter += new System.EventHandler(this.textBoxEmail_MouseEnter);
|
this.textBoxEmail.MouseEnter += new System.EventHandler(this.textBoxEmail_MouseEnter);
|
||||||
@ -48,9 +48,9 @@
|
|||||||
this.labelEmail.AutoSize = true;
|
this.labelEmail.AutoSize = true;
|
||||||
this.labelEmail.Location = new System.Drawing.Point(3, 6);
|
this.labelEmail.Location = new System.Drawing.Point(3, 6);
|
||||||
this.labelEmail.Name = "labelEmail";
|
this.labelEmail.Name = "labelEmail";
|
||||||
this.labelEmail.Size = new System.Drawing.Size(129, 25);
|
this.labelEmail.Size = new System.Drawing.Size(62, 25);
|
||||||
this.labelEmail.TabIndex = 1;
|
this.labelEmail.TabIndex = 1;
|
||||||
this.labelEmail.Text = "Введите почту";
|
this.labelEmail.Text = "Почта";
|
||||||
//
|
//
|
||||||
// EmailTextBox
|
// EmailTextBox
|
||||||
//
|
//
|
||||||
@ -59,7 +59,7 @@
|
|||||||
this.Controls.Add(this.labelEmail);
|
this.Controls.Add(this.labelEmail);
|
||||||
this.Controls.Add(this.textBoxEmail);
|
this.Controls.Add(this.textBoxEmail);
|
||||||
this.Name = "EmailTextBox";
|
this.Name = "EmailTextBox";
|
||||||
this.Size = new System.Drawing.Size(209, 118);
|
this.Size = new System.Drawing.Size(185, 86);
|
||||||
this.ResumeLayout(false);
|
this.ResumeLayout(false);
|
||||||
this.PerformLayout();
|
this.PerformLayout();
|
||||||
|
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
<UseWindowsForms>true</UseWindowsForms>
|
<UseWindowsForms>true</UseWindowsForms>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
Loading…
Reference in New Issue
Block a user