-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFormUnit.cpp
More file actions
75 lines (67 loc) · 2.27 KB
/
FormUnit.cpp
File metadata and controls
75 lines (67 loc) · 2.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
//---------------------------------------------------------------------------
#include <vcl.h>
#include <stdio.h>
#pragma hdrstop
#include "FormUnit.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm2 *Form2;
//---------------------------------------------------------------------------
__fastcall TForm2::TForm2(int itemId, TComponent* Owner)
: itemId(itemId), TForm(Owner)
{
FDTable2->Filter = "id=" + IntToStr(itemId);
if(itemId == -1) {
FDTable2->Insert();
Button2->Enabled = false;
ComboBox3->ItemIndex = 0;
} else {
FDTable2->Edit();
}
}
//---------------------------------------------------------------------------
void __fastcall TForm2::SaveClick(TObject *Sender)
{
bool isSaveModeEnabled = FDTable2->State == dsEdit
|| FDTable2->State == dsInsert;
if(isSaveModeEnabled) {
FDTable2->FieldByName("series")->AsString = ComboBox4->Text;
FDTable2->FieldByName("author")->AsString = ComboBox2->Text;
TValue genre = LinkFillControlToField3->BindList->GetSelectedValue();
UnicodeString genreId = genre.AsString();
FDTable2->FieldByName("genre")->AsString = genreId;
FDTable2->Post();
}
Close();
}
//---------------------------------------------------------------------------
void __fastcall TForm2::Button2Click(TObject *Sender)
{
if(itemId != -1) {
FDTable1->ExecSQL("DELETE FROM book WHERE id=" + IntToStr(itemId));
Close();
}
}
//---------------------------------------------------------------------------
void __fastcall TForm2::FDTable2AfterEdit(TDataSet *DataSet)
{
UnicodeString series = DataSet->FieldByName("series")->AsString;
UnicodeString author = DataSet->FieldByName("author")->AsString;
ComboBox4->Text = series;
ComboBox2->Text = author;
}
//---------------------------------------------------------------------------
void __fastcall TForm2::Button1Click(TObject *Sender)
{
if(OpenPictureDialog1->Execute()) {
auto fname = OpenPictureDialog1->FileName;
Image1->Picture->LoadFromFile(fname);
}
}
//---------------------------------------------------------------------------
void __fastcall TForm2::Button3Click(TObject *Sender)
{
Image1->Picture = nullptr;
}
//---------------------------------------------------------------------------