📄 sch_rbform.pas
字号:
unit SCH_RBFORM;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, StdCtrls,DD, dxCore, dxButtons, ComCtrls,
IdBaseComponent, IdComponent, IdTCPConnection, IdTCPClient, IdDayTime,
IdTime,DBTables;
type
TSCH_RB = class(TForm)
Shape1: TShape;
Shape2: TShape;
Shape3: TShape;
Shape4: TShape;
Shape5: TShape;
Shape7: TShape;
StaticText1: TStaticText;
Shape19: TShape;
Shape11: TShape;
Shape12: TShape;
Shape13: TShape;
Shape14: TShape;
Shape15: TShape;
Shape16: TShape;
Shape25: TShape;
Shape26: TShape;
Shape27: TShape;
Shape8: TShape;
A1: TEdit;
Label7: TLabel;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
Label5: TLabel;
Label6: TLabel;
Label8: TLabel;
Label9: TLabel;
Label10: TLabel;
Label11: TLabel;
Label12: TLabel;
Label13: TLabel;
Label14: TLabel;
Label15: TLabel;
Label16: TLabel;
Label17: TLabel;
Label18: TLabel;
Label19: TLabel;
Label20: TLabel;
Label21: TLabel;
Label22: TLabel;
Label23: TLabel;
Label24: TLabel;
A3: TEdit;
A4: TEdit;
A5: TEdit;
A6: TEdit;
A7: TEdit;
A8: TEdit;
A2: TEdit;
B1: TEdit;
C1: TEdit;
D1: TEdit;
B2: TEdit;
B3: TEdit;
B4: TEdit;
B5: TEdit;
B6: TEdit;
B7: TEdit;
B8: TEdit;
C2: TEdit;
C3: TEdit;
C4: TEdit;
C5: TEdit;
C6: TEdit;
C7: TEdit;
C8: TEdit;
D2: TEdit;
D3: TEdit;
D4: TEdit;
D5: TEdit;
D6: TEdit;
D7: TEdit;
D8: TEdit;
A9: TEdit;
B9: TEdit;
C9: TEdit;
D9: TEdit;
BtnOk: TdxButton;
dxButton2: TdxButton;
Label26: TLabel;
tq: TEdit;
Label27: TLabel;
Label28: TLabel;
ComboBox1: TComboBox;
DT: TEdit;
Timer1: TTimer;
procedure dxButton2Click(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure CheckABC(Sender: Tobject);
procedure BtnOkClick(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure Timer1Timer(Sender: TObject);
procedure FormKeyPress(Sender: TObject; var Key: Char);
procedure YanInput(Sender: TObject; var Key: Char);
procedure YanInputZero(Sender: TObject; var Key: Char);
procedure A1KeyPress(Sender: TObject; var Key: Char);
procedure A7KeyPress(Sender: TObject; var Key: Char);
procedure DisplaySCH(QuerySc: TQUERY);
private
{ Private declarations }
public
{ Public declarations }
end;
var
SCH_RB: TSCH_RB;
AB: Array[0..3,0..5] of integer; //A1-A6,
CD: Array[0..3,0..1] of real;//吨水耗电
const
cWeekCn: array[1..7] of string =
('星期天', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六');
implementation
uses main;
{$R *.dfm}
procedure TSCH_RB.dxButton2Click(Sender: TObject);
begin
close;
end;
procedure TSCH_RB.DisplaySCH(QuerySC:TQUERY);
var
ss:string;
begin
ss:='asdfa';
with QuerySC do begin
A1.Text:=FieldByName('A1').AsString;
A2.Text:=FieldByName('A2').AsString;
A3.Text:=FieldByName('A3').AsString;
A4.Text:=FieldByName('A4').AsString;
A5.Text:=FieldByName('A5').AsString;
A6.Text:=FieldByName('A6').AsString;
A7.Text:=FieldByName('A7').AsString;
A8.Text:=FieldByName('A8').AsString;
B1.Text:=FieldByName('B1').AsString;
B2.Text:=FieldByName('B2').AsString;
B3.Text:=FieldByName('B3').AsString;
B4.Text:=FieldByName('B4').AsString;
B5.Text:=FieldByName('B5').AsString;
B6.Text:=FieldByName('B6').AsString;
B7.Text:=FieldByName('B7').AsString;
B8.Text:=FieldByName('B8').AsString;
C1.Text:=FieldByName('C1').AsString;
C2.Text:=FieldByName('C2').AsString;
C3.Text:=FieldByName('C3').AsString;
C4.Text:=FieldByName('C4').AsString;
C5.Text:=FieldByName('C5').AsString;
C6.Text:=FieldByName('C6').AsString;
C7.Text:=FieldByName('C7').AsString;
C8.Text:=FieldByName('C8').AsString;
D1.Text:=FieldByName('D1').AsString;
D2.Text:=FieldByName('D2').AsString;
D3.Text:=FieldByName('D3').AsString;
D4.Text:=FieldByName('D4').AsString;
D5.Text:=FieldByName('D5').AsString;
D6.Text:=FieldByName('D6').AsString;
D7.Text:=FieldByName('D7').AsString;
D8.Text:=FieldByName('D8').AsString;
end;
end;
//检查录入数据的完整性
procedure TSCH_RB.YanInput(Sender: TObject; var Key: Char);
var
AStr:String;
begin
AStr := (sender As Tedit).Text;
case key of
'0'..'9':Key:=Key;
#8:Key:=Key;
else
Key:=#0;
end;
end;
procedure TSCH_RB.YanInputZero(Sender: TObject; var Key: Char);
var
AStr:String;
begin
AStr := (sender As Tedit).Text;
case key of
'0'..'9':Key:=Key;
'.':key:=Key;
#8:Key:=Key;
else
Key:=#0;
end;
end;
procedure TSCH_RB.CheckABC(Sender: Tobject);
var
ss,ss_value:string;
I,K,KK:integer;
s2_value:real;
begin
ss_value:='';
s2_value:=0;
KK:=0;
With Tform(Application.FindComponent('SCH_RB')) do begin
for I:=0 to 3 do begin //for1
//对界面上的A1-A6进行搜索到位赋值
for K:=0 to 5 do begin //for2
ss_value:= Tedit(FindComponent(chr(Ord('A')+I)+inttostr(K+1))).Text;//因为没有A0
//
if ss_value='' then
AB[I,K]:=0
else
AB[I,K]:=strtoint(ss_value);
end; //end for2
//对吨水耗电和吨水成本进行处理.
for K:=6 to 7 do begin
ss_value:= Tedit(FindComponent(Chr(Ord('A')+I)+inttostr(K+1))).Text;//给A7,A8值
if ss_value='' then
CD[I,K-6]:=0
else
CD[I,K-6]:=strtofloat(ss_value);
end;//enf for 5 to 6
end;//end for1
end;
end;
//
procedure TSCH_RB.FormClose(Sender: TObject; var Action: TCloseAction);
begin
SCH_Global.BBaseSetup.Items[0].Enabled:=true;
end;
procedure TSCH_RB.BtnOkClick(Sender: TObject);
begin
With DataModuleSCH.QueryW do begin
//必须先调用检查相关的ABC数组
CheckABC(Sender);
if AB[3,2]>0 then begin
//
if active then close;
SQL.Clear;
SQL.Text:='Insert into SCH_RB(RBDATE,TIANQI,A1,A2,A3,A4,A5,A6,A7,A8,B1,B2,B3,B4,B5,B6,B7,B8,C1,C2,C3,C4,C5,C6,C7,C8,D1,D2,D3,D4,D5,D6,D7,D8)';
SQL.Add(' values (:DT,:TIANQI,:A1,:A2,:A3,:A4,:A5,:A6,:A7,:A8,:B1,:B2,:B3,:B4,:B5,:B6,:B7,:B8,:C1,:C2,:C3,:C4,:C5,:C6,:C7,:C8,:D1,:D2,:D3,:D4,:D5,:D6,:D7,:D8)');
//
ParamByName('DT').AsDateTime:=now();
ParamByName('TIANQI').AsString:=tq.Text;
ParamByName('A1').AsInteger:=AB[0,0];
ParamByName('A2').AsInteger:=AB[0,1];
ParamByName('A3').AsInteger:=AB[0,2];
ParamByName('A4').AsInteger:=AB[0,3];
ParamByName('A5').AsInteger:=AB[0,4];
ParamByName('A6').AsInteger:=AB[0,5];
ParamByName('A7').asfloat:=CD[0,0];
ParamByName('A8').AsFloat:=CD[0,1];
ParamByName('B1').AsInteger:=AB[1,0];
ParamByName('B2').AsInteger:=AB[1,1];
ParamByName('B3').AsInteger:=AB[1,2];
ParamByName('B4').AsInteger:=AB[1,3];
ParamByName('B5').AsInteger:=AB[1,4];
ParamByName('B6').AsInteger:=AB[1,5];
ParamByName('B7').asfloat:=CD[1,0];
ParamByName('B8').AsFloat:=CD[1,1];
ParamByName('C1').AsInteger:=AB[2,0];
ParamByName('C2').AsInteger:=AB[2,1];
ParamByName('C3').AsInteger:=AB[2,2];
ParamByName('C4').AsInteger:=AB[2,3];
ParamByName('C5').AsInteger:=AB[2,4];
ParamByName('C6').AsInteger:=AB[2,5];
ParamByName('C7').asfloat:=CD[2,0];
ParamByName('C8').AsFloat:=CD[2,1];
ParamByName('D1').AsInteger:=AB[3,0];
ParamByName('D2').AsInteger:=AB[3,1];
ParamByName('D3').AsInteger:=AB[3,2];
ParamByName('D4').AsInteger:=AB[3,3];
ParamByName('D5').AsInteger:=AB[3,4];
ParamByName('D6').AsInteger:=AB[3,5];
ParamByName('D7').asfloat:=CD[3,0];
ParamByName('D8').AsFloat:=CD[3,1];
execsql;
end //总水量大于0
else
showmessage('总水量为0');
end;
end;
procedure TSCH_RB.FormCreate(Sender: TObject);
var
I,K:integer;
xx:string;
begin
for I:=0 to 3 do
for K:=0 to 5 do
AB[I,K]:=0;
//
DT.Text:=Datetostr(date)+''+cWeekCn[DayOfWeek(Now)]+' '+timetostr(time);
with DataModuleSCH.Query1 do begin
if active then close;
SQL.clear;
SQL.Text:='select * from SCH_RB WHERE CONVERT(varchar(10),RBDATE,121)=:pdata';
ParamByName('pdata').AsString:=FormatDateTime('yyyy-mm-dd',date);
open;
if not IsEmpty then begin
// showmessage('有记录');
BtnOk.Enabled:=false;
displaySCH(DataModuleSCH.Query1);
end
else
BtnOk.Enabled:=true;
end;
end;
procedure TSCH_RB.Timer1Timer(Sender: TObject);
begin
DT.Text:=Datetostr(date)+''+cWeekCn[DayOfWeek(Now)]+' '+timetostr(time);
end;
procedure TSCH_RB.FormKeyPress(Sender: TObject; var Key: Char);
begin
if key=#13 then
begin
key:=#0;
perform(WM_NEXTDLGCTL,0,0);
end;
end;
procedure TSCH_RB.A1KeyPress(Sender: TObject; var Key: Char);
begin
YanInput(Sender,Key);
end;
procedure TSCH_RB.A7KeyPress(Sender: TObject; var Key: Char);
begin
YanInputZero(Sender,Key);
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -