unit uRenameAlbum;
// (C) by Marco Schulze <marco@nightlabs.com>
// [YMD] 2001-03-07
// published under GPL (GNU Public Licence)

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls, Buttons;

type
  TFormRenameAlbum = class(TForm)
    Label1: TLabel;
    Label2: TLabel;
    Edit1: TEdit;
    Edit2: TEdit;
    BtnOK: TBitBtn;
    BtnCancel: TBitBtn;
    procedure Execute(AlbumID:Integer);
    procedure FormShow(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  FormRenameAlbum: TFormRenameAlbum;

implementation

uses MServClients;

{$R *.DFM}

procedure TFormRenameAlbum.Execute(AlbumID:Integer);
var
  AlbumIdx      : Integer;
begin
  try
    AlbumIdx:=MServClient.MServCData.GetAlbumIdx(AlbumID);
    if AlbumIdx<0 then raise Exception.Create('no album cached with AlbumID='+IntToStr(AlbumID));

    Edit1.Text:=MServClient.MServCData.Albums[AlbumIdx].AlbumAuthor;
    Edit2.Text:=MServClient.MServCData.Albums[AlbumIdx].AlbumName;

    if ShowModal=mrOK then begin
      MServClient.RenameAlbum(AlbumID, Edit1.Text, Edit2.Text);

    end;
  except
    on E:Exception do raise Exception.Create('TFormRenameAlbum.Execute: '+E.Message);
  end;
end;

procedure TFormRenameAlbum.FormShow(Sender: TObject);
begin
  Edit1.SetFocus;
  Edit1.SelectAll;
end;

end.
