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

📄 kucen.cpp

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

#include <vcl.h>
#pragma hdrstop

#include "kucen.h"
#include "data.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
Tfm_kucen *fm_kucen;
static int shoushu,censhu,jinshu;
static float shoujine,cenjine;
//---------------------------------------------------------------------------
__fastcall Tfm_kucen::Tfm_kucen(TComponent* Owner)
    : TForm(Owner)
{
}
//---------------------------------------------------------------------------

void __fastcall Tfm_kucen::FormShow(TObject *Sender)
{
    Left=50;
    Top=50;
    showjin->Checked=false;
    showjinClick(Sender);
}
//---------------------------------------------------------------------------

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


void __fastcall Tfm_kucen::Button1Click(TObject *Sender)
{
    Close();
}
//---------------------------------------------------------------------------

void __fastcall Tfm_kucen::showjinClick(TObject *Sender)
{
    int i=1;
    dm_data->ds_jinhuo_hj->Close();
    dm_data->ds_jinhuo_hj->Open();

    dm_data->ds_xiaoshou_hj->Close();
    dm_data->ds_xiaoshou_hj->Parameters->ParamValues["dt0"]="1900-01-01 0:0:0";
    dm_data->ds_xiaoshou_hj->Parameters->ParamValues["dt1"]="3000-01-01 23:59:59";
    dm_data->ds_xiaoshou_hj->Open();

    lb->ColCount=9;
    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]="库存数量";
    lb->Cells[7][0]="进货价格";
    lb->Cells[8][0]="库存金额";

    TLocateOptions opts;
    opts.Clear();
    shoushu=censhu=jinshu=0;
    shoujine=cenjine=0;
    dm_data->ds_jinhuo_hj->First();
    while(!dm_data->ds_jinhuo_hj->Eof)
    {

        if(dm_data->ds_xiaoshou_hj->Locate("code",dm_data->ds_jinhuo_hj->FieldValues["code"],opts))
        {
            lb->Cells[0][i]=IntToStr(i);
            lb->Cells[1][i]=dm_data->ds_jinhuo_hj->FieldValues["code"];
            lb->Cells[2][i]=dm_data->ds_jinhuo_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_hj->FieldValues["shuliang0"];
            lb->Cells[6][i]=dm_data->ds_jinhuo_hj->FieldValues["shuliang0"]-dm_data->ds_xiaoshou_hj->FieldValues["shuliang0"];
            lb->Cells[7][i]=dm_data->ds_jinhuo_hj->FieldValues["jinjia0"];
            lb->Cells[8][i]=FormatFloat("0.00",StrToFloat(lb->Cells[7][i])*StrToInt(lb->Cells[6][i]));
        }
        else
        {
            lb->Cells[0][i]=IntToStr(i);
            lb->Cells[1][i]=dm_data->ds_jinhuo_hj->FieldValues["code"];
            lb->Cells[2][i]=dm_data->ds_jinhuo_hj->FieldValues["name0"];
            lb->Cells[3][i]="0";
            lb->Cells[4][i]="0";
            lb->Cells[5][i]=dm_data->ds_jinhuo_hj->FieldValues["shuliang0"];
            lb->Cells[6][i]=dm_data->ds_jinhuo_hj->FieldValues["shuliang0"];
            lb->Cells[7][i]=dm_data->ds_jinhuo_hj->FieldValues["jinjia0"];
            lb->Cells[8][i]=FormatFloat("0.00",StrToFloat(lb->Cells[7][i])*StrToInt(lb->Cells[6][i]));
        }
        shoushu+=StrToInt(lb->Cells[3][i]);
        shoujine+=StrToFloat(lb->Cells[4][i]);
        jinshu+=StrToInt(lb->Cells[5][i]);
        censhu+=StrToInt(lb->Cells[6][i]);
        cenjine+=StrToFloat(lb->Cells[8][i]);
        dm_data->ds_jinhuo_hj->Next();
        lb->RowCount++;
        i++;
    }
    if(lb->RowCount>2)
        lb->RowCount--;
    else
        for(int j=1;j<=6;j++)
            lb->Cells[j][1]="";
    shoushus->Text=shoushu;
    jinshus->Text=jinshu;
    censhus->Text=censhu;
    shoujines->Text=FormatFloat("0.00",shoujine);
    cenjines->Text=FormatFloat("0.00",cenjine);
    if(showjin->Checked==false)
    {
        lb->ColCount=7;
        cenjines->Visible=false;
    }
    else
    {
        lb->ColCount=9;
        cenjines->Visible=true;
    }

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

⌨️ 快捷键说明

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