📄 uflat.pas
字号:
unit Uflat;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, fm_Base, Grids, ComCtrls, StdCtrls, ExtCtrls, Buttons;
type
Tfmflat = class(TfmBase)
Panel2: TPanel;
SpeedButton2: TSpeedButton;
SpeedButton3: TSpeedButton;
SpeedButton4: TSpeedButton;
Panel3: TPanel;
GroupBox1: TGroupBox;
Cmd_JSR: TSpeedButton;
Edit5: TLabeledEdit;
Edit7: TLabeledEdit;
DateTimePicker1: TDateTimePicker;
Panel6: TPanel;
Panel7: TPanel;
StringGrid1: TStringGrid;
StringGrid2: TStringGrid;
SpeedButton5: TSpeedButton;
edtshop: TLabeledEdit;
Label1: TLabel;
Edit1: TLabeledEdit;
Edit2: TLabeledEdit;
Panel10: TPanel;
Cmd_Delete: TSpeedButton;
Cmd_Add: TSpeedButton;
procedure StringGrid2DblClick(Sender: TObject);
procedure StringGrid1SelectCell(Sender: TObject; ACol, ARow: Integer;
var CanSelect: Boolean);
procedure StringGrid1KeyPress(Sender: TObject; var Key: Char);
procedure StringGrid2SelectCell(Sender: TObject; ACol, ARow: Integer;
var CanSelect: Boolean);
procedure FormShow(Sender: TObject);
procedure StringGrid2KeyPress(Sender: TObject; var Key: Char);
procedure SpeedButton4Click(Sender: TObject);
procedure SpeedButton5Click(Sender: TObject);
procedure Cmd_JSRClick(Sender: TObject);
procedure StringGrid2MouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
procedure SpeedButton2Click(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure StringGrid1DrawCell(Sender: TObject; ACol, ARow: Integer;
Rect: TRect; State: TGridDrawState);
procedure StringGrid2DrawCell(Sender: TObject; ACol, ARow: Integer;
Rect: TRect; State: TGridDrawState);
procedure Cmd_DeleteClick(Sender: TObject);
procedure Cmd_AddClick(Sender: TObject);
private
{ Private declarations }
pcol1,prow1,pcol2,prow2:integer;
procedure init;
public
{ Public declarations }
psum:tstringlist;
end;
var
fmflat: Tfmflat;
implementation
uses UntgoodCodeSelStr, untdatadm, func, Public_Don, Storage_Select,
Login_Man, Unt_PubStrGrid;
{$R *.dfm}
procedure tfmflat.init;
var
temp,make:string;
begin
InitialStrGrid(stringgrid1,'套餐定义1');
InitialStrGrid(stringgrid2,'套餐定义2');
stringgrid1.RowCount:=2;
stringgrid2.RowCount:=2;
psum:=tstringlist.Create;
if public_do<>'flatnew' then exit;
edit1.Text:=formatdatetime('yyyy''-''mm''-''dd',date);
temp:='select max(right(stock_No,4)) from dp_flat where copy_date='+''''+formatdatetime('yyyy''-''mm''-''dd',date)+'''';
make:='TC-'+trim(Handle_Part)+trim(handle_no); //5-11 用部门编号
edit2.Text:=setcode(temp,make);
edit7.Text:=trim(Handle_Man);
end;
procedure Tfmflat.StringGrid2DblClick(Sender: TObject);
var
i:integer;
tm:double;
bmbh:string;
begin
inherited;
if (trim(edtshop.Text)='') then
begin
Application.MessageBox('请选择仓库编号!',pchar(application.Title),mb_iconwarning);
stringgrid1.SetFocus;
Exit;
end;
if (trim(stringgrid1.Cells[1,1])='') then
begin
Application.MessageBox('请输入套餐商品编号!',pchar(application.Title),mb_iconwarning);
stringgrid1.SetFocus;
Exit;
end;
if pcol2 in [1,2] then
begin
bmbh:=shopid;
shopid:=edtshop.Text;
fmgoodCodeSelStr:= TfmgoodCodeSelStr.Create(self);
try
fmgoodcodeselStr.show_mode:='9';
fmgoodcodeselStr.ShowModal;
finally
fmgoodcodeselStr.Free;
shopid:=bmbh;
end;
end;
tm:=0.00;
for i:=1 to stringgrid2.RowCount-1 do
begin
if trim(stringgrid2.Cells[3,i])='' then stringgrid2.Cells[3,i]:='0';
tm:=tm+strtofloat(stringgrid2.Cells[3,i]);
end;
if trim(stringgrid1.Cells[1,prow1])<>'' then
BEGIN
stringgrid1.Cells[3,prow1]:=FLOATTOSTR(tm);
END;
end;
procedure Tfmflat.StringGrid1SelectCell(Sender: TObject; ACol,
ARow: Integer; var CanSelect: Boolean);
begin
inherited;
pcol1:=acol;
prow1:=arow;
end;
procedure Tfmflat.StringGrid1KeyPress(Sender: TObject; var Key: Char);
begin
inherited;
if pcol1 in [1,2,4,6,7,8] then
begin
if pcol1=4 then //输入单价
begin
if key in ['0'..'9',#8] then
begin
////////////////////////////////////////////
if key<> #8 then //字符第一个不为‘0’;
begin
if StringGrid1.Cells[4,prow1]<>'0' then
begin
StringGrid1.Cells[4,prow1]:=StringGrid1.Cells[4,prow1]+key;
end else
begin
StringGrid1.Cells[4,prow1]:=key;
end;
if trim(StringGrid1.Cells[3,prow1])<>'' then
begin
StringGrid1.Cells[5,prow1]:=floattostr(strtofloat(StringGrid1.Cells[3,prow1])*strtofloat(StringGrid1.Cells[4,prow1]));//总价格;
end else
begin
StringGrid1.Cells[5,prow1]:='0';
end;
///////////////////////////////////
end else
begin
StringGrid1.Cells[4,prow1]:=copy(StringGrid1.Cells[4,prow1],1,length(StringGrid1.Cells[4,prow1])-1); //减去最后数字
if trim(StringGrid1.Cells[4,prow1])='' then
begin
StringGrid1.Cells[4,prow1]:='0';
end;
if trim(StringGrid1.Cells[3,prow1])<>'' then
begin
StringGrid1.Cells[5,prow1]:=floattostr(strtofloat(StringGrid1.Cells[3,prow1])*strtofloat(StringGrid1.Cells[4,prow1]));//总价格;
end else
begin
StringGrid1.Cells[5,prow1]:='0';
end;
end;
end else
begin
applicaTION.MessageBox('只能输入数字!',pchar(application.Title),mb_iconinformation);
exit;
end;
end else
begin
if key<>#8 then //类型,生产厂商,说明
begin
StringGrid1.Cells[pcol1,prow1]:=StringGrid1.Cells[pcol1,prow1]+key;
end else
begin
StringGrid1.Cells[pcol1,prow1]:=copy(StringGrid1.Cells[pcol1,prow1],1,length(StringGrid1.Cells[pcol1,prow1])-1); //减去最后
end;
end;
end;
end;
procedure Tfmflat.StringGrid2SelectCell(Sender: TObject; ACol,
ARow: Integer; var CanSelect: Boolean);
begin
inherited;
pcol2:=acol;
prow2:=arow;
end;
procedure Tfmflat.FormShow(Sender: TObject);
var
i:integer;
tempstr:string;
begin
inherited;
init;
if public_do='flatedit' then
begin
tempstr:='Select a.*,b.goods_no as goods_code,b.amount as tamount, c.goods_name as name,baseprice as bprice,type,provider,stock_amount from dp_flat as a ,dp_flatdetail as b, vSelectGoods as c where c.goods_no=b.goods_no and a.stock_No=b.stock_No and a.stock_No='+''''+trim(List_No)+'''';
dmmain.CDSquery2.Data:=null;
dmmain.CDSquery2.Close;
//wy edit 3-14 begin
dmmain.CDSquery2.Data:=adisp.resultrecord(tempstr);
dmmain.CDSquery2.Open;
edit1.Text:=dmmain.CDSquery2.fieldbyname('copy_date').AsString;
edit2.Text:=dmmain.CDSquery2.fieldbyname('stock_no').AsString;
edtshop.Text:=dmmain.CDSquery2.fieldbyname('storage').AsString;
edit5.Text:=dmmain.CDSquery2.fieldbyname('tranman').AsString;
edit7.Text:=dmmain.CDSquery2.fieldbyname('operater').AsString;
stringgrid1.Cells[1,1]:=dmmain.CDSquery2.fieldbyname('goods_no').AsString;
stringgrid1.Cells[2,1]:=dmmain.CDSquery2.fieldbyname('goods_name').AsString;
stringgrid1.Cells[3,1]:=dmmain.CDSquery2.fieldbyname('price').AsString;
stringgrid1.Cells[4,1]:=dmmain.CDSquery2.fieldbyname('amount').AsString;
stringgrid1.Cells[5,1]:=dmmain.CDSquery2.fieldbyname('totalmoney').AsString;
stringgrid2.RowCount:=dmmain.CDSquery2.RecordCount+1;
for i:=1 to stringgrid2.RowCount-1 do
begin
stringgrid2.Cells[0,i]:=inttostr(i);
stringgrid2.Cells[1,i]:=dmmain.CDSquery2.fieldbyname('goods_code').AsString;
stringgrid2.Cells[2,i]:=dmmain.CDSquery2.fieldbyname('name').AsString;
stringgrid2.Cells[3,i]:=dmmain.CDSquery2.fieldbyname('bprice').AsString;
stringgrid2.Cells[4,i]:=dmmain.CDSquery2.fieldbyname('tamount').AsString;
stringgrid2.Cells[5,i]:=floattostr(dmmain.CDSquery2.fieldbyname('bprice').AsFloat*dmmain.CDSquery2.fieldbyname('tamount').AsFloat); //总金额
stringgrid2.Cells[6,i]:=dmmain.CDSquery2.fieldbyname('type').AsString;
stringgrid2.Cells[7,i]:=dmmain.CDSquery2.fieldbyname('provider').AsString;
psum.Add(dmmain.CDSquery2.fieldbyname('stock_amount').AsString);
dmmain.CDSquery2.next;
end;
end;
end;
procedure Tfmflat.StringGrid2KeyPress(Sender: TObject; var Key: Char);
begin
inherited;
if trim(StringGrid2.Cells[1,1])='' then exit;
if pcol2=4 then //输入单价
begin
if key in ['0'..'9',#8] then
begin
////////////////////////////////////////////
if key<> #8 then //字符第一个不为‘0’;
begin
if StringGrid2.Cells[4,prow2]<>'0' then
begin
StringGrid2.Cells[4,prow2]:=StringGrid2.Cells[4,prow2]+key;
end else
begin
StringGrid2.Cells[4,prow2]:=key;
end;
if trim(StringGrid2.Cells[3,prow2])<>'' then
begin
StringGrid2.Cells[5,prow2]:=floattostr(strtofloat(StringGrid2.Cells[3,prow2])*strtofloat(StringGrid2.Cells[4,prow2]));//总价格;
end else
begin
StringGrid2.Cells[5,prow2]:='0';
end;
///////////////////////////////////
end else
begin
StringGrid2.Cells[4,prow2]:=copy(StringGrid2.Cells[4,prow2],1,length(StringGrid2.Cells[4,prow2])-1); //减去最后数字
if trim(StringGrid2.Cells[4,prow2])='' then
begin
StringGrid2.Cells[4,prow2]:='0';
end;
if trim(StringGrid2.Cells[3,prow2])<>'' then
begin
StringGrid2.Cells[5,prow2]:=floattostr(strtofloat(StringGrid2.Cells[3,prow2])*strtofloat(StringGrid2.Cells[4,prow2]));//总价格;
end else
begin
StringGrid2.Cells[5,prow2]:='0';
end;
end;
if strtoint(StringGrid2.Cells[4,prow2])>strtoint(psum.Strings[prow2-1]) then
begin
StringGrid2.Cells[4,prow2]:='0';
application.MessageBox('输入数量已经超过库存数量!',pchar(application.Title),mb_iconinformation);
exit;
end;
end;
end;
end;
procedure Tfmflat.SpeedButton4Click(Sender: TObject);
var
i:integer;
begin
inherited;
frm_Public_Don:=Tfrm_Public_Don.Create(self);
frm_Public_Don.no:=trim(edit2.Text);
frm_Public_Don.ShowModal;
if Public_Do_Result='02' then
BEGIN
if trim(edtshop.Text)='' then
begin
application.MessageBox('请选择店面或仓库!',pchar(application.Title),mb_iconinformation);
edtshop.SetFocus;
exit;
end;
if trim(edit5.Text)='' then
begin
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -