精心打造的New MMS Form
2008-04-09 04:20:46来源:互联网 阅读 ()
//功能:添加新的彩信数据到数据库
//作者:陈鹏
//完成日期:2005-80-31
unit newmmsForlibrary;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ImgList, xpWindow, Mask, RzEdit, RzSpnEdt, StdCtrls, RzCmboBx,
ExtCtrls, xpPanel, xpBitBtn, VirtualTrees, RzButton, RzRadChk,database,
Buttons,StrUtils;
type
TNewMMS = class(TForm)
CancelBtn: TxpBitBtn;
RightPanel: TBackPanel;
lblTitle: TLabel;
lblSubject: TLabel;
lblType: TLabel;
edtSubject: TEdit;
RCBType: TRzComboBox;
xpWindow1: TxpWindow;
ilImages: TImageList;
imgNewMsg: TImage;
VSTreeResource: TVirtualStringTree;
RzRadioButton1: TRzRadioButton;
RzRadioButton2: TRzRadioButton;
lblSmil: TLabel;
XpBtnAdd: TxpBitBtn;
XpBtnDelete: TxpBitBtn;
ResourceAdd:TxpBitBtn;
lblSize: TLabel;
edtsize: TEdit;
ilTreeImage: TImageList;
dlgOpenAdd: TOpenDialog;
procedure CancelBtnClick(Sender: TObject);
procedure XpBtnAddClick(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure ResourceAddClick(Sender: TObject);
procedure VSTreeResourceGetText(Sender: TBaseVirtualTree;
Node: PVirtualNode; Column: TColumnIndex; TextType: TVSTTextType;
var CellText: WideString);
procedure XpBtnDeleteClick(Sender: TObject);
procedure FormDestroy(Sender: TObject);
procedure edtSubjectMouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
private
function getFilenameFromFullpath(s:string):string;
function getFileSize(sFileName:string):Longint;
procedure getMMSContentType();
public
totalSize:Longint;
Stringlist:TStringList;
procedure RefreshTree();
end;
type
PResource=^TResource;
TResource=record //彩信结构(好像没使用ClassID ,哈哈)
classID:string;
FullPath:string;
end;
var
NewMMS: TNewMMS;
implementation
uses
mmslibrarypage;
{$R *.dfm}
//功能:刷新树
procedure TNewMMS.RefreshTree();
begin
VSTreeResource.RootNodeCount:=Stringlist.Count;
VSTreeResource.Refresh;
end;
procedure TNewMMS.CancelBtnClick(Sender: TObject);
begin
close;
end;
procedure TNewMMS.XpBtnAddClick(Sender: TObject);
var
sql:string;
smiltype:string;
begin
if RzRadioButton1.Checked=true then
smiltype:=''''Smil 1.0''''
else
smiltype:=''''Smil 2.0'''';
// sqL:=''''insert into mmslibrary(MMS_ID,MMS_Type,MMS_Smil,MMS_Size,MMS_Subject,MMS_Binary) values''''
// ''''("'''' formatDatetime(''''yyyymmdd_hh:mm:ss'''', now) ''''","'''' RCbtype.Text ''''","'''' smiltype ''''",'''' edtsize.Text '''',"''''
// edtIpSubject.Text ''''","'''' ''''test")'''';
//添加数据到数据库,但最后一项(二进制内存块) 还没添加
sqL:=''''insert into mmslibrary(MMS_ID,MMS_Type,MMS_Smil,MMS_Size,MMS_Subject) values''''
''''("'''' formatDatetime(''''yyyy-mm-dd hh:mm:ss'''', now) ''''","'''' RCbtype.Text ''''","'''' smiltype ''''",'''' inttostr(totalSize) '''',"'''' edtSubject.Text ''''")'''';
currentdatabase.ExecuteSqlNoQurey(sql); //连接数据库,就是这么容易
Close;
ModalResult:=mrOk;//据此,mmslibraryform才能刷新树。这也曾是一个难题,哈哈
end;
procedure TNewMMS.FormCreate(Sender: TObject);
begin
currentdatabase.databases.GetByIndex(0);
Stringlist:=Tstringlist.Create;
VSTreeResource.NodeDataSize:=SizeOf(TResource);
VSTreeResource.Header.Columns[0].Width:=VSTreeResource.ClientWidth;
totalSize:=0; //用户选择彩信资源的文件总大小
end;
procedure TNewMMS.FormClose(Sender: TObject; var Action: TCloseAction);
begin
Action:=caFree;
end;
procedure TNewMMS.ResourceAddClick(Sender: TObject);
var
temp:Longint;
begin
dlgOpenAdd.Filter:=''''text files(*.txt;*.html;*.htm)|*.txt;*.html;*.htm|pictual files(*.bmp;*.jpg;*.gif)|*.bmp;*.jpg;*.gif|sound files(*.wma;*.mp3)|*.wma;*.mp3|video files(*.avi;*.mp4)|*.avi;*.mp4|'''';
if dlgOpenAdd.Execute then
begin
temp:=totalSize getFileSize(dlgOpenAdd.FileName);
if temp<102400 then //判断文件总大小不能超过100k,否则不予添加
begin
totalSize:=temp;
Stringlist.Add(dlgOpenAdd.FileName);
edtsize.Text:=IntToStr(totalSize) '''' Byte'''';
end
else
Exit;
end;
RefreshTree;
getMMSContentType;
end;
//自写函数,根据用户选择的文件,自动判断MMS的Type,虽长且繁,但好维护(
标签:
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com
特别注意:本站所有转载文章言论不代表本站观点,本站所提供的摄影照片,插画,设计作品,如需使用,请与原作者联系,版权归原作者所有
下一篇:取Run下所有值(原创)
IDC资讯: 主机资讯 注册资讯 托管资讯 vps资讯 网站建设
网站运营: 建站经验 策划盈利 搜索优化 网站推广 免费资源
网络编程: Asp.Net编程 Asp编程 Php编程 Xml编程 Access Mssql Mysql 其它
服务器技术: Web服务器 Ftp服务器 Mail服务器 Dns服务器 安全防护
软件技巧: 其它软件 Word Excel Powerpoint Ghost Vista QQ空间 QQ FlashGet 迅雷
网页制作: FrontPages Dreamweaver Javascript css photoshop fireworks Flash