//----------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "main.h"
#include "CustomManage.h"
#include "GoodManage.h"
#include "SaleManage.h"
#include "selectstore.h"
//----------------------------------------------------------------------------
#pragma resource "*.dfm"
TfmSaleManage *fmSaleManage;
//----------------------------------------------------------------------------
__fastcall TfmSaleManage::TfmSaleManage(TComponent *Owner)
: TForm(Owner)
{
}
//----------------------------------------------------------------------------
void __fastcall TfmSaleManage::FormCreate(TObject *Sender)
{
// 设置明细列表的内容
sgPurDetail->Cells[0][0] = "序号";
sgPurDetail->ColWidths[0] = 32;
sgPurDetail->Cells[1][0] = "货号(双击)";
sgPurDetail->ColWidths[1] = 84;
sgPurDetail->Cells[2][0] = "品名";
sgPurDetail->ColWidths[2] = 128;
sgPurDetail->Cells[3][0] = "单位";
sgPurDetail->ColWidths[3] = 32;
sgPurDetail->Cells[4][0] = "数量";
sgPurDetail->ColWidths[4] = 64;
sgPurDetail->Cells[5][0] = "仓库(双击)";
sgPurDetail->ColWidths[5] = 64;
sgPurDetail->Cells[6][0] = "单价";
sgPurDetail->ColWidths[6] = 64;
sgPurDetail->Cells[7][0] = "金额";
sgPurDetail->ColWidths[7] = 64;
sgPurDetail->Cells[8][0] = "税率";
sgPurDetail->ColWidths[8] = 32;
sgPurDetail->Cells[9][0] = "税额";
sgPurDetail->ColWidths[9] = 64;
sgPurDetail->Cells[10][0] = "不含税额";
sgPurDetail->ColWidths[10] = 64;
// 设置序号
for(int i=1;i<30; i++)
{
sgPurDetail->Cells[0][i] = i;
}
// 自动调用btNewClick方法,新建销售单
btNewClick(NULL);
m_CurrentCol = 1;
m_CurrentRow = 1;
}
//---------------------------------------------------------------------------
void __fastcall TfmSaleManage::FormClose(TObject *Sender,
TCloseAction &Action)
{
// 删除窗体并回收空间
Action = caFree;
}
//---------------------------------------------------------------------------
void __fastcall TfmSaleManage::cboCustomCodeDropDown(TObject *Sender)
{
// 弹出客户窗体,供用户选择客户
TfmCustomManage *pForm = new TfmCustomManage(Application);
// 改窗口不应可以编辑,把table的可以编辑属性关闭
pForm->DBNavigator->Enabled = false;
pForm->DataSource1->AutoEdit = false;
pForm->FormStyle = fsNormal;
pForm->WindowState = wsNormal;
pForm->m_Input = true;
pForm->Visible = false;
pForm->Position = poScreenCenter;
pForm->ShowModal();
// 赋予客户编号
if(!pForm->m_szSelectCode.IsEmpty())
cboCustomCode->Text = pForm->m_szSelectCode;
delete pForm;
this->Refresh();
// 获取客户信息
cboCustomCodeChange(NULL);
}
//---------------------------------------------------------------------------
void __fastcall TfmSaleManage::cboCustomCodeChange(TObject *Sender)
{
// 获取客户信息
Query2->Close();
Query2->SQL->Clear();
Query2->SQL->Add("select 名称 from 客户清单 where 客户编号='"
+ cboCustomCode->Text + "'");
Query2->Open();
if(Query2->RecordCount > 0)
{
edCustomName->Text = Query2->FieldByName("名称")->AsString;
}
Query2->Close();
}
//---------------------------------------------------------------------------
void __fastcall TfmSaleManage::sgPurDetailDblClick(TObject *Sender)
{
// 第二列双击,选择商品; 双击第五列,选择仓库
if(sgPurDetail->Col != 1 && sgPurDetail->Col != 5 ) return;
if(sgPurDetail->Col == 1)
{
// 弹出客户窗体,供用户选择客户
TfmGoodManage *pForm = new TfmGoodManage(Application);
// 改窗口不应可以编辑,把table的可以编辑属性关闭
pForm->DBNavigator->Enabled = false;
pForm->DataSource1->AutoEdit = false;
pForm->FormStyle = fsNormal;
pForm->WindowState = wsNormal;
pForm->m_Input = true;
pForm->Visible = false;
pForm->Position = poScreenCenter;
pForm->ShowModal();
// 赋予客户编号
if(!pForm->m_szSelectCode.IsEmpty())
{
sgPurDetail->Cells[1][sgPurDetail->Row] = pForm->m_szSelectCode;
// 获取商品商信息
sgPurDetail->Col = 4;
}
delete pForm;
this->Refresh();
}
if(sgPurDetail->Col == 5)
{
// 弹出选择仓库窗体,供用户选择仓库
TfmSelectStore *pForm = new TfmSelectStore(Application);
// 改窗口不应可以编辑,把table的可以编辑属性关闭
pForm->Position = poScreenCenter;
pForm->m_szGoodID = sgPurDetail->Cells[1][sgPurDetail->Row];
// 查询指定货号的商品库存信息
pForm->Query1->SQL->Clear();
AnsiString sql;
sql = "select 仓库,库存数量 from 库存库 where 货号='";
sql += sgPurDetail->Cells[1][sgPurDetail->Row] + "'";
pForm->Query1->SQL->Add(sql);
pForm->Query1->Open();
pForm->ShowModal();
// 赋予选择的仓库
if(!pForm->m_szSelectStore.IsEmpty())
{
sgPurDetail->Cells[5][sgPurDetail->Row] = pForm->m_szSelectStore;
// 如果需要检查销售数量不能大于库存数量,在此保存仓库的库存数量
// 并在保存按钮的单击事件中作检查就可以了
}
delete pForm;
this->Refresh();
}
}
//---------------------------------------------------------------------------
void __fastcall TfmSaleManage::sgPurDetailSelectCell(TObject *Sender,
int ACol, int ARow, bool &CanSelect)
{
if(ACol==2 || ACol==3 || (ACol>=7 && ACol<=10)) // 不可以编辑的列
CanSelect = false;
// 根据货号更新商品信息
if(m_CurrentCol == 1)
{
Query2->Close();
Query2->SQL->Clear();
Query2->SQL->Add("select 品名,单位 from 商品清单 where 货号='"
+ sgPurDetail->Cells[1][m_CurrentRow] + "'");
Query2->Open();
if(Query2->RecordCount > 0)
{
sgPurDetail->Cells[2][m_CurrentRow] = Query2->FieldByName("品名")->AsString;
sgPurDetail->Cells[3][m_CurrentRow] = Query2->FieldByName("单位")->AsString;
// 默认税率为17
sgPurDetail->Cells[8][m_CurrentRow] = "17";
}
Query2->Close();
}
else if((m_CurrentCol == 4 || m_CurrentCol == 6) &&
!sgPurDetail->Cells[4][m_CurrentRow].IsEmpty() &&
!sgPurDetail->Cells[6][m_CurrentRow].IsEmpty()) // 计算金额
{
double fTotalMoney, fNoTax, fTax, fTaxRatio;
fTaxRatio = StrToFloat(sgPurDetail->Cells[8][m_CurrentRow]);
// 不含税金额
fTotalMoney = StrToFloat(sgPurDetail->Cells[4][m_CurrentRow]) *
StrToFloat(sgPurDetail->Cells[6][m_CurrentRow]);
fNoTax = fTotalMoney/(1+fTaxRatio/100);
fTax = fTotalMoney - fNoTax;
sgPurDetail->Cells[7][m_CurrentRow] = FormatFloat("0.00",fTotalMoney);
sgPurDetail->Cells[9][m_CurrentRow] = FormatFloat("0.00",fTax);
sgPurDetail->Cells[10][m_CurrentRow] = FormatFloat("0.00",fNoTax);
// 计算汇总信息
fTotalMoney = 0;
fTax = 0;
fNoTax = 0;
for(int i=1; i<30; i++)
{
if(!sgPurDetail->Cells[7][i].IsEmpty())
{
fTotalMoney += StrToFloat(sgPurDetail->Cells[7][i]);
fTax += StrToFloat(sgPurDetail->Cells[9][i]);
fNoTax += StrToFloat(sgPurDetail->Cells[10][i]);
}
}
edTotal->Text = FormatFloat("0.00",fTotalMoney);
edTax->Text = FormatFloat("0.00",fTax);
edNoTax->Text = FormatFloat("0.00",fNoTax);
}
m_CurrentCol = ACol;
m_CurrentRow = ARow;
}
//---------------------------------------------------------------------------
void __fastcall TfmSaleManage::sgPurDetailKeyPress(TObject *Sender,
char &Key)
{
if(Key ==13)
{
// 跳到下一个单元格
if(m_Current
c++ builder数据库开发案例1
需积分: 0 30 浏览量
2008-12-25
11:11:52
上传
评论
收藏 9.09MB RAR 举报
zhoushan119
- 粉丝: 0
- 资源: 2
最新资源
- JSP Explorer 文件浏览器 v1.0-fileexplorer.zip
- JS+Flash让网页元素发光的插件 glow! 0.1-glow.zip
- JdonFramework开源框架 v5.1 Build20071025-jdonframework-5.1.zip
- 汽车行驶工况数据,excel,m文件
- Xshell6是一款功能强大的终端模拟器软件,主要用于远程管理和访问多种网络设备和服务器
- OPA548运放E/S脚使能后,输入电压为零时,输出电压为0.6V;电路如何设计才能使输出电压偏置为:0V
- MicrosoftRootCertificateAuthority2011.rar
- ISOSAE21434.D1-2020SAE美国汽车标准
- 奥比中光RGBD在JETSON ORIN NX的ROS程序
- SerialNumberUtil.java
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