Не работает создание договора

This commit is contained in:
maxnes3 2023-05-02 22:57:54 +04:00
parent 963ead9e0a
commit 422eba9d32
47 changed files with 2611 additions and 686 deletions

View File

@ -11,7 +11,7 @@ namespace PersonnelDepartmentContracts.BindingModels
{
public DateTime DateFrom { get; set; }
public DateTime? DateTo { get; set; }
public DateTime DateTo { get; set; }
public int PositionId { get; set; }

View File

@ -11,7 +11,7 @@ namespace PersonnelDepartmentContracts.BindingModels
{
public string Name { get; set; } = string.Empty;
public int Telephone { get; set; }
public long Telephone { get; set; }
public int Id { get; set; }
}

View File

@ -12,6 +12,6 @@ namespace PersonnelDepartmentContracts.SearchModels
public string? Name { get; set; }
public int? Telephone { get; set; }
public long? Telephone { get; set; }
}
}

View File

@ -13,7 +13,7 @@ namespace PersonnelDepartmentContracts.ViewModels
[DisplayName("Дата с")]
public DateTime DateFrom { get; set; }
[DisplayName("Дата по")]
public DateTime? DateTo { get; set; }
public DateTime DateTo { get; set; }
public int PositionId { get; set; }
[DisplayName("Должность")]
public string PositionName { get; set; } = string.Empty;

View File

@ -13,7 +13,7 @@ namespace PersonnelDepartmentContracts.ViewModels
[DisplayName("Название")]
public string Name { get; set; } = string.Empty;
[DisplayName("Контактный телефон")]
public int Telephone { get; set; }
public long Telephone { get; set; }
[DisplayName("Код")]
public int Id { get; set; }
}

View File

@ -9,7 +9,7 @@ namespace PersonnelDepartmentDataModels.Models
public interface IDealModel : IId
{
DateTime DateFrom { get; }
DateTime? DateTo { get; }
DateTime DateTo { get; }
int PositionId { get; }
int EmployeeId { get; }
int DepartmentId { get; }

View File

@ -9,6 +9,6 @@ namespace PersonnelDepartmentDataModels.Models
public interface IDepartmentModel : IId
{
string Name { get; }
int Telephone { get; }
long Telephone { get; }
}
}

View File

@ -0,0 +1,183 @@
// <auto-generated />
using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
using PersonnelDepartmentDatabaseImplement;
#nullable disable
namespace PersonnelDepartmentDatabaseImplement.Migrations
{
[DbContext(typeof(PersonnelDepartmentDatabase))]
[Migration("20230502180408_InitMig")]
partial class InitMig
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "7.0.5")
.HasAnnotation("Relational:MaxIdentifierLength", 63);
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
modelBuilder.Entity("PersonnelDepartmentDatabaseImplement.Models.Deal", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<DateTime>("DateFrom")
.HasColumnType("timestamp with time zone");
b.Property<DateTime>("DateTo")
.HasColumnType("timestamp with time zone");
b.Property<int>("DepartmentId")
.HasColumnType("integer");
b.Property<int>("EmployeeId")
.HasColumnType("integer");
b.Property<int>("PositionId")
.HasColumnType("integer");
b.Property<int>("TypeId")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("DepartmentId");
b.HasIndex("EmployeeId");
b.HasIndex("PositionId");
b.HasIndex("TypeId");
b.ToTable("Deals");
});
modelBuilder.Entity("PersonnelDepartmentDatabaseImplement.Models.Department", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.Property<int>("Telephone")
.HasColumnType("integer");
b.HasKey("Id");
b.ToTable("Departments");
});
modelBuilder.Entity("PersonnelDepartmentDatabaseImplement.Models.Employee", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("FirstName")
.IsRequired()
.HasColumnType("text");
b.Property<string>("LastName")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Patronymic")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.ToTable("Employees");
});
modelBuilder.Entity("PersonnelDepartmentDatabaseImplement.Models.Position", 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("Positions");
});
modelBuilder.Entity("PersonnelDepartmentDatabaseImplement.Models.Type", 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("Types");
});
modelBuilder.Entity("PersonnelDepartmentDatabaseImplement.Models.Deal", b =>
{
b.HasOne("PersonnelDepartmentDatabaseImplement.Models.Department", "Department")
.WithMany()
.HasForeignKey("DepartmentId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("PersonnelDepartmentDatabaseImplement.Models.Employee", "Employee")
.WithMany()
.HasForeignKey("EmployeeId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("PersonnelDepartmentDatabaseImplement.Models.Position", "Position")
.WithMany()
.HasForeignKey("PositionId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("PersonnelDepartmentDatabaseImplement.Models.Type", "Type")
.WithMany()
.HasForeignKey("TypeId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Department");
b.Navigation("Employee");
b.Navigation("Position");
b.Navigation("Type");
});
#pragma warning restore 612, 618
}
}
}

View File

