السلام عليكم ورحمة الله
عندى قاعدة بيانات آكسس لمرتبات موظفين أريد تحديث كل السجلات بزيادة المرتبات حسب المعطيات التالية
1 - المرتب الأساسى زيادة بقيمة التكست بوكس
2 - غلاء المعيشة الزيادة حسب الدرجات الوظيفية كلأتى:
الدرجة التاسعة 40% من المرتب الأساسى , الدرجة الثامنه 35% من المرتب الأساسى , الدرجة السابعة 30% من المرتب الأساسى... وهكذا
3 - علاوة فنية بنسبة 30% من المرتب الأساسى
4 - بدل سكن بنسبة 40% من المرتب الأساسى
وهكذا..
أستخدم فيجوال بيسك دوت نت 2010
وجزاكم الله خيراً
جزاك الله أخى سعود وجعلها فى ميزان حسناتك ما قصرت فكرتك ح تفيدنى كثير
الحمد لله الذى بنعمته تتم الصالحات
لقد تم الحل ولله الحمد أولاً وأخيراً ومن ثم الشكر لأخى المهندس eng_ashraf (من منتديات الفريق العربي للبرمجة) الذى أوحى بفكرة الحل فجزاءه الله خير الجزاء وكذلك الشكر أجزله للأخ الفاضل سعود الذى حاول المساعدة وأدلى بفكرته . لذلك أضع الكود الذى توصلت إليه بحمد الله وتوفيقه لكى يستفيد من الفكرة الجميع وأرجو من الجميع شاكراً لو أى حد عنده ملاحظة أو إضافة أو تصويب لخطأ ما أن لا يبخل به علينا وجزاكم الله خيرا
كود :
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
'On Error Resume Next
If TextBox28.Text = "" Or TextBox28.Text = "0" Then
MsgBox("You can't Update with Nul value", vbCritical, "Error")
Exit Sub
TextBox28.Select()
End If
Dim bsc As Double = Val(TextBox28.Text / 100)
If conn.State = ConnectionState.Closed Then
conn.Open()
End If
Dim oleDBC As New OleDbCommand
Dim oleDBDR As OleDbDataReader
Dim c As Integer
c = 0
With oleDBC
.Connection = conn
.CommandText = "select * from EMP where DEPT<>'" & Trim("Management") & "'and c_cont= False"
End With
oleDBDR = oleDBC.ExecuteReader
If oleDBDR.HasRows Then
While oleDBDR.Read
DataSet1.Tables("EMP").Rows(c).BeginEdit()
DataSet1.Tables("EMP").Rows(c).Item("BASIC") = Math.Round((Val(DataSet1.Tables("EMP").Rows(c).Item("BASIC") * bsc) + DataSet1.Tables("EMP").Rows(c).Item("BASIC")), 0)
If (DataSet1.Tables("EMP").Rows(c).Item("DEGREE") = "12") And (DataSet1.Tables("EMP").Rows(c).Item("Staff") = "1") Then
DataSet1.Tables("EMP").Rows(c).Item("life") = Math.Round(Val(DataSet1.Tables("EMP").Rows(c).Item("BASIC") * 0.41), 0)
ElseIf (DataSet1.Tables("EMP").Rows(c).Item("DEGREE") = "11") And (DataSet1.Tables("EMP").Rows(c).Item("Staff") = "1") Then
DataSet1.Tables("EMP").Rows(c).Item("life") = Math.Round(Val(DataSet1.Tables("EMP").Rows(c).Item("BASIC") * 0.38), 0)
ElseIf (DataSet1.Tables("EMP").Rows(c).Item("DEGREE") = "10") And (DataSet1.Tables("EMP").Rows(c).Item("Staff") = "1") Then
DataSet1.Tables("EMP").Rows(c).Item("life") = Math.Round(Val(DataSet1.Tables("EMP").Rows(c).Item("BASIC") * 0.35), 0)
ElseIf (DataSet1.Tables("EMP").Rows(c).Item("DEGREE") = "9") And (DataSet1.Tables("EMP").Rows(c).Item("Staff") = "1") Then
DataSet1.Tables("EMP").Rows(c).Item("life") = Math.Round(Val(DataSet1.Tables("EMP").Rows(c).Item("BASIC") * 0.32), 0)
ElseIf (DataSet1.Tables("EMP").Rows(c).Item("DEGREE") = "8") And (DataSet1.Tables("EMP").Rows(c).Item("Staff") = "1") Then
DataSet1.Tables("EMP").Rows(c).Item("life") = Math.Round(Val(DataSet1.Tables("EMP").Rows(c).Item("BASIC") * 0.29), 0)
ElseIf (DataSet1.Tables("EMP").Rows(c).Item("DEGREE") = "7") And (DataSet1.Tables("EMP").Rows(c).Item("Staff") = "1") Then
DataSet1.Tables("EMP").Rows(c).Item("life") = Math.Round(Val(DataSet1.Tables("EMP").Rows(c).Item("BASIC") * 0.26), 0)
ElseIf (DataSet1.Tables("EMP").Rows(c).Item("DEGREE") = "6") And (DataSet1.Tables("EMP").Rows(c).Item("Staff") = "1") Then
DataSet1.Tables("EMP").Rows(c).Item("life") = Math.Round(Val(DataSet1.Tables("EMP").Rows(c).Item("BASIC") * 0.23), 0)
ElseIf (DataSet1.Tables("EMP").Rows(c).Item("DEGREE") = "5") And (DataSet1.Tables("EMP").Rows(c).Item("Staff") = "1") Then
DataSet1.Tables("EMP").Rows(c).Item("life") = Math.Round(Val(DataSet1.Tables("EMP").Rows(c).Item("BASIC") * 0.2), 0)
ElseIf (DataSet1.Tables("EMP").Rows(c).Item("DEGREE") = "4") And (DataSet1.Tables("EMP").Rows(c).Item("Staff") = "1") Then
DataSet1.Tables("EMP").Rows(c).Item("life") = Math.Round(Val(DataSet1.Tables("EMP").Rows(c).Item("BASIC") * 0.17), 0)
ElseIf (DataSet1.Tables("EMP").Rows(c).Item("DEGREE") = "3") And (DataSet1.Tables("EMP").Rows(c).Item("Staff") = "1") Then
DataSet1.Tables("EMP").Rows(c).Item("life") = Math.Round(Val(DataSet1.Tables("EMP").Rows(c).Item("BASIC") * 0.16), 0)
ElseIf (DataSet1.Tables("EMP").Rows(c).Item("DEGREE") = "3") And (DataSet1.Tables("EMP").Rows(c).Item("Staff") = "2") Then
DataSet1.Tables("EMP").Rows(c).Item("life") = Math.Round(Val(DataSet1.Tables("EMP").Rows(c).Item("BASIC") * 0.44), 0)
ElseIf (DataSet1.Tables("EMP").Rows(c).Item("DEGREE") = "4") And (DataSet1.Tables("EMP").Rows(c).Item("Staff") = "2") Then
DataSet1.Tables("EMP").Rows(c).Item("life") = Math.Round(Val(DataSet1.Tables("EMP").Rows(c).Item("BASIC") * 0.41), 0)
ElseIf (DataSet1.Tables("EMP").Rows(c).Item("DEGREE") = "5") And (DataSet1.Tables("EMP").Rows(c).Item("Staff") = "2") Then
DataSet1.Tables("EMP").Rows(c).Item("life") = Math.Round(Val(DataSet1.Tables("EMP").Rows(c).Item("BASIC") * 0.38), 0)
ElseIf (DataSet1.Tables("EMP").Rows(c).Item("DEGREE") = "6") And (DataSet1.Tables("EMP").Rows(c).Item("Staff") = "2") Then
DataSet1.Tables("EMP").Rows(c).Item("life") = Math.Round(Val(DataSet1.Tables("EMP").Rows(c).Item("BASIC") * 0.35), 0)
ElseIf (DataSet1.Tables("EMP").Rows(c).Item("DEGREE") = "7") And (DataSet1.Tables("EMP").Rows(c).Item("Staff") = "22") Then
DataSet1.Tables("EMP").Rows(c).Item("life") = Math.Round(Val(DataSet1.Tables("EMP").Rows(c).Item("BASIC") * 0.32), 0)
ElseIf (DataSet1.Tables("EMP").Rows(c).Item("DEGREE") = "8") And (DataSet1.Tables("EMP").Rows(c).Item("Staff") = "2") Then
DataSet1.Tables("EMP").Rows(c).Item("life") = Math.Round(Val(DataSet1.Tables("EMP").Rows(c).Item("BASIC") * 0.29), 0)
ElseIf (DataSet1.Tables("EMP").Rows(c).Item("DEGREE") = "9") And (DataSet1.Tables("EMP").Rows(c).Item("Staff") = "2") Then
DataSet1.Tables("EMP").Rows(c).Item("life") = Math.Round(Val(DataSet1.Tables("EMP").Rows(c).Item("BASIC") * 0.27), 0)
ElseIf (DataSet1.Tables("EMP").Rows(c).Item("DEGREE") = "10") And (DataSet1.Tables("EMP").Rows(c).Item("Staff") = "22") Then
DataSet1.Tables("EMP").Rows(c).Item("life") = Math.Round(Val(DataSet1.Tables("EMP").Rows(c).Item("BASIC") * 0.25), 0)
ElseIf (DataSet1.Tables("EMP").Rows(c).Item("DEGREE") = "11") And (DataSet1.Tables("EMP").Rows(c).Item("Staff") = "2") Then
DataSet1.Tables("EMP").Rows(c).Item("life") = Math.Round(Val(DataSet1.Tables("EMP").Rows(c).Item("BASIC") * 0.25), 0)
End If
DataSet1.Tables("EMP").Rows(c).EndEdit()
Validate()
DataAdapter.Update(DataSet1.Tables("EMP"))
DataSet1.AcceptChanges()
c = c + 1
End While
End If
conn.Close()
MessageBox.Show("updated Successfully", "Modify", MessageBoxButtons.OK, MessageBoxIcon.Information)
End Sub[/align]
[align=left]