【delphi开源代码栏目提醒】:网学会员为广大网友收集整理了,Dbgl_info_Browser_U.pas,希望对大家有所帮助!
{
unit name : Dbgl_info_Browser_U
Author : 李涛
Create date: 2004-06-02 11:11:13
description: 调拨信息编辑单元
}
unit Dbgl_info_Browser_U;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, BaseBrowser_Form_U, StdCtrls, Buttons, ExtCtrls, DB, ADODB,
Grids, DBCtrls, ComCtrls, Public_unit_u, Menus;
type
TDbgl_info_Browser = class(TBaseBrowser_Form)
Panel1: TPanel;
Panel3: TPanel;
Panel4: TPanel;
Panel5: TPanel;
Panel6: TPanel;
GroupBox1: TGroupBox;
Label1: TLabel;
Label3: TLabel;
Label4: TLabel;
Label5: TLabel;
Label9: TLabel;
Label10: TLabel;
Label12: TLabel;
Label13: TLabel;
SpeedButton1: TSpeedButton;
DateTimePicker1: TDateTimePicker;
Edit2: TEdit;
Edit3: TEdit;
Edit5: TEdit;
DBLookupComboBox1: TDBLookupComboBox;
Panel7: TPanel;
DJ_StringGrid: TStringGrid;
Panel8: TPanel;
Label6: TLabel;
Label8: TLabel;
Label14: TLabel;
Label15: TLabel;
Panel9: TPanel;
Panel10: TPanel;
Sub_ADO: TADOQuery;
DRCK_ADO: TADOQuery;
DRCK_DataSource: TDataSource;
DBLookupComboBox2: TDBLookupComboBox;
DCCK_ADO: TADOQuery;
DCCK_DataSource: TDataSource;
PopupMenu1: TPopupMenu;
D1: TMenuItem;
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure FormShow(Sender: TObject);
procedure DJ_StringGridKeyPress(Sender: TObject; var Key: Char);
procedure DJ_StringGridKeyUp(Sender: TObject; var Key: Word;
Shift: TShiftState);
procedure Edit3Enter(Sender: TObject);
procedure Edit3Exit(Sender: TObject);
procedure Edit2KeyPress(Sender: TObject; var Key: Char);
procedure SpeedButton1Click(Sender: TObject);
procedure ADD_BitClick(Sender: TObject);
procedure D1Click(Sender: TObject);
private
procedure sum_info;
Function JC: String; //检查信息的准确性 0成功,1失败
procedure append;
procedure update;
procedure Read_sub; //载入调拨信息[update时]
{ Private declarations }
public
State: String; //状态:append新单据update修改
dbdh: String; //入库单号[update 时使用]
dbr_code,dbr_name:String; //调拨人编号、
{ Public declarations }
end;
var
Dbgl_info_Browser: TDbgl_info_Browser;
implementation
uses Select_Merchandise_info_u, Select_fwy_Browser_U,MainDataModule_u,
MainForm_U;
{$R *.dfm}
procedure TDbgl_info_Browser.Read_sub;
var
I: integer;
begin
I:=1;
with Sub_ADO do
begin
Close;
SQL.Clear;
SQL.Add('Exec Find_kc_db_sub '''+Edit3.Text+'''');
Open;
if RecordCount<=0 then
ShowMessage('没有发现['+Edit3.Text+']单据中的有任何调拨信息!!')
else
while not Eof do
begin
with DJ_StringGrid do
begin
if RowCount=I then
begin
RowCount:=RowCount+1;
Cells[0,I+1]:=IntToStr(I+1);
end;
Cells[1,I]:=FieldByName('C_spbm').AsString; //编码
Cells[2,I]:=FieldByName('C_name').AsString; //名称
Cells[3,I]:=FieldByName('C_sort').AsString; //类别
Cells[4,I]:=FieldByName('C_model').AsString; //型号
Cells[5,I]:=FieldByName('C_unit').AsString; //单位
Cells[6,I]:=FieldByName('dec_sum').AsString; //数量
Cells[7,I]:=FieldByName('dec_jg').AsString; //单价
Cells[8,I]:=FieldByName('dec_xj').AsString; //小计
end;
Inc(I);
Next;
end;
end;
end;
procedure TDbgl_info_Browser.append;
var
I:integer;
begin
try
MainForm.ADOConnection1.BeginTrans;
with MainDataModule.Temp_Query do
begin
Close;
SQL.Clear;
SQL.Add('Select C_dbdh from T_kc_db_main where C_dbdh='''+Edit3.Text+'''');
Open;
if RecordCount>0 then
begin
ShowMessage('['+Edit3.Text+']号调拨单据已经存在,请重新输入调拨单据号!!');
Exit;
end;
Close;
SQL.Clear;
SQL.Add('INSERT INTO T_kc_db_main (c_dbdh, dt_dbrq, c_dbry, c_dcck, c_drck, c_czy, C_bz, C_sh)');
SQL.Add('values ('''+Edit3.Text+''','''+DateTimeToStr(DateTimePicker1.DateTime)+''','''+
Self.dbr_code+''','''+DBLookupComboBox2.KeyValue+''','''+
DBLookupComboBox1.KeyValue+''','''+MySelf.User_Code+''','''+Edit5.Text+''','''+'0'+''')');
ExecSQL;
with DJ_StringGrid do
For I:=1 to DJ_StringGrid.RowCount-1 do
begin
if (Length(Cells[1,I])>0) and (Length(Cells[2,I])>0) and
(Length(Cells[6,I])>0) and (Length(Cells[7,I])>0) then
begin
Close;
SQL.Clear;
SQL.Add('INSERT INTO T_kc_db_sub (c_db_code, c_spbm, dec_dbsl)');
SQL.Add('values('''+Edit3.Text+''','''+Cells[1,I]+''','''+Cells[6,I]+''')');
ExecSQL;
end;
end;
end;
MainForm.ADOConnection1.CommitTrans;
ShowMessage('['+Edit3.Text+']调拨单据登记成功!!');
Cancel_Bit.Click;
except
MainForm.ADOConnection1.RollbackTrans;
ShowMessage('调拨单据登记失败!!');
end;
end;
procedure TDbgl_info_Browser.update;
begin
with Sub_ADO do
begin
Close;
SQL.Clear;
SQL.Add('delete T_kc_db_sub where C_db_code='''+Self.dbdh+'''');
SQL.Add('delete T_kc_db_main where C_dbdh='''+Self.dbdh+'''');
ExecSQL;
end;
Self.append;
end;
procedure TDbgl_info_Browser.sum_info;
var
dbsl,dbze:Real;
I:integer;
begin
if (Length(Dj_STringGrid.Cells[6,Dj_STringGrid.Row])>0) and
(Length(Dj_STringGrid.Cells[7,Dj_STringGrid.Row])>0) then
DJ_StringGrid.Cells[8,Dj_STringGrid.Row]:=FloatToStr(
StrToFloat(Dj_STringGrid.Cells[6,Dj_STringGrid.Row])*
StrToFloat(Dj_STringGrid.Cells[7,Dj_STringGrid.Row])
);
for I:=1 to DJ_StringGrid.RowCount -1 do
begin
if (Length(DJ_StringGrid.Cells[1,I])>0) and
(Length(DJ_StringGrid.Cells[2,I])>0) and
(Length(DJ_StringGrid.Cells[6,I])>0) and
(Length(DJ_StringGrid.Cells[7,I])>0) and
(Length(DJ_StringGrid.Cells[8,I])>0) then
begin
dbsl:=dbsl+StrToFloat(Dj_StringGrid.Cells[6,I]);
dbze:=dbze+StrToFloat(Dj_StringGrid.Cells[8,I]);
end
else
Break;
end;
if (Length(FloatToStr(dbze))>0) then
begin
Label14.Caption:=Format('%8.2f',[dbsl]); //调拨数量
Label15.Caption:=Format('%8.2f',[dbze]); //调拨总额
end
else
begin
Label14.Caption:=Format('%8.2f',[dbsl]); //调拨数量
Label15.Caption:='0.00'
end;
end;
Function TDbgl_info_Browser.JC: String;
var
I: integer;
label Cancel;
begin
JC:='0';
with DJ_StringGrid do
if (Length(Cells[1,1])=0) or
(Length(Cells[2,1])=0) or
(Length(Cells[6,1])=0) or
(Length(Cells[7,1])=0) then
begin
ShowMessage('请输入调拨商品信息!!');
goto Cancel;
end;
for I:=1 to DJ_StringGrid.RowCount-1 do
with DJ_StringGrid do
if Length(Cells[1,I])>0 then
if (Length(Cells[6,I])=0) or (Length(Cells[7,I])=0) then
begin
ShowMessage('请检查第['+IntToStr(I)+']行信息的数量和金额信息!!');
if Length(Cells[6,I])=0 then Col:=6;
if Length(Cells[7,I])=0 then Col:=7;
Row:=I;
Cancel:
DJ_StringGrid.SetFocus;
JC:='1';
Exit;
end
else
begin
//检查库存商品是否存在及数量是否够调拨使用
with MainDataModule.Temp_Query do
begin
Close;
SQL.Clear;
SQL.Add('select * from T_kc_kcqkb');
SQL.Add('where C_spbm='''+Cells[1,I]+''' and C_ckbm='''+DBLookupComboBox2.keyValue+'''');
Open;
if RecordCount<=0 then
begin
ShowMessage('['+DBLookupComboB
上一篇:
dbfxz.pas
下一篇:
心力衰竭的中医证素及常见证型