@ -0,0 +1,152 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable
namespace PersonnelDepartmentDatabaseImplement.Migrations
{
/// <inheritdoc />
public partial class InitMig : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "Departments",
columns: table => new
{
Id = table.Column<int>(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
Name = table.Column<string>(type: "text", nullable: false),
Telephone = table.Column<int>(type: "integer", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Departments", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Employees",
columns: table => new
{
Id = table.Column<int>(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
FirstName = table.Column<string>(type: "text", nullable: false),
LastName = table.Column<string>(type: "text", nullable: false),
Patronymic = table.Column<string>(type: "text", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Employees", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Positions",
columns: table => new
{
Id = table.Column<int>(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
Name = table.Column<string>(type: "text", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Positions", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Types",
columns: table => new
{
Id = table.Column<int>(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
Name = table.Column<string>(type: "text", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Types", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Deals",
columns: table => new
{
Id = table.Column<int>(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
DateFrom = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
DateTo = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
PositionId = table.Column<int>(type: "integer", nullable: false),
EmployeeId = table.Column<int>(type: "integer", nullable: false),
DepartmentId = table.Column<int>(type: "integer", nullable: false),
TypeId = table.Column<int>(type: "integer", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Deals", x => x.Id);
table.ForeignKey(
name: "FK_Deals_Departments_DepartmentId",
column: x => x.DepartmentId,
principalTable: "Departments",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_Deals_Employees_EmployeeId",
column: x => x.EmployeeId,
principalTable: "Employees",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_Deals_Positions_PositionId",
column: x => x.PositionId,
principalTable: "Positions",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_Deals_Types_TypeId",
column: x => x.TypeId,
principalTable: "Types",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateIndex(
name: "IX_Deals_DepartmentId",
table: "Deals",
column: "DepartmentId");
migrationBuilder.CreateIndex(
name: "IX_Deals_EmployeeId",
table: "Deals",
column: "EmployeeId");
migrationBuilder.CreateIndex(
name: "IX_Deals_PositionId",
table: "Deals",
column: "PositionId");
migrationBuilder.CreateIndex(
name: "IX_Deals_TypeId",
table: "Deals",
column: "TypeId");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "Deals");
migrationBuilder.DropTable(
name: "Departments");
migrationBuilder.DropTable(
name: "Employees");
migrationBuilder.DropTable(
name: "Positions");
migrationBuilder.DropTable(
name: "Types");
}
}
}

View File

@ -0,0 +1,183 @@
// <auto-generated />
using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
using PersonnelDepartmentDatabaseImplement;
#nullable disable
namespace PersonnelDepartmentDatabaseImplement.Migrations
{
[DbContext(typeof(PersonnelDepartmentDatabase))]
[Migration("20230502183034_SecMig")]
partial class SecMig
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "7.0.5")
.HasAnnotation("Relational:MaxIdentifierLength", 63);
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
modelBuilder.Entity("PersonnelDepartmentDatabaseImplement.Models.Deal", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<DateTime>("DateFrom")
.HasColumnType("timestamp with time zone");
b.Property<DateTime>("DateTo")
.HasColumnType("timestamp with time zone");
b.Property<int>("DepartmentId")
.HasColumnType("integer");
b.Property<int>("EmployeeId")
.HasColumnType("integer");
b.Property<int>("PositionId")
.HasColumnType("integer");
b.Property<int>("TypeId")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("DepartmentId");
b.HasIndex("EmployeeId");
b.HasIndex("PositionId");
b.HasIndex("TypeId");
b.ToTable("Deals");
});
modelBuilder.Entity("PersonnelDepartmentDatabaseImplement.Models.Department", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.Property<long>("Telephone")
.HasColumnType("bigint");
b.HasKey("Id");
b.ToTable("Departments");
});
modelBuilder.Entity("PersonnelDepartmentDatabaseImplement.Models.Employee", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("FirstName")
.IsRequired()
.HasColumnType("text");
b.Property<string>("LastName")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Patronymic")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.ToTable("Employees");
});
modelBuilder.Entity("PersonnelDepartmentDatabaseImplement.Models.Position", 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("Positions");
});
modelBuilder.Entity("PersonnelDepartmentDatabaseImplement.Models.Type", 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("Types");
});
modelBuilder.Entity("PersonnelDepartmentDatabaseImplement.Models.Deal", b =>
{
b.HasOne("PersonnelDepartmentDatabaseImplement.Models.Department", "Department")
.WithMany()
.HasForeignKey("DepartmentId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("PersonnelDepartmentDatabaseImplement.Models.Employee", "Employee")
.WithMany()
.HasForeignKey("EmployeeId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("PersonnelDepartmentDatabaseImplement.Models.Position", "Position")
.WithMany()
.HasForeignKey("PositionId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("PersonnelDepartmentDatabaseImplement.Models.Type", "Type")
.WithMany()
.HasForeignKey("TypeId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Department");
b.Navigation("Employee");
b.Navigation("Position");
b.Navigation("Type");
});
#pragma warning restore 612, 618
}
}
}

View File

@ -0,0 +1,34 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace PersonnelDepartmentDatabaseImplement.Migrations
{
/// <inheritdoc />
public partial class SecMig : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AlterColumn<long>(
name: "Telephone",
table: "Departments",
type: "bigint",
nullable: false,
oldClrType: typeof(int),
oldType: "integer");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.AlterColumn<int>(
name: "Telephone",
table: "Departments",
type: "integer",
nullable: false,
oldClrType: typeof(long),
oldType: "bigint");
}
}
}

View File

@ -0,0 +1,180 @@
// <auto-generated />
using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
using PersonnelDepartmentDatabaseImplement;
#nullable disable
namespace PersonnelDepartmentDatabaseImplement.Migrations
{
[DbContext(typeof(PersonnelDepartmentDatabase))]
partial class PersonnelDepartmentDatabaseModelSnapshot : ModelSnapshot
{
protected override void BuildModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "7.0.5")
.HasAnnotation("Relational:MaxIdentifierLength", 63);
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
modelBuilder.Entity("PersonnelDepartmentDatabaseImplement.Models.Deal", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<DateTime>("DateFrom")
.HasColumnType("timestamp with time zone");
b.Property<DateTime>("DateTo")
.HasColumnType("timestamp with time zone");
b.Property<int>("DepartmentId")
.HasColumnType("integer");
b.Property<int>("EmployeeId")
.HasColumnType("integer");
b.Property<int>("PositionId")
.HasColumnType("integer");
b.Property<int>("TypeId")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("DepartmentId");
b.HasIndex("EmployeeId");
b.HasIndex("PositionId");
b.HasIndex("TypeId");
b.ToTable("Deals");
});
modelBuilder.Entity("PersonnelDepartmentDatabaseImplement.Models.Department", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.Property<long>("Telephone")
.HasColumnType("bigint");
b.HasKey("Id");
b.ToTable("Departments");
});
modelBuilder.Entity("PersonnelDepartmentDatabaseImplement.Models.Employee", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("FirstName")
.IsRequired()
.HasColumnType("text");
b.Property<string>("LastName")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Patronymic")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.ToTable("Employees");
});
modelBuilder.Entity("PersonnelDepartmentDatabaseImplement.Models.Position", 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("Positions");
});
modelBuilder.Entity("PersonnelDepartmentDatabaseImplement.Models.Type", 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("Types");
});
modelBuilder.Entity("PersonnelDepartmentDatabaseImplement.Models.Deal", b =>
{
b.HasOne("PersonnelDepartmentDatabaseImplement.Models.Department", "Department")
.WithMany()
.HasForeignKey("DepartmentId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("PersonnelDepartmentDatabaseImplement.Models.Employee", "Employee")
.WithMany()
.HasForeignKey("EmployeeId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("PersonnelDepartmentDatabaseImplement.Models.Position", "Position")
.WithMany()
.HasForeignKey("PositionId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("PersonnelDepartmentDatabaseImplement.Models.Type", "Type")
.WithMany()
.HasForeignKey("TypeId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Department");
b.Navigation("Employee");
b.Navigation("Position");
b.Navigation("Type");
});
#pragma warning restore 612, 618
}
}
}

View File

@ -14,7 +14,7 @@ namespace PersonnelDepartmentDatabaseImplement.Models
{
[Required]
public DateTime DateFrom { get; set; }
public DateTime? DateTo { get; set; }
public DateTime DateTo { get; set; }
[Required]
public int PositionId { get; set; }
[Required]
@ -38,8 +38,8 @@ namespace PersonnelDepartmentDatabaseImplement.Models
return new Deal
{
Id = model.Id,
DateFrom = model.DateFrom,
DateTo = model.DateTo,
DateFrom = DateTime.SpecifyKind(model.DateFrom, DateTimeKind.Utc),
DateTo = DateTime.SpecifyKind(model.DateTo, DateTimeKind.Utc),
PositionId = model.PositionId,
EmployeeId = model.EmployeeId,
DepartmentId = model.DepartmentId,
@ -53,8 +53,8 @@ namespace PersonnelDepartmentDatabaseImplement.Models
{
return;
}
DateFrom = model.DateFrom;
DateTo = model.DateTo;
DateFrom = DateTime.SpecifyKind(model.DateFrom, DateTimeKind.Utc);
DateTo = DateTime.SpecifyKind(model.DateTo, DateTimeKind.Utc);
}
public DealViewModel GetViewModel => new()

View File

@ -15,7 +15,7 @@ namespace PersonnelDepartmentDatabaseImplement.Models
[Required]
public string Name { get; set; } = string.Empty;
[Required]
public int Telephone { get; set; }
public long Telephone { get; set; }
public int Id { get; set; }
public static Department? Create(DepartmentBindingModel model)

View File

@ -8,6 +8,10 @@
<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="7.0.5" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="7.0.5">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="7.0.4" />
</ItemGroup>

View File

@ -28,12 +28,194 @@
/// </summary>
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(800, 450);
this.Text = "FormDeal";
buttonCancel = new Button();
buttonSave = new Button();
label1 = new Label();
label2 = new Label();
dateTimePickerFrom = new DateTimePicker();
dateTimePickerTo = new DateTimePicker();
label3 = new Label();
comboBoxType = new ComboBox();
label4 = new Label();
comboBoxEmployee = new ComboBox();
label5 = new Label();
comboBoxDepartment = new ComboBox();
label6 = new Label();
comboBoxPosition = new ComboBox();
label7 = new Label();
SuspendLayout();
//
// buttonCancel
//
buttonCancel.Location = new Point(230, 186);
buttonCancel.Name = "buttonCancel";
buttonCancel.Size = new Size(75, 23);
buttonCancel.TabIndex = 19;
buttonCancel.Text = "Отмена";
buttonCancel.UseVisualStyleBackColor = true;
buttonCancel.Click += ButtonCancel_Click;
//
// buttonSave
//
buttonSave.Location = new Point(149, 186);
buttonSave.Name = "buttonSave";
buttonSave.Size = new Size(75, 23);
buttonSave.TabIndex = 18;
buttonSave.Text = "Сохранить";
buttonSave.UseVisualStyleBackColor = true;
buttonSave.Click += ButtonSave_Click;
//
// label1
//
label1.AutoSize = true;
label1.Location = new Point(15, 20);
label1.Name = "label1";
label1.Size = new Size(44, 15);
label1.TabIndex = 20;
label1.Text = "Дата с:";
//
// label2
//
label2.AutoSize = true;
label2.Location = new Point(15, 47);
label2.Name = "label2";
label2.Size = new Size(52, 15);
label2.TabIndex = 21;
label2.Text = "Дата по:";
//
// dateTimePickerFrom
//
dateTimePickerFrom.Location = new Point(105, 12);
dateTimePickerFrom.Name = "dateTimePickerFrom";
dateTimePickerFrom.Size = new Size(200, 23);
dateTimePickerFrom.TabIndex = 22;
//
// dateTimePickerTo
//
dateTimePickerTo.Location = new Point(105, 41);
dateTimePickerTo.Name = "dateTimePickerTo";
dateTimePickerTo.Size = new Size(200, 23);
dateTimePickerTo.TabIndex = 23;
//
// label3
//
label3.AutoSize = true;
label3.Location = new Point(15, 73);
label3.Name = "label3";
label3.Size = new Size(84, 15);
label3.TabIndex = 24;
label3.Text = "Тип договора:";
//
// comboBoxType
//
comboBoxType.FormattingEnabled = true;
comboBoxType.Location = new Point(105, 70);
comboBoxType.Name = "comboBoxType";
comboBoxType.Size = new Size(200, 23);
comboBoxType.TabIndex = 25;
//
// label4
//
label4.AutoSize = true;
label4.Location = new Point(114, 144);
label4.Name = "label4";
label4.Size = new Size(0, 15);
label4.TabIndex = 26;
//
// comboBoxEmployee
//
comboBoxEmployee.FormattingEnabled = true;
comboBoxEmployee.Location = new Point(105, 99);
comboBoxEmployee.Name = "comboBoxEmployee";
comboBoxEmployee.Size = new Size(200, 23);
comboBoxEmployee.TabIndex = 28;
//
// label5
//
label5.AutoSize = true;
label5.Location = new Point(15, 102);
label5.Name = "label5";
label5.Size = new Size(69, 15);
label5.TabIndex = 27;
label5.Text = "Сотрудник:";
//
// comboBoxDepartment
//
comboBoxDepartment.FormattingEnabled = true;
comboBoxDepartment.Location = new Point(105, 128);
comboBoxDepartment.Name = "comboBoxDepartment";
comboBoxDepartment.Size = new Size(200, 23);
comboBoxDepartment.TabIndex = 30;
//
// label6
//
label6.AutoSize = true;
label6.Location = new Point(15, 131);
label6.Name = "label6";
label6.Size = new Size(43, 15);
label6.TabIndex = 29;
label6.Text = "Отдел:";
//
// comboBoxPosition
//
comboBoxPosition.FormattingEnabled = true;
comboBoxPosition.Location = new Point(105, 157);
comboBoxPosition.Name = "comboBoxPosition";
comboBoxPosition.Size = new Size(200, 23);
comboBoxPosition.TabIndex = 32;
//
// label7
//
label7.AutoSize = true;
label7.Location = new Point(15, 160);
label7.Name = "label7";
label7.Size = new Size(72, 15);
label7.TabIndex = 31;
label7.Text = "Должность:";
//
// FormDeal
//
AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(324, 223);
Controls.Add(comboBoxPosition);
Controls.Add(label7);
Controls.Add(comboBoxDepartment);
Controls.Add(label6);
Controls.Add(comboBoxEmployee);
Controls.Add(label5);
Controls.Add(label4);
Controls.Add(comboBoxType);
Controls.Add(label3);
Controls.Add(dateTimePickerTo);
Controls.Add(dateTimePickerFrom);
Controls.Add(label2);
Controls.Add(label1);
Controls.Add(buttonCancel);
Controls.Add(buttonSave);
Name = "FormDeal";
Text = "Договор";
Load += FormDeal_Load;
ResumeLayout(false);
PerformLayout();
}
#endregion
private Button buttonCancel;
private Button buttonSave;
private Label label1;
private Label label2;
private DateTimePicker dateTimePickerFrom;
private DateTimePicker dateTimePickerTo;
private Label label3;
private ComboBox comboBoxType;
private Label label4;
private ComboBox comboBoxEmployee;
private Label label5;
private ComboBox comboBoxDepartment;
private Label label6;
private ComboBox comboBoxPosition;
private Label label7;
}
}

View File

@ -1,4 +1,8 @@
using System;
using Microsoft.EntityFrameworkCore.Metadata.Internal;
using PersonnelDepartmentContracts.BindingModels;
using PersonnelDepartmentContracts.BusinessLogicContracts;
using PersonnelDepartmentContracts.SearchModels;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
@ -12,9 +16,124 @@ namespace PersonnelDepartmentView
{
public partial class FormDeal : Form
{
public FormDeal()
private readonly IDealLogic _dealLogic;
private readonly IDepartmentLogic _departmentLogic;
private readonly IEmployeeLogic _employeeLogic;
private readonly IPositionLogic _positionLogic;
private readonly ITypeLogic _typeLogic;
private int? _id;
public int Id { set { _id = value; } }
public FormDeal(IDealLogic dealLogic, IDepartmentLogic departmentLogic, IEmployeeLogic employeeLogic, IPositionLogic positionLogic, ITypeLogic typeLogic)
{
InitializeComponent();
_dealLogic = dealLogic;
_departmentLogic = departmentLogic;
_employeeLogic = employeeLogic;
_positionLogic = positionLogic;
_typeLogic = typeLogic;
}
private void FormDeal_Load(object sender, EventArgs e)
{
comboBoxDepartment.DisplayMember = "Name";
comboBoxDepartment.ValueMember = "Id";
comboBoxDepartment.DataSource = _departmentLogic.ReadList(null);
comboBoxEmployee.DisplayMember = "LastName";
comboBoxEmployee.ValueMember = "Id";
comboBoxEmployee.DataSource = _employeeLogic.ReadList(null);
comboBoxPosition.DisplayMember = "Name";
comboBoxPosition.ValueMember = "Id";
comboBoxPosition.DataSource = _positionLogic.ReadList(null);
comboBoxType.DisplayMember = "Name";
comboBoxType.ValueMember = "Id";
comboBoxType.DataSource = _typeLogic.ReadList(null);
if (_id.HasValue)
{
try
{
var view = _dealLogic.ReadElement(new DealSearchModel
{
Id = _id.Value
});
if (view != null)
{
dateTimePickerFrom.Value = view.DateFrom;
dateTimePickerTo.Value = view.DateTo;
comboBoxDepartment.SelectedItem = view.DepartmentId;
comboBoxEmployee.SelectedItem = view.EmployeeId;
comboBoxPosition.SelectedItem = view.PositionId;
comboBoxType.SelectedItem = view.TypeId;
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
MessageBoxIcon.Error);
}
}
else
{
comboBoxDepartment.SelectedItem = null;
comboBoxEmployee.SelectedItem = null;
comboBoxPosition.SelectedItem = null;
comboBoxType.SelectedItem = null;
}
}
private void ButtonSave_Click(object sender, EventArgs e)
{
if (comboBoxDepartment.SelectedItem == null)
{
MessageBox.Show("Выберите отдел", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
if (comboBoxEmployee.SelectedItem == null)
{
MessageBox.Show("Выберите сотрудника", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
if (comboBoxPosition.SelectedItem == null)
{
MessageBox.Show("Выберите должность", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
if (comboBoxType.SelectedItem == null)
{
MessageBox.Show("Выберите тип договора", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
try
{
var model = new DealBindingModel
{
Id = _id ?? 0,
DateFrom = DateTime.SpecifyKind(dateTimePickerFrom.Value, DateTimeKind.Utc),
DateTo = DateTime.SpecifyKind(dateTimePickerTo.Value, DateTimeKind.Utc),
DepartmentId = Convert.ToInt32(comboBoxDepartment.SelectedValue),
EmployeeId = Convert.ToInt32(comboBoxEmployee.SelectedValue),
PositionId = Convert.ToInt32(comboBoxPosition.SelectedValue),
TypeId = Convert.ToInt32(comboBoxType.SelectedValue)
};
var operationResult = _id.HasValue ? _dealLogic.Update(model) : _dealLogic.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();
}
}
}

View File

@ -1,64 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<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">

View File

@ -28,12 +28,139 @@
/// </summary>
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(800, 450);
this.Text = "Form1";
dataGridView = new DataGridView();
buttonAdd = new Button();
buttonChange = new Button();
buttonDelete = new Button();
buttonUpdate = new Button();
buttonDepartment = new Button();
buttonEmployee = new Button();
buttonPosition = new Button();
buttonType = new Button();
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
SuspendLayout();
//
// dataGridView
//
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
dataGridView.Location = new Point(12, 41);
dataGridView.Name = "dataGridView";
dataGridView.RowTemplate.Height = 25;
dataGridView.Size = new Size(888, 368);
dataGridView.TabIndex = 0;
//
// buttonAdd
//
buttonAdd.Location = new Point(12, 12);
buttonAdd.Name = "buttonAdd";
buttonAdd.Size = new Size(75, 23);
buttonAdd.TabIndex = 1;
buttonAdd.Text = "Создать";
buttonAdd.UseVisualStyleBackColor = true;
buttonAdd.Click += ButtonAdd_Click;
//
// buttonChange
//
buttonChange.Location = new Point(93, 12);
buttonChange.Name = "buttonChange";
buttonChange.Size = new Size(75, 23);
buttonChange.TabIndex = 2;
buttonChange.Text = "Изменить";
buttonChange.UseVisualStyleBackColor = true;
buttonChange.Click += ButtonChange_Click;
//
// buttonDelete
//
buttonDelete.Location = new Point(174, 12);
buttonDelete.Name = "buttonDelete";
buttonDelete.Size = new Size(75, 23);
buttonDelete.TabIndex = 3;
buttonDelete.Text = "Удалить";
buttonDelete.UseVisualStyleBackColor = true;
buttonDelete.Click += ButtonDelete_Click;
//
// buttonUpdate
//
buttonUpdate.Location = new Point(255, 12);
buttonUpdate.Name = "buttonUpdate";
buttonUpdate.Size = new Size(75, 23);
buttonUpdate.TabIndex = 4;
buttonUpdate.Text = "Обновить";
buttonUpdate.UseVisualStyleBackColor = true;
buttonUpdate.Click += ButtonUpdate_Click;
//
// buttonDepartment
//
buttonDepartment.Location = new Point(336, 12);
buttonDepartment.Name = "buttonDepartment";
buttonDepartment.Size = new Size(128, 23);
buttonDepartment.TabIndex = 5;
buttonDepartment.Text = "Таблица с отделами";
buttonDepartment.UseVisualStyleBackColor = true;
buttonDepartment.Click += ButtonDepartment_Click;
//
// buttonEmployee
//
buttonEmployee.Location = new Point(470, 12);
buttonEmployee.Name = "buttonEmployee";
buttonEmployee.Size = new Size(152, 23);
buttonEmployee.TabIndex = 6;
buttonEmployee.Text = "Таблица с сотрудниками";
buttonEmployee.UseVisualStyleBackColor = true;
buttonEmployee.Click += ButtonEmployee_Click;
//
// buttonPosition
//
buttonPosition.Location = new Point(628, 12);
buttonPosition.Name = "buttonPosition";
buttonPosition.Size = new Size(149, 23);
buttonPosition.TabIndex = 7;
buttonPosition.Text = "Таблица с должностями";
buttonPosition.UseVisualStyleBackColor = true;
buttonPosition.Click += ButtonPosition_Click;
//
// buttonType
//
buttonType.Location = new Point(783, 12);
buttonType.Name = "buttonType";
buttonType.Size = new Size(117, 23);
buttonType.TabIndex = 8;
buttonType.Text = "Таблица с типами";
buttonType.UseVisualStyleBackColor = true;
buttonType.Click += ButtonType_Click;
//
// FormDeals
//
AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(914, 422);
Controls.Add(buttonType);
Controls.Add(buttonPosition);
Controls.Add(buttonEmployee);
Controls.Add(buttonDepartment);
Controls.Add(buttonUpdate);
Controls.Add(buttonDelete);
Controls.Add(buttonChange);
Controls.Add(buttonAdd);
Controls.Add(dataGridView);
Name = "FormDeals";
StartPosition = FormStartPosition.CenterScreen;
Text = "Таблица Договоров";
Load += FormDeals_Load;
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
ResumeLayout(false);
}
#endregion
private DataGridView dataGridView;
private Button buttonAdd;
private Button buttonChange;
private Button buttonDelete;
private Button buttonUpdate;
private Button buttonDepartment;
private Button buttonEmployee;
private Button buttonPosition;
private Button buttonType;
}
}

View File

@ -1,10 +1,143 @@
using PersonnelDepartmentContracts.BindingModels;
using PersonnelDepartmentContracts.BusinessLogicContracts;
namespace PersonnelDepartmentView
{
public partial class Form1 : Form
public partial class FormDeals : Form
{
public Form1()
private readonly IDealLogic _dealLogic;
public FormDeals(IDealLogic dealLogic)
{
InitializeComponent();
_dealLogic = dealLogic;
}
private void LoadData()
{
try
{
var list = _dealLogic.ReadList(null);
if (list != null)
{
dataGridView.DataSource = list;
dataGridView.Columns["Id"].Visible = false;
dataGridView.Columns["EmployeeId"].Visible = false;
dataGridView.Columns["PositionId"].Visible = false;
dataGridView.Columns["DepartmentId"].Visible = false;
dataGridView.Columns["TypeId"].Visible = false;
dataGridView.Columns["DateFrom"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
dataGridView.Columns["DateTo"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
dataGridView.Columns["TypeName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
dataGridView.Columns["EmployeeName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
dataGridView.Columns["DepartmentName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
dataGridView.Columns["PositionName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Îøèáêà çàãðóçêè", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void FormDeals_Load(object sender, EventArgs e)
{
LoadData();
}
private void ButtonDepartment_Click(object sender, EventArgs e)
{
var service = Program.ServiceProvider?.GetService(typeof(FormDepartments));
if (service is FormDepartments form)
{
form.ShowDialog();
}
}
private void ButtonEmployee_Click(object sender, EventArgs e)
{
var service = Program.ServiceProvider?.GetService(typeof(FormEmployees));
if (service is FormEmployees form)
{
form.ShowDialog();
}
}
private void ButtonPosition_Click(object sender, EventArgs e)
{
var service = Program.ServiceProvider?.GetService(typeof(FormPositions));
if (service is FormPositions form)
{
form.ShowDialog();
}
}
private void ButtonType_Click(object sender, EventArgs e)
{
var service = Program.ServiceProvider?.GetService(typeof(FormTypes));
if (service is FormTypes form)
{
form.ShowDialog();
}
}
private void ButtonAdd_Click(object sender, EventArgs e)
{
var service = Program.ServiceProvider?.GetService(typeof(FormDeal));
if (service is FormDeal form)
{
if (form.ShowDialog() == DialogResult.OK)
{
LoadData();
}
}
}
private void ButtonChange_Click(object sender, EventArgs e)
{
if (dataGridView.SelectedRows.Count == 1)
{
var service = Program.ServiceProvider?.GetService(typeof(FormDeal));
if (service is FormDeal form)
{
form.Id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
if (form.ShowDialog() == DialogResult.OK)
{
LoadData();
}
}
}
}
private void ButtonDelete_Click(object sender, EventArgs e)
{
if (dataGridView.SelectedRows.Count == 1)
{
if (MessageBox.Show("Óäàëèòü çàïèñü?", "Âîïðîñ", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
{
int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
try
{
if (!_dealLogic.Delete(new DealBindingModel
{
Id = id
}))
{
throw new Exception("Îøèáêà ïðè óäàëåíèè.");
}
LoadData();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Îøèáêà", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
}
private void ButtonUpdate_Click(object sender, EventArgs e)
{
LoadData();
}
}
}

View File

@ -1,64 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<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">

View File

@ -28,12 +28,91 @@
/// </summary>
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(800, 450);
this.Text = "FormDepartment";
label2 = new Label();
textBoxTelephone = new TextBox();
buttonCancel = new Button();
buttonSave = new Button();
label1 = new Label();
textBoxName = new TextBox();
SuspendLayout();
//
// label2
//
label2.AutoSize = true;
label2.Location = new Point(20, 44);
label2.Name = "label2";
label2.Size = new Size(126, 15);
label2.TabIndex = 19;
label2.Text = "Контактный телефон:";
//
// textBoxTelephone
//
textBoxTelephone.Location = new Point(153, 41);
textBoxTelephone.Name = "textBoxTelephone";
textBoxTelephone.Size = new Size(202, 23);
textBoxTelephone.TabIndex = 18;
//
// buttonCancel
//
buttonCancel.Location = new Point(280, 70);
buttonCancel.Name = "buttonCancel";
buttonCancel.Size = new Size(75, 23);
buttonCancel.TabIndex = 17;
buttonCancel.Text = "Отмена";
buttonCancel.UseVisualStyleBackColor = true;
buttonCancel.Click += ButtonCancel_Click;
//
// buttonSave
//
buttonSave.Location = new Point(199, 70);
buttonSave.Name = "buttonSave";
buttonSave.Size = new Size(75, 23);
buttonSave.TabIndex = 16;
buttonSave.Text = "Сохранить";
buttonSave.UseVisualStyleBackColor = true;
buttonSave.Click += ButtonSave_Click;
//
// label1
//
label1.AutoSize = true;
label1.Location = new Point(20, 15);
label1.Name = "label1";
label1.Size = new Size(102, 15);
label1.TabIndex = 15;
label1.Text = "Название отдела:";
//
// textBoxName
//
textBoxName.Location = new Point(153, 12);
textBoxName.Name = "textBoxName";
textBoxName.Size = new Size(202, 23);
textBoxName.TabIndex = 14;
//
// FormDepartment
//
AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(375, 108);
Controls.Add(label2);
Controls.Add(textBoxTelephone);
Controls.Add(buttonCancel);
Controls.Add(buttonSave);
Controls.Add(label1);
Controls.Add(textBoxName);
Name = "FormDepartment";
Text = "Отдел";
Load += FormDepartment_Load;
ResumeLayout(false);
PerformLayout();
}
#endregion
private Label label2;
private TextBox textBoxTelephone;
private Button buttonCancel;
private Button buttonSave;
private Label label1;
private TextBox textBoxName;
}
}

View File

@ -1,4 +1,8 @@
using System;
using PersonnelDepartmentBusinessLogic.BusinessLogics;
using PersonnelDepartmentContracts.BindingModels;
using PersonnelDepartmentContracts.BusinessLogicContracts;
using PersonnelDepartmentContracts.SearchModels;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
@ -12,9 +16,78 @@ namespace PersonnelDepartmentView
{
public partial class FormDepartment : Form
{
public FormDepartment()
private readonly IDepartmentLogic _departmentLogic;
private int? _id;
public int Id { set { _id = value; } }
public FormDepartment(IDepartmentLogic departmentLogic)
{
InitializeComponent();
_departmentLogic = departmentLogic;
}
private void FormDepartment_Load(object sender, EventArgs e)
{
if (_id.HasValue)
{
try
{
var view = _departmentLogic.ReadElement(new DepartmentSearchModel
{
Id = _id.Value
});
if (view != null)
{
textBoxName.Text = view.Name;
textBoxTelephone.Text = view.Telephone.ToString();
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
MessageBoxIcon.Error);
}
}
}
private void ButtonSave_Click(object sender, EventArgs e)
{
if (string.IsNullOrEmpty(textBoxName.Text))
{
MessageBox.Show("Введите название", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
if (string.IsNullOrEmpty(textBoxTelephone.Text))
{
MessageBox.Show("Введите контактный номер", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
try
{
var model = new DepartmentBindingModel
{
Id = _id ?? 0,
Name = textBoxName.Text,
Telephone = long.Parse(textBoxTelephone.Text)
};
var operationResult = _id.HasValue ? _departmentLogic.Update(model) : _departmentLogic.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();
}
}
}

View File

@ -1,64 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<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">

View File

@ -28,12 +28,86 @@
/// </summary>
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(800, 450);
this.Text = "FormDepartments";
buttonUpdate = new Button();
buttonDelete = new Button();
buttonChange = new Button();
buttonAdd = new Button();
dataGridView = new DataGridView();
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
SuspendLayout();
//
// buttonUpdate
//
buttonUpdate.Location = new Point(255, 9);
buttonUpdate.Name = "buttonUpdate";
buttonUpdate.Size = new Size(75, 23);
buttonUpdate.TabIndex = 9;
buttonUpdate.Text = "Обновить";
buttonUpdate.UseVisualStyleBackColor = true;
buttonUpdate.Click += ButtonUpdate_Click;
//
// buttonDelete
//
buttonDelete.Location = new Point(174, 9);
buttonDelete.Name = "buttonDelete";
buttonDelete.Size = new Size(75, 23);
buttonDelete.TabIndex = 8;
buttonDelete.Text = "Удалить";
buttonDelete.UseVisualStyleBackColor = true;
buttonDelete.Click += ButtonDelete_Click;
//
// buttonChange
//
buttonChange.Location = new Point(93, 9);
buttonChange.Name = "buttonChange";
buttonChange.Size = new Size(75, 23);
buttonChange.TabIndex = 7;
buttonChange.Text = "Изменить";
buttonChange.UseVisualStyleBackColor = true;
buttonChange.Click += ButtonChange_Click;
//
// buttonAdd
//
buttonAdd.Location = new Point(12, 9);
buttonAdd.Name = "buttonAdd";
buttonAdd.Size = new Size(75, 23);
buttonAdd.TabIndex = 6;
buttonAdd.Text = "Создать";
buttonAdd.UseVisualStyleBackColor = true;
buttonAdd.Click += ButtonAdd_Click;
//
// dataGridView
//
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
dataGridView.Location = new Point(12, 38);
dataGridView.Name = "dataGridView";
dataGridView.RowTemplate.Height = 25;
dataGridView.Size = new Size(564, 368);
dataGridView.TabIndex = 5;
//
// FormDepartments
//
AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(590, 418);
Controls.Add(buttonUpdate);
Controls.Add(buttonDelete);
Controls.Add(buttonChange);
Controls.Add(buttonAdd);
Controls.Add(dataGridView);
Name = "FormDepartments";
Text = "Таблица Отделов";
Load += FormDepartments_Load;
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
ResumeLayout(false);
}
#endregion
private Button buttonUpdate;
private Button buttonDelete;
private Button buttonChange;
private Button buttonAdd;
private DataGridView dataGridView;
}
}

View File

@ -1,4 +1,7 @@
using System;
using PersonnelDepartmentBusinessLogic.BusinessLogics;
using PersonnelDepartmentContracts.BindingModels;
using PersonnelDepartmentContracts.BusinessLogicContracts;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
@ -12,9 +15,94 @@ namespace PersonnelDepartmentView
{
public partial class FormDepartments : Form
{
public FormDepartments()
private readonly IDepartmentLogic _departmentLogic;
public FormDepartments(IDepartmentLogic departmentLogic)
{
InitializeComponent();
_departmentLogic = departmentLogic;
}
private void LoadData()
{
try
{
var list = _departmentLogic.ReadList(null);
if (list != null)
{
dataGridView.DataSource = list;
dataGridView.Columns["Id"].Visible = false;
dataGridView.Columns["Name"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
dataGridView.Columns["Telephone"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка загрузки", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void ButtonAdd_Click(object sender, EventArgs e)
{
var service = Program.ServiceProvider?.GetService(typeof(FormDepartment));
if (service is FormDepartment form)
{
if (form.ShowDialog() == DialogResult.OK)
{
LoadData();
}
}
}
private void ButtonChange_Click(object sender, EventArgs e)
{
if (dataGridView.SelectedRows.Count == 1)
{
var service = Program.ServiceProvider?.GetService(typeof(FormDepartment));
if (service is FormDepartment form)
{
form.Id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
if (form.ShowDialog() == DialogResult.OK)
{
LoadData();
}
}
}
}
private void ButtonDelete_Click(object sender, EventArgs e)
{
if (dataGridView.SelectedRows.Count == 1)
{
if (MessageBox.Show("Удалить запись?", "Вопрос", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
{
int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
try
{
if (!_departmentLogic.Delete(new DepartmentBindingModel
{
Id = id
}))
{
throw new Exception("Ошибка при удалении.");
}
LoadData();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
}
private void ButtonUpdate_Click(object sender, EventArgs e)
{
LoadData();
}
private void FormDepartments_Load(object sender, EventArgs e)
{
LoadData();
}
}
}

View File

@ -1,64 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<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">

View File

@ -28,12 +28,113 @@
/// </summary>
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(800, 450);
this.Text = "FormEmployee";
buttonCancel = new Button();
buttonSave = new Button();
label1 = new Label();
textBoxFirstName = new TextBox();
label2 = new Label();
textBoxLastName = new TextBox();
label3 = new Label();
textBoxPatronymic = new TextBox();
SuspendLayout();
//
// buttonCancel
//
buttonCancel.Location = new Point(276, 99);
buttonCancel.Name = "buttonCancel";
buttonCancel.Size = new Size(75, 23);
buttonCancel.TabIndex = 11;
buttonCancel.Text = "Отмена";
buttonCancel.UseVisualStyleBackColor = true;
buttonCancel.Click += ButtonCancel_Click;
//
// buttonSave
//
buttonSave.Location = new Point(195, 99);
buttonSave.Name = "buttonSave";
buttonSave.Size = new Size(75, 23);
buttonSave.TabIndex = 10;
buttonSave.Text = "Сохранить";
buttonSave.UseVisualStyleBackColor = true;
buttonSave.Click += ButtonSave_Click;
//
// label1
//
label1.AutoSize = true;
label1.Location = new Point(16, 15);
label1.Name = "label1";
label1.Size = new Size(100, 15);
label1.TabIndex = 9;
label1.Text = "Имя сотрудника:";
//
// textBoxFirstName
//
textBoxFirstName.Location = new Point(149, 12);
textBoxFirstName.Name = "textBoxFirstName";
textBoxFirstName.Size = new Size(202, 23);
textBoxFirstName.TabIndex = 8;
//
// label2
//
label2.AutoSize = true;
label2.Location = new Point(16, 44);
label2.Name = "label2";
label2.Size = new Size(127, 15);
label2.TabIndex = 13;
label2.Text = "Фамилия сотрудника:";
//
// textBoxLastName
//
textBoxLastName.Location = new Point(149, 41);
textBoxLastName.Name = "textBoxLastName";
textBoxLastName.Size = new Size(202, 23);
textBoxLastName.TabIndex = 12;
//
// label3
//
label3.AutoSize = true;
label3.Location = new Point(16, 73);
label3.Name = "label3";
label3.Size = new Size(127, 15);
label3.TabIndex = 15;
label3.Text = "Отчество сотрудника:";
//
// textBoxPatronymic
//
textBoxPatronymic.Location = new Point(149, 70);
textBoxPatronymic.Name = "textBoxPatronymic";
textBoxPatronymic.Size = new Size(202, 23);
textBoxPatronymic.TabIndex = 14;
//
// FormEmployee
//
AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(369, 136);
Controls.Add(label3);
Controls.Add(textBoxPatronymic);
Controls.Add(label2);
Controls.Add(textBoxLastName);
Controls.Add(buttonCancel);
Controls.Add(buttonSave);
Controls.Add(label1);
Controls.Add(textBoxFirstName);
Name = "FormEmployee";
Text = "Сотрудник";
Load += FormEmployee_Load;
ResumeLayout(false);
PerformLayout();
}
#endregion
private Button buttonCancel;
private Button buttonSave;
private Label label1;
private TextBox textBoxFirstName;
private Label label2;
private TextBox textBoxLastName;
private Label label3;
private TextBox textBoxPatronymic;
}
}

View File

@ -1,4 +1,8 @@
using System;
using PersonnelDepartmentBusinessLogic.BusinessLogics;
using PersonnelDepartmentContracts.BindingModels;
using PersonnelDepartmentContracts.BusinessLogicContracts;
using PersonnelDepartmentContracts.SearchModels;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
@ -12,9 +16,80 @@ namespace PersonnelDepartmentView
{
public partial class FormEmployee : Form
{
public FormEmployee()
private readonly IEmployeeLogic _employeeLogic;
private int? _id;
public int Id { set { _id = value; } }
public FormEmployee(IEmployeeLogic employeeLogic)
{
InitializeComponent();
_employeeLogic = employeeLogic;
}
private void FormEmployee_Load(object sender, EventArgs e)
{
if (_id.HasValue)
{
try
{
var view = _employeeLogic.ReadElement(new EmployeeSearchModel
{
Id = _id.Value
});
if (view != null)
{
textBoxFirstName.Text = view.FirstName;
textBoxLastName.Text = view.LastName;
textBoxPatronymic.Text = view.Patronymic;
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
MessageBoxIcon.Error);
}
}
}
private void ButtonSave_Click(object sender, EventArgs e)
{
if (string.IsNullOrEmpty(textBoxFirstName.Text))
{
MessageBox.Show("Введите название", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
if (string.IsNullOrEmpty(textBoxLastName.Text))
{
MessageBox.Show("Введите контактный номер", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
try
{
var model = new EmployeeBindingModel
{
Id = _id ?? 0,
FirstName = textBoxFirstName.Text,
LastName = textBoxLastName.Text,
Patronymic = textBoxPatronymic.Text
};
var operationResult = _id.HasValue ? _employeeLogic.Update(model) : _employeeLogic.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();
}
}
}

View File

@ -1,64 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<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">

View File

@ -28,12 +28,86 @@
/// </summary>
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(800, 450);
this.Text = "FormEmployees";
buttonUpdate = new Button();
buttonDelete = new Button();
buttonChange = new Button();
buttonAdd = new Button();
dataGridView = new DataGridView();
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
SuspendLayout();
//
// buttonUpdate
//
buttonUpdate.Location = new Point(255, 9);
buttonUpdate.Name = "buttonUpdate";
buttonUpdate.Size = new Size(75, 23);
buttonUpdate.TabIndex = 9;
buttonUpdate.Text = "Обновить";
buttonUpdate.UseVisualStyleBackColor = true;
buttonUpdate.Click += ButtonUpdate_Click;
//
// buttonDelete
//
buttonDelete.Location = new Point(174, 9);
buttonDelete.Name = "buttonDelete";
buttonDelete.Size = new Size(75, 23);
buttonDelete.TabIndex = 8;
buttonDelete.Text = "Удалить";
buttonDelete.UseVisualStyleBackColor = true;
buttonDelete.Click += ButtonDelete_Click;
//
// buttonChange
//
buttonChange.Location = new Point(93, 9);
buttonChange.Name = "buttonChange";
buttonChange.Size = new Size(75, 23);
buttonChange.TabIndex = 7;
buttonChange.Text = "Изменить";
buttonChange.UseVisualStyleBackColor = true;
buttonChange.Click += ButtonChange_Click;
//
// buttonAdd
//
buttonAdd.Location = new Point(12, 9);
buttonAdd.Name = "buttonAdd";
buttonAdd.Size = new Size(75, 23);
buttonAdd.TabIndex = 6;
buttonAdd.Text = "Создать";
buttonAdd.UseVisualStyleBackColor = true;
buttonAdd.Click += ButtonAdd_Click;
//
// dataGridView
//
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
dataGridView.Location = new Point(12, 38);
dataGridView.Name = "dataGridView";
dataGridView.RowTemplate.Height = 25;
dataGridView.Size = new Size(564, 368);
dataGridView.TabIndex = 5;
//
// FormEmployees
//
AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(589, 418);
Controls.Add(buttonUpdate);
Controls.Add(buttonDelete);
Controls.Add(buttonChange);
Controls.Add(buttonAdd);
Controls.Add(dataGridView);
Name = "FormEmployees";
Text = "Таблица Сотрудников";
Load += FormEmployees_Load;
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
ResumeLayout(false);
}
#endregion
private Button buttonUpdate;
private Button buttonDelete;
private Button buttonChange;
private Button buttonAdd;
private DataGridView dataGridView;
}
}

View File

@ -1,4 +1,7 @@
using System;
using PersonnelDepartmentBusinessLogic.BusinessLogics;
using PersonnelDepartmentContracts.BindingModels;
using PersonnelDepartmentContracts.BusinessLogicContracts;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
@ -12,9 +15,95 @@ namespace PersonnelDepartmentView
{
public partial class FormEmployees : Form
{
public FormEmployees()
private readonly IEmployeeLogic _employeeLogic;
public FormEmployees(IEmployeeLogic employeeLogic)
{
InitializeComponent();
_employeeLogic = employeeLogic;
}
private void LoadData()
{
try
{
var list = _employeeLogic.ReadList(null);
if (list != null)
{
dataGridView.DataSource = list;
dataGridView.Columns["Id"].Visible = false;
dataGridView.Columns["FirstName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
dataGridView.Columns["LastName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
dataGridView.Columns["Patronymic"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка загрузки", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void ButtonAdd_Click(object sender, EventArgs e)
{
var service = Program.ServiceProvider?.GetService(typeof(FormEmployee));
if (service is FormEmployee form)
{
if (form.ShowDialog() == DialogResult.OK)
{
LoadData();
}
}
}
private void ButtonChange_Click(object sender, EventArgs e)
{
if (dataGridView.SelectedRows.Count == 1)
{
var service = Program.ServiceProvider?.GetService(typeof(FormEmployee));
if (service is FormEmployee form)
{
form.Id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
if (form.ShowDialog() == DialogResult.OK)
{
LoadData();
}
}
}
}
private void ButtonDelete_Click(object sender, EventArgs e)
{
if (dataGridView.SelectedRows.Count == 1)
{
if (MessageBox.Show("Удалить запись?", "Вопрос", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
{
int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
try
{
if (!_employeeLogic.Delete(new EmployeeBindingModel
{
Id = id
}))
{
throw new Exception("Ошибка при удалении.");
}
LoadData();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
}
private void ButtonUpdate_Click(object sender, EventArgs e)
{
LoadData();
}
private void FormEmployees_Load(object sender, EventArgs e)
{
LoadData();
}
}
}

View File

@ -1,64 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<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">

View File

@ -28,12 +28,69 @@
/// </summary>
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(800, 450);
this.Text = "FormPosition";
buttonCancel = new Button();
buttonSave = new Button();
label1 = new Label();
textBoxName = new TextBox();
SuspendLayout();
//
// buttonCancel
//
buttonCancel.Location = new Point(112, 56);
buttonCancel.Name = "buttonCancel";
buttonCancel.Size = new Size(75, 23);
buttonCancel.TabIndex = 7;
buttonCancel.Text = "Отмена";
buttonCancel.UseVisualStyleBackColor = true;
buttonCancel.Click += ButtonCancel_Click;
//
// buttonSave
//
buttonSave.Location = new Point(31, 56);
buttonSave.Name = "buttonSave";
buttonSave.Size = new Size(75, 23);
buttonSave.TabIndex = 6;
buttonSave.Text = "Сохранить";
buttonSave.UseVisualStyleBackColor = true;
buttonSave.Click += ButtonSave_Click;
//
// label1
//
label1.AutoSize = true;
label1.Location = new Point(15, 15);
label1.Name = "label1";
label1.Size = new Size(62, 15);
label1.TabIndex = 5;
label1.Text = "Название:";
//
// textBoxName
//
textBoxName.Location = new Point(80, 12);
textBoxName.Name = "textBoxName";
textBoxName.Size = new Size(107, 23);
textBoxName.TabIndex = 4;
//
// FormPosition
//
AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(205, 92);
Controls.Add(buttonCancel);
Controls.Add(buttonSave);
Controls.Add(label1);
Controls.Add(textBoxName);
Name = "FormPosition";
Text = "Должность";
Load += FormPosition_Load;
ResumeLayout(false);
PerformLayout();
}
#endregion
private Button buttonCancel;
private Button buttonSave;
private Label label1;
private TextBox textBoxName;
}
}

View File

@ -1,4 +1,8 @@
using System;
using PersonnelDepartmentBusinessLogic.BusinessLogics;
using PersonnelDepartmentContracts.BindingModels;
using PersonnelDepartmentContracts.BusinessLogicContracts;
using PersonnelDepartmentContracts.SearchModels;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
@ -12,9 +16,71 @@ namespace PersonnelDepartmentView
{
public partial class FormPosition : Form
{
public FormPosition()
private readonly IPositionLogic _positionLogic;
private int? _id;
public int Id { set { _id = value; } }
public FormPosition(IPositionLogic positionLogic)
{
InitializeComponent();
_positionLogic = positionLogic;
}
private void FormPosition_Load(object sender, EventArgs e)
{
if (_id.HasValue)
{
try
{
var view = _positionLogic.ReadElement(new PositionSearchModel
{
Id = _id.Value
});
if (view != null)
{
textBoxName.Text = view.Name;
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
MessageBoxIcon.Error);
}
}
}
private void ButtonSave_Click(object sender, EventArgs e)
{
if (string.IsNullOrEmpty(textBoxName.Text))
{
MessageBox.Show("Введите название", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
try
{
var model = new PositionBindingModel
{
Id = _id ?? 0,
Name = textBoxName.Text
};
var operationResult = _id.HasValue ? _positionLogic.Update(model) : _positionLogic.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();
}
}
}

View File

@ -1,64 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<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">

View File

@ -28,12 +28,86 @@
/// </summary>
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(800, 450);
this.Text = "FormPositions";
buttonUpdate = new Button();
buttonDelete = new Button();
buttonChange = new Button();
buttonAdd = new Button();
dataGridView = new DataGridView();
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
SuspendLayout();
//
// buttonUpdate
//
buttonUpdate.Location = new Point(255, 9);
buttonUpdate.Name = "buttonUpdate";
buttonUpdate.Size = new Size(75, 23);
buttonUpdate.TabIndex = 9;
buttonUpdate.Text = "Обновить";
buttonUpdate.UseVisualStyleBackColor = true;
buttonUpdate.Click += ButtonUpdate_Click;
//
// buttonDelete
//
buttonDelete.Location = new Point(174, 9);
buttonDelete.Name = "buttonDelete";
buttonDelete.Size = new Size(75, 23);
buttonDelete.TabIndex = 8;
buttonDelete.Text = "Удалить";
buttonDelete.UseVisualStyleBackColor = true;
buttonDelete.Click += ButtonDelete_Click;
//
// buttonChange
//
buttonChange.Location = new Point(93, 9);
buttonChange.Name = "buttonChange";
buttonChange.Size = new Size(75, 23);
buttonChange.TabIndex = 7;
buttonChange.Text = "Изменить";
buttonChange.UseVisualStyleBackColor = true;
buttonChange.Click += ButtonChange_Click;
//
// buttonAdd
//
buttonAdd.Location = new Point(12, 9);
buttonAdd.Name = "buttonAdd";
buttonAdd.Size = new Size(75, 23);
buttonAdd.TabIndex = 6;
buttonAdd.Text = "Создать";
buttonAdd.UseVisualStyleBackColor = true;
buttonAdd.Click += ButtonAdd_Click;
//
// dataGridView
//
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
dataGridView.Location = new Point(12, 38);
dataGridView.Name = "dataGridView";
dataGridView.RowTemplate.Height = 25;
dataGridView.Size = new Size(564, 368);
dataGridView.TabIndex = 5;
//
// FormPositions
//
AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(590, 418);
Controls.Add(buttonUpdate);
Controls.Add(buttonDelete);
Controls.Add(buttonChange);
Controls.Add(buttonAdd);
Controls.Add(dataGridView);
Name = "FormPositions";
Text = "Таблица Должностей";
Load += FormPositions_Load;
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
ResumeLayout(false);
}
#endregion
private Button buttonUpdate;
private Button buttonDelete;
private Button buttonChange;
private Button buttonAdd;
private DataGridView dataGridView;
}
}

View File

@ -1,4 +1,8 @@
using System;
using PersonnelDepartmentBusinessLogic.BusinessLogics;
using PersonnelDepartmentContracts.BindingModels;
using PersonnelDepartmentContracts.BusinessLogicContracts;
using PersonnelDepartmentContracts.SearchModels;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
@ -12,9 +16,93 @@ namespace PersonnelDepartmentView
{
public partial class FormPositions : Form
{
public FormPositions()
private readonly IPositionLogic _positionLogic;
public FormPositions(IPositionLogic positionLogic)
{
InitializeComponent();
_positionLogic = positionLogic;
}
private void LoadData()
{
try
{
var list = _positionLogic.ReadList(null);
if (list != null)
{
dataGridView.DataSource = list;
dataGridView.Columns["Id"].Visible = false;
dataGridView.Columns["Name"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка загрузки", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void ButtonAdd_Click(object sender, EventArgs e)
{
var service = Program.ServiceProvider?.GetService(typeof(FormPosition));
if (service is FormPosition form)
{
if (form.ShowDialog() == DialogResult.OK)
{
LoadData();
}
}
}
private void ButtonChange_Click(object sender, EventArgs e)
{
if (dataGridView.SelectedRows.Count == 1)
{
var service = Program.ServiceProvider?.GetService(typeof(FormPosition));
if (service is FormPosition form)
{
form.Id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
if (form.ShowDialog() == DialogResult.OK)
{
LoadData();
}
}
}
}
private void ButtonDelete_Click(object sender, EventArgs e)
{
if (dataGridView.SelectedRows.Count == 1)
{
if (MessageBox.Show("Удалить запись?", "Вопрос", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
{
int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
try
{
if (!_positionLogic.Delete(new PositionBindingModel
{
Id = id
}))
{
throw new Exception("Ошибка при удалении.");
}
LoadData();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
}
private void ButtonUpdate_Click(object sender, EventArgs e)
{
LoadData();
}
private void FormPositions_Load(object sender, EventArgs e)
{
LoadData();
}
}
}

View File

@ -1,64 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<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">

View File

@ -28,12 +28,69 @@
/// </summary>
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(800, 450);
this.Text = "FormType";
textBoxName = new TextBox();
label1 = new Label();
buttonSave = new Button();
buttonCancel = new Button();
SuspendLayout();
//
// textBoxName
//
textBoxName.Location = new Point(78, 12);
textBoxName.Name = "textBoxName";
textBoxName.Size = new Size(107, 23);
textBoxName.TabIndex = 0;
//
// label1
//
label1.AutoSize = true;
label1.Location = new Point(13, 15);
label1.Name = "label1";
label1.Size = new Size(62, 15);
label1.TabIndex = 1;
label1.Text = "Название:";
//
// buttonSave
//
buttonSave.Location = new Point(29, 56);
buttonSave.Name = "buttonSave";
buttonSave.Size = new Size(75, 23);
buttonSave.TabIndex = 2;
buttonSave.Text = "Сохранить";
buttonSave.UseVisualStyleBackColor = true;
buttonSave.Click += ButtonSave_Click;
//
// buttonCancel
//
buttonCancel.Location = new Point(110, 56);
buttonCancel.Name = "buttonCancel";
buttonCancel.Size = new Size(75, 23);
buttonCancel.TabIndex = 3;
buttonCancel.Text = "Отмена";
buttonCancel.UseVisualStyleBackColor = true;
buttonCancel.Click += ButtonCancel_Click;
//
// FormType
//
AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(204, 91);
Controls.Add(buttonCancel);
Controls.Add(buttonSave);
Controls.Add(label1);
Controls.Add(textBoxName);
Name = "FormType";
Text = "Тип договора";
Load += FormType_Load;
ResumeLayout(false);
PerformLayout();
}
#endregion
private TextBox textBoxName;
private Label label1;
private Button buttonSave;
private Button buttonCancel;
}
}

View File

@ -1,4 +1,8 @@
using System;
using PersonnelDepartmentBusinessLogic.BusinessLogics;
using PersonnelDepartmentContracts.BindingModels;
using PersonnelDepartmentContracts.BusinessLogicContracts;
using PersonnelDepartmentContracts.SearchModels;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
@ -12,9 +16,71 @@ namespace PersonnelDepartmentView
{
public partial class FormType : Form
{
public FormType()
private readonly ITypeLogic _typeLogic;
private int? _id;
public int Id { set { _id = value; } }
public FormType(ITypeLogic typeLogic)
{
InitializeComponent();
_typeLogic = typeLogic;
}
private void FormType_Load(object sender, EventArgs e)
{
if (_id.HasValue)
{
try
{
var view = _typeLogic.ReadElement(new TypeSearchModel
{
Id = _id.Value
});
if (view != null)
{
textBoxName.Text = view.Name;
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
MessageBoxIcon.Error);
}
}
}
private void ButtonSave_Click(object sender, EventArgs e)
{
if (string.IsNullOrEmpty(textBoxName.Text))
{
MessageBox.Show("Введите название", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
try
{
var model = new TypeBindingModel
{
Id = _id ?? 0,
Name = textBoxName.Text
};
var operationResult = _id.HasValue ? _typeLogic.Update(model) : _typeLogic.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();
}
}
}

View File

@ -1,64 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<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">

View File

@ -28,12 +28,86 @@
/// </summary>
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(800, 450);
this.Text = "FormTypes";
buttonUpdate = new Button();
buttonDelete = new Button();
buttonChange = new Button();
buttonAdd = new Button();
dataGridView = new DataGridView();
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
SuspendLayout();
//
// buttonUpdate
//
buttonUpdate.Location = new Point(255, 9);
buttonUpdate.Name = "buttonUpdate";
buttonUpdate.Size = new Size(75, 23);
buttonUpdate.TabIndex = 9;
buttonUpdate.Text = "Обновить";
buttonUpdate.UseVisualStyleBackColor = true;
buttonUpdate.Click += ButtonUpdate_Click;
//
// buttonDelete
//
buttonDelete.Location = new Point(174, 9);
buttonDelete.Name = "buttonDelete";
buttonDelete.Size = new Size(75, 23);
buttonDelete.TabIndex = 8;
buttonDelete.Text = "Удалить";
buttonDelete.UseVisualStyleBackColor = true;
buttonDelete.Click += ButtonDelete_Click;
//
// buttonChange
//
buttonChange.Location = new Point(93, 9);
buttonChange.Name = "buttonChange";
buttonChange.Size = new Size(75, 23);
buttonChange.TabIndex = 7;
buttonChange.Text = "Изменить";
buttonChange.UseVisualStyleBackColor = true;
buttonChange.Click += ButtonChange_Click;
//
// buttonAdd
//
buttonAdd.Location = new Point(12, 9);
buttonAdd.Name = "buttonAdd";
buttonAdd.Size = new Size(75, 23);
buttonAdd.TabIndex = 6;
buttonAdd.Text = "Создать";
buttonAdd.UseVisualStyleBackColor = true;
buttonAdd.Click += ButtonAdd_Click;
//
// dataGridView
//
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
dataGridView.Location = new Point(12, 38);
dataGridView.Name = "dataGridView";
dataGridView.RowTemplate.Height = 25;
dataGridView.Size = new Size(564, 368);
dataGridView.TabIndex = 5;
//
// FormTypes
//
AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(590, 420);
Controls.Add(buttonUpdate);
Controls.Add(buttonDelete);
Controls.Add(buttonChange);
Controls.Add(buttonAdd);
Controls.Add(dataGridView);
Name = "FormTypes";
Text = "Таблица Типов";
Load += FormTypes_Load;
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
ResumeLayout(false);
}
#endregion
private Button buttonUpdate;
private Button buttonDelete;
private Button buttonChange;
private Button buttonAdd;
private DataGridView dataGridView;
}
}

View File

@ -1,4 +1,7 @@
using System;
using PersonnelDepartmentBusinessLogic.BusinessLogics;
using PersonnelDepartmentContracts.BindingModels;
using PersonnelDepartmentContracts.BusinessLogicContracts;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
@ -12,9 +15,93 @@ namespace PersonnelDepartmentView
{
public partial class FormTypes : Form
{
public FormTypes()
private readonly ITypeLogic _typeLogic;
public FormTypes(ITypeLogic typeLogic)
{
InitializeComponent();
_typeLogic = typeLogic;
}
private void LoadData()
{
try
{
var list = _typeLogic.ReadList(null);
if (list != null)
{
dataGridView.DataSource = list;
dataGridView.Columns["Id"].Visible = false;
dataGridView.Columns["Name"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка загрузки", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void ButtonAdd_Click(object sender, EventArgs e)
{
var service = Program.ServiceProvider?.GetService(typeof(FormType));
if (service is FormType form)
{
if (form.ShowDialog() == DialogResult.OK)
{
LoadData();
}
}
}
private void ButtonChange_Click(object sender, EventArgs e)
{
if (dataGridView.SelectedRows.Count == 1)
{
var service = Program.ServiceProvider?.GetService(typeof(FormType));
if (service is FormType form)
{
form.Id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
if (form.ShowDialog() == DialogResult.OK)
{
LoadData();
}
}
}
}
private void ButtonDelete_Click(object sender, EventArgs e)
{
if (dataGridView.SelectedRows.Count == 1)
{
if (MessageBox.Show("Удалить запись?", "Вопрос", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
{
int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
try
{
if (!_typeLogic.Delete(new TypeBindingModel
{
Id = id
}))
{
throw new Exception("Ошибка при удалении.");
}
LoadData();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
}
private void ButtonUpdate_Click(object sender, EventArgs e)
{
LoadData();
}
private void FormTypes_Load(object sender, EventArgs e)
{
LoadData();
}
}
}

View File

@ -1,64 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<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">

View File

@ -13,6 +13,13 @@
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="7.0.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\PersonnelDepartmentBusinessLogic\PersonnelDepartmentBusinessLogic.csproj" />
<ProjectReference Include="..\PersonnelDepartmentContracts\PersonnelDepartmentContracts.csproj" />
<ProjectReference Include="..\PersonnelDepartmentDatabaseImplement\PersonnelDepartmentDatabaseImplement.csproj" />
</ItemGroup>
</Project>

View File

@ -21,15 +21,14 @@ namespace PersonnelDepartmentView
// To customize application configuration such as set high DPI settings or default font,
// see https://aka.ms/applicationconfiguration.
ApplicationConfiguration.Initialize();
Application.Run(new FormDeals());
var services = new ServiceCollection();
ConfigureServices(services);
_serviceProvider = services.BuildServiceProvider();
Application.Run(_serviceProvider.GetRequiredService<FormDeals>());
}
private static void ConfigureServices(ServiceCollection services)
{
_serviceProvider = services.BuildServiceProvider();
services.AddTransient<IDealLogic, DealLogic>();
services.AddTransient<IDepartmentLogic, DepartmentLogic>();
services.AddTransient<IEmployeeLogic, EmployeeLogic>();