procedure TFormContent.ButtonAdd_OKClick(Sender: TObject);
var
Login: TELNETANDFTPLOGIN;
Echo: PChar;
MiniSecond, MPEGFORMAT: String ;
B1, B2: Boolean;
bitrate, milliseconds: Integer;
StringList1: TStringList;
begin
Screen.Cursor := StartCursor;
B1 := False;
B2 := False;
if EditAdd_CONTENT_NAME.Text = '' then
begin
Application.MessageBox('节目名称不能为空。', MessageTitle, WARNING_ICON + MB_OK);
EditAdd_CONTENT_NAME.SetFocus;
end
else
if EditAdd_SALE_PRICE.Text = '' then
begin
Application.MessageBox('标准价格不能为空。', MessageTitle, WARNING_ICON + MB_OK);
EditAdd_SALE_PRICE.SetFocus;
end
else
if IsFloat(EditAdd_SALE_PRICE.Text) = False then
begin
Application.MessageBox('标准价格不是数值。', MessageTitle, WARNING_ICON + MB_OK);
EditAdd_SALE_PRICE.SetFocus;
end
else
if StrToFloat(EditAdd_SALE_PRICE.Text) < 0 then
begin
Application.MessageBox('标准价格必须大于等于零。', MessageTitle, WARNING_ICON + MB_OK);
EditAdd_SALE_PRICE.SetFocus;
end
else
if EditAdd_PERTIMES_PRICE.Text = '' then
begin
Application.MessageBox('每次价格不能为空。', MessageTitle, WARNING_ICON + MB_OK);
EditAdd_PERTIMES_PRICE.SetFocus;
end
else
if IsFloat(EditAdd_PERTIMES_PRICE.Text) = False then
begin
Application.MessageBox('每次价格不是数值。', MessageTitle, WARNING_ICON + MB_OK);
EditAdd_PERTIMES_PRICE.SetFocus;
end
else
if StrToFloat(EditAdd_PERTIMES_PRICE.Text) < 0 then
begin
Application.MessageBox('每次价格必须大于等于零。', MessageTitle, WARNING_ICON + MB_OK);
EditAdd_PERTIMES_PRICE.SetFocus;
end
else
if EditAdd_CONTENT_SUBCATEGORY_NAME.Text = '' then
begin
Application.MessageBox('节目子类不能为空。', MessageTitle, WARNING_ICON + MB_OK);
EditAdd_CONTENT_SUBCATEGORY_ID.SetFocus;
end
else
if EditAdd_RATING_NAME.Text = '' then
begin
Application.MessageBox('节目等级不能为空。', MessageTitle, WARNING_ICON + MB_OK);
EditAdd_RATING_ID.SetFocus;
end
else
if EditAdd_PROVIDER_NAME.Text = '' then
begin
Application.MessageBox('节目供应商不能为空。', MessageTitle, WARNING_ICON + MB_OK);
EditAdd_PROVIDER_ID.SetFocus;
end
else
if EditAdd_Location.Text = '' then
begin
Application.MessageBox('节目位置不能为空。', MessageTitle, WARNING_ICON + MB_OK);
EditAdd_Location.SetFocus;
end
else
begin
try
with DataModule1.Clientdataset1 do
begin
Close ;
CommandText := Format('Select MEDIA_FILENAME From CONTENT_CODE Where MEDIA_FILENAME = ''%s'' ',[FormContentLocation.ListView1.Selected.Caption]) ;
Open ;
if RecordCount > 0 then
B1 := True;
end;
if B1 = True then
Application.MessageBox('影片文件和其它节目的影片文件重名。', MessageTitle, WARNING_ICON + MB_OK)
else
begin
with DataModule1.ClientDataSet1 do
begin
Close ;
CommandText := Format('Select TELNETUSER_NAME, TELNET_PASSWORD, FTPUSER_NAME, FTP_PASSWORD from Device_Code where Device_ID = ''%s'' ', [SelectNcube]) ;
Open ;
Login.TelUsername := PChar(FieldByName('TELNETUSER_NAME').AsString) ;
Login.TelPassword := PChar(FieldByName('TELNET_PASSWORD').AsString) ;
Login.FTPUsername := PChar(FieldByName('FTPUSER_NAME').AsString) ;
Login.FTPPassword := PChar(FieldByName('FTP_PASSWORD').AsString) ;
Close;
CommandText := Format('Select IP_ADDRESS, PORT_NO from Device_Port where PORT_TYPE = ''%s'' and DEVICE_ID = ''%s'' ', ['TELNET',SelectNcube]);
Open;
if RecordCount > 0 then
begin
Login.IP := PChar(FieldByName('IP_ADDRESS').AsString) ;
Login.TelPort := FieldByName('PORT_NO').AsInteger;
GetMem(Echo, 2048);
StringList1 := TStringList.Create();
try
DllVstagPrint(@Login, PChar(SelectLPARTITION), PChar(Copy(FormContentLocation.ListView1.Selected.Caption, 1, Length(FormContentLocation.ListView1.Selected.Caption) - 4) + '.mpi'), Echo);
StringList1.SetText(Echo);
MPEGFORMAT := Trim(StringList1.Strings[0]);
bitrate := StrToInt(Trim(StringList1.Strings[1]));
milliseconds := StrToInt(Trim(StringList1.Strings[2]));
Except
B2 := True;
end;
StringList1.Free;
FreeMem(Echo, 2048);
if B2 = False then
begin
try
begin
with DataModule1.ADD_CONTENT_CODE85ClientDataSet do
begin
Close;
FetchParams;
Params.ParamByName('ARG_CONTENT_NAME').AsString := EditAdd_CONTENT_NAME.Text;
Params.ParamByName('ARG_CONTENT_TITLE').AsString := '';
Params.ParamByName('ARG_SPELLING_CODE').AsString := EditAdd_SPELLING_CODE.Text;
Params.ParamByName('ARG_ORIGINAL_NAME').AsString := EditAdd_ORIGINAL_NAME.Text;
Params.ParamByName('ARG_ALIAS').AsString := '';
Params.ParamByName('ARG_CAST_NAME').AsString := EditAdd_CAST_NAME.Text;
Params.ParamByName('ARG_METRO_UNIT').AsString := ComboBoxAdd_METRO_UNIT.Text;
Params.ParamByName('ARG_SALE_PRICE').AsString := EditAdd_SALE_PRICE.Text;
Params.ParamByName('ARG_LENGTH').AsString := FormContentLocation.ListView1.Selected.SubItems[0] ;
Params.ParamByName('ARG_MILLISECS').AsInteger := milliseconds;
with DataModule1.ClientDataSet1 do
begin
Close;
CommandText := Format('Select a.CATEGORY_ID From CONTENT_SUBCATEGORY a Where SUBCATEGORY_ID=''%S'' ',[EditAdd_CONTENT_SUBCATEGORY_ID.Text]);
Open;
end;
Params.ParamByName('ARG_CATEGORY_ID').AsString := DataModule1.ClientDataSet1.FieldByName('CATEGORY_ID').AsString;
Params.ParamByName('ARG_SUBCATEGORY_ID').AsString := EditAdd_CONTENT_SUBCATEGORY_ID.Text;
Params.ParamByName('ARG_RATING_ID').AsString := EditAdd_RATING_ID.Text;
Params.ParamByName('ARG_FILENAME').AsString := Copy(FormContentLocation.ListView1.Selected.Caption, 1, Length(FormContentLocation.ListView1.Selected.Caption) - 4) + '.mpi';
Params.ParamByName('ARG_MEDIA_FILENAME').AsString := FormContentLocation.ListView1.Selected.Caption;
MiniSecond := EditAdd_TIMESLICE.Text + '000';
Params.ParamByName('ARG_TIMESLICE').AsString := MiniSecond;
Params.ParamByName('ARG_TIMESLICE_PRICE').AsFloat := StrToFloat(EditAdd_SALE_PRICE.Text) * (StrToInt(MiniSecond)/milliseconds);
Params.ParamByName('ARG_CREATION_DATE').AsDateTime := Now();
Params.ParamByName('ARG_LASTMODIFIED_DATE').AsDateTime := Now();
Params.ParamByName('ARG_OBSOLETE_DATE').AsDateTime := Now();
//Reg := TRegistry.Create;
Reg.RootKey :=HKEY_CURRENT_USER;
Reg.OpenKey(CB_RegKey, True) ;
if Reg.ValueExists(CB_LoginUsername) then
Begin
Params.ParamByName('ARG_ADDED_BY').AsString := Reg.ReadString(CB_LoginUsername) ;
//Reg.Free ;
end
else
begin
Reg.WriteString(CB_LoginUsername, 'SUPPER MAN');
Params.ParamByName('ARG_ADDED_BY').AsString := Reg.ReadString(CB_LoginUsername) ;
//Reg.Free ;
end ;
Params.ParamByName('ARG_DESCRIPTION').AsString := '';
Params.ParamByName('ARG_ENCODE_TYPE').AsInteger := bitrate;
Params.ParamByName('ARG_VIDEO_FORMAT').AsString := MPEGFORMAT;
Params.ParamByName('ARG_CONTENT_SOURCE').AsString := '';
Params.ParamByName('ARG_PROVIDER_ID').AsString := EditAdd_PROVIDER_ID.Text;
Params.ParamByName('ARG_LINK_URL').AsString := EditAdd_LINK_URL.Text;
Params.ParamByName('ARG_VOD_FLAG').AsString := '10';
Params.ParamByName('ARG_PERTIMES_PRICE').AsString := EditAdd_PERTIMES_PRICE.Text;
Params.ParamByName('ARG_DIRECT_NAME').AsString := EditAdd_DIRECT_NAME.Text;
Params.ParamByName('ARG_PICTURE_URL').AsString := EditAdd_PICTURE_URL.Text;
Params.ParamByName('arg_VODSERVER_ID').AsString := SelectNcube;
with DataModule1.ClientDataSet1 do
begin
Close;
CommandText := Format('Select DEVICE_NAME From DEVICE_CODE Where DEVICE_ID=''%S'' ',[SelectNcube]);
Open;
end;
Params.ParamByName('arg_VODSERVER_NAME').AsString := DataModule1.ClientDataSet1.FieldByName('DEVICE_NAME').AsString;
Params.ParamByName('arg_PATH').AsString := SelectLPARTITION;
Params.ParamByName('arg_TOTAL_CLICKS').AsString := '0';
Params.ParamByName('arg_LOAD_DATE').AsDateTime := Now();
Params.ParamByName('arg_AVAILABLE_FLAG').AsString := 'AVAILABLE';
Execute;
end;
Application.MessageBox('点播节目增加成功。', MessageTitle, OK_ICON + MB_OK);
end;
except
Application.MessageBox('数据库异常。', MessageTitle, ERROR_ICON + MB_OK);
end;
end
else
Application.MessageBox('此视频文件不是完整文件。', MessageTitle, ERROR_ICON + MB_OK);
end
else
Application.MessageBox('没有TELNET端口数据。', MessageTitle, WARNING_ICON + MB_OK);
end;
end;
//SaveCookie(Direct_Name, EditAdd_DIRECT_NAME.Text, Direct_Name_Len);
except
Application.MessageBox('点播节目增加失败。', MessageTitle, ERROR_ICON + MB_OK);
end;
end;
Screen.Cursor := EndCursor;
end;
看看吧
留下你的 qq或 mail