📄 standardgravity.pas
字号:
unit StandardGravity;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
Grids, ExtCtrls,wsTypes,wsCores,SendCommand;
type
TfrmStandardGravity = class(TForm)
Panel1: TPanel;
Panel2: TPanel;
StringGrid: TStringGrid;
procedure FormCreate(Sender: TObject);
procedure FormKeyPress(Sender: TObject; var Key: Char);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
private
{ Private declarations }
public
{ Public declarations }
end;
var
frmStandardGravity: TfrmStandardGravity;
implementation
uses MainDB;
{$R *.DFM}
procedure TfrmStandardGravity.FormCreate(Sender: TObject);
var
i,j,iRow:Integer;
begin
Height:=360;
Width:=600;
With StringGrid do
begin
RowCount:=13;
ColCount:=11;
Cells[0,0]:='分机号';
for i:=1 to RowCount-1 do begin
Cells[0,i]:=IntToStr(i-1);
end;
for i:=1 to ColCount-1 do begin
Cells[i,0]:=IntToStr(i-1);
end;
for i:=1 to ColCount-1 do
for j:=1 to RowCount-1 do
begin
iRow:=(j-1)*(ColCount-1)+i-1;
if (iRow<=(MaxExtensionCount-1)) then
Cells[i,j]:=FloatToStr(StandardG[iRow].Value)
else
Cells[i,j]:='0';
end;
end;
end;
procedure TfrmStandardGravity.FormKeyPress(Sender: TObject; var Key: Char);
begin
if not (Key in ['0','1','2','3','4','5','6','7','8','9','.']) then
begin
Key:=#0;
end;
end;
procedure TfrmStandardGravity.FormClose(Sender: TObject;
var Action: TCloseAction);
var
i,j,iRow:Integer;
begin
with dmMainDB do
begin
tbStandardG.CachedUpdates:=True;
tbStandardG.Filter:='HourseID='+''''+frmSendCommand.ProjectInfo.HourseID +'''';
tbStandardG.Filtered:=True;
tbStandardG.Open;
// While not tbStandardG.eof do
// begin
// if tbStandardG['HourseID']=frmSendCommand.ProjectInfo.HourseID then
// tbStandardG.delete;
// end;
// tbStandardG.ApplyUpdates;
// tbStandardG.CommitUpdates;
// end;
if tbStandardG.Eof then
begin
With StringGrid do
begin
for i:=1 to ColCount-1 do
for j:=1 to RowCount-1 do
begin
iRow:=(j-1)*(ColCount-1)+i-1;
if (iRow>=MaxExtensionCount) then
Break;
if Trim(Cells[i,j])='' then
begin
StandardG[iRow].Value:=0;
end
else
begin
StandardG[iRow].Value:=StrToFloat(Cells[i,j]);
end;
StandardG[iRow].ExtensionID:=StringOfChar('0',3-Length(Trim(IntToStr(iRow))))+Trim(IntToStr(iRow));
with dmMainDB do
begin
tbStandardG.Append;
tbStandardG['HourseID']:=frmSendCommand.ProjectInfo.HourseID;
tbStandardG['ExtensionID']:=StandardG[iRow].ExtensionID;
tbStandardG['Value']:=StandardG[iRow].Value;
tbStandardG.Post;
end;
end;
end;
end
else
begin
With StringGrid do
begin
for i:=1 to ColCount-1 do
for j:=1 to RowCount-1 do
begin
iRow:=(j-1)*(ColCount-1)+i-1;
StandardG[iRow].Value:=StrToFloat(Cells[i,j]);
StandardG[iRow].ExtensionID:=StringOfChar('0',3-Length(Trim(IntToStr(iRow))))+Trim(IntToStr(iRow));
end;
end;
with dmMainDB do
begin
While not tbStandardG.Eof do
begin
tbStandardG.Edit;
// tbStandardG['HourseID']:=frmSendCommand.ProjectInfo.HourseID;
// tbStandardG['ExtensionID']:=StandardG[iRow].ExtensionID;
tbStandardG['Value']:=StandardG[StrToInt(tbStandardG['ExtensionID'])].Value;
tbStandardG.Next;
end;
end;
end;
end;
with dmMainDB do
begin
tbStandardG.ApplyUpdates;
tbStandardG.CommitUpdates;
tbStandardG.Close;
end;
Action:=caFree;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -