📄 u_mp3copy.pas
字号:
application.MessageBox(Pchar('从硬盘删除'+trim(DSQuery.DataSet.FieldByName('Name').AsString)+'音乐文件失败'),'提示',MB_OK);
//DSQuery.DataSet.Delete;
if DSQuery.DataSet.Locate('ID',cxGridDBTableView1.DataController.Values[i,0],[]) then
DSQuery.DataSet.Delete;
//Action8.OnExecute(Action8);
end;
end;
end
else
begin
for i:=cxGridDBTableView1.DataController.RowCount-1 downto 0 do
begin
if cxGridDBTableView1.DataController.IsRowSelected(i) then
if DSQuery.DataSet.Locate('ID',cxGridDBTableView1.DataController.Values[i,0],[]) then
DSQuery.DataSet.Delete;
//Action8.OnExecute(Action8);
end;
end;
end;
application.MessageBox('删除成功!','提示',MB_OK);
except
application.MessageBox('删除失败!','提示',MB_ICONERROR+MB_OK);
end;
end;
procedure TFrm_MP3Copy.Action8Execute(Sender: TObject);
begin
try
if DSQuery.DataSet.State in [dsInsert,dsEdit] then
begin
DSQuery.DataSet.Post;
end;
DSQuery.DataSet.Refresh;
// cxGridDBColumn1.Properties.ReadOnly := true;
// cxGridDBColumn2.Properties.ReadOnly := true;
// cxGridDBColumn3.Properties.ReadOnly := true;
// cxGridDBColumn4.Properties.ReadOnly := true;
// cxGridDBColumn5.Properties.ReadOnly := true;
except
end;
end;
procedure TFrm_MP3Copy.Action7Execute(Sender: TObject);
begin
// cxGridDBColumn1.Properties.ReadOnly := false;
// cxGridDBColumn2.Properties.ReadOnly := false;
// cxGridDBColumn3.Properties.ReadOnly := false;
// cxGridDBColumn4.Properties.ReadOnly := false;
// cxGridDBColumn5.Properties.ReadOnly := false;
if DSQuery.State in [dsInsert,dsEdit] then
begin
if application.MessageBox('资料已经修改是否保存','提示',MB_ICONQUESTION+MB_YESNO)=IDYES then
begin
DSQuery.DataSet.Post;
end;
end;
//DSQuery.DataSet.Edit;
Query.Edit;
end;
procedure TFrm_MP3Copy.Action14Execute(Sender: TObject);
begin
cxGridDBTableView1.OptionsCustomize.ColumnFiltering := not cxGridDBTableView1.OptionsCustomize.ColumnFiltering
end;
procedure TFrm_MP3Copy.FormShow(Sender: TObject);
function IfExists(aFileName:string;aFile:TIniFile;aFileCount:integer ):boolean;
var x: integer;
begin
for x:=0 to aFileCount do
begin
if aFile.ReadString('文件列表','No.[' + IntToStr(x) + ']','')=aFileName then
begin
Result := true;
exit;
end;
end;
end;
var FileCount,FileIndex,i: integer ;
begin
try
Query.Open;
if frmPlayList=nil then
frmPlayList := TfrmPlayList.Create(nil);
frmPlayList.Parent := Panel7;
frmPlayList.Show;
//ShowProgressDlg('正在家载文件,请稍后......');
//for i:=0 to cxGridDBTableView1.DataController.RowCount-1 do
//begin
// ChgProgressMsg('正加载'+cxGridDBTableView1.DataController.Values[i,6]);
//if IfExists(cxGridDBTableView1.DataController.Values[i,6],frmPlayList.FileListName,cxGridDBTableView1.DataController.RowCount-1) then
//continue;
//frmPlayList.FileListName.WriteString('文件列表', 'No.[' + cxGridDBTableView1.DataController.Values[i,0] + ']', cxGridDBTableView1.DataController.Values[i,6]);
//end;
//frmPlayList.FileIndex := 0;//frmPlayList.FileCount;
//frmPlayList.FileCount := cxGridDBTableView1.DataController.RowCount-1 ;
//frmPlayList.FileListName.WriteInteger('播放文件', '文件号', FileIndex);
//frmPlayList.FileListName.WriteInteger('播放文件', '文件数', FileCount);
//CloseProgressDlg;
except
//CloseProgressDlg;
end;
end;
procedure TFrm_MP3Copy.Action12Update(Sender: TObject);
begin
RzToolButton8.Enabled := not DsQuery.DataSet.Eof;
end;
procedure TFrm_MP3Copy.Action11Update(Sender: TObject);
begin
RzToolButton7.Enabled := not DsQuery.DataSet.Eof;
end;
procedure TFrm_MP3Copy.Action10Update(Sender: TObject);
begin
RzToolButton6.Enabled := not DsQuery.DataSet.Bof;
end;
procedure TFrm_MP3Copy.Action9Update(Sender: TObject);
begin
RzToolButton5.Enabled := not DsQuery.DataSet.Bof;
end;
procedure TFrm_MP3Copy.PDJButton1Click(Sender: TObject);
var aSQL,aSQL1,aReplacS:string;
begin
{按歌曲名
按演唱者
按专辑名
按大小
按类型
}
aReplacS := ''''+','+'''';
if trim(Edit1.Text)='' then
begin
with Query do
begin
if Active then close;
SQL.Clear;
SQL.Text := 'select * from MP3Table ';
Open;
end;
end;
//case combobox1.ItemIndex of
// 0:begin
// if DSQuery.DataSet.Locate('AName',trim(Edit1.Text),[]) then
// DSQuery.DataSet.MoveBy(DsQuery.DataSet.RecNo);
// end;
//end;
aSQL := 'select * from MP3Table ';
if trim(Edit1.Text)<>'' then
begin
if RadioButton1.Checked then
begin
case ComboBox1.ItemIndex of
0:begin
aSQL1 := ' where ID in ('''+StringReplace(trim(Edit1.Text),',',aReplacS,[rfReplaceAll, rfIgnoreCase])+''''+')';
end;
1:begin
aSQL1 := ' where AName='''+trim(Edit1.Text)+'''';
end;
2:begin
aSQL1 := ' where Autor='''+trim(Edit1.Text)+'''';
end;
3:begin
aSQL1 := ' where DiskName='''+trim(Edit1.Text)+'''';
end;
4:begin
aSQL1 := ' where Size='''+trim(Edit1.Text)+'''';
end;
5:begin
aSQL1 := ' where Type='''+trim(Edit1.Text)+'''';
end;
end;
end
else
begin
case ComboBox1.ItemIndex of
0:begin
aSQL1 := ' where ID like '''+'%'+trim(Edit1.Text)+'%'+'''';
end;
1:begin
aSQL1 := ' where AName like '''+'%'+trim(Edit1.Text)+'%'+'''';
end;
2:begin
aSQL1 := ' where Autor like '''+'%'+trim(Edit1.Text)+'%'+'''';
end;
3:begin
aSQL1 := ' where DiskName like '''+'%'+trim(Edit1.Text)+'%'+'''';
end;
4:begin
aSQL1 := ' where Size>='+trim(Edit1.Text);
end;
5:begin
aSQL1 := ' where Type like '''+'%'+trim(Edit1.Text)+'%'+'''';
end;
end;
end;
end;
aSQL := aSQL+aSQL1;
try
with Query do
begin
if Active then close;
SQL.Clear;
SQL.Text := aSQL;
{if trim(Edit1.Text)<>'' then
begin
case Combobox1.ItemIndex of
0:Parameters.ParamByName('AName').Value := '%'+trim(Edit1.Text)+'%';
1:Parameters.ParamByName('Autor').Value := '%'+trim(Edit1.Text)+'%';
2:Parameters.ParamByName('DiskName').Value := '%'+trim(Edit1.Text)+'%';
3:Parameters.ParamByName('Size').Value := trim(Edit1.Text);
4:Parameters.ParamByName('Type').Value := '%'+trim(Edit1.Text)+'%';
end;
end; }
Open;
end;
except
end;
end;
procedure TFrm_MP3Copy.Edit1KeyPress(Sender: TObject; var Key: Char);
begin
if key=#13 then
begin
PDJButton1Click(PDJButton1);
end;
end;
procedure TFrm_MP3Copy.DSQueryStateChange(Sender: TObject);
begin
//DSQuery.DataSet.FieldByName('AName').ReadOnly := not (DSQuery.DataSet.State in [dsInsert,dsEdit]);
//DSQuery.DataSet.FieldByName('Autor').ReadOnly := not (DSQuery.DataSet.State in [dsInsert,dsEdit]);
//DSQuery.DataSet.FieldByName('DiskName').ReadOnly := not (DSQuery.DataSet.State in [dsInsert,dsEdit]);
Action5.Enabled := not (DSQuery.DataSet.State in [dsInsert,dsEdit]);
Action6.Enabled := not (DSQuery.DataSet.State in [dsInsert,dsEdit]);
Action7.Enabled := not (DSQuery.DataSet.State in [dsInsert,dsEdit]);
Action8.Enabled := DSQuery.DataSet.State in [dsInsert,dsEdit];
//DSQuery.DataSet.FieldByName('Size').ReadOnly := not (DSQuery.DataSet.State in [dsInsert,dsEdit]);
//DSQuery.DataSet.FieldByName('AName').ReadOnly := not (DSQuery.DataSet.State in [dsInsert,dsEdit]);
end;
procedure TFrm_MP3Copy.PDJButton6Click(Sender: TObject);
begin
bdSearchFile(RzShellList1.Folder.PathName);
CloseProgressDlg;
end;
procedure TFrm_MP3Copy.PDJButton5Click(Sender: TObject);
begin
bdSearchFile(RzShellList1.Folder.PathName);
CloseProgressDlg;
end;
procedure TFrm_MP3Copy.QueryBeforePost(DataSet: TDataSet);
begin
if (DataSet.FieldByName('AName').Value=NULL) or(DataSet.FieldByName('AName').AsString='') then
begin
Application.MessageBox('歌曲名称不能为空','提示',MB_OK);
abort;
end;
if (DataSet.FieldByName('Path').Value=NULL) or(DataSet.FieldByName('Path').AsString='') then
begin
Application.MessageBox('歌曲路径不能为空','提示',MB_OK);
abort;
end;
end;
procedure TFrm_MP3Copy.QueryNewRecord(DataSet: TDataSet);
begin
DataSet.FieldByName('ID').AsString := DM.GetMaxID;
end;
procedure TFrm_MP3Copy.QueryAfterScroll(DataSet: TDataSet);
begin
dxNavBar1Item1.Caption := '名称 '+DataSet.FieldByName('AName').AsString;
dxNavBar1Item2.Caption := '演唱 '+DataSet.FieldByName('Autor').AsString;
dxNavBar1Item3.Caption := '大小 '+DataSet.FieldByName('Size').AsString+'M';
dxNavBar1Item4.Caption := '专辑名 '+DataSet.FieldByName('DiskName').AsString;
dxNavBar1Item5.Caption := '索引 '+DataSet.FieldByName('ID').AsString;
end;
procedure TFrm_MP3Copy.PDJButton4Click(Sender: TObject);
var FileName1,FileName: string;
I: integer;
FileCount: integer;
begin
FileName1 := RzShellList1.Folder.PathName;
FileCount := 0;
ShowProgressDlg('正处理文件'+Query.FieldByName('AName').AsString);
for i:=0 to cxGridDBTableView1.DataController.RowCount-1 do
begin
FileName1 := RzShellList1.Folder.PathName;
if cxGridDBTableView1.DataController.IsRowSelected(i) then
begin
ChgProgressMsg('正处理文件'+VarToStr(cxGridDBTableView1.DataController.Values[i,1]));
FileName := FileName1+'\'+VarToStr(cxGridDBTableView1.DataController.Values[i,1])+'.'+VarToStr(cxGridDBTableView1.DataController.Values[i,4]);
if FileExists(FileName) then
begin
if application.MessageBox('文件已经存在是否覆盖?','提示',MB_ICONQUESTION+MB_YESNO)=IDYES then
begin
CopyFile(Pchar(vartoStr(cxGridDBTableView1.DataController.Values[i,6])),Pchar(FileName),False);
inc(FileCount);
end
else continue;
end
else
begin
CopyFile(Pchar(vartoStr(cxGridDBTableView1.DataController.Values[i,6])),Pchar(FileName),False) ;
inc(FileCount);
end;
end;
end;
CloseProgressDlg;
if FileCount<=1 then exit;
application.MessageBox(Pchar('成功Copy【 '+InttoStr(FileCount)+' 】个文件'),'提示',MB_OK)
end;
procedure TFrm_MP3Copy.PDJButton3Click(Sender: TObject);
var FileName1,FileName: string;
I: integer;
FileCount: integer;
begin
FileName1 := RzShellList1.Folder.PathName;
FileCount := 0;
ShowProgressDlg('正处理文件'+Query.FieldByName('AName').AsString);
for i:=0 to cxGridDBTableView1.DataController.RowCount-1 do
begin
FileName1 := RzShellList1.Folder.PathName;
//if cxGridDBTableView1.DataController.IsRowSelected(i) then
//begin
ChgProgressMsg('正处理文件'+VarToStr(cxGridDBTableView1.DataController.Values[i,1]));
FileName := FileName1+'\'+VarToStr(cxGridDBTableView1.DataController.Values[i,1])+'.'+VarToStr(cxGridDBTableView1.DataController.Values[i,4]);
if FileExists(FileName) then
begin
if application.MessageBox('文件已经存在是否覆盖?','提示',MB_ICONQUESTION+MB_YESNO)=IDYES then
begin
CopyFile(Pchar(vartoStr(cxGridDBTableView1.DataController.Values[i,6])),Pchar(FileName),False);
inc(FileCount);
end
else continue;
end
else
begin
CopyFile(Pchar(vartoStr(cxGridDBTableView1.DataController.Values[i,6])),Pchar(FileName),False) ;
inc(FileCount);
end;
//end;
end;
CloseProgressDlg;
application.MessageBox(Pchar('成功Copy【 '+InttoStr(FileCount)+' 】个文件'),'提示',MB_OK)
end;
procedure TFrm_MP3Copy.cxGridDBTableView1DblClick(Sender: TObject);
function GetFileIndxe(aFileName:string;aFile:TIniFile;aFileCount:integer ):integer;
var x: integer;
begin
for x:=0 to aFileCount do
begin
if aFile.ReadString('文件列表','No.[' + IntToStr(x) + ']','')=aFileName then
begin
Result := x;
exit;
end;
end;
end;
var Index,rowindex: integer;
aFileName: string ;
begin
rowindex := cxGridDBTableView1.DataController.RecNo-1;;
aFileName := cxGridDBTableView1.DataController.GetValue(rowindex,6);
//Index := GetFileIndxe(aFileName,frmPlayList.FileListName,frmPlayList.FileCount);
//if Index < 0 then Exit;
//if Index = frmPlayList.FileIndex then Exit;
//frmEPlayer.MediaPlayer.Close;
//frmPlayList.FileIndex := Index;
//frmPlayList.FileListName.WriteInteger('播放文件', '文件号', frmPlayList.FileIndex);
frmPlayList.PlayMedia(aFileName);
end;
procedure TFrm_MP3Copy.BtnRefreshClick(Sender: TObject);
function IfExists(aFileName:string;aFile:TIniFile;aFileCount:integer ):boolean;
var x: integer;
begin
for x:=0 to aFileCount do
begin
if aFile.ReadString('文件列表','No.[' + IntToStr(x) + ']','')=aFileName then
begin
Result := true;
exit;
end;
end;
end;
var FileCount,FileIndex,i: integer ;
begin
try
if Query.Active then Query.Close;
Query.Open;
if frmPlayList=nil then
frmPlayList := TfrmPlayList.Create(nil);
frmPlayList.Parent := Panel7;
frmPlayList.Show;
for i:=0 to cxGridDBTableView1.DataController.RowCount-1 do
begin
//if IfExists(cxGridDBTableView1.DataController.Values[i,6],frmPlayList.FileListName,cxGridDBTableView1.DataController.RowCount-1) then
//continue;
frmPlayList.FileListName.WriteString('文件列表', 'No.[' + cxGridDBTableView1.DataController.Values[i,0] + ']', cxGridDBTableView1.DataController.Values[i,6]);
end;
frmPlayList.FileIndex := 0;//frmPlayList.FileCount;
frmPlayList.FileCount := cxGridDBTableView1.DataController.RowCount-1 ;
frmPlayList.FileListName.WriteInteger('播放文件', '文件号', FileIndex);
frmPlayList.FileListName.WriteInteger('播放文件', '文件数', FileCount);
except
end;
end;
procedure TFrm_MP3Copy.FormCreate(Sender: TObject);
begin
combobox1.ImeMode := imChinese;
combobox1.ImeName := '';
edit1.ImeMode := imChinese;
edit1.ImeName := '';
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -