咏南3层数据集控件--TYNDataSet
和2层CS数据集的语法非常近似。有了这个控件,学习掌握3层开发变得如此地简单。
新增数据:
procedure Tfunit.btnappendClick(Sender: TObject);
begin
ynDataSet1.Append;
end;
修改数据:
procedure Tfunit.btneditClick(Sender: TObject);
begin
ynDataSet1.Edit;
end;
删除数据:
procedure Tfunit.btndeleteClick(Sender: TObject);
begin
if Application.MessageBox('是否删除?', '', MB_YESNO + MB_ICONQUESTION) =
IDYES then
begin
if ynDataSet1.Delete2 then
ynmsg('删除成功') else
ynmsg('删除失败');
end;
end;
保存数据:
procedure Tfunit.cxButton1Click(Sender: TObject);
begin
if ynDataSet1.Post2 then begin
ynmsg('保存成功');
end
else
ynmsg('保存失败');
end;
取消数据:
procedure Tfunit.cxButton2Click(Sender: TObject);
begin
ynDataSet1.Cancel;
end;
调用存储过程:
function Tfcgrk.updatekc(const action: string): Boolean;
begin
ynDataSet1.Close;
ynDataSet1.ProcedureName := 'sp_kc';
ynDataSet1.Parameters.ParamByName('billtype').Text := '采购入库';
ynDataSet1.Parameters.ParamByName('billid').Text := ynDataSet1.fieldbyname('billid').Text;
ynDataSet1.Parameters.ParamByName('action').Text := action;
Result := ynDataSet1.ExecProc;
end;
事务批提交:
if ynDataSet1.SaveDatas(VarArrayOf(['tcgrk', 'tcgrk2']), VarArrayOf([ynDataSet1.Delta, ynDataSet2.Delta]), 2) then
begin
ynDataSet1.MergeChangeLog;
ynDataSet2.MergeChangeLog;
ynmsg('保存成功');
end else
ynmsg('保存失败');
end;