السلام عليكم ورحمة الله وبركاته
عندي مشكلة عند تعديل السجل رقم 22 مثلا
بعد الحفظ ينتقل المؤشر للسجل الأول في الجدول
هل من طريقة لجعلة المؤشر يقف على السجل التالي
قاعدة البيانات المستخدمة sqlite3
وشكرا جزيلا
كود :
procedure TempEdit_frm.btnSaveClick(Sender: TObject);
begin
try
if fname.Text = '' then
begin
showmessage('يجب ادخال اسم الموظف');
fname.SetFocus;
exit;
end
else if card.Text = '' then
begin
showmessage('يجب ادخال الرقم القومي');
card.SetFocus;
exit;
end ;
if dm.qry_emp.State in[dsEdit,dsInsert] then
begin
dm.qry_emp.Post;
close;
end
else
ShowMessage('لا يوجد تغييرات لحفظها !');
except on E: Exception do
ShowMessage('حدث خطأ ما !');
end;
end;
السلام عليكم ورحمة الله وبركاته
تم حل المشكلة بتغيير أداة الاتصال بقاعدة البيانات من zeosdb الى sqliteconnection المرفق مع لازاروس
وعليكم السلام ورحمة الله
في الدلفي هناك Bookmark يمكنك استخدامها مهما كانت الادوات التي تستخدمها
على سبيل المثال
كود :
{
This example uses a button to copy the value of a field in
the previous record into the corresponding field in the
current record.
}
procedure TForm1.Button1Click(Sender: TObject);
var
SavePlace: TBookmark;
PrevValue: Variant;
begin
with Customers do
begin
{ get a bookmark so that we can return to the same record }
SavePlace := GetBookmark;
try
{ move to prior record}
FindPrior;
{ get the value }
PrevValue := FindField('Field2').Value;
{Move back to the bookmark
this may not be the next record anymore
if something else is changing the dataset asynchronously }
GotoBookmark(SavePlace);
{ Set the value }
Edit;
FindField('Field2').Value := PrevValue;
{ Free the bookmark }
finally
FreeBookmark(SavePlace);
end;
end;
end;
{
To ensure that the button is disabled when there is no
previous record, the OnDataChange event of the DataSource
detects when the user moves to the beginning of file (BOF
property becomes true), and disables the button. Detection
occurs on scrolling and editing, not selection with the mouse.
}
procedure TForm1.DS2DataChange(Sender: TObject; Field: TField);
begin
if Customers.Bof then
Button1.Enabled := False
else
Button1.Enabled := True;
end;
تم تعريف متغير من نوع TBookmark
قبل ان يجري اي شئ وضع فيه مكانه الحالي
كود :
SavePlace := GetBookmark;
باي وقت وبعد اجراءك لأي تعديلات اضافة حذف او اي شئ
يمكنك الانتقال للسجل الذي كنت تقف عليه
كود :
GotoBookmark(SavePlace);
ايضا من المهم لانهاء شفرتك بطريقة صحيحة ان تتخلص من التعريف بعد الانتهاء منه
كود :
FreeBookmark(SavePlace);
شكرا جزيلا أخ viv تم تطبيق مثال ال bookmark بنجاح
ولكن ملاحظة هذه المشكلة كانت تحدث فقط عند تغيير ترتيب الجريد الى ترتيب ابجدي باستخدام zeosdbo
كود :
if cbsort.Text = 'الاسم' then dm.qry_emp.SortedFields:='fname';
if cbsort.Text = 'الرقم القومي' then dm.qry_emp.SortedFields:='card';
if cbsort.Text = 'القسم' then dm.qry_emp.SortedFields:='department';
اجل بحال التعديل لا ينتقل المؤشر الى اول السجل ابدا الا بحال قمت بعمل ما مثل الفلترة او الترتيب كما فعلت هنا