主题:[原创]财务管理系统(C语言)
程序运行画面:
[img]http://img320.photo.163.com/225ysg2003/37573264/1021540632.gif[/img]
如果图片显示不出来的话, 可以把:http://img320.photo.163.com/225ysg2003/37573264/1021540632.gif复制到地址栏上回车即可看到.
下载可执行程序:[url=http://www.programfan.com/wysoft/showwysoft.asp?id=1430]http://www.programfan.com/wysoft/showwysoft.asp?id=1430[/url]
以下为源代码 - 开发平台:Turbo C2.0 + SGWINDOW2.0
#include <stdio.h>
#include <math.h>
#include <ctype.h>
#include <dos.h>
#include <sgwindow.h> /*SGWINDOW 程序必须的头文件*/
#include "savescr.c"
#define VERSIONSTRING "财务管理系统 1.2 For SGWINDOW 2.0\nCopyright (C) 2005-8 - 2006-3 SGPRO"
#define APPNAME "财务管理系统 1.2 For SGWINDOW 2.0"
#define VERSIONVAL 1
#define VERSIONSUBVAL 2
#define ID_ABOUT 10000
#define ID_FRMOPRT 10010
#define ID_FRMVIEW 10011
#define ID_OPTNVIEWALL 10020
#define ID_OPTNVIEWOUT 10021
#define ID_OPTNVIEWINC 10022
#define ID_OPTNVIEWAMT 10023
#define ID_OPTNOUTG 10024
#define ID_OPTNINC 100025
#define ID_LABFINA 10030
#define ID_LABCOMMENT 10031
#define ID_LABDATETIP 10032
#define ID_LABRECKTIP 10033
#define ID_LABCURRECK 10034
#define ID_TXTFINA 10040
#define ID_TXTCOMMENT 10041
#define ID_TXTRECKNAME 10042
#define ID_TXTDATE 10043
#define ID_TXTPASSWORD 1044
#define ID_LSTVIEW 10050
#define ID_CMDOPRT 10060
#define ID_CMDVIEW 10061
#define ID_CMDUPDATE 10062
#define ID_CMDDELETE 10063
#define ID_CMDRECK 10064
#define ID_CMDADDRECK 10065
#define ID_CMDCLEAR 10066
#define ID_CMDRESET 10067
#define ID_CMDSAVEPWD 10068
#define ID_CMDEXIT 10069
#define ID_CHECKUSEPASS 10070
#define LEFT Get_FormUserarealeft(FORM(window))
#define TOP Get_FormUserareatop(FORM(window))
#define LISTSIZE 40
#define PASSWORDMAXLENGTH
#define format "%-10d%-12s%-10s"
void Dispatch_Message(WinMessage WinMsg); /*消息处理函数定义*/
void form_onload();
void form_unload();
void On_Clear();
void On_AddNewReck();
void LoadData();
void On_operate();
void On_view();
void clearlistbox();
void On_delete();
void On_Reset();
void On_Password();
void On_SavePassword();
bool GetPassword(const char*promt);
char *GetAppVersion();
wndhnd window; /*主窗体句柄*/
wndhnd about; /* '关于' 按扭句柄*/
wndhnd frmoprt,frmview;
wndhnd optnoutg,optninc;
wndhnd optnviewall,optnviewout,optnviewin,optnviewamt;
wndhnd labfina,labcomment,labdatetip,labrecktip,labcurreck;
wndhnd txtfina,txtcomment,txtreckname,txtdate,txtpassword;
wndhnd lstview;
wndhnd cmdoprt,cmdview,cmdreset;
wndhnd cmddelete,cmdupdate,cmdreck,cmdaddreck,cmdclear,cmdsavepwd,cmdexit;
wndhnd chkpas;
bool enableupdate = false;
int Recordsum = 0;
typedef struct
{
int sum;
char date[11];
char comment[64];
}finaitem;
long amount = 0;
typedef struct
{
char DatabaseName[20];
int pflag;
char Password[8];
}user;
user User = {"",0,""};
void main()
{
WinMessage msg; /*主消息*/
winfont wft; /*字体*/
fprintf(stdout,"%s\n",VERSIONSTRING);
if (!GetPassword("Please enter the password:\n"))
{
fprintf(stdout,"\nPassword error\n");
system("pause");
exit(1);
}
SGWINDOWinit(); /*加载SGWINDOW*/
setfont(&wft,0,0,WIN12,0); /*设置字体*/
window = new_form(0,0,639,458,1,wft,7,APPNAME,"windoc.bmp",true,true,true,32); /*设置窗体属性*/
about = new_Button(Get_FormUserarealeft(FORM(window))+Get_FormUserareawidth(FORM(window))-170,
Get_FormUserareatop(FORM(window))+Get_FormUserareaheight(FORM(window))-40,50,20,
wft," 关于 ",7,true,true);/* '关于' 按扭属性设置 */
cmdexit = new_Button(Get_FormUserarealeft(FORM(window))+Get_FormUserareawidth(FORM(window))-80,
Get_FormUserareatop(FORM(window))+Get_FormUserareaheight(FORM(window))-40,50,20,
wft," 退出 ",7,true,true);/* '退出' 按扭属性设置 */
frmoprt = new_frame(LEFT+20,TOP+20,270,160,wft,"出入帐操作",true);
labrecktip = new_Defaultlabel(LEFT+320,TOP+20,"在下面的方框中输入你要打开或增加的帐单名");
labcurreck = new_Defaultlabel(LEFT+320,TOP+140,"");
cmdreck = new_Defaultbutton(LEFT+445,TOP+90," 打开帐单 ");
cmdaddreck = new_Defaultbutton(LEFT+340,TOP+90," 增加帐单 ");
cmdclear = new_Defaultbutton(LEFT+540,TOP+55," 重填 ");
optnoutg = new_DefaultOption(LEFT+40,TOP+40,"出帐");
optninc = new_DefaultOption(LEFT+100,TOP+40,"入帐");
labfina = new_Defaultlabel(LEFT+25,TOP+70,"金额:");
labcomment = new_Defaultlabel(LEFT+25,TOP+100,"备注:");
labdatetip = new_Defaultlabel(LEFT+25,TOP+130,"日期:");
txtfina = new_Textbox(LEFT+70,TOP+70,200,18,15,wft,"",10,false,true,true,false);
txtcomment =new_Textbox(LEFT+70,TOP+100,200,18,15,wft,"",30,false,true,true,false);
txtdate = new_Textbox(LEFT+70,TOP+130,200,18,15,wft,"",10,false,true,true,false);
txtreckname = new_Textbox(LEFT+340,TOP+55,180,18,15,wft,"",20,false,true,true,false);
txtpassword = new_Textbox(LEFT+460,TOP+260,150,18,15,wft,"",40,false,false,true,false);
cmdreset = new_Defaultbutton(LEFT+70,TOP+155," 重置 ");
cmdoprt = new_Defaultbutton(LEFT+225,TOP+155," 确定 ");
cmdsavepwd = new_Defaultbutton(LEFT+460,TOP+220," 设置系统登陆口令 ");
frmview = new_frame(LEFT+20,TOP+210,410,200,wft,"查看/删除帐目",true);
optnviewamt = new_DefaultOption(LEFT+30,TOP+230," 总额 ");
optnviewall = new_DefaultOption(LEFT+30,TOP+260,"全部记录");
optnviewout = new_DefaultOption(LEFT+30,TOP+290,"出帐记录");
optnviewin = new_DefaultOption(LEFT+30,TOP+320,"入帐记录");
cmdview = new_Defaultbutton(LEFT+40,TOP+350," 查看 ");
cmddelete = new_Defaultbutton(LEFT+40,TOP+380," 删除 ");
chkpas = new_DefaultCheckbox(LEFT+460,TOP+320,"使用口令进入本系统");
lstview = new_Listbox(LEFT+120, TOP+220, 300,180,wft,15,LISTSIZE,false,true,true);
Register_Windowhandletoform(window,about,SGWNDBUTTON,ID_ABOUT);/*在主窗体中 注册 '关于' 按扭句柄 */
Register_Windowhandletoform(window,cmdexit,SGWNDBUTTON,ID_CMDEXIT);/*在主窗体中 注册 '退出' 按扭句柄 */
Register_Windowhandletoform(window,frmoprt,SGWNDFRAME,ID_FRMOPRT);
Register_Windowhandletoform(window,frmview,SGWNDFRAME,ID_FRMVIEW);
Register_Windowhandletoform(window,optnoutg,SGWNDOPTION,ID_OPTNOUTG);
Register_Windowhandletoform(window,optninc,SGWNDOPTION,ID_OPTNINC);
Register_Windowhandletoform(window,labfina,SGWNDLABEL,ID_LABFINA);
Register_Windowhandletoform(window,labcomment,SGWNDLABEL,ID_LABCOMMENT);
Register_Windowhandletoform(window,labdatetip,SGWNDLABEL,ID_LABDATETIP);
Register_Windowhandletoform(window,labrecktip,SGWNDLABEL,ID_LABRECKTIP);
Register_Windowhandletoform(window,labcurreck,SGWNDLABEL,ID_LABCURRECK);
Register_Windowhandletoform(window,txtdate,SGWNDTEXTBOX,ID_TXTDATE);
Register_Windowhandletoform(window,txtfina,SGWNDTEXTBOX,ID_TXTFINA);
Register_Windowhandletoform(window,txtcomment,SGWNDTEXTBOX,ID_TXTCOMMENT);
Register_Windowhandletoform(window,txtreckname,SGWNDTEXTBOX,ID_TXTRECKNAME);
Register_Windowhandletoform(window,txtpassword,SGWNDTEXTBOX,ID_TXTPASSWORD);
Register_Windowhandletoform(window,cmdoprt,SGWNDBUTTON,ID_CMDOPRT);
Register_Windowhandletoform(window,cmdreset,SGWNDBUTTON,ID_CMDRESET);
Register_Windowhandletoform(window,cmdreck,SGWNDBUTTON,ID_CMDRECK);
Register_Windowhandletoform(window,cmdaddreck,SGWNDBUTTON,ID_CMDADDRECK);
Register_Windowhandletoform(window,cmdclear,SGWNDBUTTON,ID_CMDCLEAR);
Register_Windowhandletoform(window,cmdsavepwd,SGWNDBUTTON,ID_CMDSAVEPWD);
Register_Windowhandletoform(window,optnviewamt,SGWNDOPTION,ID_OPTNVIEWAMT);
Register_Windowhandletoform(window,optnviewall,SGWNDOPTION,ID_OPTNVIEWALL);
Register_Windowhandletoform(window,optnviewout,SGWNDOPTION,ID_OPTNVIEWOUT);
Register_Windowhandletoform(window,optnviewin,SGWNDOPTION,ID_OPTNVIEWINC);
Register_Windowhandletoform(window,lstview,SGWNDLISTBOX,ID_LSTVIEW);
Register_Windowhandletoform(window,cmdview,SGWNDBUTTON,ID_CMDVIEW);
Register_Windowhandletoform(window,cmddelete,SGWNDBUTTON,ID_CMDDELETE);
Register_Windowhandletoform(window,chkpas,SGWNDCHECKBOX,ID_CHECKUSEPASS);
Change_LabelBackcolor(labcomment,Get_FormBackcolor(FORM(window)));
Change_LabelBackcolor(labfina,Get_FormBackcolor(FORM(window)));
Change_LabelBackcolor(labdatetip,Get_FormBackcolor(FORM(window)));
Change_LabelBackcolor(labrecktip,Get_FormBackcolor(FORM(window)));
Change_LabelBackcolor(labcurreck,Get_FormBackcolor(FORM(window)));
Change_CheckboxBackcolor(chkpas,Get_FormBackcolor(FORM(window)));
Change_TextboxBackcolor(txtdate,10);
Change_TextboxBackcolor(txtreckname,13);
Change_ListboxBackcolor(lstview,14);
while (TestMessageSource(window))/*当消息源存在时,进入消息循环*/
{
msg = WindowSend_Message(GetMessageSource(window));/*提取并发送消息*/
Dispatch_Message(msg); /*处理消息*/
}
}
void Dispatch_Message(WinMessage msg) /*消息处理函数*/
{
int ObjectID = Get_MessagescrID(msg); /*获取发送消息的对象的ID号*/
int MessageType = Get_MessagescrType(msg); /*获取该消息的类型*/
if (MessageType == WE_KEYDOWN)
{
if ( Get_EventKeycode() == F5)
{
GenBmp("SGFNCMG2.BMP",0,0,639,479);
}
}
switch (ObjectID)
{
case ID_MAINFORM:/*主窗体对象*/
if (MessageType == WE_EXIT)/*主窗体发送退出消息*/
{
if (Messagebox(APPNAME," 确实要退出本系统吗? ",
SGMSGBOX_YESNO,SGMSGBOXICON_question) == SGMSGBOX_YES)
{
delete_form(&FORMPTR(window));
}
}
else if (MessageType == WE_FORMLOAD)/*主窗体发送加载消息*/
{
Show_Form(window);/*显示主窗体*/
form_onload();
}
else if (MessageType == WE_FORMUNLOAD)
{
form_unload();
}
break;
case ID_ABOUT:/* '关于'按扭对象*/
if (MessageType == WE_CLICK) /*关于按扭发送鼠标单击消息*/
{
Messagebox("关于",VERSIONSTRING,SGMSGBOX_OKONLY,SGMSGBOXICON_information);
}
break;
case ID_CMDEXIT:/* '关于'按扭对象*/
if (MessageType == WE_CLICK) /*关于按扭发送鼠标单击消息*/
{
if (Messagebox(APPNAME," 确实要退出本系统吗? ",
SGMSGBOX_YESNO,SGMSGBOXICON_question) == SGMSGBOX_YES)
{
form_unload();
delete_form(&FORMPTR(window));
}
}
break;
case ID_CMDOPRT:
if (MessageType == WE_CLICK)
{
On_operate();
}
break;
case ID_CMDRESET:
if (MessageType == WE_CLICK)
{
On_Reset();
}
break;
case ID_CMDVIEW:
if (MessageType == WE_CLICK)
{
On_view();
}
break;
case ID_CMDDELETE:
if (MessageType == WE_CLICK)
{
On_delete();
}
break;
case ID_CMDSAVEPWD:
if (MessageType == WE_CLICK)
{
On_Password();
}
break;
case ID_CMDRECK:
if (MessageType == WE_CLICK)
{
LoadData();
}
break;
case ID_CMDADDRECK:
if (MessageType == WE_CLICK)
{
On_AddNewReck();
}
break;
case ID_CMDCLEAR:
if (MessageType == WE_CLICK)
{
On_Clear();
}
break;
case ID_TXTPASSWORD:
if (MessageType == WE_CLICK)
{
Change_TextboxText(txtpassword,"");
}
else if (MessageType == WE_KEYDOWN )
{
On_SavePassword();
}
break;
case ID_CHECKUSEPASS:
if ( MessageType == WE_CLICK)
{
User.pflag = Get_CheckboxValue(CHECKBOX(chkpas));
}
break;
}
}
void form_onload()
{
struct date day;
getdate(&day);
Formats_Textbox(txtdate,"%d-%d-%d",
day.da_year,day.da_mon,day.da_day);
if (User.pflag)
{
Change_CheckboxValue(chkpas,true);
}
if (User.Password[0] != '\0')
{
Change_ButtonCaption(cmdsavepwd," 修改系统登陆口令 ");
}
else
{
Change_CheckboxEnable(chkpas,false);
}
Change_TextboxText(txtreckname,User.DatabaseName);
Change_OptionValue(optnviewamt,true);
On_view();
}
void On_Clear()
{
Change_TextboxText(txtreckname,"");
WndhndGetFocus(GetMessageSource(window),ID_TXTRECKNAME);
}
void On_AddNewReck()
{
char infor[40]="";
strcpy(User.DatabaseName,Get_TextboxText(TEXTBOX(txtreckname)));
if (strcmp(User.DatabaseName,""))
{
if (!access(User.DatabaseName,0))
{
sprintf(infor,"帐单:%s已经存在,操作失败!",User.DatabaseName);
Messagebox(APPNAME,infor,
SGMSGBOX_OKONLY,SGMSGBOXICON_critical);
On_Clear();
}
else
{
sprintf(infor,"成功添加帐单:%s!",User.DatabaseName);
Messagebox(APPNAME,infor,
SGMSGBOX_OKONLY,SGMSGBOXICON_information);
fclose(fopen(User.DatabaseName,"wb"));
On_view();
}
}
else
{
Messagebox(APPNAME,"帐单名不能为空!",
SGMSGBOX_OKONLY,SGMSGBOXICON_critical);
On_Clear();
}
}
void LoadData()
{
strcpy(User.DatabaseName,Get_TextboxText(TEXTBOX(txtreckname)));
On_view();
}
bool GetPassword(const char *promt)
{
char c;
char pass[20]="";
int i = 0;
FILE *fp = fopen("user.db","rb");
if (!fp)
{
fp = fopen("user.db","wb");
}
fread(&User, sizeof(user),1,fp);
fclose(fp);
if (User.pflag == 0) /* 未启用密码*/
{
return true;
}
fprintf(stdout,"%s",promt);
#undef getch
while ((c = getch())!='\r')
{
if (isascii(c))
{
pass[i++] = c;
fputc('*',stdout);
}
if ( i >= 20)
{
break;
}
}
return !strcmp(pass,User.Password);
}
void On_Reset()
{
struct date day;
getdate(&day);
Change_TextboxText(txtfina,"");
Change_TextboxText(txtcomment,"");
Formats_Textbox(txtdate,"%d-%d-%d",
day.da_year,day.da_mon,day.da_day);
WndhndGetFocus(GetMessageSource(window),ID_TXTFINA);
}
void On_operate()
{
finaitem instance;
FILE *fdatabas;
int flagsn =0;
int rec =0;
fdatabas = fopen(User.DatabaseName,"ab");
if ( Recordsum >= LISTSIZE-1)
{
Messagebox(APPNAME,
"由于本帐单记录太多, 列表无法全部加载, 请新增帐单!",SGMSGBOX_OKONLY,SGMSGBOXICON_exclamation);
On_Clear();
fclose(fdatabas);
return;
}
Format_StringToLabel(labcurreck,"当前操作的帐单名:%s.",User.DatabaseName);
if (Get_OptionValue(OPTION(optnoutg))==true)
{
flagsn = -1;
}
else if (Get_OptionValue(OPTION(optninc))==true)
{
flagsn = 1;
}
sscanf(Get_TextboxText(TEXTBOX(txtfina)),"%d",&rec);
if (rec <= 0)
{
Messagebox(APPNAME,
"资金只能填写正数!",SGMSGBOX_OKONLY,SGMSGBOXICON_critical);
WndhndGetFocus(GetMessageSource(window),ID_TXTFINA);
return;
}
rec = flagsn*rec;
if (rec == 0)
{
Messagebox(APPNAME,
"没有选择出帐入帐模式!",SGMSGBOX_OKONLY,SGMSGBOXICON_critical);
return;
}
instance.sum = rec;
strcpy(instance.date,Get_TextboxText(TEXTBOX(txtdate)));
strcpy(instance.comment,Get_TextboxText(TEXTBOX(txtcomment)));
amount += rec;
if (amount < 0)
{
Messagebox(APPNAME,
"出帐错误,资金不足!",SGMSGBOX_OKONLY,SGMSGBOXICON_exclamation);
return;
}
if (fwrite(&instance,sizeof(finaitem),1,fdatabas)!=1)
{
Messagebox(APPNAME,
"向磁盘写入数据时发生错误,操作终止!",SGMSGBOX_OKONLY,SGMSGBOXICON_critical);
}
Recordsum++;
fclose(fdatabas);
Messagebox(APPNAME,"操作完成!",
SGMSGBOX_OKONLY,SGMSGBOXICON_information);
}
void On_view()
{
finaitem instance={0L,"",""};
FILE *fdatabas;
int ptr = 1;
int flag;
int oamt =0,iamt=0;
enableupdate = false;
Recordsum = 0;
fdatabas = fopen(User.DatabaseName,"rb");
Change_ListboxVisible(lstview,false);
(LISTBOX(lstview)).itemcount = 0;
Format_StringToLabel(labcurreck,"当前操作的帐单名:%s",User.DatabaseName);
if (!fdatabas)
{
Additem_Listbox(lstview,0,"帐单文件:'%s'不存在,视图无内容",User.DatabaseName);
}
else
{
amount = 0;
Additem_Listbox(lstview,0,"资金数额 日期 备注");
while (!feof(fdatabas))
{
if (fread(&instance,sizeof(finaitem),1,fdatabas)!=1)
{
/*Messagebox(APPNAME,
"读取磁盘中的数据时发生错误,操作终止",SGMSGBOX_OKONLY,SGMSGBOXICON_critical);*/
break;
}
Recordsum++;
amount += instance.sum;
if (Get_OptionValue(OPTION(optnviewamt))==true)
{
(instance.sum> 0 )? (iamt+=instance.sum) :
(oamt += instance.sum);
}
else if (Get_OptionValue(OPTION(optnviewall))==true)
{
enableupdate = true;
if (instance.sum != 0)
{
Additem_Listbox(lstview,ptr++,format,
instance.sum,instance.date,instance.comment);
}
}
else if (Get_OptionValue(OPTION(optnviewin))==true)
{
if (instance.sum > 0)
{
Additem_Listbox(lstview,ptr++,format,
instance.sum,instance.date,instance.comment);
}
}
else if (Get_OptionValue(OPTION(optnviewout))==true)
{
if (instance.sum < 0)
{
Additem_Listbox(lstview,ptr++,format,
instance.sum,instance.date,instance.comment);
}
}
else
{
Messagebox(APPNAME,
"没有选择查询方式!",SGMSGBOX_OKONLY,SGMSGBOXICON_critical);
break;
}
}
if (Get_OptionValue(OPTION(optnviewamt))==true)
{
Deleteitem_Listbox(lstview,0);
Additem_Listbox(lstview,0,"帐单名称: %11s",User.DatabaseName);
Additem_Listbox(lstview,1,"资金余额: %11d",amount);
Additem_Listbox(lstview,2,"出帐总额: %11d",-oamt);
Additem_Listbox(lstview,3,"入帐总额: %11d",iamt);
}
}
(LISTBOX(lstview)).selectindex = -1;
(LISTBOX(lstview)).startindex = 0;
Change_ListboxVisible(lstview,true);
fclose(fdatabas);
}
void On_delete()
{
finaitem instance ={0L,"",""};
int select = Get_ListboxSelectedIndex(LISTBOX(lstview));
FILE *fdatbas;
int cnt;
if (enableupdate==false)
{
Messagebox(APPNAME,
"没有可供删除的项目!\n务必在查看所有记录的情况下使用此功能",SGMSGBOX_OKONLY,SGMSGBOXICON_exclamation);
return;
}
if (select == -1 || select > Get_ListboxItemcount(LISTBOX(lstview))-1)
{
Messagebox(APPNAME,
"从右边的列表中选择你要删除的项.",SGMSGBOX_OKONLY,SGMSGBOXICON_exclamation);
return;
}
if ( select == 0 )
{
Messagebox(APPNAME,
"操作拒绝!",SGMSGBOX_OKONLY,SGMSGBOXICON_critical);
return;
}
if (Messagebox(APPNAME,"确实要删除选定项吗?",
SGMSGBOX_YESNO,SGMSGBOXICON_question) == SGMSGBOX_NO)
return;
sscanf((char*)Get_ListboxItem(LISTBOX(lstview),select),
"%d%s%s",
&(instance.sum),instance.date,instance.comment);
Deleteitem_Listbox(lstview,select);
amount -= instance.sum;
Recordsum--;
fdatbas = fopen(User.DatabaseName,"wb");
for ( cnt = 1; cnt < Get_ListboxItemcount(LISTBOX(lstview)); cnt++)
{
sscanf((char*)Get_ListboxItem(LISTBOX(lstview),cnt),
"%d%s%s",
&(instance.sum),instance.date,instance.comment);
fwrite(&instance,sizeof(finaitem),1,fdatbas);
}
fclose(fdatbas);
}
void On_Password()
{
if (Get_TextboxVisible(TEXTBOX(txtpassword)) == false)
{
Change_TextboxVisible(txtpassword,true);
}
Change_TextboxText(txtpassword,"在此输入口令回车结束.");
}
void On_SavePassword()
{
int i = 0;
int ok = 1;
int keycode = Get_EventKeycode();
if ( keycode == ENTER)
{
if ( strlen(Get_TextboxText(TEXTBOX(txtpassword))) < 8 &&
strlen(Get_TextboxText(TEXTBOX(txtpassword))) != 0)
{
strcpy(User.Password,Get_TextboxText(TEXTBOX(txtpassword)));
while (User.Password[i])
{
if (!isascii(User.Password[i]))
{
Messagebox(APPNAME,"口令必须由字母和数字组成!",
SGMSGBOX_OKONLY,SGMSGBOXICON_exclamation);
ok = 0;
break;
}
i++;
}
}
else if (strlen(Get_TextboxText(TEXTBOX(txtpassword))) > 8)
{
Messagebox(APPNAME,"口令长度不能大于8位",
SGMSGBOX_OKONLY,SGMSGBOXICON_exclamation);
ok = 0;
}
else if (strlen(Get_TextboxText(TEXTBOX(txtpassword))) == 0)
{
ok = 0;
}
if ( ok == 1)
{
Change_TextboxVisible(txtpassword,false);
Change_CheckboxEnable(chkpas,true);
Messagebox(APPNAME,"口令保存成功,请牢记口令",
SGMSGBOX_OKONLY,SGMSGBOXICON_exclamation);
Change_ButtonCaption(cmdsavepwd," 修改系统登陆口令 ");
}
else
{
Change_TextboxText(txtpassword,"在此输入口令回车结束.");
}
}
}
void form_unload()
{
FILE *fp = fopen("user.db","wb");
fwrite(&User,sizeof(user),1,fp);
fclose(fp);
}
char *GetAppVersion()
{
char vstr[20];
sprintf(vstr,"%s %d.%d For SGWINDOW 2.0",
APPNAME, VERSIONVAL,VERSIONSUBVAL);
return vstr;
}