📄 frm_main.~pas
字号:
i: integer;
begin
LV.Selected.caption := tvararray[0];
for i := 1 to varcount do
begin
lv.Selected.SubItems.Strings[i - 1] := TvarArray[i];
end;
end;
procedure TFrmMain.AddColumn(var LV: TlistView; Name: string; Width: integer);
var
Col: TListColumn;
begin
Col := LV.Columns.add;
Col.Caption := Name;
Col.Width := Width;
end;
procedure TFrmMain.SortLvData(var LV: TlistView; SortInt: Integer);
var
Context: array of array of string;
Context2: array of array of string;
MyRow, MyCol: Integer;
i, j, p: integer;
Turn: Boolean;
begin
Turn := true;
//行数
myrow := lv.Items.Count;
//列数
MyCol := lv.Columns.Count;
setlength(context, myrow);
setlength(context2, myrow);
for i := 0 to lv.Items.Count - 1 do
begin
//设置数组的长度值
setlength(context[i], mycol);
setlength(context2[i], mycol);
//添加数据的数据。
context[i, 0] := lv.Items.Item[i].caption;
for j := 1 to lv.Columns.count - 1 do
begin
context[i, j] := lv.Items.Item[i].SubItems.Strings[j - 1];
end;
end;
//比较数据的大小,排列数据
for i := 0 to lv.Items.Count - 1 do
begin
for j := i + 1 to lv.items.count - 1 do
begin
//比较数据,然后排列
if context[j, SortInt] < context[i, SortInt] then
begin
for p := 0 to lv.Columns.count - 1 do
begin
turn := false;
context2[i, p] := context[i, p];
context[i, p] := context[j, p];
context[j, p] := context2[i, p];
end;
end;
end;
end;
//添加数据,如果从大到小排列,那么ture,否则从小大排列。
if turn then
begin
//从大到小排列
for i := 0 to myrow - 1 do
begin
lv.Items.Item[i].Caption := context[myrow - 1 - i, 0];
for j := 1 to mycol - 1 do
begin
lv.Items.Item[i].SubItems.Strings[j - 1] := context[myrow - 1 - i, j];
end;
end;
end
else
begin
for i := 0 to myrow - 1 do
begin
//从小到大开始排列
lv.Items.Item[i].Caption := context[i, 0];
for j := 1 to mycol - 1 do
begin
lv.Items.Item[i].SubItems.Strings[j - 1] := context[i, j];
end;
end;
end;
end;
procedure TFrmMain.UseListCondition(Combobox: TCombobox; Table, Fields, CFields,
OrderField, Condition: string);
var
Rect: TRect;
MyQuery: TAdoQuery;
MyFields, MyCFields: Tstringlist;
i, c: integer;
begin
//准备数据
MyCFields := Tstringlist.Create;
MyCFields.CommaText := CFields;
MyFields := Tstringlist.Create;
MyFields.CommaText := Fields;
MyQuery := TAdoQuery.Create(self);
MyQuery.Connection := UseDB;
if Condition = '' then
MyQuery.SQL.Text := 'select ' + Fields + ' from ' + Table;
if Condition <> '' then
MyQuery.SQL.Text := 'select ' + Fields + ' from ' + Table + ' where ' +
Condition;
MyQuery.Open;
c := RecordCount(MyQuery);
MyQuery.Close;
//列表定位
GetWindowRect(Combobox.Handle, Rect);
FrmList := TFrmList.Create(self);
FrmList.Width := Combobox.Width * MyFields.Count + 2;
if c = 0 then FrmList.Height := 38;
if c > 8 then
begin
FrmList.Height := 17 * 8 + 4;
FrmList.Width := FrmList.Width + 17;
end;
if (c >= 1) and (c <= 8) then FrmList.Height := 17 * (c + 1) + 4;
if Rect.Left + FrmList.Width > 800 then
FrmList.Left := Rect.Left - (FrmList.Width - (Rect.Right - Rect.Left))
else
FrmList.Left := Rect.Left;
if Rect.Bottom + FrmList.Height > 600 then
FrmList.Height := 600 - Rect.Bottom;
FrmList.Top := Rect.Bottom;
FrmList.Show;
//添加列表标题
for i := 0 to MyFields.Count - 1 do
begin
FrmList.Lv.Columns.Add;
FrmList.Lv.Column[i].Width := Combobox.Width;
if trim(CFields) <> '' then FrmList.Lv.Column[i].Caption := MyCFields[i];
if trim(CFields) = '' then
FrmList.Lv.Column[i].Caption := GetFieldCName(Table, MyFields[i]);
end;
//添加数据
FrmList.lv.Clear;
if Condition = '' then
MyQuery.SQL.Text := 'select Distinct ' + Fields + ' from ' + Table +
' Order by ' + OrderField;
if Condition <> '' then
MyQuery.SQL.Text := 'select Distinct ' + Fields + ' from ' + Table +
' where '
+ Condition + ' Order by ' + OrderField;
MyQuery.Open;
AddData(FrmList.lv, MyQuery);
FrmList.Lv.Update;
MyQuery.Close;
MyQuery.Destroy;
MyFields.Destroy;
MyCFields.Destroy;
//指定目标容器
FrmList.Combobox := Combobox;
end;
function TFrmMain.CheckExistCount(FieldName, FieldValue,
TableName: string): integer;
begin
with QryTemp do
begin
close;
sql.text := 'select ' + FieldName + ' from ' + tablename + ' where ' +
fieldname + '=''' + fieldvalue + '''';
open;
end;
Result := QryTemp.RecordCount;
end;
function TFrmMain.GetCustomerValue(CodeName,CodeValue,FieldName,
TableName: String): Variant;
var
zcrbh:string;
begin
try
Try
Result:='';
QryTemp.close;
with QryTemp do
begin
sql.text:='Select * From '+Tablename+' where '+CodeName+'='''+CodeValue+'''';
Open;
if QryTemp.RecordCount <1 then
result:=''
else
if QryTemp.fieldbyname(Fieldname).asstring='' then
Result:=''
else
Result:=QryTemp.FieldByName(FieldName).AsVariant;
end;
Except
Raise;
end;
Finally
if QryTemp.Active then QryTemp.close;
end;
end;
procedure TFrmMain.N2Click(Sender: TObject);
begin
if (FrmCompany = nil) or not (Assigned(FrmCompany)) then
FrmCompany := TFrmCompany.create(Self);
FrmCompany.Show;
end;
procedure TFrmMain.N4Click(Sender: TObject);
begin
if (FrmPlaneCompanyInfo = nil) or not (Assigned(FrmPlaneCompanyInfo)) then
FrmPlaneCompanyInfo := TFrmPlaneCompanyInfo.Create(Self);
FrmPlaneCompanyInfo.Show;
end;
procedure TFrmMain.N5Click(Sender: TObject);
begin
if (FrmPortInfo = nil) or not (Assigned(FrmPortInfo)) then
FrmPortInfo := TFrmPortInfo.Create(Self);
FrmPortInfo.Show;
end;
procedure TFrmMain.N6Click(Sender: TObject);
begin
if (FrmStationInfo = nil) or not (Assigned(FrmStationInfo)) then
FrmStationInfo := TFrmStationInfo.Create(Self);
FrmStationInfo.Show;
end;
procedure TFrmMain.N7Click(Sender: TObject);
begin
if (FrmFareNameInfo = nil) or not (Assigned(FrmFareNameInfo)) then
FrmFareNameInfo := TFrmFareNameInfo.Create(Self);
FrmFareNameInfo.Show;
end;
procedure TFrmMain.N9Click(Sender: TObject);
begin
if (FrmCurrencyInfo = nil) or not (Assigned(FrmCurrencyInfo)) then
FrmCurrencyInfo := TFrmCurrencyInfo.Create(Self);
FrmCurrencyInfo.Show;
end;
procedure TFrmMain.N22Click(Sender: TObject);
begin
if FrmMain.IncludeValue('客户档案浏览') then
else
begin
ShowMessage('对不起,你不具有该操作的权限!');
exit;
end;
if (FrmCustomerInfo = nil) or not (Assigned(FrmCustomerInfo)) then
FrmCustomerInfo := TFrmCustomerInfo.Create(Self);
FrmCustomerInfo.Show;
end;
procedure TFrmMain.N11Click(Sender: TObject);
begin
if (FrmBussinessMan = nil) or not (Assigned(FrmBussinessMan)) then
FrmBussinessMan := TFrmBussinessMan.Create(Self);
FrmBussinessMan.Show;
end;
procedure TFrmMain.N3Click(Sender: TObject);
begin
if (FrmBaseData = nil) or not (assigned(FrmBaseData)) then
begin
FrmBaseData := TFrmBaseData.Create(self);
end;
FrmBaseData.Show;
end;
procedure TFrmMain.N14Click(Sender: TObject);
begin
if (FrmFileNoGeneralRuleInfo = nil) or not (Assigned(FrmFileNoGeneralRuleInfo))
then
FrmFileNoGeneralRuleInfo := TFrmFileNoGeneralRuleInfo.Create(Self);
FrmFileNoGeneralRuleInfo.Show;
end;
procedure TFrmMain.N18Click(Sender: TObject);
begin
if (FrmUserInfo = nil) or not (Assigned(FrmUserInfo)) then
FrmUserInfo := TFrmUserInfo.Create(Self);
FrmUserInfo.Show;
end;
procedure TFrmMain.N15Click(Sender: TObject);
begin
if (FrmFileNoAssignUser = nil) or not (Assigned(FrmFileNoAssignUser)) then
FrmFileNoAssignUser := TFrmFileNoAssignUser.Create(Self);
FrmFileNoAssignUser.Show;
end;
procedure TFrmMain.N17Click(Sender: TObject);
begin
if (FrmRightInfo = nil) or not (Assigned(FrmRightInfo)) then
FrmRightInfo := TFrmRightInfo.Create(Self);
FrmRightInfo.Show;
end;
procedure TFrmMain.N25Click(Sender: TObject);
begin
if FrmMain.IncludeValue('交接单浏览') then
else
begin
exit;
end;
if (FrmBussinessBillInfo = nil) or not (Assigned(FrmBussinessBillInfo)) then
FrmBussinessBillInfo := TFrmBussinessBillInfo.create(Self);
FrmBussinessBillInfo.Show;
end;
procedure TFrmMain.N26Click(Sender: TObject);
begin
if FrmMain.IncludeValue('底价浏览') then
else
begin
ShowMessage('对不起,你不具有该操作的权限!');
exit;
end;
if (FrmPlaneQuoteInfo = nil) or not (Assigned(FrmPlaneQuoteInfo)) then
FrmPlaneQuoteInfo := TFrmPlaneQuoteInfo.create(Self);
FrmPlaneQuoteInfo.Show;
end;
procedure TFrmMain.N28Click(Sender: TObject);
begin
if FrmMain.IncludeValue('进口业务浏览') then
else
begin
ShowMessage('对不起,你不具有该操作的权限!');
exit;
end;
if (FrmAllImportBillInfo = nil) or not (Assigned(FrmAllImportBillInfo)) then
FrmAllImportBillInfo := TFrmAllImportBillInfo.create(Self);
FrmAllImportBillInfo.Show;
end;
procedure TFrmMain.N34Click(Sender: TObject);
begin
if FrmMain.IncludeValue('出口业务浏览') then
else
begin
ShowMessage('对不起,你不具有该操作的权限!');
exit;
end;
if (FrmAllExportBillInfo = nil) or not (Assigned(FrmAllExportBillInfo)) then
FrmAllExportBillInfo := TFrmAllExportBillInfo.create(Self);
FrmAllExportBillInfo.Show;
end;
function TFrmMain.SetSearchStr(Str1, Str2: String): String;
Var
Count:Integer;
i:integer;
Stemp:String;
VarArray:Array[0..20] of String;
begin
Stemp:='';
Count:=GetSplitText(Str2,',',VarArray);
For i:=0 to Count do
begin
Stemp:=Stemp+' And '+Str1+' like ''%'+VarArray[i]+'%'' ';
end;
Result:=Stemp;
end;
procedure TFrmMain.N30Click(Sender: TObject);
begin
If (frmgoodsstat=nil) or not (assigned(frmgoodsstat)) then
else
begin
frmgoodsstat.WindowState :=wsMaximized ;
exit;
end;
frmgoodsstat:=tfrmgoodsstat.create(self);
frmgoodsstat.show;
end;
procedure TFrmMain.N36Click(Sender: TObject);
begin
If (FrmMainFeeGrid=nil) or not (assigned(FrmMainFeeGrid)) then
else
begin
FrmMainFeeGrid.WindowState :=wsMaximized ;
exit;
end;
FrmMainFeeGrid:=TFrmMainFeeGrid.Create(self);
FrmMainFeeGrid.show;
end;
procedure TFrmMain.N38Click(Sender: TObject);
begin
If (FrmFareWh=nil) or not (assigned(FrmFareWh)) then
else
begin
FrmFareWh.WindowState :=wsMaximized ;
exit;
end;
FrmFareWh:=tFrmFareWh.create(self);
FrmFareWh.Show;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -