66 lines
1.3 KiB
C#
66 lines
1.3 KiB
C#
|
using Commentbase;
|
|||
|
using Microsoft.VisualBasic.ApplicationServices;
|
|||
|
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 FormAuthor : Form
|
|||
|
{
|
|||
|
public int? AuthorId { get; set; }
|
|||
|
private Abstracts db;
|
|||
|
public FormAuthor(Abstracts abstracts)
|
|||
|
{
|
|||
|
InitializeComponent();
|
|||
|
db = abstracts;
|
|||
|
}
|
|||
|
private void button1_Click(object sender, EventArgs e)
|
|||
|
{
|
|||
|
if (AuthorId.HasValue)
|
|||
|
{
|
|||
|
db.UpdateAuthor(new()
|
|||
|
{
|
|||
|
Id = AuthorId.Value,
|
|||
|
Name = textBox1.Text,
|
|||
|
PhoneNum = textBox2.Text,
|
|||
|
Email = textBox3.Text
|
|||
|
});
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
db.CreateAuthor(new()
|
|||
|
{
|
|||
|
Name = textBox1.Text,
|
|||
|
PhoneNum = textBox2.Text,
|
|||
|
Email = textBox3.Text
|
|||
|
});
|
|||
|
}
|
|||
|
DialogResult = DialogResult.OK;
|
|||
|
}
|
|||
|
|
|||
|
private void button2_Click(object sender, EventArgs e)
|
|||
|
{
|
|||
|
DialogResult = DialogResult.Cancel;
|
|||
|
Close();
|
|||
|
}
|
|||
|
|
|||
|
private void FormAuthor_Load(object sender, EventArgs e)
|
|||
|
{
|
|||
|
if (AuthorId.HasValue)
|
|||
|
{
|
|||
|
var author = db.GetAuthor(AuthorId.Value);
|
|||
|
textBox1.Text = author.Name;
|
|||
|
textBox2.Text = author.PhoneNum;
|
|||
|
textBox3.Text = author.Email;
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
}
|