【delphi开源代码栏目提醒】:网学会员为需要delphi开源代码的朋友们搜集整理了MC_CHPZGL.pas相关资料,希望对各位网友有所帮助!
unit MC_CHPZGL;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
ExtCtrls, StdCtrls, Buttons, Grids, Db, DBTables, DBGrids, Qrctrls,
QuickRpt;
type
TCHPZGL = class(TForm)
Label2: TLabel;
Label1: TLabel;
Shape1: TShape;
GroupBox1: TGroupBox;
Label3: TLabel;
Label4: TLabel;
Label5: TLabel;
Label6: TLabel;
Label9: TLabel;
Edit1: TEdit;
Panel1: TPanel;
Label7: TLabel;
Label8: TLabel;
Label10: TLabel;
Label11: TLabel;
Bevel1: TBevel;
BitBtn2: TBitBtn;
BitBtn3: TBitBtn;
BitBtn4: TBitBtn;
BitBtn1: TBitBtn;
StringGrid1: TStringGrid;
Query1: TQuery;
Query2: TQuery;
DBGrid1: TDBGrid;
DataSource1: TDataSource;
Query3: TQuery;
QuickRep1: TQuickRep;
PageHeaderBand1: TQRBand;
QRLabel1: TQRLabel;
QRLabel2: TQRLabel;
QRShape1: TQRShape;
QRLabel3: TQRLabel;
QRDBText1: TQRDBText;
QRLabel4: TQRLabel;
QRLabel5: TQRLabel;
QRLabel7: TQRLabel;
QRDBText3: TQRDBText;
QRShape3: TQRShape;
TitleBand1: TQRBand;
QRShape2: TQRShape;
QRLabel8: TQRLabel;
QRLabel9: TQRLabel;
QRLabel10: TQRLabel;
QRLabel11: TQRLabel;
QRLabel12: TQRLabel;
QRLabel13: TQRLabel;
QRLabel15: TQRLabel;
QRShape4: TQRShape;
QRShape5: TQRShape;
QRShape6: TQRShape;
QRShape7: TQRShape;
QRShape8: TQRShape;
QRShape9: TQRShape;
DetailBand1: TQRBand;
QRShape11: TQRShape;
QRShape12: TQRShape;
QRShape13: TQRShape;
QRShape14: TQRShape;
QRShape15: TQRShape;
QRShape16: TQRShape;
QRShape17: TQRShape;
QRDBText4: TQRDBText;
QRDBText5: TQRDBText;
QRDBText6: TQRDBText;
QRDBText7: TQRDBText;
QRDBText8: TQRDBText;
QRDBText9: TQRDBText;
QRDBText11: TQRDBText;
Query4: TQuery;
SummaryBand1: TQRBand;
QRShape19: TQRShape;
QRLabel16: TQRLabel;
QRDBText12: TQRDBText;
QRLabel17: TQRLabel;
QRExpr1: TQRExpr;
Query4BDEDesigner: TIntegerField;
Query4BDEDesigner2: TStringField;
Query4BDEDesigner3: TDateTimeField;
Query4BDEDesigner4: TIntegerField;
Query4BDEDesigner5: TStringField;
Query4BDEDesigner6: TStringField;
Query4BDEDesigner7: TIntegerField;
Query4BDEDesigner8: TFloatField;
Query4BDEDesigner9: TFloatField;
Query4BDEDesigner10: TStringField;
QRLabel14: TQRLabel;
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure FormShow(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure BitBtn1Click(Sender: TObject);
procedure Edit1KeyPress(Sender: TObject; var Key: Char);
procedure StringGrid1KeyPress(Sender: TObject; var Key: Char);
procedure DBGrid1KeyPress(Sender: TObject; var Key: Char);
procedure Edit1Enter(Sender: TObject);
procedure Edit1Exit(Sender: TObject);
procedure BitBtn3Click(Sender: TObject);
procedure BitBtn2Click(Sender: TObject);
procedure BitBtn4Click(Sender: TObject);
procedure QuickRep1Preview(Sender: TObject);
procedure StringGrid1KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
private
x,y:integer;
{ Private declarations }
public
{ Public declarations }
end;
var
CHPZGL: TCHPZGL;
implementation
uses MC_DYYLBrose;
{$R *.DFM}
procedure TCHPZGL.FormShow(Sender: TObject);
var a:integer;
begin
ANimateWindow(Handle,300,AW_SLIDE+AW_VER_NEGATIVE);
Label1.Refresh;
Label2.Refresh;
Shape1.Refresh;
GroupBox1.Refresh;
panel1.Refresh;
Bevel1.Refresh;
StringGrid1.Refresh;
For a:=1 to 100 do
begin
StringGrid1.Cells[0,a]:=IntToStr(a);
end;
end;
//设置 StringGrid1控件
procedure TCHPZGL.FormCreate(Sender: TObject);
begin
StringGrid1.Cells[1,0]:='商品编号';
StringGrid1.Cells[2,0]:='商品名称';
StringGrid1.Cells[3,0]:='单位';
StringGrid1.Cells[4,0]:='数量';
StringGrid1.Cells[5,0]:='单价';
StringGrid1.Cells[6,0]:='合计金额';
StringGrid1.Cells[7,0]:='商品说明';
StringGrid1.Cells[8,0]:='出货说明';
StringGrid1.Cells[9,0]:='所在仓库';
StringGrid1.Cells[10,0]:='编号';
end;
//出库登记
procedure TCHPZGL.BitBtn1Click(Sender: TObject);
var a,b:integer;
begin
For a:=1 to 100 do
begin
for b:=1 to 10 do
StringGrid1.Cells[b,a]:='';
end;
Label8.Caption:=DateToStr(Date);
Query1.Close;
Query1.SQL.Clear;
Query1.SQL.Add('select * From 出货历史单据表 Order by 单据编号 DESC');
Query1.Open;
if Query1.RecordCount=0 then Label4.Caption:='10000'
else Label4.Caption:=IntToStr(Query1.FieldByName('单据编号').AsInteger+1);
Query1.Close;
BitBtn2.Enabled:=True;
BitBtn4.Enabled:=True;
BitBtn1.Enabled:=False;
Edit1.Enabled:=True;
Edit1.SetFocus;
end;
//选择经手人
procedure TCHPZGL.Edit1KeyPress(Sender: TObject; var Key: Char);
begin
if Key=#13 then
begin
if Length(Edit1.Text)=0 then
begin
ShowMessage('请输入经手人.');
Edit1.Setfocus;
end
else
begin
Edit1.Enabled:=False;
StringGrid1.Enabled:=True;
StringGrid1.SetFocus;
end;
end;
end;
procedure TCHPZGL.StringGrid1KeyPress(Sender: TObject; var Key: Char);
var abc:Real;
a:integer;
begin
x:=StringGrid1.Row;//行变量x
y:=StringGrid1.Col;//列变量y
if key=#13 then
begin
//开始判断回车换行
if StringGrid1.Col<9 then StringGrid1.Col:=StringGrid1.Col+1
else
if StringGrid1.row<>100 then
begin
StringGrid1.row:=StringGrid1.row+1;
StringGrid1.Col:=1;
end;
//结束回车键换行的判断
//开始判断第一列
if y=1 then
begin
if Length(StringGrid1.Cells[1,x])<>0 then
begin
Query2.Close;
Query2.SQL.Clear;
Query2.SQL.Add('select * From 库存信息表');
Query2.SQL.Add('Where 商品编号 Like :A Order by 仓库名称 ASC,商品编号 ASC');
Query2.ParamByName('A').AsString:=StringGrid1.Cells[1,x]+'%';
Query2.Open;
DBGrid1.Visible:=True;
DBGrid1.SetFocus;
end;
end;
//结束第一列的判断
//开始第四列的判断
if y=4 then
begin
if Length(StringGrid1.Cells[2,x])<>0 then //当前商品名称不为空
if Length(StringGrid1.Cells[4,x])=0 then
begin
ShowMessage('请输入出货数量');
StringGrid1.Col:=4;
end
else
begin
StringGrid1.Cells[6,x]:=FloatToStr(StrToInt(StringGrid1.Cells[4,x])*StrToFloat(StringGrid1.Cells[5,x]));
end;
end;
//结束第四列的判断
//开始第五列的判断
if y=5 then
begin
if Length(StringGrid1.Cells[2,x])<>0 then //当前商品名称不为空
if Length(StringGrid1.Cells[5,x])=0 then
begin
ShowMessage('请输入出货数量');
StringGrid1.Col:=5;
end
else
begin
StringGrid1.Cells[6,x]:=FloatToStr(StrToInt(StringGrid1.Cells[4,x])*StrToFloat(StringGrid1.Cells[5,x]));
end;
end;
//结束第五列的判断
//开始第六列的判断
if y=6 then
begin
abc:=0;
for a:=1 to 100 do
begin
if Length(StringGrid1.Cells[6,a])<>0 then
abc:=abc+StrToFloat(StringGrid1.Cells[6,a]);
end;
Label11.Caption:=FloatToStr(abc);
end;
//结束第六列的判断
end;
//结束回车键的判断
if Length(StringGrid1.Cells[2,x-1])=0 then key:=#0//判断当前行的上一行是否为空
else
begin
//-判断是否是1,5,7,10列
if not ((y=1) or (y=4) or (y=5) or (y=8) or (y=10)) then key:=#0
上一篇:
MC_BTSZ_KT.pas
下一篇:
恋沫