63 lines
1.2 KiB
C#
63 lines
1.2 KiB
C#
|
using Commentbase;
|
|||
|
using Npgsql.Internal.Postgres;
|
|||
|
using System;
|
|||
|
using System.Collections.Generic;
|
|||
|
using System.ComponentModel;
|
|||
|
using System.Data;
|
|||
|
using System.Drawing;
|
|||
|
using System.Linq;
|
|||
|
using System.Text;
|
|||
|
using System.Threading.Tasks;
|
|||
|
using System.Windows.Forms;
|
|||
|
|
|||
|
namespace View
|
|||
|
{
|
|||
|
public partial class FormAlbum : Form
|
|||
|
{
|
|||
|
public int? AlbumId { get; set; }
|
|||
|
private Abstracts db;
|
|||
|
public FormAlbum(Abstracts abstracts)
|
|||
|
{
|
|||
|
InitializeComponent();
|
|||
|
db = abstracts;
|
|||
|
}
|
|||
|
private void button1_Click(object sender, EventArgs e)
|
|||
|
{
|
|||
|
if (AlbumId.HasValue)
|
|||
|
{
|
|||
|
db.UpdateAlbum(new()
|
|||
|
{
|
|||
|
Id = AlbumId.Value,
|
|||
|
Title = textBox1.Text,
|
|||
|
Description = textBox2.Text,
|
|||
|
});
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
db.CreateAlbum(new()
|
|||
|
{
|
|||
|
Title = textBox1.Text,
|
|||
|
Description = textBox2.Text
|
|||
|
});
|
|||
|
|
|||
|
}
|
|||
|
DialogResult = DialogResult.OK;
|
|||
|
}
|
|||
|
|
|||
|
private void button2_Click(object sender, EventArgs e)
|
|||
|
{
|
|||
|
DialogResult = DialogResult.Cancel;
|
|||
|
Close();
|
|||
|
}
|
|||
|
private void FormAlbum_Load(object sender, EventArgs e)
|
|||
|
{
|
|||
|
if (AlbumId.HasValue)
|
|||
|
{
|
|||
|
var album = db.GetAlbum(AlbumId.Value);
|
|||
|
textBox1.Text = album.Title;
|
|||
|
textBox2.Text = album.Description;
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
}
|