?? drwhunt.pas
字號:
unit drwhunt;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ComCtrls, Grids, DBGridEh, StdCtrls, Buttons, DB, ExtCtrls,
BaseGrid, AdvGrid;
type
Tdrwhfrm = class(TForm)
GroupBox1: TGroupBox;
AdvStringGrid1: TAdvStringGrid;
AdvStringGrid2: TAdvStringGrid;
GroupBox4: TGroupBox;
Label1: TLabel;
Edit3: TEdit;
BitBtn2: TBitBtn;
Timer1: TTimer;
BitBtn1: TBitBtn;
BitBtn3: TBitBtn;
GroupBox2: TGroupBox;
Label2: TLabel;
DateTimePicker1: TDateTimePicker;
BitBtn4: TBitBtn;
ComboBox1: TComboBox;
procedure BitBtn5Click(Sender: TObject);
procedure BitBtn1Click(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure BitBtn3Click(Sender: TObject);
procedure FormActivate(Sender: TObject);
procedure FormKeyPress(Sender: TObject; var Key: Char);
procedure Edit3Enter(Sender: TObject);
procedure Edit3Exit(Sender: TObject);
procedure Timer1Timer(Sender: TObject);
procedure BitBtn4Click(Sender: TObject);
procedure ComboBox1Change(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
drwhfrm: Tdrwhfrm;
implementation
uses data;
{$R *.dfm}
var
drm:integer;
dcdj:string;
procedure Tdrwhfrm.BitBtn5Click(Sender: TObject);
var
m:integer;
begin
if edit3.Text='' then exit;
dcdj:=trim(edit3.Text);
with dataman.dbQuery do
begin
close;
sql.Clear;
sql.Add('select 貨物條形碼,單價,數(shù)量,金額 from movein where 進貨單據(jù)號='''+edit3.text+'''');
sql.Add('order by 貨物條形碼 DESC');
prepared;
open;
end;
if dataman.dbQuery.IsEmpty then
showmessage('沒有單據(jù)號為'+trim(edit3.Text)+'的單據(jù)')
else
begin
m:=1;
dataman.dbquery.first;
while not dataman.dbquery.eof do
begin
advstringgrid1.cells[1,m]:=dataman.dbquery.fields[0].value;
advstringgrid1.cells[2,m]:=dataman.dbquery.fields[1].asstring;
advstringgrid1.cells[3,m]:=dataman.dbquery.fields[2].asstring;
advstringgrid1.cells[4,m]:=dataman.dbquery.fields[3].asstring;
advstringgrid2.cells[0,m]:=dataman.dbquery.fields[2].asstring;
dataman.dbquery.next;
inc(m);
drm:=m;
end;
end;
end;
procedure Tdrwhfrm.BitBtn1Click(Sender: TObject);
var
l,qualityt:integer;
totalt:real;
begin
timer1.Enabled:=false;
qualityt:=0;
totalt:=0;
try
if messagedlg('確定要修改此條記錄?',mtwarning,[mbyes,mbno],0)=mryes then
begin
dataman.ADOCon.BeginTrans;
//更新進貨單據(jù)表
for l:=1 to drm do
begin
if trim(advstringgrid1.Cells[1,l])='' then break;
qualityt:=strtoint(advstringgrid1.cells[3,l])+qualityt;
totalt:=strtoint(advstringgrid1.Cells[4,l])+totalt;
end;
with dataman.dbQuery do
begin
close;
sql.Clear;
sql.Add('update moveinm');
sql.Add('set 進貨數(shù)量=:wgno,進貨金額=:tje');
sql.Add('where 進貨單據(jù)號='''+dcdj+'''');
parameters.ParamByName('wgno').Value:=qualityt;
parameters.ParamByName('tje').Value:=totalt;
prepared;
execsql;
//修改進貨明細表
close;
sql.Clear;
for l:=1 to drm do
begin
if trim(advstringgrid1.Cells[1,l])='' then break;
sql.Add('update movein');
sql.add('set 單價=:dj,數(shù)量=:qu,金額=:total');
sql.Add('where 進貨單據(jù)號='''+trim(dcdj)+''' and 貨物條形碼='''+trim(advstringgrid1.Cells[1,l])+'''');
parameters.ParamByName('dj').Value:=strtofloat(trim(advstringgrid1.cells[2,l]));
parameters.ParamByName('qu').Value:=strtoint(trim(advstringgrid1.Cells[3,l]));
parameters.ParamByName('total').Value:=strtofloat(trim(advstringgrid1.Cells[4,l]));
execsql;
end;
//修改庫存
close;
sql.Clear;
for l:=1 to drm do
begin
if trim(advstringgrid1.Cells[1,l])='' then break;
sql.Add('update kc set 庫存數(shù)量=庫存數(shù)量+:thno where 貨物條形碼='''+trim(advstringgrid1.Cells[1,l])+'''');
parameters.ParamByName('thno').Value:=strtoint(advstringgrid1.Cells[3,l])-strtoint(advstringgrid2.Cells[0,l]);
execsql;
end;
end;
dataman.ADOCon.CommitTrans;
showmessage('調(diào)入單據(jù)號'+dcdj+'修改成功!');
end;
except
dataman.ADOCon.RollbackTrans;
messagedlg('對不起!失敗了!',mtconfirmation,[mbok],0);
end;
end;
procedure Tdrwhfrm.FormClose(Sender: TObject; var Action: TCloseAction);
begin
inherited;
drwhfrm:=nil;
drwhfrm.Free;
end;
procedure Tdrwhfrm.BitBtn3Click(Sender: TObject);
begin
close;
end;
procedure Tdrwhfrm.FormActivate(Sender: TObject);
var
n:integer;
begin
dataman.dcQuery.Active:=false;
for n:=1 to 8 do
advstringgrid1.Cells[0,n]:=inttostr(n);
advstringgrid1.Cells[1,0]:='貨物條形碼';
advstringgrid1.Cells[2,0]:='單價';
advstringgrid1.Cells[3,0]:='數(shù)量';
advstringgrid1.Cells[4,0]:='金額';
combobox1.Text:='---請選擇單據(jù)號---';
end;
procedure Tdrwhfrm.FormKeyPress(Sender: TObject; var Key: Char);
begin
if key=#13 then
begin
Perform(CM_DialogKey,Vk_TAB,0);
key:=#0;
end;
end;
procedure Tdrwhfrm.Edit3Enter(Sender: TObject);
begin
Edit3.Color:=clSkyBlue;
end;
procedure Tdrwhfrm.Edit3Exit(Sender: TObject);
begin
Edit3.color:=clWindow;
end;
procedure Tdrwhfrm.Timer1Timer(Sender: TObject);
var
m:integer;
begin
for m:=1 to drm do
begin
if advstringgrid1.Cells[1,m]='' then break;
advstringgrid1.Cells[4,m]:=floattostr(strtoint(advstringgrid1.Cells[2,m])*strtofloatdef(advstringgrid1.Cells[3,m],0));
end;
end;
procedure Tdrwhfrm.BitBtn4Click(Sender: TObject);
begin
with dataman.dbQuery do
begin
close;
sql.Clear;
sql.Add('select 進貨單據(jù)號 from moveinm where 進貨時間=:dcdate');
parameters.ParamByName('dcdate').Value:=datetimepicker1.Date;
open;
combobox1.Items.Clear;
first;
while not Eof do
begin
combobox1.Items.add(trim(fieldbyname('進貨單據(jù)號').asString));
next;
end;
end;
end;
procedure Tdrwhfrm.ComboBox1Change(Sender: TObject);
var
m:integer;
begin
if combobox1.Text='' then exit;
dcdj:=trim(combobox1.Text);
with dataman.dbQuery do
begin
close;
sql.Clear;
sql.Add('select 貨物條形碼,單價,數(shù)量,金額 from movein where 進貨單據(jù)號='''+combobox1.Text+'''');
sql.Add('order by 貨物條形碼 DESC');
prepared;
open;
end;
if dataman.dbQuery.IsEmpty then
showmessage('沒有單據(jù)號為'+trim(combobox1.Text)+'的單據(jù)')
else
begin
m:=1;
dataman.dbquery.first;
while not dataman.dbquery.eof do
begin
advstringgrid1.cells[1,m]:=dataman.dbquery.fields[0].value;
advstringgrid1.cells[2,m]:=dataman.dbquery.fields[1].asstring;
advstringgrid1.cells[3,m]:=dataman.dbquery.fields[2].asstring;
advstringgrid1.cells[4,m]:=dataman.dbquery.fields[3].asstring;
advstringgrid2.cells[0,m]:=dataman.dbquery.fields[2].asstring;
dataman.dbquery.next;
inc(m);
drm:=m;
end;
end;
end;
end.
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -