【delphi开源代码栏目提醒】:网学会员为广大网友收集整理了,FormInput.pas,希望对大家有所帮助!
unit FormInput;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Grids, StdCtrls, ExtCtrls, DB, ADODB;
type
Tinput = class(TForm)
Panel1: TPanel;
Label1: TLabel;
Edit1: TEdit;
Label2: TLabel;
Edit2: TEdit;
Label3: TLabel;
ComboBox1: TComboBox;
ComboBox2: TComboBox;
Edit3: TEdit;
Label4: TLabel;
StringGrid1: TStringGrid;
ADOQuery1: TADOQuery;
ComboBox3: TComboBox;
Button1: TButton;
Label5: TLabel;
Edit4: TEdit;
Label6: TLabel;
Edit5: TEdit;
Label7: TLabel;
Edit6: TEdit;
Button2: TButton;
ADOCommand1: TADOCommand;
Button3: TButton;
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure FormShow(Sender: TObject);
procedure ComboBox2DropDown(Sender: TObject);
procedure StringGrid1DblClick(Sender: TObject);
procedure StringGrid1SelectCell(Sender: TObject; ACol, ARow: Integer;
var CanSelect: Boolean);
procedure FormCreate(Sender: TObject);
procedure StringGrid1MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
procedure ComboBox3Select(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
private
{ Private declarations }
public
//-------------设置选取的stringgrid单元成员的行,列值为public,以供其他窗体中调用-----------------
currentRow: integer;
currentCol:integer;
{ Public declarations }
end;
var
input: Tinput;
currentRow: integer;
currentCol:integer;
implementation
uses FormManage, FormInfo, FormReport;
{$R *.dfm}
//----------------关闭窗体时打开管理窗体----------------------------
procedure Tinput.FormClose(Sender: TObject; var Action: TCloseAction);
var i,j:integer;
begin
manage.show;
end;
//---------------窗体显示时设置当前值-------------------------
procedure Tinput.FormShow(Sender: TObject);
begin
//制表事件为当前日期
edit1.Text:=datetostr(date);
//制单人即登录用户
edit2.Text:=manage.StatusBar1.Panels[0].Text;
currentCol:=1;
currentRow:=1;
end;
//----------------动态添加供货商数据词典-----------------------
//--------供货商窗体中双击读入数据功能见供货商窗体的代码--------
procedure Tinput.ComboBox2DropDown(Sender: TObject);
begin
//显示供货商清单
info.visible:=true;
info.N3.Click;
//显示供货商清单时,不允许对进货单窗体进行操作
input.Enabled:=false;
end;
//----------双击货号列读入商品信息----------------------
procedure Tinput.StringGrid1DblClick(Sender: TObject);
begin
//只允许在第一列由“(双击)”标示处双击
if currentCol=1 then
begin
//显示商品清单
info.Visible:=true;
info.N2.Click;
//显示商品清单时,不允许对进货单窗体进行操作
input.Enabled:=false;
end;
end;
//------------------设置选取的单元行,列值--------------------------
//-----------------添加单价,数量等信息并根据这些信息进行计算---------
//-------------------将统计结果显示在窗体下方的文本框中-----------------
procedure Tinput.StringGrid1SelectCell(Sender: TObject; ACol,
ARow: Integer; var CanSelect: Boolean);
var
price,number,tax,sum:double;
j:integer;
begin
//读取选取的当前单元的行,列值
currentCol:=ACol;
currentRow:=ARow;
//只有当选取仓库时,动态下拉列表才显示
if (currentCol<>5) then
combobox3.Visible:=false;
//只有商品信息不为空时才可以输入单位和默认税率
if (currentCol=3)and(stringgrid1.Cells[2,currentRow]<>'') then
begin
adoquery1.Close;
adoquery1.SQL.Clear;
adoquery1.SQL.Add('select distinct 单位 from 商品清单 where 货号='''+stringgrid1.Cells[1,currentRow]+'''');
adoquery1.Open;
stringgrid1.Cells[3,currentRow]:=adoquery1.FieldByName('单位').AsString;
stringgrid1.Cells[8,currentRow]:='17';
end;
//--------------------当商品信息,数量,单价不为空时,才能进行计算------------------------
if (currentRow<>0)and(stringgrid1.Cells[1,currentRow]<>'')and(stringgrid1.Cells[4,currentRow]<>'')and(stringgrid1.Cells[6,currentRow]<>'')and(stringgrid1.Cells[5,currentRow]<>'') then
begin
//----------计算某条进货单明细的进货金额,税额和不含税额-----------------------
number:=strtofloat(stringgrid1.Cells[4,currentRow]);
price:=strtofloat(stringgrid1.Cells[6,currentRow]);
tax:=strtofloat(stringgrid1.Cells[8,currentRow])/100;
stringgrid1.Cells[7,currentRo