Add avatars and avatar document
This commit is contained in:
parent
c3d19cda92
commit
93ffc24a90
30
AbazovApp/AccountsApp/FormAccount.Designer.cs
generated
30
AbazovApp/AccountsApp/FormAccount.Designer.cs
generated
@ -28,7 +28,6 @@
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(FormAccount));
|
||||
this.label1 = new System.Windows.Forms.Label();
|
||||
this.textBoxLogin = new System.Windows.Forms.TextBox();
|
||||
this.textBoxPassword = new System.Windows.Forms.TextBox();
|
||||
@ -39,6 +38,8 @@
|
||||
this.label4 = new System.Windows.Forms.Label();
|
||||
this.buttonSave = new System.Windows.Forms.Button();
|
||||
this.buttonCancel = new System.Windows.Forms.Button();
|
||||
this.openFileDialog = new System.Windows.Forms.OpenFileDialog();
|
||||
this.buttonAvatar = new System.Windows.Forms.Button();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// label1
|
||||
@ -100,7 +101,7 @@
|
||||
// abazovCheckedListBox
|
||||
//
|
||||
this.abazovCheckedListBox.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.abazovCheckedListBox.Location = new System.Drawing.Point(12, 195);
|
||||
this.abazovCheckedListBox.Location = new System.Drawing.Point(12, 207);
|
||||
this.abazovCheckedListBox.Name = "abazovCheckedListBox";
|
||||
this.abazovCheckedListBox.selectedItem = null;
|
||||
this.abazovCheckedListBox.Size = new System.Drawing.Size(389, 130);
|
||||
@ -110,7 +111,7 @@
|
||||
//
|
||||
this.label4.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.label4.AutoSize = true;
|
||||
this.label4.Location = new System.Drawing.Point(12, 172);
|
||||
this.label4.Location = new System.Drawing.Point(12, 184);
|
||||
this.label4.Name = "label4";
|
||||
this.label4.Size = new System.Drawing.Size(78, 20);
|
||||
this.label4.TabIndex = 7;
|
||||
@ -118,7 +119,7 @@
|
||||
//
|
||||
// buttonSave
|
||||
//
|
||||
this.buttonSave.Location = new System.Drawing.Point(12, 364);
|
||||
this.buttonSave.Location = new System.Drawing.Point(12, 420);
|
||||
this.buttonSave.Name = "buttonSave";
|
||||
this.buttonSave.Size = new System.Drawing.Size(94, 29);
|
||||
this.buttonSave.TabIndex = 8;
|
||||
@ -128,7 +129,7 @@
|
||||
//
|
||||
// buttonCancel
|
||||
//
|
||||
this.buttonCancel.Location = new System.Drawing.Point(307, 364);
|
||||
this.buttonCancel.Location = new System.Drawing.Point(307, 420);
|
||||
this.buttonCancel.Name = "buttonCancel";
|
||||
this.buttonCancel.Size = new System.Drawing.Size(94, 29);
|
||||
this.buttonCancel.TabIndex = 9;
|
||||
@ -136,11 +137,26 @@
|
||||
this.buttonCancel.UseVisualStyleBackColor = true;
|
||||
this.buttonCancel.Click += new System.EventHandler(this.buttonCancel_Click);
|
||||
//
|
||||
// openFileDialog
|
||||
//
|
||||
this.openFileDialog.FileName = "openFileDialog1";
|
||||
//
|
||||
// buttonAvatar
|
||||
//
|
||||
this.buttonAvatar.Location = new System.Drawing.Point(12, 343);
|
||||
this.buttonAvatar.Name = "buttonAvatar";
|
||||
this.buttonAvatar.Size = new System.Drawing.Size(389, 29);
|
||||
this.buttonAvatar.TabIndex = 10;
|
||||
this.buttonAvatar.Text = "Выбрать аватар";
|
||||
this.buttonAvatar.UseVisualStyleBackColor = true;
|
||||
this.buttonAvatar.Click += new System.EventHandler(this.buttonAvatar_Click);
|
||||
//
|
||||
// FormAccount
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(413, 405);
|
||||
this.ClientSize = new System.Drawing.Size(413, 461);
|
||||
this.Controls.Add(this.buttonAvatar);
|
||||
this.Controls.Add(this.buttonCancel);
|
||||
this.Controls.Add(this.buttonSave);
|
||||
this.Controls.Add(this.label4);
|
||||
@ -171,5 +187,7 @@
|
||||
private Label label4;
|
||||
private Button buttonSave;
|
||||
private Button buttonCancel;
|
||||
private OpenFileDialog openFileDialog;
|
||||
private Button buttonAvatar;
|
||||
}
|
||||
}
|
@ -21,6 +21,7 @@ namespace AccountsApp
|
||||
private readonly IAccountLogic _logic;
|
||||
private readonly IInterestLogic _interestLogic;
|
||||
private List<InterestViewModel> _interests;
|
||||
private string? avatar = null;
|
||||
public int Id { set { _id = value; } }
|
||||
|
||||
public FormAccount(IAccountLogic logic, IInterestLogic interestLogic)
|
||||
@ -47,6 +48,7 @@ namespace AccountsApp
|
||||
textBoxLogin.Text = view.Login;
|
||||
textBoxPassword.Text = view.Password;
|
||||
mailControl.Email = view.Email;
|
||||
avatar = view.Avatar;
|
||||
|
||||
abazovCheckedListBox.selectedItem = view.InterestName;
|
||||
}
|
||||
@ -86,6 +88,11 @@ namespace AccountsApp
|
||||
MessageBox.Show("Заполните интересы", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
if (avatar == null)
|
||||
{
|
||||
MessageBox.Show("Выберите аватар", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
try
|
||||
{
|
||||
var model = new AccountBindingModel
|
||||
@ -94,7 +101,8 @@ namespace AccountsApp
|
||||
Login = textBoxLogin.Text,
|
||||
Password = textBoxPassword.Text,
|
||||
Email = mailControl.Email,
|
||||
InterestId = _interests.First(x => x.Name == abazovCheckedListBox.selectedItem).Id
|
||||
InterestId = _interests.First(x => x.Name == abazovCheckedListBox.selectedItem).Id,
|
||||
Avatar = avatar
|
||||
};
|
||||
var operationResult = _id.HasValue ? _logic.Update(model) : _logic.Create(model);
|
||||
if (!operationResult)
|
||||
@ -110,5 +118,13 @@ namespace AccountsApp
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void buttonAvatar_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (openFileDialog.ShowDialog() != DialogResult.Cancel)
|
||||
{
|
||||
avatar = openFileDialog.FileName;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -57,12 +57,7 @@
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<data name="abazovCheckedListBox.selectedItems" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>
|
||||
AAEAAAD/////AQAAAAAAAAAEAQAAAH9TeXN0ZW0uQ29sbGVjdGlvbnMuR2VuZXJpYy5MaXN0YDFbW1N5
|
||||
c3RlbS5TdHJpbmcsIG1zY29ybGliLCBWZXJzaW9uPTQuMC4wLjAsIEN1bHR1cmU9bmV1dHJhbCwgUHVi
|
||||
bGljS2V5VG9rZW49Yjc3YTVjNTYxOTM0ZTA4OV1dAwAAAAZfaXRlbXMFX3NpemUIX3ZlcnNpb24GAAAI
|
||||
CAkCAAAAAAAAAAAAAAARAgAAAAAAAAAL
|
||||
</value>
|
||||
</data>
|
||||
<metadata name="openFileDialog.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>17, 17</value>
|
||||
</metadata>
|
||||
</root>
|
4
AbazovApp/AccountsApp/FormMain.Designer.cs
generated
4
AbazovApp/AccountsApp/FormMain.Designer.cs
generated
@ -28,6 +28,7 @@
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.components = new System.ComponentModel.Container();
|
||||
this.menuStrip1 = new System.Windows.Forms.MenuStrip();
|
||||
this.аккаунтыToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.создатьToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
@ -39,6 +40,7 @@
|
||||
this.документСДиаграммойToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.интересыToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.controlDataTable = new ControlsLibraryNet60.Data.ControlDataTableTable();
|
||||
this.excelImagesComponent = new AbazovViewComponents.LogicalComponents.ExcelImagesComponent(this.components);
|
||||
this.menuStrip1.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
@ -105,6 +107,7 @@
|
||||
this.документToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.S)));
|
||||
this.документToolStripMenuItem.Size = new System.Drawing.Size(313, 26);
|
||||
this.документToolStripMenuItem.Text = "Документ";
|
||||
this.документToolStripMenuItem.Click += new System.EventHandler(this.документToolStripMenuItem_Click);
|
||||
//
|
||||
// документСТаблицейToolStripMenuItem
|
||||
//
|
||||
@ -167,5 +170,6 @@
|
||||
private ToolStripMenuItem документСДиаграммойToolStripMenuItem;
|
||||
private ToolStripMenuItem интересыToolStripMenuItem;
|
||||
private ControlsLibraryNet60.Data.ControlDataTableTable controlDataTable;
|
||||
private AbazovViewComponents.LogicalComponents.ExcelImagesComponent excelImagesComponent;
|
||||
}
|
||||
}
|
@ -1,4 +1,5 @@
|
||||
using AccountsContracts.BindingModels;
|
||||
using AbazovViewComponents.LogicalComponents;
|
||||
using AccountsContracts.BindingModels;
|
||||
using AccountsContracts.BusinessLogicContracts;
|
||||
using AccountsContracts.ViewModels;
|
||||
using ControlsLibraryNet60.Core;
|
||||
@ -90,5 +91,16 @@ namespace AccountsApp
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void документToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
List<string> avatars = new List<string>();
|
||||
foreach (var account in _logic.ReadList(null))
|
||||
{
|
||||
avatars.Add(account.Avatar);
|
||||
}
|
||||
string path = AppDomain.CurrentDomain.BaseDirectory + "Аватары.xlsx";
|
||||
if (excelImagesComponent.createWithImages(new ExcelImageInfo(path, "Аватары", avatars.ToArray()))) MessageBox.Show("Документ создан");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -60,6 +60,9 @@
|
||||
<metadata name="menuStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>17, 17</value>
|
||||
</metadata>
|
||||
<metadata name="excelImagesComponent.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>152, 0</value>
|
||||
</metadata>
|
||||
<metadata name="$this.TrayHeight" type="System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>25</value>
|
||||
</metadata>
|
||||
|
@ -18,5 +18,7 @@ namespace AccountsContracts.BindingModels
|
||||
public int Id { get; set; }
|
||||
|
||||
public int InterestId { get; set; }
|
||||
|
||||
public string Avatar { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -19,5 +19,6 @@ namespace AccountsContracts.ViewModels
|
||||
public int Id { get; set; }
|
||||
public int InterestId { get; set; }
|
||||
public string InterestName { get; set; } = string.Empty;
|
||||
public string Avatar { get; set; } = string.Empty;
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,91 @@
|
||||
// <auto-generated />
|
||||
using AccountsDataBaseImplement;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace AccountsDataBaseImplement.Migrations
|
||||
{
|
||||
[DbContext(typeof(AccountsDatabase))]
|
||||
[Migration("20231129200602_AddColumnAvatarToAccountTable")]
|
||||
partial class AddColumnAvatarToAccountTable
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder
|
||||
.HasAnnotation("ProductVersion", "7.0.3")
|
||||
.HasAnnotation("Relational:MaxIdentifierLength", 63);
|
||||
|
||||
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
|
||||
|
||||
modelBuilder.Entity("AccountsDataBaseImplement.Models.Account", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("Avatar")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("Email")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<int>("InterestId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<string>("Login")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("Password")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("InterestId");
|
||||
|
||||
b.ToTable("Accounts");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("AccountsDataBaseImplement.Models.Interest", 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("Interests");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("AccountsDataBaseImplement.Models.Account", b =>
|
||||
{
|
||||
b.HasOne("AccountsDataBaseImplement.Models.Interest", "Interest")
|
||||
.WithMany()
|
||||
.HasForeignKey("InterestId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Interest");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,29 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace AccountsDataBaseImplement.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class AddColumnAvatarToAccountTable : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AddColumn<string>(
|
||||
name: "Avatar",
|
||||
table: "Accounts",
|
||||
type: "text",
|
||||
nullable: false,
|
||||
defaultValue: "");
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropColumn(
|
||||
name: "Avatar",
|
||||
table: "Accounts");
|
||||
}
|
||||
}
|
||||
}
|
@ -29,6 +29,10 @@ namespace AccountsDataBaseImplement.Migrations
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("Avatar")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("Email")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
@ -26,6 +26,9 @@ namespace AccountsDataBaseImplement.Models
|
||||
|
||||
public virtual Interest Interest { get; set; } = new();
|
||||
|
||||
[Required]
|
||||
public string Avatar { get; set; } = string.Empty;
|
||||
|
||||
public static Account? Create(AccountsDatabase context, AccountBindingModel? model)
|
||||
{
|
||||
if (model == null)
|
||||
@ -40,6 +43,7 @@ namespace AccountsDataBaseImplement.Models
|
||||
Email = model.Email,
|
||||
InterestId = model.InterestId,
|
||||
Interest = context.Interests.First(x => x.Id == model.InterestId),
|
||||
Avatar = model.Avatar,
|
||||
};
|
||||
}
|
||||
|
||||
@ -53,6 +57,7 @@ namespace AccountsDataBaseImplement.Models
|
||||
Password = model.Password;
|
||||
InterestId = model.InterestId;
|
||||
Interest = context.Interests.First(x => x.Id == model.InterestId);
|
||||
Avatar = model.Avatar;
|
||||
}
|
||||
|
||||
public AccountViewModel GetViewModel => new()
|
||||
@ -63,6 +68,7 @@ namespace AccountsDataBaseImplement.Models
|
||||
Email = Email,
|
||||
InterestId = InterestId,
|
||||
InterestName = Interest.Name,
|
||||
Avatar = Avatar,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -12,5 +12,6 @@ namespace AccountsDataModels.Models
|
||||
string Password { get; }
|
||||
string Email { get; }
|
||||
public int InterestId { get; }
|
||||
public string Avatar { get; }
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user