【delphi开源代码栏目提醒】:本文主要为网学会员提供F_StordOdd.pas,希望对需要F_StordOdd.pas网友有所帮助,学习一下!
unit F_StordOdd;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, DB, ADODB, ComCtrls, ExtCtrls, StdCtrls, Buttons, Grids;
type
TFrm_StordOdd = class(TForm)
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
Label5: TLabel;
SpeedButton1: TSpeedButton;
SpeedButton3: TSpeedButton;
Label6: TLabel;
Label7: TLabel;
Edit2: TEdit;
Edit3: TEdit;
Edit4: TEdit;
Edit5: TEdit;
StringGrid1: TStringGrid;
BitBtn1: TBitBtn;
BitBtn2: TBitBtn;
Edit6: TEdit;
Panel1: TPanel;
DateTimePicker1: TDateTimePicker;
procedure FormShow(Sender: TObject);
procedure StringGrid1Click(Sender: TObject);
procedure StringGrid1KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
procedure StringGrid1KeyPress(Sender: TObject; var Key: Char);
procedure StringGrid1KeyUp(Sender: TObject; var Key: Word;
Shift: TShiftState);
procedure SpeedButton3Click(Sender: TObject);
procedure StringGrid1SelectCell(Sender: TObject; ACol, ARow: Integer;
var CanSelect: Boolean);
procedure SpeedButton1Click(Sender: TObject);
procedure BitBtn2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Frm_StordOdd: TFrm_StordOdd;
strdbrows : Integer;
myrow : Integer;
implementation
uses F_AddStordOdd, F_Provider, F_Data, F_Main;
{$R *.dfm}
procedure TFrm_StordOdd.FormShow(Sender: TObject);
begin
Frm_Main.ModuleIfTrue(DataModule1.ADO_Pop,Frm_StordOdd);
DateTimePicker1.Date:=now();
with StringGrid1 do
begin
Cells[1,0]:='商品编号';
Cells[2,0]:='商品全称';
Cells[3,0]:='商品型号';
Cells[4,0]:='商品规格';
Cells[5,0]:='单位';
Cells[6,0]:='产地';
Cells[7,0]:='数量';
Cells[8,0]:='进货价';
Cells[9,0]:='金额';
end;
with DataModule1.ADOQuery1 do
begin
close;
SQl.Clear;
SQl.Add('select * from tb_warehouse_main');
Open;
end;
end;
procedure TFrm_StordOdd.StringGrid1Click(Sender: TObject);
var
xh:integer;
begin
inherited;
for xh:=1 to StringGrid1.RowCount do
begin
if (Trim(StringGrid1.Cells[1,xh])<>'') and (Trim(StringGrid1.Cells[7,xh])<>'') and (Trim(StringGrid1.Cells[8,xh])<>'')then
begin
StringGrid1.Cells[9,xh]:=format('%10.4f',[(strtofloat(StringGrid1.Cells[7,xh]) * strtofloat(StringGrid1.Cells[8,xh]))]);
end;
end;
end;
procedure TFrm_StordOdd.StringGrid1KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
if key=13 then
speedbutton3.Click;
end;
procedure TFrm_StordOdd.StringGrid1KeyPress(Sender: TObject;
var Key: Char);
begin
if not (key in ['0'..'9','.',#8]) then key:=#0;
end;
procedure TFrm_StordOdd.StringGrid1KeyUp(Sender: TObject; var Key: Word;
Shift: TShiftState);
var
xh:integer;
ss:real;
begin
inherited;
ss:=0;
stringgrid1.OnClick(sender);
for xh:=1 to StringGrid1.RowCount do
begin
if (Trim(StringGrid1.Cells[1,xh])<>'') and (Trim(StringGrid1.Cells[7,xh])<>'') and (Trim(StringGrid1.Cells[8,xh])<>'')then
begin
ss:=ss+ strtofloat(StringGrid1.Cells[9,xh]);
strdbrows:=xh;
end;
end;
panel1.Caption:=format('%10.4f',[ss]);
end;
procedure TFrm_StordOdd.SpeedButton3Click(Sender: TObject);
begin
Application.CreateForm(TFrm_AddStordOdd, Frm_AddStordOdd);
Frm_AddStordOdd.ShowModal;
Frm_AddStordOdd.Free;
end;
procedure TFrm_StordOdd.StringGrid1SelectCell(Sender: TObject; ACol,
ARow: Integer; var CanSelect: Boolean);
begin
if (Acol=7) or (Acol=8) then
stringgrid1.Options:=[goFixedVertLine,goFixedHorzLine,goVertLine,goHorzLine,goRangeSelect,goEditing]
else
stringgrid1.Options:=[goFixedVertLine,goFixedHorzLine,goVertLine,goHorzLine,goRangeSelect];
myrow:=ARow;
end;
procedure TFrm_StordOdd.SpeedButton1Click(Sender: TObject);
begin
Application.CreateForm(TFrm_Provider, Frm_Provider);
Frm_Provider.ShowModal;
Frm_Provider.Free;
end;
procedure TFrm_StordOdd.BitBtn2Click(Sender: TObject);
begin
while myrow<StringGrid1.RowCount-1 do
begin
StringGrid1.Rows[myrow] := StringGrid1.Rows[myrow+1];
Inc(myrow);
end;
StringGrid1.RowCount:= StringGrid1.RowCount-1;
end;
end.