【delphi开源代码栏目提醒】:网学会员鉴于大家对delphi开源代码十分关注,论文会员在此为大家搜集整理了“Bill.pas”一文,供大家参考学习
unit Bill;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ComCtrls, Buttons, ExtCtrls, RzPanel;
type
TBillForm = class(TForm)
SpeedButton1: TSpeedButton;
SpeedButton2: TSpeedButton;
RzGroupBox1: TRzGroupBox;
Label4: TLabel;
Memo1: TMemo;
ComboBox2: TComboBox;
Label5: TLabel;
Label3: TLabel;
DateTimePicker1: TDateTimePicker;
Label2: TLabel;
ComboBox1: TComboBox;
Label1: TLabel;
Edit1: TEdit;
SpeedButton3: TSpeedButton;
procedure SpeedButton1Click(Sender: TObject);
procedure SpeedButton2Click(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure SpeedButton3Click(Sender: TObject);
private
{ Private declarations }
procedure GetAccountList;
function GetCID(OrderId:string):integer;
public
{ Public declarations }
end;
var
BillForm: TBillForm;
implementation
uses BillList,inc, POSIIDM;
{$R *.dfm}
procedure TBillForm.SpeedButton1Click(Sender: TObject);
var
sqlStr:string;
begin
if (AccountType=BuyIn) or (AccountType=SellOut) then begin//判断进货还是销售
if Edit1.Text ='' then begin
MessageDlg('请输入具体的单号', mtInformation,[mbOk], 0);
Exit;
end;
if Combobox2.Text ='' then begin
MessageDlg('请选择交易对象', mtInformation,[mbOk], 0);
Exit;
end;
end else begin
if Combobox2.Text ='' then begin
MessageDlg('请输入具体的单号', mtInformation,[mbOk], 0);
Exit;
end;
end;
if attr='Edit' then begin//编辑状态下
sqlStr:='select * from Orders where S_O_EXIST=0 AND S_O_ID='+MyOrder.OID;
with DM.HumanResQuery do begin
Close;
SQL.Clear;
SQL.Add(sqlStr);
Open;
Edit;
FieldValues['S_O_SERIAL']:=Edit1.Text;
MyOrder.SeriesNO :=Edit1.Text;//对全局变量进行赋值
FieldValues['S_O_DATE']:=DateTimePicker1.DateTime;
FieldValues['S_O_E_ID']:=GetEmpID(Combobox1.text);
FieldValues['S_O_REMARK']:=Memo1.Text;
case AccountType of
BuyIn:begin
FieldValues['S_O_C_ID']:=GetMacID(Combobox2.text);//获取供货商编号
FieldValues['S_O_TYPE']:=1;
end;
SellOut:begin
FieldValues['S_O_C_ID']:=GetCustID(Combobox2.text);//获取客户编号
FieldValues['S_O_TYPE']:=3;
end;
InHandBack:begin
FieldValues['S_O_C_ID']:=GetMacID(Combobox2.text);
FieldValues['S_O_TYPE']:=2;
end;
OutHandBack:begin
FieldValues['S_O_C_ID']:=GetCustID(Combobox2.text);
FieldValues['S_O_TYPE']:=4;
end;
end;
Post;
end;
end else begin
if (AccountType=BuyIn) or (AccountType=SellOut) then
sqlStr:='select * from Orders where S_O_EXIST=0 AND S_O_SERIAL='''+Edit1.Text+''''
else
sqlStr:='select * from Orders WHERE S_O_EXIST=0';
with DM.HumanResQuery do begin
Close;
SQL.Clear;
SQL.Add(sqlStr);
Open;
Edit;
Append;
case AccountType of
BuyIn:begin
if Not Eof then begin//判断时候帐簿中是否已经存在相同的编号
MessageDlg('帐簿中已经有单号为:'+Edit1.Text+',请重新输入', mtInformation,[mbOk], 0);
Exit;
end;
FieldValues['S_O_SERIAL']:=Edit1.Text;
MyOrder.SeriesNO :=Edit1.Text;
FieldValues['S_O_TYPE']:=1;
FieldValues['S_O_E_ID']:=GetEmpID(Combobox1.text);
FieldValues['S_O_C_ID']:=GetMacID(Combobox2.text);
end;
InHandBack:begin
if Combobox2.Text ='' then begin//判断是否存在指定的编号进行退货
MessageDlg('帐簿中没有可以退货的单号,请重新选择', mtInformation,[mbOk], 0);
Exit;
end;
FieldValues['S_O_SERIAL']:=Combobox2.Text;
MyOrder.SeriesNO :=Combobox2.Text;
FieldValues['S_O_E_ID']:=GetEmpID(Combobox1.text);
FieldValues['S_O_C_ID']:=GetCID(Combobox2.text);
FieldValues['S_O_TYPE']:=2;
end;
SellOut:begin
if Not Eof then begin
MessageDlg('帐簿中已经有单号为:'+Edit1.Text+',请重新输入', mtInformation,[mbOk], 0);
Exit;
end;
FieldValues['S_O_SERIAL']:=Edit1.Text;
MyOrder.SeriesNO :=Edit1.Text;
FieldValues['S_O_E_ID']:=GetEmpID(Combobox1.text);
FieldValues['S_O_C_ID']:=GetCustID(Combobox2.text);
FieldValues['S_O_TYPE']:=3;
end;
OutHandBack:begin
if Combobox2.Text ='' then begin
MessageDlg('帐簿中没有可以退货的单号,请重新选择', mtInformation,[mbOk], 0);
Exit;
end;
FieldValues['S_O_SERIAL']:=Combobox2.text;
MyOrder.SeriesNO :=Combobox2.Text;
FieldValues['S_O_E_ID']:=GetEmpID(Combobox1.text);
FieldValues['S_O_C_ID']:=GetCID(Combobox2.text);
FieldValues['S_O_TYPE']:=4;
end;
end;
FieldValues['S_O_DATE']:=DateTimePicker1.DateTime;
FieldValues['S_O_REMARK']:=Memo1.Text;
Post;
SQL.Clear;
SQL.Add('select MAX(S_O_ID) AS S_O_ID from Orders');
Open;
MyOrder.OID :=FieldValues['S_O_ID'];
end;
end;
MyOrder.EmpName :=Combobox1.Text;
MyOrder.OrderDate :=DateTimePicker1.DateTime;
SetLogs('更新帐单信息操作');//操作日志记录
Close;
BillListForm:=TBillListForm.Create(Self);//调用窗体创建过程
BillListForm.ShowModal;//显示窗体
end;
procedure TBillForm.SpeedButton2Click(Sender: TObject);
begin
Close;
end;
procedure TBillForm.FormShow(Sender: TObject);
var
sqlStr,vStr:string;
vSerial,vRemark,vEName,vCName:string;
vDate:TDateTime;
i:integer;
begin
//BillForm.Caption :=BillTitle;
Edit1.Enabled :=true;
Combobox1.Items.Clear;
Combobox1.Items.AddStrings(GetEmpList);//获取员工列表
Combobox1.ItemIndex :=0;
if attr='Edit' then begin//判断是否是编辑状态下
if (AccountType=BuyIn) or (AccountType=InHandBack) then begin//进货或进货退货
if AccountType=BuyIn then
vStr:=' and S_O_TYPE=1'
else
vStr:=' and S_O_TYPE=2';
sqlStr:='select S_O_ID,S_O_SERIAL,S_O_DATE,S_O_REMARK,E_NAME,M_NAME from Orders '+
'O,Employees E,Manufactory M where O.S_O_C_ID=M.M_ID and O.S_O_E_ID=E.E_ID AND O.S_O_EXIST=0 '+
'and S_O_SERIAL='''+SelName+''''+vStr;
end else begin
if AccountType=SellOut then//销售
vStr:=' and S_O_TYPE=3'
else
vStr:=' and S_O_TYPE=4';//销售退货
sqlStr:='select S_O_ID,S_O_SERIAL,S_O_DATE,S_O_REMARK,E_NAME,C_NAME from Orders '+
'O,Employees E,Customers C where O.S_O_C_ID=C.C_ID and O.S_O_E_ID=E.E_ID AND O.S_O_EXIST=0 '+
'and S_O_SERIAL='''+SelName+''''+vStr;
end;
with DM.HumanResQuery do begin
Close;
SQL.Clear;
SQL.Add(sqlStr);
Open;
if Eof then Exit;
MyOrder.OID :=FieldValues['S_O_ID'];
vSerial:=FieldValues['S_O_SERIAL'];
vRemark:=FieldValues['S_O_REMARK'];
vEName :=FieldValues['E_NAME'];
if (AccountType=BuyIn) or (AccountType=InHandBack) then
vCName :=FieldValues['M_NAME']
else
vCName :=FieldValues['C_NAME'];
vDate :=FieldValues['S_O_DATE'];
end;
end;
//===========================================================================
if attr='Edit' then
if (AccountType=BuyIn) or (AccountType=InHandBack) then begin
Edit1.Left :=64;//定义窗体
上一篇:
DigitalStatic.cpp
下一篇:
百公里油耗仅6.45L,哈弗F7智能节油赛燃“擎”登陆石家庄