📄 c++ builder 程序设计实用教程 - 程序完整源代码如下所 - 张晋 - 17xie.htm
字号:
style="mso-spacerun: yes"> </SPAN>if (MessageDlg("</SPAN><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">数据库已经被修改过,是否保存结果</SPAN><SPAN
lang=EN-US style="FONT-FAMILY: 'Times New Roman'">?", mtWarning,
TMsgDlgButtons() << <o:p></o:p></SPAN></FONT></P>
<P class=a0 style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US
style="FONT-FAMILY: 'Times New Roman'"><FONT size=2><SPAN
style="mso-spacerun: yes"> </SPAN>mbYes << mbNo,
0) == mrYes)<o:p></o:p></FONT></SPAN></P>
<P class=a0 style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US
style="FONT-FAMILY: 'Times New Roman'"><FONT size=2><SPAN
style="mso-spacerun: yes">
</SPAN>Query1->Post();<o:p></o:p></FONT></SPAN></P>
<P class=a0 style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US
style="FONT-FAMILY: 'Times New Roman'"><FONT size=2><SPAN
style="mso-spacerun: yes"> </SPAN>else<o:p></o:p></FONT></SPAN></P>
<P class=a0 style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US
style="FONT-FAMILY: 'Times New Roman'"><FONT size=2><SPAN
style="mso-spacerun: yes">
</SPAN>Query1->Cancel();<o:p></o:p></FONT></SPAN></P>
<P class=a0 style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US
style="FONT-FAMILY: 'Times New Roman'"><FONT size=2><SPAN
style="mso-spacerun: yes"> </SPAN>}<o:p></o:p></FONT></SPAN></P>
<P class=a0 style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US
style="FONT-FAMILY: 'Times New Roman'"><FONT
size=2>}<o:p></o:p></FONT></SPAN></P>
<P class=a0 style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US
style="FONT-FAMILY: 'Times New Roman'"><FONT
size=2>//-----------------------------------------------------------------------<o:p></o:p></FONT></SPAN></P>
<P class=a0 style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US
style="FONT-FAMILY: 'Times New Roman'"><o:p><FONT
size=2> </FONT></o:p></SPAN></P>
<P class=a0 style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US
style="FONT-FAMILY: 'Times New Roman'"><FONT size=2>void __fastcall
TForm1::Button3Click(TObject *Sender)<o:p></o:p></FONT></SPAN></P>
<P class=a0 style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US
style="FONT-FAMILY: 'Times New Roman'"><FONT
size=2>{<o:p></o:p></FONT></SPAN></P>
<P class=a0 style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US
style="FONT-FAMILY: 'Times New Roman'"><FONT
size=2>Form1->Query1->Insert();<o:p></o:p></FONT></SPAN></P>
<P class=a0 style="MARGIN: 0cm 0cm 0pt"><FONT size=2><SPAN lang=EN-US
style="FONT-FAMILY: 'Times New Roman'">//</SPAN><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">插入一条新的记录</SPAN><SPAN
lang=EN-US style="FONT-FAMILY: 'Times New Roman'"><o:p></o:p></SPAN></FONT></P>
<P class=a0 style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US
style="FONT-FAMILY: 'Times New Roman'"><FONT
size=2>}<o:p></o:p></FONT></SPAN></P>
<P class=a0 style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US
style="FONT-FAMILY: 'Times New Roman'"><FONT
size=2>//-----------------------------------------------------------------------<o:p></o:p></FONT></SPAN></P>
<P class=a0 style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US
style="FONT-FAMILY: 'Times New Roman'"><o:p><FONT
size=2> </FONT></o:p></SPAN></P>
<P class=a0 style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US
style="FONT-FAMILY: 'Times New Roman'"><FONT size=2>void __fastcall
TForm1::FormClose(TObject *Sender, TCloseAction
&Action)<o:p></o:p></FONT></SPAN></P>
<P class=a0 style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US
style="FONT-FAMILY: 'Times New Roman'"><FONT
size=2>{<o:p></o:p></FONT></SPAN></P>
<P class=a0 style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US
style="FONT-FAMILY: 'Times New Roman'"><FONT size=2>if
(!Form1->Query1->Modified)<o:p></o:p></FONT></SPAN></P>
<P class=a0 style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US
style="FONT-FAMILY: 'Times New Roman'"><FONT size=2><SPAN
style="mso-spacerun: yes"> </SPAN>{<o:p></o:p></FONT></SPAN></P>
<P class=a0 style="MARGIN: 0cm 0cm 0pt"><FONT size=2><SPAN lang=EN-US
style="FONT-FAMILY: 'Times New Roman'"><SPAN
style="mso-spacerun: yes"> </SPAN>if (MessageDlg("</SPAN><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">数据库已经被修改过,是否保存结果</SPAN><SPAN
lang=EN-US style="FONT-FAMILY: 'Times New Roman'">?", mtWarning,
TMsgDlgButtons() << <o:p></o:p></SPAN></FONT></P>
<P class=a0 style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US
style="FONT-FAMILY: 'Times New Roman'"><FONT size=2><SPAN
style="mso-spacerun: yes"> </SPAN>mbYes << mbNo,
0) == mrYes)<o:p></o:p></FONT></SPAN></P>
<P class=a0 style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US
style="FONT-FAMILY: 'Times New Roman'"><FONT size=2><SPAN
style="mso-spacerun: yes">
</SPAN>Query1->Post();<o:p></o:p></FONT></SPAN></P>
<P class=a0 style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US
style="FONT-FAMILY: 'Times New Roman'"><FONT size=2><SPAN
style="mso-spacerun: yes"> </SPAN>else<o:p></o:p></FONT></SPAN></P>
<P class=a0 style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US
style="FONT-FAMILY: 'Times New Roman'"><FONT size=2><SPAN
style="mso-spacerun: yes">
</SPAN>Query1->Cancel();<o:p></o:p></FONT></SPAN></P>
<P class=a0 style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US
style="FONT-FAMILY: 'Times New Roman'"><FONT size=2><SPAN
style="mso-spacerun: yes"> </SPAN>}<o:p></o:p></FONT></SPAN></P>
<P class=a0 style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US
style="FONT-FAMILY: 'Times New Roman'"><FONT
size=2>Query1->Close();<o:p></o:p></FONT></SPAN></P>
<P class=a0 style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US
style="FONT-FAMILY: 'Times New Roman'"><FONT
size=2>}<o:p></o:p></FONT></SPAN></P>
<P class=a0 style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US
style="FONT-FAMILY: 'Times New Roman'"><FONT
size=2>//-----------------------------------------------------------------------<o:p></o:p></FONT></SPAN></P>
<P class=a0 style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US
style="FONT-FAMILY: 'Times New Roman'"><o:p><FONT
size=2> </FONT></o:p></SPAN></P>
<P class=a0 style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US
style="FONT-FAMILY: 'Times New Roman'"><FONT size=2>void __fastcall
TForm1::Button4Click(TObject *Sender)<o:p></o:p></FONT></SPAN></P>
<P class=a0 style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US
style="FONT-FAMILY: 'Times New Roman'"><FONT
size=2>{<o:p></o:p></FONT></SPAN></P>
<P class=a0 style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US
style="FONT-FAMILY: 'Times New Roman'"><FONT
size=2>Form1->Query1->Delete();<o:p></o:p></FONT></SPAN></P>
<P class=a0 style="MARGIN: 0cm 0cm 0pt"><FONT size=2><SPAN lang=EN-US
style="FONT-FAMILY: 'Times New Roman'">//</SPAN><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">删除一条记录</SPAN><SPAN
lang=EN-US style="FONT-FAMILY: 'Times New Roman'"><o:p></o:p></SPAN></FONT></P>
<P class=a0 style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US
style="FONT-FAMILY: 'Times New Roman'"><FONT
size=2>}<o:p></o:p></FONT></SPAN></P>
<P class=a0 style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US
style="FONT-FAMILY: 'Times New Roman'"><FONT
size=2>//-----------------------------------------------------------------------<o:p></o:p></FONT></SPAN></P>
<P class=a0 style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US
style="FONT-FAMILY: 'Times New Roman'"><o:p><FONT
size=2> </FONT></o:p></SPAN></P>
<P class=a0 style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US
style="FONT-FAMILY: 'Times New Roman'"><FONT size=2>void __fastcall
TForm1::Button5Click(TObject *Sender)<o:p></o:p></FONT></SPAN></P>
<P class=a0 style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US
style="FONT-FAMILY: 'Times New Roman'"><FONT
size=2>{<o:p></o:p></FONT></SPAN></P>
<P class=a0 style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US
style="FONT-FAMILY: 'Times New Roman'"><FONT
size=2>Form1->Query1->First();<o:p></o:p></FONT></SPAN></P>
<P class=a0 style="MARGIN: 0cm 0cm 0pt"><FONT size=2><SPAN lang=EN-US
style="FONT-FAMILY: 'Times New Roman'">//</SPAN><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">移动到第一条记录</SPAN><SPAN
lang=EN-US style="FONT-FAMILY: 'Times New Roman'"><o:p></o:p></SPAN></FONT></P>
<P class=a0 style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US
style="FONT-FAMILY: 'Times New Roman'"><FONT
size=2>}<o:p></o:p></FONT></SPAN></P>
<P class=a0 style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US
style="FONT-FAMILY: 'Times New Roman'"><FONT
size=2>//-----------------------------------------------------------------------<o:p></o:p></FONT></SPAN></P>
<P class=a0 style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US
style="FONT-FAMILY: 'Times New Roman'"><o:p><FONT
size=2> </FONT></o:p></SPAN></P>
<P class=a0 style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US
style="FONT-FAMILY: 'Times New Roman'"><FONT size=2>void __fastcall
TForm1::Button6Click(TObject *Sender)<o:p></o:p></FONT></SPAN></P>
<P class=a0 style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US
style="FONT-FAMILY: 'Times New Roman'"><FONT
size=2>{<o:p></o:p></FONT></SPAN></P>
<P class=a0 style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US
style="FONT-FAMILY: 'Times New Roman'"><FONT
size=2>Form1->Query1->Last();<o:p></o:p></FONT></SPAN></P>
<P class=a0 style="MARGIN: 0cm 0cm 0pt"><FONT size=2><SPAN lang=EN-US
style="FONT-FAMILY: 'Times New Roman'">//</SPAN><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">移动到最后一条记录</SPAN><SPAN
lang=EN-US style="FONT-FAMILY: 'Times New Roman'"><o:p></o:p></SPAN></FONT></P>
<P class=a0 style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US
style="FONT-FAMILY: 'Times New Roman'"><FONT
size=2>}<o:p></o:p></FONT></SPAN></P>
<P class=a0 style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US
style="FONT-FAMILY: 'Times New Roman'"><FONT
size=2>//-----------------------------------------------------------------------<o:p></o:p></FONT></SPAN></P>
<P class=a0 style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US
style="FONT-FAMILY: 'Times New Roman'"><o:p><FONT
size=2> </FONT></o:p></SPAN></P>
<P class=a0 style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US
style="FONT-FAMILY: 'Times New Roman'"><FONT size=2>void __fastcall
TForm1::Button7Click(TObject *Sender)<o:p></o:p></FONT></SPAN></P>
<P class=a0 style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US
style="FONT-FAMILY: 'Times New Roman'"><FONT
size=2>{<o:p></o:p></FONT></SPAN></P>
<P class=a0 style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US
style="FONT-FAMILY: 'Times New Roman'"><FONT
size=2>Form1->Query1->Prior();<o:p></o:p></FONT></SPAN></P>
<P class=a0 style="MARGIN: 0cm 0cm 0pt"><FONT size=2><SPAN lang=EN-US
style="FONT-FAMILY: 'Times New Roman'">//</SPAN><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">移动到前一条记录</SPAN><SPAN
lang=EN-US style="FONT-FAMILY: 'Times New Roman'"><o:p></o:p></SPAN></FONT></P>
<P class=a0 style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US
style="FONT-FAMILY: 'Times New Roman'"><FONT
size=2>}<o:p></o:p></FONT></SPAN></P>
<P class=a0 style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US
style="FONT-FAMILY: 'Times New Roman'"><FONT
size=2>//-----------------------------------------------------------------------<o:p></o:p></FONT></SPAN></P>
<P class=a0 style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US
style="FONT-FAMILY: 'Times New Roman'"><o:p><FONT
size=2> </FONT></o:p></SPAN></P>
<P class=a0 style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US
style="FONT-FAMILY: 'Times New Roman'"><FONT size=2>void __fastcall
TForm1::Button8Click(TObject *Sender)<o:p></o:p></FONT></SPAN></P>
<P class=a0 style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US
style="FONT-FAMILY: 'Times New Roman'"><FONT
size=2>{<o:p></o:p></FONT></SPAN></P>
<P class=a0 style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US
style="FONT-FAMILY: 'Times New Roman'"><FONT
size=2>Form1->Query1->Next();<o:p></o:p></FONT></SPAN></P>
<P class=a0 style="MARGIN: 0cm 0cm 0pt"><FONT size=2><SPAN lang=EN-US
style="FONT-FAMILY: 'Times New Roman'">//</SPAN><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">移动到下一条记录</SPAN><SPAN
lang=EN-US style="FONT-FAMILY: 'Times New Roman'"><o:p></o:p></SPAN></FONT></P>
<P class=a0 style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US
style="FONT-FAMILY: 'Times New Roman'"><FONT
size=2>}<o:p></o:p></FONT></SPAN></P>
<P class=a0 style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US
style="FONT-FAMILY: 'Times New Roman'"><FONT
size=2>//-----------------------------------------------------------------------<o:p></o:p></FONT></SPAN></P>
<P class=a0 style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US
style="FONT-FAMILY: 'Times New Roman'"><o:p><FONT
size=2> </FONT></o:p></SPAN></P>
<P class=a0 style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US
style="FONT-FAMILY: 'Times New Roman'"><FONT size=2>void __fastcall
TForm1::Button1Click(TObject *Sender)<o:p></o:p></FONT></SPAN></P>
<P class=a0 style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US
style="FONT-FAMILY: 'Times New Roman'"><FONT
size=2>{<o:p></o:p></FONT></SPAN></P>
<P class=a0 style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US
style="FONT-FAMILY: 'Times New Roman'"><FONT
size=2>Form1->Query1->Close();<o:p></o:p></FONT></SPAN></P>
<P class=a0 style="MARGIN: 0cm 0cm 0pt"><FONT size=2><SPAN lang=EN-US
style="FONT-FAMILY: 'Times New Roman'">//</SPAN><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">关闭数据库</SPAN><SPAN
lang=EN-US style="FONT-FAMILY: 'Times New Roman'"><o:p></o:p></SPAN></FONT></P>
<P class=a0 style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US
style="FONT-FAMILY: 'Times New Roman'"><FONT
size=2>Form1->Query1->SQL->Clear();<o:p></o:p></FONT></SPAN></P>
<P class=a0 style="MARGIN: 0cm 0cm 0pt"><FONT size=2><SPAN lang=EN-US
style="FONT-FAMILY: 'Times New Roman'">//</SPAN><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">清除</SPAN><SPAN
lang=EN-US style="FONT-FAMILY: 'Times New Roman'">SQL</SPAN><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">语句</SPAN><SPAN
lang=EN-US style="FONT-FAMILY: 'Times New Roman'"><o:p></o:p></SPAN></FONT></P>
<P class=a0 style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US
style="FONT-FAMILY: 'Times New Roman'"><FONT
size=2>Form1->Query1->SQL->Add(Form1->Memo1->Text);<o:p></o:p></FONT></SPAN></P>
<P class=a0 style="MARGIN: 0cm 0cm 0pt"><FONT size=2><SPAN lang=EN-US
style="FONT-FAMILY: 'Times New Roman'">//</SPAN><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">读入新的</SPAN><SPAN
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -