//---------------------------------------------------------------------------
#include <vcl.h>
#include"math.h"
#pragma hdrstop
#include <stdio.h>
#include "main.h"
#include "data.h"
#include "name_gl.h"
#include "jinhuo_gl.h"
#include "lingshou.h"
#include "kucen.h"
#include "xiaoshou.h"
#include "passwd.h"
#include "check.h"
#include "xiaopiao.h"
#include "qingli.h"
#include "xiaoshoumx.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
Tfm_main *fm_main;
//-----------------------------------------------------
int danjuhao,row;;
//---------------------------------------------------------------------------
__fastcall Tfm_main::Tfm_main(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall Tfm_main::bt_nameClick(TObject *Sender)
{
fm_name_gl->ShowModal();
}
//---------------------------------------------------------------------------
void __fastcall Tfm_main::bt_jinhuoClick(TObject *Sender)
{
fm_jinhuo_gl->ShowModal();
}
//---------------------------------------------------------------------------
void __fastcall Tfm_main::FormShow(TObject *Sender)
{
//计算单据号
dm_data->ds_guest->Close();
dm_data->ds_guest->CommandText="select top 1 * from xiaoshou order by danjuhao desc";
dm_data->ds_guest->Open();
if(dm_data->ds_guest->RecordCount<1 && (shuliang->Focused()==true || shoujia->Focused()==true || dazhe->Focused()==true))
danjuhao=1;
else
danjuhao=dm_data->ds_guest->FieldByName("danjuhao")->AsInteger+1;
dm_data->ds_guest->Close();
row=0;
lb->RowCount=1;
lb->ColCount=8;
lb->ColWidths[3]=30;
lb->ColWidths[7]=150;
lb->Cells[0][0]="序号";
lb->Cells[1][0]="货号";
lb->Cells[2][0]="货名";
lb->Cells[3][0]="数量";
lb->Cells[4][0]="定价";
lb->Cells[5][0]="优惠价";
lb->Cells[6][0]="金额";
lb->Cells[7][0]="时间";
danjuhaos->Text=danjuhao;
shuliang_hj->Text="0";
jine_hj->Text="0";
xianfu->Text="0";
}
//---------------------------------------------------------------------------
void __fastcall Tfm_main::codeKeyPress(TObject *Sender, char &Key)
{
if(Key==VK_RETURN)
PostMessage(Handle,WM_KEYDOWN,VK_TAB,0);
}
//---------------------------------------------------------------------------
void __fastcall Tfm_main::shuliangKeyPress(TObject *Sender, char &Key)
{
if(Key==VK_RETURN)
PostMessage(Handle,WM_KEYDOWN,VK_TAB,0);
}
//---------------------------------------------------------------------------
void __fastcall Tfm_main::shoujiaKeyPress(TObject *Sender, char &Key)
{
if(Key==VK_RETURN)
PostMessage(Handle,WM_KEYDOWN,VK_TAB,0);
}
//---------------------------------------------------------------------------
void __fastcall Tfm_main::dazheKeyPress(TObject *Sender, char &Key)
{
if(Key==VK_RETURN)
PostMessage(Handle,WM_KEYDOWN,VK_TAB,0);
}
//---------------------------------------------------------------------------
void __fastcall Tfm_main::codeExit(TObject *Sender)
{
dm_data->ds_guest->Close();
dm_data->ds_guest->CommandText="select jinhuo.*,name.name from jinhuo,name where jinhuo.code='"+code->Text+"' and name.code=jinhuo.code order by id desc";
dm_data->ds_guest->Open();
if(dm_data->ds_guest->RecordCount<1 && (shuliang->Focused()==true || shoujia->Focused()==true || dazhe->Focused()==true || chuhuo->Focused()==true))
{
Application->MessageBoxA("该货物可能没有进货,请重新输入","提示",MB_OK);
code->SetFocus();
}
else
{
int sn=0;
shoujia->Text=dm_data->ds_guest->FieldByName("shoujia")->AsString;
dingjia->Text=shoujia->Text;
name->Text=dm_data->ds_guest->FieldByName("name")->AsString;
shuliang->Text="1";
while(!dm_data->ds_guest->Eof)
{
sn=sn+dm_data->ds_guest->FieldByName("shuliang")->AsInteger;
dm_data->ds_guest->Next();
}
shuliang0->Text=IntToStr(sn);
}
dm_data->ds_guest->Close();
}
//---------------------------------------------------------------------------
void __fastcall Tfm_main::shoujiaChange(TObject *Sender)
{
float shoujian,dazhen,shoujia0n;
if((shoujia->Text.Trim()!="") && (dazhe->Text.Trim()!=""))
{
shoujian=StrToFloat(shoujia->Text);
dazhen=StrToFloat(dazhe->Text);
shoujia0n=shoujian*dazhen/10;
shoujia0->Text=FormatFloat("0.00",shoujia0n);
}
}
//---------------------------------------------------------------------------
void __fastcall Tfm_main::shoujiaxgClick(TObject *Sender)
{
if(shoujiaxg->Checked==true)
shoujia->Enabled=true;
else
shoujia->Enabled=false;
}
//---------------------------------------------------------------------------
void __fastcall Tfm_main::dazhexgClick(TObject *Sender)
{
if(dazhexg->Checked==true)
dazhe->Enabled=true;
else
dazhe->Enabled=false;
}
//---------------------------------------------------------------------------
void __fastcall Tfm_main::chuhuoClick(TObject *Sender)
{
dm_data->ds_guest->Close();
dm_data->ds_guest->CommandText="select jinhuo.*,name.name from jinhuo,name where jinhuo.code='"+code->Text+"' and name.code=jinhuo.code order by id desc";
dm_data->ds_guest->Open();
if(dm_data->ds_guest->RecordCount<1)
{
Application->MessageBoxA("该货物可能没有进货,请重新输入","提示",MB_OK);
code->SetFocus();
dm_data->ds_guest->Close();
return;
}
row=row+1;
lb->RowCount=row+1;
lb->Cells[0][row]=row;
lb->Cells[1][row]=code->Text;
lb->Cells[2][row]=name->Text;
lb->Cells[3][row]=shuliang->Text;
lb->Cells[4][row]=FormatFloat("0.00",StrToFloat(dingjia->Text));
lb->Cells[5][row]=shoujia0->Text;
lb->Cells[6][row]=FormatFloat("0.00",StrToFloat(shoujia0->Text)*StrToInt(shuliang->Text));
lb->Cells[7][row]=Now();
shuliang_hj->Text=StrToInt(shuliang_hj->Text)+StrToInt(shuliang->Text);
jine_hj->Text=FormatFloat("0.00",StrToFloat(jine_hj->Text)+StrToFloat(lb->Cells[6][row]));
code->SetFocus();
}
//---------------------------------------------------------------------------
void __fastcall Tfm_main::xianfuKeyPress(TObject *Sender, char &Key)
{
if(Key==VK_RETURN)
PostMessage(Handle,WM_KEYDOWN,VK_TAB,0);
}
//---------------------------------------------------------------------------
void __fastcall Tfm_main::xianfuExit(TObject *Sender)
{
zhaoling->Text=FloatToStr(StrToFloat(xianfu->Text)-StrToFloat(jine_hj->Text));
}
//---------------------------------------------------------------------------
void __fastcall Tfm_main::jiezhangClick(TObject *Sender)
{
AnsiString price;
TDateTime dd;
//
if(row<1)
{
Application->MessageBoxA("没有货物可供结帐,请输入货物代码","提示",MB_OK);
code->SetFocus();
return;
}
//打印
if(dy->Checked==true)
{
FILE *fp;
AnsiString str="";
if((fp=fopen("Lpt1","wb"))==NULL)
{
Application->MessageBoxA("打印机出错","警告",MB_OK);
return;
}
if(huiyuan->Checked==true)
price="会员价";
else
price="定价";
dm_data->ds_guest->Close();
dm_data->ds_guest->CommandText="select * from code where id>=20000 and id<30000 order by id";
dm_data->ds_guest->Open();
dm_data->ds_guest->First();
str=str.cat_sprintf("%s\n",dm_data->ds_guest->FieldByName("content")->AsString);
str=str.cat_sprintf("流水号: %d\n",danjuhao);
str=str.cat_sprintf("时 间: %s
chaoshi.rar_商品管理系统_超市商品管理_超市管理系统
版权申诉
162 浏览量
2022-09-14
17:15:42
上传
评论
收藏 755KB RAR 举报
局外狗
- 粉丝: 68
- 资源: 1万+