📄 check.pas
字号:
if Panel2.Controls[i]is TEdit then
if Trim(TEdit(Panel2.Controls[i]).Text)='' then
begin
Result := True;
Break;
end;
end;
procedure Tf_check.BooknameChange(Sender: TObject);
begin
inherited;
if (Trim(Bookname.Text)<>'')and(Bookname.Focused) then
begin
With t_data.Query1 do
begin
Close;
SQL.Clear;
SQL.Add('select bookname,barcode,bookconcern,author from tb_bookinfo where bookname like :name');
Parameters.ParamByName('name').Value := Trim(Bookname.Text)+'%';
Open;
end;
if t_data.Query1.RecordCount>0 then
begin
Source1.DataSet := t_data.Query1;
Grid1.Visible := True;
end
else
begin
t_data.Query1.Close;
Grid1.Visible := False;
end;
end;
end;
procedure Tf_check.GridSelectCell(Sender: TObject; ACol, ARow: Integer;
var CanSelect: Boolean);
begin
inherited;
x := ARow;
y := ACol;
end;
procedure Tf_check.SaveClick(Sender: TObject);
var
Connect: TADOConnection;
Query1,Query2: TADOQuery;
row: Integer;
inid: String;
begin
inherited;
Connect := Nil;
Query1 := Nil;
Query2 := Nil;
if GridIsNull = True then
begin
Application.MessageBox('表格信息不能为空.','提示',64);
Exit;
end;
if ((Radio1.Checked)and(Trim(Depot.Text)=''))or((Radio2.Checked)and(Trim(Counter.Text)='')) then
begin
Application.MessageBox('仓库名称或柜台名称不能为空.','提示',64);
Exit;
end;
Try
Connect := TADOConnection.Create(nil);
Connect.LoginPrompt := False;
Connect.ConnectionString := t_data.Connection1.ConnectionString;
Connect.Open;
Query1 := TADOQuery.Create(nil);
Query2 := TADOQuery.Create(nil);
Query1.Connection := Connect;
Query2.Connection := Connect;
if Lose.Checked then //进行报损处理
begin
if Application.MessageBox('确实要进行报损处理吗?','提示',mb_yesno)= id_Yes then
begin
Try
Connect.BeginTrans;
if Radio1.Checked then
begin
With Query1 do
begin
Close;
SQL.Clear;
SQL.Add('Exec Add_CheckID :ID,:Storage,:Operator,:Date,:Checkid Output,:Ismore');
Parameters.ParamByName('Id').Value := 0;//0代表对仓库进行报损或报溢处理
Parameters.ParamByName('Storage').Value := Trim(Depot.Text);
Parameters.ParamByName('Operator').Value := Trim(Username);
Parameters.ParamByName('Date').Value := Picker1.DateTime;
Parameters.ParamByName('Checkid').Value := 'temp';
Parameters.ParamByName('Ismore').Value := 0;//0代表进行报损处理
ExecSQL;
end;
inid := Trim(Query1.Parameters.ParamByName('Checkid').Value);
For Row := 1 to Grid.RowCount-2 do
begin
With Query1 do
begin
Close;
SQL.Clear;
SQL.Add('Insert into tb_depotcheckdetail values (:checkid,:barcode,:num)');
Parameters.ParamByName('CheckId').Value := inid;
Parameters.ParamByName('barcode').Value := Trim(Grid.Cells[c_barcode,Row]);
Parameters.ParamByName('num').Value := StrToFloat(Grid.Cells[c_sum,Row]);
ExecSQL;
end;
With Query1 do
begin
Close;
SQL.Clear;
SQL.Add('update tb_bookdepot set num = num-:sum where depot = :depot and barcode = :barcode');
Parameters.ParamByName('sum').Value := StrToFloat(Grid.Cells[c_sum,Row]);
Parameters.ParamByName('barcode').Value := Trim(Grid.Cells[c_barcode,Row]);
Parameters.ParamByName('depot').Value := Trim(Depot.Text);
ExecSQL;
end;
end;
end
else //进行柜台报损处理
begin
With Query1 do
begin
Close;
SQL.Clear;
SQL.Add('Exec Add_CheckID :ID,:Storage,:Operator,:Date,:Checkid Output,:Ismore');
Parameters.ParamByName('Id').Value := 1;//1代表对柜台进行报损或报溢处理
Parameters.ParamByName('Storage').Value := Trim(Counter.Text);
Parameters.ParamByName('Operator').Value := Trim(Username);
Parameters.ParamByName('Date').Value := Picker1.DateTime;
Parameters.ParamByName('Checkid').Value := 'temp';
Parameters.ParamByName('Ismore').Value := 0;//0代表进行报损处理
ExecSQL;
end;
inid := Trim(Query1.Parameters.ParamByName('Checkid').Value);
For Row := 1 to Grid.RowCount-2 do
begin
With Query1 do
begin
Close;
SQL.Clear;
SQL.Add('Insert into tb_countercheckdetail values (:checkid,:barcode,:num)');
Parameters.ParamByName('CheckId').Value := inid;
Parameters.ParamByName('barcode').Value := Trim(Grid.Cells[c_barcode,Row]);
Parameters.ParamByName('num').Value := StrToFloat(Grid.Cells[c_sum,Row]);
ExecSQL;
end;
With Query1 do
begin
Close;
SQL.Clear;
SQL.Add('update tb_bookcounter set num = num-:sum where counter = :counter and barcode = :barcode');
Parameters.ParamByName('sum').Value := StrToFloat(Grid.Cells[c_sum,Row]);
Parameters.ParamByName('barcode').Value := Trim(Grid.Cells[c_barcode,Row]);
Parameters.ParamByName('counter').Value := Trim(counter.Text);
ExecSQL;
end;
end;
end;
Connect.CommitTrans;
Application.MessageBox(Pchar('操作成功,票号为: '+ inid),'提示',64);
Cancel.Click;
Except
Connect.RollbackTrans;
Application.MessageBox('操作失败.','提示',64);
End;
end;
end
else //进行报溢处理
begin
if Application.MessageBox('确实要进行报溢处理吗?','提示',mb_yesno)= id_Yes then
begin
Try
Connect.BeginTrans;
if Radio1.Checked then
begin
With Query1 do
begin
Close;
SQL.Clear;
SQL.Add('Exec Add_CheckID :ID,:Storage,:Operator,:Date,:Checkid Output,:Ismore');
Parameters.ParamByName('Id').Value := 0;//0代表对仓库进行报损或报溢处理
Parameters.ParamByName('Storage').Value := Trim(Depot.Text);
Parameters.ParamByName('Operator').Value := Trim(Username);
Parameters.ParamByName('Date').Value := Picker1.DateTime;
Parameters.ParamByName('Checkid').Value := 'temp';
Parameters.ParamByName('Ismore').Value := 1;//0代表进行报损处理
ExecSQL;
end;
inid := Trim(Query1.Parameters.ParamByName('Checkid').Value);
For Row := 1 to Grid.RowCount-2 do
begin
With Query1 do
begin
Close;
SQL.Clear;
SQL.Add('Insert into tb_depotcheckdetail values (:checkid,:barcode,:num)');
Parameters.ParamByName('CheckId').Value := inid;
Parameters.ParamByName('barcode').Value := Trim(Grid.Cells[c_barcode,Row]);
Parameters.ParamByName('num').Value := StrToFloat(Grid.Cells[c_sum,Row]);
ExecSQL;
end;
With Query1 do
begin
Close;
SQL.Clear;
SQL.Add('update tb_bookdepot set num = num+:sum where depot = :depot and barcode = :barcode');
Parameters.ParamByName('sum').Value := StrToFloat(Grid.Cells[c_sum,Row]);
Parameters.ParamByName('barcode').Value := Trim(Grid.Cells[c_barcode,Row]);
Parameters.ParamByName('depot').Value := Trim(Depot.Text);
ExecSQL;
end;
end;
end
else //进行柜台报溢处理
begin
With Query1 do
begin
Close;
SQL.Clear;
SQL.Add('Exec Add_CheckID :ID,:Storage,:Operator,:Date,:Checkid Output,:Ismore');
Parameters.ParamByName('Id').Value := 1;//1代表对柜台进行报损或报溢处理
Parameters.ParamByName('Storage').Value := Trim(Counter.Text);
Parameters.ParamByName('Operator').Value := Trim(Username);
Parameters.ParamByName('Date').Value := Picker1.DateTime;
Parameters.ParamByName('Checkid').Value := 'temp';
Parameters.ParamByName('Ismore').Value := 1;//0代表进行报损处理
ExecSQL;
end;
inid := Trim(Query1.Parameters.ParamByName('Checkid').Value);
For Row := 1 to Grid.RowCount-2 do
begin
With Query1 do
begin
Close;
SQL.Clear;
SQL.Add('Insert into tb_countercheckdetail values (:checkid,:barcode,:num)');
Parameters.ParamByName('CheckId').Value := inid;
Parameters.ParamByName('barcode').Value := Trim(Grid.Cells[c_barcode,Row]);
Parameters.ParamByName('num').Value := StrToFloat(Grid.Cells[c_sum,Row]);
ExecSQL;
end;
With Query1 do
begin
Close;
SQL.Clear;
SQL.Add('update tb_bookcounter set num = num+:sum where counter = :counter and barcode = :barcode');
Parameters.ParamByName('sum').Value := StrToFloat(Grid.Cells[c_sum,Row]);
Parameters.ParamByName('barcode').Value := Trim(Grid.Cells[c_barcode,Row]);
Parameters.ParamByName('counter').Value := Trim(counter.Text);
ExecSQL;
end;
end;
end;
Connect.CommitTrans;
Application.MessageBox(Pchar('操作成功,票号为: '+ inid),'提示',64);
Cancel.Click;
Except
Connect.RollbackTrans;
Application.MessageBox('操作失败.','提示',64);
End;
end;
end;
Finally
Query1.Free;
Query2.Free;
Connect.Free;
End;
end;
function Tf_check.GridIsNull: Boolean;
var
i,j: Integer;
begin
Result := False;
if Grid.RowCount =2 then
begin
Result := True;
Exit;
end;
For i := 1 to Grid.RowCount-2 do
begin
For j := 0 to Grid.ColCount-1 do
if Trim(Grid.Cells[j,i])= '' then
begin
Result := True;
Break;
end;
end;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -