?? khhjgl.~pas
字號:
with datam.ADOQuery4 do
begin
Close;
SQL.Clear;
SQL.Add('select * from 商品基礎信息表 where 商品編號 =:a');
Parameters.ParamByName('a').Value := Trim(StringGrid1.Cells[2,x]);
Open;
end;
Jg:= datam.ADOQuery4.FieldByName('批發價').Value;
StringGrid1.Cells[5,x]:= FloatToStr(StrToInt(StringGrid1.Cells[4,x])* Jg*(StrToFloat(StringGrid1.Cells[6,x])));
if jcxmlb = True then
begin
Label17.Caption := FloatToStr(SumPrice);
Label16.Caption := IntToStr(SumSL);
Label15.Caption := IntToStr(Kinds);
end;
Exit;
end
else
begin
StringGrid1.Cells[5,x]:='';
Exit;
end;
if (ss = False)and(s1 = False)then
begin
if ACol = 3 then
begin
with datam.ADOQuery1 do
begin
Close;
SQL.Clear;
SQL.Add('select * from 商品基礎信息表 where 商品名稱 like :b ');
Parameters.ParamByName('b').Value := Trim(StringGrid1.Cells[3,x])+'%';
Open;
end;
if datam.ADOQuery1.RecordCount>0 then
begin
DataSource1.DataSet := datam.ADOQuery1;
DBGrid1.Visible := True;
end
else
begin
DataSource1.DataSet := nil;
DBGrid1.Visible := False;
S1 := True;
Application.MessageBox('庫中沒有此商品。','提示',64 );
For a1 := 2 to 5 do
StringGrid1.Cells[a1,x]:= '';
StringGrid1.SetFocus;
StringGrid1.Col := 1;
end;
end;
end ;
end;
function TForm30.JCxmlb: Boolean;
var
a,b: integer;
begin
ReSult := True;
for a := 1 to StringGrid1.RowCount-1 do
For b := 0 to StringGrid1.ColCount-1 do
if Trim(StringGrid1.Cells[b,a]) = '' then
begin
Jcxmlb := False;
break;
end ;
end;
function TForm30.SumPrice: Real;
var
nn: Integer;
sum: Real;
begin
sum := 0.0;
For nn := 1 to StringGrid1.RowCount-1 do
sum := Sum + StrToFloat(StringGrid1.Cells[5,nn]);
ReSult := Sum;
end;
function TForm30.SumSL: integer;
var
nn: Integer;
sum: Integer;
begin
sum := 0;
For nn := 1 to StringGrid1.RowCount-1 do
sum := Sum + StrToInt(StringGrid1.Cells[4,nn]);
ReSult := Sum;
end;
function TForm30.Kinds: Integer;
var
i,m,mm: Integer;
Iscf: Boolean; //判斷當前記錄是否與之前的記錄重復
begin
mm:= 0;
Iscf := False;
Result := StringGrid1.RowCount-1;
For m := 1 to StringGrid1.RowCount-1 do
For i := m+1 to StringGrid1.RowCount-1 do
begin
Iscf := False;
if m >1 then
For mm := 1 to m-1 do
if Trim(StringGrid1.Cells[2,m])= Trim(StringGrid1.Cells[2,mm])then
begin
Iscf := True;
Break;
end;
if Iscf = True then
Continue;
if Trim(StringGrid1.Cells[2,m])=Trim(StringGrid1.Cells[2,i])then
ReSult := Result -1;
end;
end;
procedure TForm30.DBGrid1DblClick(Sender: TObject);
begin
StringGrid1.Cells[2,x]:= datam.ADOQuery1.FieldByName('商品編號').Value;
StringGrid1.Cells[3,x]:= datam.ADOQuery1.FieldByName('商品名稱').Value;
DataSource1.DataSet := nil;
DBGrid1.Visible := False;
StringGrid1.SetFocus;
StringGrid1.Col := 4;
end;
procedure TForm30.DBGrid1KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
if Key = VK_ReTurn then
DBGrid1.OnDblClick(Sender);
end;
function TForm30.IsNull: Boolean;
var
b: integer;
begin
isNull := False;
For b := 0 to StringGrid1.ColCount-1 do
begin
if StringGrid1.Cells[b,x]='' then
begin
Isnull := True;
break;
end;
end;
end;
procedure TForm30.ClearString;
var
i: Integer;
begin
For i := 2 to 5 do
StringGrid1.Cells[i,x]:= '';
end;
procedure TForm30.ClearStringEnd;
var
mm: Integer;
begin
For mm:= 2 to 5 do
StringGrid1.Cells[mm,StringGrid1.RowCount-1]:= '';
end;
function TForm30.CurrentIsCF: Boolean;
var
i: Integer;
begin
ReSult := False;
if x > 1 then
begin
For i := 1 to x-1 do
begin
if Trim(StringGrid1.Cells[2,x])= Trim(StringGrid1.Cells[2,i]) then
begin
ReSult := True;
Break;
Exit;
end;
end;
For i := x+1 to StringGrid1.RowCount-1 do
begin
if Trim(StringGrid1.Cells[2,x])= Trim(StringGrid1.Cells[2,i]) then
begin
ReSult := True;
Break;
Exit;
end;
end;
end
else if x = 1 then
begin
For i := 2 to StringGrid1.RowCount-1 do
if Trim(StringGrid1.Cells[2,x])= Trim(StringGrid1.Cells[2,i]) then
begin
ReSult := True;
Break;
Exit;
end;
end;
end;
procedure TForm30.Edit8Exit(Sender: TObject);
begin
if Edit8.Text = '' then
begin
Application.MessageBox('折扣不能為空。','提示',0+64);
Edit8.SetFocus;
Exit;
end;
if (StrToFloat(Edit8.Text)>1)or(StrToFloat(Edit8.Text)<0)then
begin
Application.MessageBox('折扣不能大于1或小于0。','提示',0+64);
Edit8.Text := '1.0';
Edit8.SetFocus;
Exit;
end;
try
StrToFloat(Edit8.Text);
except
On EConvertError do
begin
Application.MessageBox('請輸入合法字符。','提示',0+64);
Edit8.Text := '1.0';
Edit8.SetFocus;
Exit;
end;
end;
end;
procedure TForm30.Edit8KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
if key = VK_return then
if (Trim(Edit8.Text)<>'')and(Trim(StringGrid1.Cells[4,x])='') then
begin
Edit8.OnExit(sender);
StringGrid1.Cells[6,StringGrid1.RowCount-1]:= Edit8.Text;
StringGrid1.Col := 4;
StringGrid1.SetFocus;
end;
end;
procedure TForm30.Edit8KeyPress(Sender: TObject; var Key: Char);
var
a: Boolean;
begin
a := (Key <#8)or(Key >#8)and(Key<#46)or(Key>#46)and(Key<#48)or(Key>#57);
if a then
Key := #0;
end;
procedure TForm30.Clear;
var
r,c: integer;
begin
MaskEdit1.ReadOnly := False;
Label7.Caption := '';
Label10.Caption := '';
MaskEdit1.Clear;
Edit8.Text := '1.0';
Label15.Caption := '0';
Label16.Caption := '0';
Label17.Caption := '0.0';
For r := 1 to StringGrid1.RowCount-1 do
For c := 0 to StringGrid1.ColCount-1 do
StringGrid1.Cells[c,r]:='';
StringGrid1.RowCount :=2;
end;
procedure TForm30.BitBtn7Click(Sender: TObject);
begin
Clear;
BitBtn3.SetFocus;
end;
procedure TForm30.BitBtn4Click(Sender: TObject);
var
m: Integer;
begin
if (Trim(Edit4.Text)<>'')and(Trim(Label10.Caption)<>'')and(Trim(Label15.Caption)<>'')and
(Trim(Label16.Caption)<>'')and(Trim(Label17.Caption)<>'')and(JCxmlb = True)then
begin
datam.ADOConnection1.BeginTrans;
Try
with datam.ADOQuery2 do
begin
Close;
SQL.Clear;
SQL.Add('insert 客戶集中呼叫票號表 Values(:a,:b,:c,:d,Default,:e) ');
Parameters.ParamByName('a').Value := Trim(Label10.Caption);
Parameters.ParamByName('b').Value := StrToInt(Label15.Caption);
Parameters.ParamByName('c').Value := StrToInt(Label16.Caption);
Parameters.ParamByName('d').Value := StrToFloat(Label17.Caption);
Parameters.ParamByName('e').Value := Trim(Edit4.Text);
ExecSQL;
end;
For m := 1 to StringGrid1.RowCount-1 do
begin
with datam.ADOQuery2 do
begin
Close;
SQL.Clear;
SQL.Add('insert 客戶集中呼叫表 Values(:a,:b,:c,:d,:e,:f,:g,:h)');
Parameters.ParamByName('a').Value := Trim(StringGrid1.Cells[2,m]);
Parameters.ParamByName('b').Value := Trim(StringGrid1.Cells[3,m]);
Parameters.ParamByName('c').Value := Trim(StringGrid1.Cells[0,m]);
Parameters.ParamByName('d').Value := Trim(StringGrid1.Cells[1,m]);
Parameters.ParamByName('e').Value := StrToInt(StringGrid1.Cells[4,m]);
Parameters.ParamByName('f').Value := StrToFloat(StringGrid1.Cells[5,m]);
Parameters.ParamByName('g').Value := StrToFloat(StringGrid1.Cells[6,m]);
Parameters.ParamByName('h').Value := Trim(Label10.Caption);
ExecSQL;
end;
end;
datam.ADOConnection1.CommitTrans;
Application.MessageBox('數據保存成功。','提示',64);
BitBtn7.OnClick(Sender);
Except
datam.ADOConnection1.RollbackTrans;
Application.MessageBox('系統出錯。','提示',64);
Close;
end;
end
else
Application.MessageBox('項目列表有誤,請查看項目列表是否有空項。','提示',64);
end;
end.
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -