?? main_scxsth.pas
字號:
unit MAIN_SCXSTH;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, MAIN_DATAINPUT, DB, DBTables, Grids, StdCtrls,
TFlatComboBoxUnit, ComCtrls, DsFancyButton, ExtCtrls,myself,frmmain;
type
TFrm_main_scxsth = class(TFrm_main_input)
procedure FormCreate(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean);
procedure OKBtnClick(Sender: TObject);
function User_save():boolean;
private
{ Private declarations }
public
{ Public declarations }
end;
var
Frm_main_scxsth: TFrm_main_scxsth;
implementation
{$R *.dfm}
procedure TFrm_main_scxsth.FormCreate(Sender: TObject);
begin
inherited;
self.Caption :='商場銷售退貨數據錄入';
end;
procedure TFrm_main_scxsth.FormShow(Sender: TObject);
begin
inherited;
with query_data do
begin
close;
sql.Clear ;
sql.Text :='select name from depot where setid=999 and type="外部"';
open;
cb_depot.Items.Clear ;
cb_depot.Style:=csDropDownList;
while not eof do
begin
CB_depot.Items.add(fieldbyname('name').asstring);
next;
end;
close;
sql.Clear ;
sql.Text :='select name from people';
open;
cb_ywy.Items.Clear ;
cb_ywy.Style :=csDropDownList;
while not eof do
begin
CB_ywy.Items.add(fieldbyname('name').asstring);
next;
end;
close;
end;
end;
procedure TFrm_main_scxsth.FormCloseQuery(Sender: TObject;
var CanClose: Boolean);
var
T_temp:TModalResult;
begin
inherited;
if OKBtn.Enabled then
begin
T_temp:=messagedlg(Askmsg0001,mtConfirmation,mbYesnoCancel,0);
if T_temp=mrYes then
begin
if not user_save then
begin
messagedlg('【'+cb_ywy.text+'】在〖'+cb_depot.Text+'〗的銷售退貨'+Infmsg0004,mtError,[mbok],0);
canclose:=false;
end
else
begin
messagedlg(Infmsg0001,mtInformation,[mbok],0);
canclose:=true;
end;
end
else if T_temp=mrNo then
canclose:=true
else
canclose:=false;
end
else
canclose:=true;
end;
procedure TFrm_main_scxsth.OKBtnClick(Sender: TObject);
var
T_temp:TModalResult;
begin
T_temp:=messagedlg(Askmsg0002+' - 【'+cb_ywy.text+'】在〖'+cb_depot.Text
+'〗的銷售退貨',mtConfirmation,mbOKCancel,0);
if T_temp=mrOk then
begin
if not user_save then
begin
messagedlg('【'+cb_ywy.text+'】在〖'+cb_depot.Text+'〗的銷售退貨'+Infmsg0004,mtError,[mbok],0);
end
else
begin
messagedlg(Infmsg0001,mtInformation,[mbok],0);
okbtn.Enabled :=false;
self.close;
end;
end;
end;
function TFrm_main_scxsth.User_save():boolean;
var
I_errordb,I_temp,I_count,I_number:integer;
S_depotid,S_peopleid,S_id:string;
begin
I_errordb:=0;
I_count:=0;
S_depotid:='';
S_peopleid:='';
S_id:='';
if not Checkrights(USERRIGHTS,'增加') then
begin
messagedlg(Errormsg0006+'0007',mterror,[mbok],0);
result:=false;
exit;
end;
if CB_depot.Text ='' then
begin
messagedlg(Errormsg0002+'0002',mtwarning,[mbok],0);
cb_depot.SetFocus ;
result:=false;
exit;
end;
if CB_ywy.Text ='' then
begin
messagedlg(Errormsg0002+'0002',mtwarning,[mbok],0);
cb_ywy.SetFocus ;
result:=false;
exit;
end
else
result:=true;
if result then
begin
for I_temp:=1 to 99 do //逐行檢測進貨記錄是否有效
begin
if IMPSG_DATA.Cells[1,I_temp]<>'' then //有效記錄
begin
inc(I_count);
if (IMPSG_DATA.cells[4,I_temp]='') or (IMPSG_DATA.cells[5,I_temp]='')
or (IMPSG_DATA.cells[6,I_temp]='') then
begin
messagedlg('第'+inttostr(I_temp)+
'行記錄的'+Errormsg0002+'0015',mtError,[mbok],0);
IMPSG_DATA.Row :=I_temp;
IMPSG_DATA.Col :=4;
IMPSG_DATA.SetFocus ;
result:=false;
exit;
end;
try
strtofloat(IMPSG_DATA.Cells[4,I_temp]);
strtofloat(IMPSG_DATA.Cells[5,I_temp]);
strtofloat(IMPSG_DATA.Cells[6,I_temp]);
except
messagedlg('第'+inttostr(I_temp)+
'行記錄的'+Errormsg0002+'0015',mtError,[mbok],0);
IMPSG_DATA.Row :=I_temp;
IMPSG_DATA.Col :=4;
IMPSG_DATA.SetFocus ;
result:=false;
exit;
end;
end;
end;
if I_count<1 then
begin
result:=false;
messagedlg(Errormsg0008,mtwarning,[mbok],0);
end;
end;
if result then
begin
with query_data do
begin
try
close;
sql.Clear ;
sql.Text :='select id from depot where name="'+ cb_depot.Text+'"';
open;
S_depotid:=fieldbyname('id').AsString ;
close;
sql.Clear ;
sql.Text :='select id from people where name="'+ cb_ywy.Text+'"';
open;
S_peopleid:=fieldbyname('id').AsString ;
close;
for I_temp:=1 to 99 do
begin
if IMPSG_DATA.Cells[1,I_temp]<>'' then //有效記錄
begin
I_errordb:=1;
close;
sql.clear;
sql.text:='insert into XSTHRECORD (id,depotid,peopleid,mydate,goodsid,number,'
+'price,sellprice,memo) values ("'+Nowindex+'-'+inttostr(I_temp)+'","'
+S_depotid+'","'+S_peopleid+'","'+formatdatetime('yyyy-mm-dd',DTP_date.DateTime)+'","'
+IMPSG_DATA.Cells[1,I_temp]+'",'+IMPSG_DATA.Cells[4,I_temp]+','+IMPSG_DATA.Cells[5,I_temp]+','
+IMPSG_DATA.Cells[6,I_temp]+',"'+IMPSG_DATA.Cells[9,I_temp]+'")';
execsql;
close;
I_errordb:=2;
sql.Clear ;
sql.text:='select id,number from kccount where depotid="'+
S_depotid+'" and goodsid="'+ IMPSG_DATA.Cells[1,I_temp]+'"';
open;
I_count:=recordcount;
S_id:=fieldbyname('id').asstring;
I_number:=fieldbyname('number').AsInteger+strtoint(IMPSG_DATA.cells[4,I_temp]);
close;
I_errordb:=3;
sql.Clear ;
if (I_count>0) and (S_id<>'') then
sql.text :='update kccount set number='+inttostr(i_number)+' where id="'+s_id+'"'
else
sql.text:='insert into kccount (depotid,goodsid,number,price,id,memo)'
+' values ("'+S_depotid+'","'
+IMPSG_DATA.Cells[1,I_temp]+'",'+IMPSG_DATA.cells[4,I_temp]+','
+IMPSG_DATA.cells[5,I_temp]+',"'+Nowindex+'-'+inttostr(I_temp)+'","'
+ IMPSG_DATA.cells[9,i_temp]+'")';
execsql;
close;
end;
end;
except
result:=false;
if I_errordb=1 then
messagedlg(Errormsg0004+'0022',mtwarning,[mbok],0)
else if I_errordb=2 then
messagedlg(Errormsg0001+'0019',mtwarning,[mbok],0)
else if I_errordb=3 then
messagedlg(Errormsg0004+'0016',mtwarning,[mbok],0)
else
messagedlg(Errormsg0001+'0000',mtwarning,[mbok],0);
close;
exit;
end;
end;
end;
end;
end.
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -