SUBD/View/TypeForm.cs

61 lines
1.0 KiB
C#
Raw Normal View History

2024-05-05 22:00:25 +04:00
using Database;
using System;
2024-04-16 22:38:56 +04:00
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 TypeForm : Form
{
2024-05-05 22:00:25 +04:00
public int? TypeId { get; set; }
private Abstracts db;
public TypeForm(Abstracts abstracts)
2024-04-16 22:38:56 +04:00
{
InitializeComponent();
2024-05-05 22:00:25 +04:00
db = abstracts;
}
private void button1_Click(object sender, EventArgs e)
{
if (TypeId.HasValue)
{
db.UpdateType(new()
{
Id = TypeId.Value,
title = textBox1.Text
});
}
else
{
db.CreateType(new() {
title = textBox1.Text
});
}
DialogResult = DialogResult.OK;
}
private void button2_Click(object sender, EventArgs e)
{
DialogResult = DialogResult.Cancel;
Close();
}
private void TypeForm_Load(object sender, EventArgs e)
{
if (TypeId.HasValue)
{
var type = db.GetType(TypeId.Value);
textBox1.Text = type.title;
}
2024-04-16 22:38:56 +04:00
}
}
}