fout.pas.~295~
来自「delphi2007开发的汽车配件进销存系统.实用级的源码.」· ~295~ 代码 · 共 648 行 · 第 1/2 页
~295~
648 行
{*******************************************************}
{ }
{ 单证打印 }
{ Fout.pas 销售窗体
{ 2007-07-01 19:05:14
{ 独孤九剑 rhcgrys@sina.com }
{ 版权所有 (C) 2007 未来科技 }
{ }
{*******************************************************}
unit Fout;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, cxPC, cxControls, Menus, cxLookAndFeelPainters, StdCtrls, cxButtons,
cxContainer, cxEdit, cxGroupBox, GridsEh, DBGridEh, cxTextEdit, cxGraphics,
cxMaskEdit, cxDropDownEdit, cxLookupEdit, cxDBLookupEdit, cxDBLookupComboBox,
cxLabel, cxCheckBox, cxLookAndFeels, cxDBEdit,db, cxDBLabel, ADODB, frxClass,
frxDBSet, cxMemo;
type
Tfrmout = class(TForm)
cxPageControl1: TcxPageControl;
cxTabSheet1: TcxTabSheet;
cxButton1: TcxButton;
cxGroupBox1: TcxGroupBox;
cxGroupBox2: TcxGroupBox;
cxGroupBox3: TcxGroupBox;
cxTextEdit1: TcxTextEdit;
DBGridEh2: TDBGridEh;
DBGridEh1: TDBGridEh;
cxButton2: TcxButton;
cxButton3: TcxButton;
cxButton4: TcxButton;
cxTextEdit2: TcxTextEdit;
DBGridEh3: TDBGridEh;
cxButton6: TcxButton;
cxButton7: TcxButton;
cxLookAndFeelController1: TcxLookAndFeelController;
cxButton8: TcxButton;
cxLabel2: TcxLabel;
cxDBLabel1: TcxDBLabel;
cxLabel3: TcxLabel;
cxDBTextEdit2: TcxDBTextEdit;
cxDBTextEdit3: TcxDBTextEdit;
cxDBTextEdit4: TcxDBTextEdit;
cxDBTextEdit5: TcxDBTextEdit;
cxLabel4: TcxLabel;
cxLabel5: TcxLabel;
cxLabel6: TcxLabel;
cxLabel7: TcxLabel;
cxButton5: TcxButton;
frxReport1: TfrxReport;
frxDBDataset1: TfrxDBDataset;
frxDBDataset2: TfrxDBDataset;
Memo1: TMemo;
frxDBDataset3: TfrxDBDataset;
procedure cxButton1Click(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure cxTextEdit1Click(Sender: TObject);
procedure cxTextEdit1KeyUp(Sender: TObject; var Key: Word;
Shift: TShiftState);
procedure FormCreate(Sender: TObject);
procedure DBGridEh3CellClick(Column: TColumnEh);
procedure cxButton7Click(Sender: TObject);
procedure DBGridEh1CellClick(Column: TColumnEh);
procedure DBGridEh1KeyPress(Sender: TObject; var Key: Char);
procedure DBGridEh1DrawColumnCell(Sender: TObject; const Rect: TRect;
DataCol: Integer; Column: TColumnEh; State: TGridDrawState);
procedure DBGridEh1ColExit(Sender: TObject);
procedure cxButton2Click(Sender: TObject);
procedure DBGridEh1Columns2UpdateData(Sender: TObject; var Text: string;
var Value: Variant; var UseText, Handled: Boolean);
procedure DBGridEh1DrawDataCell(Sender: TObject; const Rect: TRect;
Field: TField; State: TGridDrawState);
procedure cxButton3Click(Sender: TObject);
procedure cxButton8Click(Sender: TObject);
procedure cxButton6Click(Sender: TObject);
procedure DBGridEh2DblClick(Sender: TObject);
procedure DBGridEh3Enter(Sender: TObject);
procedure RefreshTable;
procedure cxButton5Click(Sender: TObject);
procedure cxTextEdit2Click(Sender: TObject);
procedure cxTextEdit2KeyUp(Sender: TObject; var Key: Word;
Shift: TShiftState);
procedure cxButton4Click(Sender: TObject);
procedure DBGridEh1Exit(Sender: TObject);
procedure CreatePrintFile(ph:string);
private
{ Private declarations }
public
{ Public declarations }
end;
var
frmout: Tfrmout;
s_xsdh:string;
implementation
uses UDM, Fkhgl, Foutadd;
{$R *.dfm}
procedure CreateTempTable();
begin
with dm.connqry do begin
close;
with sql do begin
clear;
add('CREATE TABLE ');
add(Trim(s_xsdh));
add('(');
add(' [xsdh] [varchar](15) NULL, ');
add(' [bm] [varchar](30) NOT NULL, ');
add(' [pm] [nvarchar](50) NULL, ');
add(' [gg] [nchar](15) NULL, ');
add(' [cd] [varchar](50) NULL, ');
add(' [sl] [float] NOT NULL, ');
add(' [jj] [money] NULL, ');
add(' [dj] [money] NOT NULL, ');
add(' [je] [money] NULL ');
add(') ON [PRIMARY] ');
end;
ExecSQL;
end;
end;
procedure Tfrmout.CreatePrintFile(ph:string);
var
s1,S2,S3:string;
begin
//<TfrxReportPage Name="Page1" PaperWidth="210" PaperHeight="2000" PaperSize="256" LeftMargin="10" RightMargin="10" TopMargin="7" BottomMargin="7" ColumnWidth="0" ColumnPositions.Text="" HGuides.Text="" VGuides.Text="">
S1:=' <TfrxReportPage Name="Page1" PaperWidth="210" PaperHeight=';
S2:=' PaperSize="256" LeftMargin="10" RightMargin="10" '+
'TopMargin="7" BottomMargin="7" ColumnWidth="0" '+
'ColumnPositions.Text="" HGuides.Text="" VGuides.Text="">';
S3:='"'+ph+'"';
Memo1.Lines.Strings[3]:= S1+S3+S2;
Memo1.Lines.SaveToFile('.\report\print.fr3');
end;
procedure Tfrmout.cxButton1Click(Sender: TObject);
begin
close;
end;
procedure Tfrmout.cxButton2Click(Sender: TObject);
begin
if dm.qry8.RecordCount>0 then
begin
if Application.MessageBox('删除选择的记录吗?', '提示信息', MB_OKCANCEL +
MB_ICONQUESTION) = IDOK then
begin
dm.qry8.Delete;
end
end
else
showmessage('操作员不要开玩笑了好不?现在已无记录可以删除了!');
end;
procedure Tfrmout.cxButton3Click(Sender: TObject);
begin
//取销售单号
s_xsdh:=FormatDateTime('"XS"YYMMDDHHMMss',now);
cxLabel3.Caption:= s_xsdh;
//先建立表,然后连接
CreateTempTable;
with dm.qry8 do begin
Close;
with sql do begin
Clear;
add('select * from ');
add(trim(s_xsdh));
end;
open;
end;
//选择单位
frmKHGL.BorderStyle:=bsNone;
frmkhgl.ShowModal;
//关闭
dm.qry5.Close;
with dm.connqry do begin
close;
with sql do begin
clear;
add('insert into xsd(xsdh,dwbm,xsrq) values(:p_xsdh,:p_dwbm,:p_xsrq)');
end;
Parameters.ParamByName('p_xsdh').value:=s_xsdh;
Parameters.ParamByName('p_xsrq').value:=FormatDateTime('YYYY-MM-DD',now);
Parameters.ParamByName('p_dwbm').value:=dm.qry7.FieldByName('dwbm').AsString;
ExecSQL;
end;
//打开
dm.qry5.Open;;
DBGridEh1.ReadOnly:=false;
cxbutton8.Enabled:=true;
cxbutton2.Enabled:=true;
cxbutton4.Enabled:=false;
cxButton5.Enabled := true;
end;
procedure Tfrmout.cxButton4Click(Sender: TObject);
begin
with DM.qryPrint do begin
Close;
with SQL do begin
Clear;
Add('select a.*,b.dw,b.hw from '+Trim(cxLabel3.Caption)+' a');
Add(',spxx b where a.bm=b.bm order by a.gg');
end;
Open;
end;
with DM.qryPrint1 do begin
Close;
with SQL do begin
Clear;
Add('select a.*,b.* from xsd a,dwgl b where '
+' a.dwbm=b.dwbm and a.xsdh =:p_xsdh');
end;
Parameters.ParamByName('p_xsdh').Value := DM.qry5.FieldByName('xsdh').Value;
Open;
end;
Memo1.Lines.Clear;
Memo1.Lines.LoadFromFile('.\report\Tprint-1.fr3');
if DM.qryPrint.RecordCount<=1 then
CreatePrintFile('77')
else begin
CreatePrintFile(IntToStr((DM.qryPrint.RecordCount-1)*6+77));
end;
frxReport1.LoadFromFile('.\report\print.fr3');
frxReport1.ShowReport(true);
end;
procedure Tfrmout.cxButton5Click(Sender: TObject);
var
I: Integer;
begin
//结帐出库
dm.qry8.First;
for I := 0 to dm.qry8.RecordCount - 1 do begin
with dm.connqry do begin
close;
with sql do begin
clear;
add('update kcxx set sl=sl-:p_sl where bm=:p_bm');
end;
Parameters.ParamByName('p_sl').Value := dm.qry8.FieldByName('sl').Value;
Parameters.ParamByName('p_bm').Value := dm.qry8.FieldByName('bm').asstring;
try
ExecSQL;
except
showmessage('结帐过程中出错');
end;
end;
//更新配件显示
DM.qry8.Next;
dm.qry3.Refresh;
end;
//修改标志
with dm.connqry do begin
close;
with sql do begin
clear;
add('update xsd set jzbz=''Y'' where xsdh=:p_xsdh');
end;
Parameters.ParamByName('p_xsdh').Value:=trim(cxlabel3.Caption);
ExecSQL;
end;
//更新销售单
dm.qry5.Refresh;
//结账按钮状态
cxButton5.Enabled := false;
//所用产品加入到XSDMC以备统计用
if DM.qry8.RecordCount>0 then begin
DM.qry8.First;
for I := 1 to DM.qry8.RecordCount do begin
with DM.connqry do begin
close;
with SQL do begin
clear;
Add('insert into xsdmx(xsdh,bm,pm,sl,dj,je) ');
Add('values(:p_xsdh,:p_bm,:p_pm,:p_sl,:p_dj,:p_je)');
end;
Parameters.ParamByName('p_xsdh').Value:=Trim(cxLabel3.Caption);
Parameters.ParamByName('p_bm').Value:=DM.qry8.FieldByName('bm').Value;
if DM.qry8.FieldByName('pm').Value='' then
Parameters.ParamByName('p_pm').Value:='无'
else
Parameters.ParamByName('p_pm').Value:=DM.qry8.FieldByName('pm').Value;
Parameters.ParamByName('p_sl').Value:=DM.qry8.FieldByName('sl').Value;
Parameters.ParamByName('p_dj').Value:=DM.qry8.FieldByName('dj').Value;
Parameters.ParamByName('p_je').Value:=DM.qry8.FieldByName('je').Value;
ExecSQL;
end;
dm.qry8.next;
end;
end;
end;
procedure Tfrmout.cxButton6Click(Sender: TObject);
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?