⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 xiaoshou.cpp

📁 一个用VC写的超市管理系统
💻 CPP
字号:
//---------------------------------------------------------------------------

#include <vcl.h>
#pragma hdrstop

#include "xiaoshou.h"
#include "data.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
Tfm_xiaoshou *fm_xiaoshou;\
int shuliang0;
float jine0,maoli0;

//---------------------------------------------------------------------------
__fastcall Tfm_xiaoshou::Tfm_xiaoshou(TComponent* Owner)
    : TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall Tfm_xiaoshou::huizongClick(TObject *Sender)
{
    dm_data->ds_jinhuo_jia->Close();
    dm_data->ds_jinhuo_jia->Open();

    dm_data->ds_xiaoshou_hj->Close();
    dm_data->ds_xiaoshou_hj->Parameters->ParamValues["dt0"]=dt0->Date.FormatString("yyyy-mm-dd")+" 0:0:0";
    dm_data->ds_xiaoshou_hj->Parameters->ParamValues["dt1"]=dt1->Date.FormatString("yyyy-mm-dd")+" 23:59:59";
    dm_data->ds_xiaoshou_hj->Open();

    lb->ColCount=7;
    lb->RowCount=2;
    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]="销售毛利";

    shuliang0=0;
    jine0=0;
    maoli0=0;
    int i=1;
    dm_data->ds_xiaoshou_hj->First();
    while(!dm_data->ds_xiaoshou_hj->Eof)
    {
        lb->Cells[0][i]=IntToStr(i);
        lb->Cells[1][i]=dm_data->ds_xiaoshou_hj->FieldValues["code"];
        lb->Cells[2][i]=dm_data->ds_xiaoshou_hj->FieldValues["name0"];
        lb->Cells[3][i]=dm_data->ds_xiaoshou_hj->FieldValues["shuliang0"];
        lb->Cells[4][i]=dm_data->ds_xiaoshou_hj->FieldValues["jine0"];
        lb->Cells[5][i]=dm_data->ds_jinhuo_jia->FieldValues["jinjia0"];
        lb->Cells[6][i]=FormatFloat("0.00",StrToFloat(lb->Cells[4][i])-StrToFloat(lb->Cells[5][i])*StrToInt(lb->Cells[3][i]));
        shuliang0+=StrToInt(lb->Cells[3][i]);
        jine0+=StrToFloat(lb->Cells[4][i]);
        maoli0+=StrToFloat(lb->Cells[6][i]);

        dm_data->ds_xiaoshou_hj->Next();
        lb->RowCount++;
        i++;
    }
    if(lb->RowCount>2)
        lb->RowCount--;
    else
        for(int j=1;j<=6;j++)
            lb->Cells[j][1]="";
    shuliang->Text=shuliang0;
    jine->Text=FormatFloat("0.00",jine0);
    maoli->Text=FormatFloat("0.00",maoli0);

}
//---------------------------------------------------------------------------

void __fastcall Tfm_xiaoshou::FormShow(TObject *Sender)
{
    Left=100;
    Top=80;
    dt0->DateTime=Now();
    dt1->DateTime=Now();
    dt0->SetFocus();
    huizongClick(Sender);
}
//---------------------------------------------------------------------------

void __fastcall Tfm_xiaoshou::Button2Click(TObject *Sender)
{
    Close();
}
//---------------------------------------------------------------------------

void __fastcall Tfm_xiaoshou::FormClose(TObject *Sender,
      TCloseAction &Action)
{
    dm_data->ds_xiaoshou_hj->Close();
    dm_data->ds_jinhuo_jia->Close();
}
//---------------------------------------------------------------------------


⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -