الفريق العربي للبرمجةأرشيف المنتديات · 2000 – 2023
نسخة أرشيفية للقراءة فقط — التسجيل والمشاركة مغلقان، والمحتوى محفوظ كما كان.

مساعدة فى تحديث قاعدة بيانات بكبسة واحدة

بدأه hsab في 1 فبراير 2014 · 6 رد · 577 مشاهدة · في Microsoft Visual Basic.NET
مشاركة: واتساب X فيسبوك تيليجرام
#1 صاحب الموضوع

السلام عليكم ورحمة الله


عندى قاعدة بيانات آكسس لمرتبات موظفين أريد تحديث كل السجلات بزيادة المرتبات حسب المعطيات التالية


1 - المرتب الأساسى زيادة بقيمة التكست بوكس


2 - غلاء المعيشة الزيادة حسب الدرجات الوظيفية كلأتى:


الدرجة التاسعة 40% من المرتب الأساسى , الدرجة الثامنه 35% من المرتب الأساسى , الدرجة السابعة 30% من المرتب الأساسى... وهكذا


3 - علاوة فنية بنسبة 30% من المرتب الأساسى


4 - بدل سكن بنسبة 40% من المرتب الأساسى


وهكذا..


أستخدم فيجوال بيسك دوت نت 2010


وجزاكم الله خيراً


#2

للتوضيح

 

أنا إستخدمت الكود التالى لتحديث سجل موظف واحد ولم أستطع تحويره لتحدي كل البيانات

     ' On Error Resume Next
        If Trim(TextBox20.Text) = "" Then TextBox20.Text = "0"
        If Trim(TextBox14.Text) = "" Then TextBox14.Text = "0"
        If Trim(TextBox15.Text) = "" Then TextBox15.Text = "0"

        '.....................................................reprsentif
        If Trim(ComboBox2.Text) = "Officer" Then
            If Trim(txtclss.Text) >= "9" Then
                TextBox5.Text = "20"
            ElseIf Trim(txtclss.Text) = "8" Then
                TextBox5.Text = "25"
            ElseIf Trim(TextBox4.Text) = "7" Then
                TextBox5.Text = "30"
            ElseIf Trim(TextBox4.Text) = "7A" Then
                TextBox5.Text = "35"
            ElseIf Trim(txtclss.Text) = "6" Then
                TextBox5.Text = "40"
            ElseIf Trim(txtclss.Text) = "5" Then
                TextBox5.Text = "45"
            ElseIf Trim(txtclss.Text) = "4" Then
                TextBox5.Text = "50"
            ElseIf Trim(txtclss.Text) = "10" Then
                TextBox5.Text = "20"
            ElseIf Trim(txtclss.Text) = "11" Then
                TextBox5.Text = "20"
            Else
                TextBox5.Text = "0"
            End If
            '..........................................................
        ElseIf Trim(ComboBox2.Text) = "Technical" Then
            If Trim(txtclss.Text) = "3" Or Trim(txtclss.Text) = "2" Then
                TextBox5.Text = "100"
            ElseIf Trim(txtclss.Text) = "7" Then
                TextBox5.Text = "50"
            ElseIf Trim(txtclss.Text) = "6" Then
                TextBox5.Text = "60"
            ElseIf Trim(txtclss.Text) = "5" Then
                TextBox5.Text = "80"
            ElseIf Trim(txtclss.Text) = "4" Then
                TextBox5.Text = "90"
            ElseIf Val(txtclss.Text) > "7" Then
                TextBox5.Text = "40"
            Else
                TextBox5.Text = "0"
            End If
        Else
            TextBox5.Text = "0"
        End If

        '....................................................................
        If Trim(txttype.Text) = "1" And Trim(txtclss.Text) = "12" Then
            TextBox8.Text = Math.Round(TextBox6.Text * 0.41, 0)
        ElseIf Trim(txttype.Text) = "1" And Trim(txtclss.Text) = "11" Then
            TextBox8.Text = Math.Round(TextBox6.Text * 0.38, 0)
        ElseIf Trim(txttype.Text) = "1" And Trim(txtclss.Text) = "10" Then
            TextBox8.Text = Math.Round(TextBox6.Text * 0.35, 0)
        ElseIf Trim(txttype.Text) = "1" And Trim(txtclss.Text) = "9" Then
            TextBox8.Text = Math.Round(TextBox6.Text * 0.32, 0)
        ElseIf Trim(txttype.Text) = "1" And Trim(txtclss.Text) = "8" Then
            TextBox8.Text = Math.Round(TextBox6.Text * 0.29, 0)
        ElseIf Trim(txttype.Text) = "1" And Trim(txtclss.Text) = "7" Then
            TextBox8.Text = Math.Round(TextBox6.Text * 0.26, 0)
        ElseIf Trim(txttype.Text) = "1" And Trim(txtclss.Text) = "6" Then
            TextBox8.Text = Math.Round(TextBox6.Text * 0.23, 0)
        ElseIf Trim(txttype.Text) = "1" And Trim(txtclss.Text) = "5" Then
            TextBox8.Text = Math.Round(TextBox6.Text * 0.2, 0)
        ElseIf Trim(txttype.Text) = "1" And Trim(txtclss.Text) = "4" Then
            TextBox8.Text = Math.Round(TextBox6.Text * 0.17, 0)
        ElseIf Trim(txttype.Text) = "1" And Trim(txtclss.Text) = "3" Then
            TextBox8.Text = Math.Round(TextBox6.Text * 0.16, 0)
        ElseIf Trim(txttype.Text) = "2" And Trim(txtclss.Text) = "3" Then
            TextBox8.Text = Math.Round(TextBox6.Text * 0.44, 0)
        ElseIf Trim(txttype.Text) = "2" And Trim(txtclss.Text) = "4" Then
            TextBox8.Text = Math.Round(TextBox6.Text * 0.41, 0)
        ElseIf Trim(txttype.Text) = "2" And Trim(txtclss.Text) = "5" Then
            TextBox8.Text = Math.Round(TextBox6.Text * 0.38, 0)
        ElseIf Trim(txttype.Text) = "2" And Trim(txtclss.Text) = "6" Then
            TextBox8.Text = Math.Round(TextBox6.Text * 0.35, 0)
        ElseIf Trim(txttype.Text) = "2" And Trim(txtclss.Text) = "7" Then
            TextBox8.Text = Math.Round(TextBox6.Text * 0.32, 0)
        ElseIf Trim(txttype.Text) = "2" And Trim(txtclss.Text) = "8" Then
            TextBox8.Text = Math.Round(TextBox6.Text * 0.29, 0)
        ElseIf Trim(txttype.Text) = "2" And Trim(txtclss.Text) = "9" Then
            TextBox8.Text = Math.Round(TextBox6.Text * 0.27, 0)
        ElseIf Trim(txttype.Text) = "2" And Trim(txtclss.Text) = "10" Then
            TextBox8.Text = Math.Round(TextBox6.Text * 0.25, 0)
        ElseIf Trim(txttype.Text) = "2" And Trim(txtclss.Text) = "11" Then
            TextBox8.Text = Math.Round(TextBox6.Text * 0.25, 0)
        End If
        '....................................................................Cola
        TextBox8.Text = Math.Round(TextBox8.Text + 100, 0)
        '....................................................................Mohda
        TextBox9.Text = Math.Round(TextBox6.Text * 0.25, 0, MidpointRounding.AwayFromZero) '"0.00" '
        '....................................................................fire
        TextBox7.Text = 50
        '....................................................................
        If CheckBox3.Checked = True Then
            TextBox12.Text = Math.Round(TextBox6.Text * 0.4, 0, MidpointRounding.AwayFromZero)
            TextBox14.Text = "0.00"
        Else
            TextBox12.Text = "0.00"
            TextBox14.Text = "100"

        End If
        '....................................................................shift
        If CheckBox1.Checked = True Then
            TextBox10.Text = Math.Round(TextBox6.Text * 0.4, 0, MidpointRounding.AwayFromZero)
        Else
            TextBox10.Text = "0.00"
        End If
        '....................................................................
        TextBox11.Text = Math.Round(TextBox6.Text * 0.2, 0, MidpointRounding.AwayFromZero)
        '....................................................................bounus
        TextBox19.Text = Math.Round(TextBox6.Text * 0.4, 0, MidpointRounding.AwayFromZero)
        btxt.Text = Val(TextBox5.Text) + Val(TextBox31.Text) + Val(TextBox6.Text) + Val(TextBox7.Text) + Val(TextBox8.Text) + Val(TextBox9.Text) + Val(TextBox10.Text) + Val(TextBox11.Text) + Val(TextBox19.Text)
        '....................................................................TOTAL
        TextBox13.Text = Val(TextBox5.Text) + Val(TextBox31.Text) + Val(TextBox6.Text) + Val(TextBox7.Text) + Val(TextBox8.Text) + Val(TextBox9.Text) + Val(TextBox10.Text) + Val(TextBox11.Text) + Val(TextBox12.Text) + Val(TextBox14.Text)
        TextBox23.Text = Val(TextBox5.Text) + Val(TextBox31.Text) + Val(TextBox6.Text) + Val(TextBox7.Text) + Val(TextBox8.Text) + Val(TextBox10.Text) + Val(TextBox11.Text) + Val(TextBox12.Text) + Val(TextBox14.Text)
        '....................................................................SSF
        TextBox18.Text = (Val(btxt.Text) - 120) * 0.08
        TextBox22.Text = Val(btxt.Text) * 0.17
        '....................................................................LPF
        If CheckBox4.Checked = True Then
            TextBox17.Text = Val(TextBox6.Text) * (Val(TextBox15.Text) / 100) 'Val(LPFtxt.Text)
        Else
            TextBox17.Text = "0.00"
        End If


        '....................................................................status
        If Val(ComboBox1.Text) = 2 Then ComboBox1.Text = "Married"

        If Val(ComboBox1.Text) = 1 Then ComboBox1.Text = "Single"
        '....................................................................Teckits
        If Trim(btxt.Text) <> "" Then
            If Trim(txtstatus.Text) = "1" Then
                TextBox21.Text = Math.Round(Val(btxt.Text) * 3.5, 0, MidpointRounding.AwayFromZero)
            ElseIf Trim(txtstatus.Text) = "2" And Trim(TextBox20.Text) = "0" Then
                TextBox21.Text = Math.Round(Val(btxt.Text) * 4.5, 0, MidpointRounding.AwayFromZero)
            ElseIf Trim(txtstatus.Text) = "2" And Trim(TextBox20.Text) = "1" Or Trim(TextBox20.Text) = "2" Or Trim(TextBox20.Text) = "3" Then
                TextBox21.Text = Math.Round(Val(btxt.Text) * 5.75, 0, MidpointRounding.AwayFromZero)
            Else
                TextBox21.Text = Math.Round(Val(btxt.Text) * 7.75, 0, MidpointRounding.AwayFromZero)
            End If
        End If

وكود التحديث

    Private Sub cmdw_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdw.Click
        s = "Update EMP set DISCNO='" & TextBox3.Text
        s += "', NAME='" & TextBox1.Text
        s += "', MARRIED='" & txtstatus.Text
        s += "', DEGREE='" & TextBox4.Text
        s += "', DEPT='" & TextBox2.Text
        s += "', Staff='" & txttype.Text
        s += "', BASIC='" & TextBox6.Text
        s += "', life='" & TextBox8.Text
        s += "', Mohda='" & TextBox9.Text
        s += "', rent='" & TextBox12.Text
        s += "', emp_fire='" & TextBox7.Text
        s += "', exp='" & TextBox11.Text
        s += "', shft='" & TextBox10.Text
        s += "', reprs='" & TextBox5.Text
        s += "', stove='" & TextBox31.Text
        s += "', emp_gross='" & TextBox13.Text
        s += "', q_society='" & TextBox25.Text
        s += "', clasif='" & ComboBox2.Text
        s += "', LPFperc='" & TextBox15.Text
        s += "', flt_enc='" & TextBox14.Text
        s += "', LPFval='" & TextBox17.Text
        s += "', nochild='" & TextBox20.Text
        s += "', dsort='" & TextBox24.Text
        s += "', ticket_V='" & TextBox21.Text
        s += "', comssf='" & TextBox22.Text
        s += "', all_gross='" & btxt.Text
        s += "', bounus='" & btxt.Text * 2
        s += "', SSF='" & TextBox18.Text & "'"
        s += ", firee=" & ch1.Checked
        s += ", emp_has_shift=" & CheckBox1.Checked
        s += ", rentee=" & CheckBox3.Checked
        s += ", emp_has_taxes=" & CheckBox2.Checked
        s += ", LPF=" & CheckBox4.Checked
        s += ", q_soc=" & CheckBox5.Checked
        s += " where NAME='" & Dlst.Items(Dlst.SelectedIndex) & "'" '& TextBox1.Text & "'"
        r = MsgBox("Are you sure", vbYesNo + vbCritical, "Modify")
        If r = vbYes Then
            ExQuery("Update")
        End If
        MessageBox.Show("updated Successfully", "Modify", MessageBoxButtons.OK, MessageBoxIcon.Information)
        showdata()
    End Sub
#3

يا أخوان ممكن بس توضحوا لى كيف أحدث السجل داخل القاعدة مثلاً  مثل ما فى فيشوال 6:

rs.field(t1) = rs.field(t1)* 0.08

تم تعديل هذه المشاركة بواسطة hsab في 1 فبراير 2014 في 16:58

#4

اذا انت تقصد انك تريد تغيير قيمة بيانات ماليه لكل موظف حسب شرط معين فاقترح عمل الاتي:

اولا

جلب كافة البيانات التي تخص كل موضف عن طريق استعلام مثلا

و خزن البيانات ب DataTable و ليكن اسمها  DT مثلا

و بعد ذلك استخدم  foreach للمرور على كل الصفوف مثل

foreach(DataRow r in DT.rows)

{

و هن تعمل الفحص و التغيير مثلا لفحص القسم و لنفرض انك مخزن القسم بالعمود job

if(r["job"].toString=="officer")

{

تعدل قيمة الراتب مثلا تريد زيادة الراتب 20 ريال

r["sal"]=((Conver.ToDouble(r["Sal"].ToString)+20).ToString();

}


}

هيك الفكره اللي ببالي اذا بتساعدك

المهندس

#5
eng_ashraf كتب:

اذا انت تقصد انك تريد تغيير قيمة بيانات ماليه لكل موظف حسب شرط معين فاقترح عمل الاتي:

اولا

جلب كافة البيانات التي تخص كل موضف عن طريق استعلام مثلا

و خزن البيانات ب DataTable و ليكن اسمها  DT مثلا

و بعد ذلك استخدم  foreach للمرور على كل الصفوف مثل

foreach(DataRow r in DT.rows)

{

و هن تعمل الفحص و التغيير مثلا لفحص القسم و لنفرض انك مخزن القسم بالعمود job

if(r["job"].toString=="officer")

{

تعدل قيمة الراتب مثلا تريد زيادة الراتب 20 ريال

r["sal"]=((Conver.ToDouble(r["Sal"].ToString)+20).ToString();

}


}

هيك الفكره اللي ببالي اذا بتساعدك

 

أخى جزاك الله خيراً فكرتك رائعة ممكن أحاول أطبقها ولكن ياريت لو تكرمت بتبسيطها أكتر وشكلك بتستخدم   C#    أرجو فقط توضيح بسيط بكود حى  لجزء من مثالى ولك الشكر والتقدير

 

وفى كل الأحوال لقد وضعتنى فى بداية الطريق الصحيح

تم تعديل هذه المشاركة بواسطة hsab في 1 فبراير 2014 في 17:44

#6

عملت هذا الكود بالفيجوال بيسك 6 وهو يعمل بصورة ممتازة بس لم أستطع تحويره للدوت نت وهذا ربما يساعد الأخوة فى فهم المطلوب بالضبط


'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx form basic increase

'íÍÊæì ÇáÝæÑã Úáì ÊßÓÊ æÇÍÏ ÈÅÓã txtincrease(1)

'æÒÑ æÇÍÏ ÈÅÓã cmdsavbsc

Private Sub cmdsavbsc_Click()

On Error Resume Next

If txtincrease(1).Text = "" Or txtincrease(1).Text = "0" Then

   MsgBox "You can't Update with Nul value", vbCritical, "Error"

Exit Sub

txtincrease(1).SetFocus

End If

   Cont = InputBox("Are you sure you want to increase the Basic? (Y/N)")

   If (UCase(Cont) = "Y") Then


      Raz = MsgBox("You can't be able to undo this step", vbYesNo + vbCritical, "Caution")

        If Raz = vbYes Then


Dim rgh, stot, Nbsc As Double

With rs

.MoveFirst

Do While Not .EOF

.Find "DISCNO = " + Trim(!DISCNO)

!old_basic = !BASIC


'Nbsc = Format$((CSng(!BASIC) * CSng(txtincrease(1) / 100) + CSng(!BASIC)), "0")

      Nbsc = Round(rs.Fields("BASIC") * (txtincrease(1) / 100) + (rs.Fields("BASIC")))

'.....................................................Cola

         If rs.Fields("degree") = "1" Then

         Select Case rs.Fields("degree")

                Case 4

                     rs.Fields("life") = Round(Nbsc * 0.17)

                Case 5

                      rs.Fields("life") = Round(Nbsc * 0.2)

                Case 6

                      rs.Fields("life") = Round(Nbsc * 0.23)

                Case 7

                      rs.Fields("life") = Round(Nbsc * 0.26)

                Case 8

                      rs.Fields("life") = Round(Nbsc * 0.29)

                Case 9

                      rs.Fields("life") = Round(Nbsc * 0.32)

                Case 10

                      rs.Fields("life") = Round(Nbsc * 0.35)

                Case 11

                      rs.Fields("life") = Round(Nbsc * 0.38)

                Case 12

                      rs.Fields("life") = Round(Nbsc * 0.41)

          End Select

      End If

                  If rs.Fields("degree") = "2" Then

         Select Case rs.Fields("degree")

                Case 1

                      rs.Fields("life") = Round((Nbsc * 0.5))

                Case 2

                      rs.Fields("life") = Round((Nbsc * 0.47))

                Case 3

                      rs.Fields("life") = Round((Nbsc * 0.44))

                Case 4

                      rs.Fields("life") = Round((Nbsc * 0.41))

                Case 5

                      rs.Fields("life") = Round((Nbsc * 0.38))

                Case 6

                      rs.Fields("life") = Round((Nbsc * 0.35))

                Case 7

                      rs.Fields("life") = Round((Nbsc * 0.32))

                Case 8

                      rs.Fields("life") = Round((Nbsc * 0.29))

                Case 9

                      rs.Fields("life") = Round((Nbsc * 0.27))

                Case 10

                      rs.Fields("life") = Round((Nbsc * 0.25))

                Case 11

                      rs.Fields("life") = Round((Nbsc * 0.25))




         End Select

      End If



'.....................................................Representation

If Trim(!clasif) = "Officer" Then

If Trim(!degree) >= "9" Then

!reprs = "20"

ElseIf Trim(!degree) = "8" Then

!reprs = "25"

ElseIf Trim(!degree) = "7" Then

!reprs = "30"

ElseIf Trim(!degree) = "7A" Then

!reprs = "35"

ElseIf Trim(!degree) = "6" Then

!reprs = "40"

ElseIf Trim(!degree) = "5" Then

!reprs = "45"

ElseIf Trim(!degree) = "4" Then

!reprs = "50"

ElseIf Trim(!degree) = "10" Then

!reprs = "20"

ElseIf Trim(!degree) = "11" Then

!reprs = "20"

Else

!reprs = "0"

End If

'..........................................................

ElseIf Trim(!clasif) = "Technical" Then

If Trim(!degree) = "3" Or Trim(!degree) = "2" Then

!reprs = "100"

ElseIf Trim(!degree) = "7" Then

!reprs = "50"

ElseIf Trim(!degree) = "6" Then

!reprs = "60"

ElseIf Trim(!degree) = "5" Then

!reprs = "80"

ElseIf Trim(!degree) = "4" Then

!reprs = "90"

ElseIf CSng(!degree) > "7" Then

!reprs = "40"

Else

!reprs = "0"

End If

Else

!reprs = "0"

End If

!stove = "5"

!emp_fire = "50"

        '....................................................................Basic

          !BASIC = Nbsc

        '....................................................................Unified Alw.

         ' !mohda = Format$(CSng(Nbsc * 0.25), "0")

          !mohda = Round(0.25 * Nbsc)

        '....................................................................Rent

If !rentee = True Then

          !rent = Round(0.4 * Nbsc)

!flt_enc = "0.00"

Else

!rent = "0.00"

!flt_enc = "100"

End If

        '....................................................................shift

If !emp_has_shift = True Then

          !shft = Round(0.4 * Nbsc)

Else

!shft = "0.00"

End If

        '....................................................................exp

                  !Exp = Round(0.2 * Nbsc)


        '....................................................................All gross

                  rgh = Format$(CSng(Nbsc * 0.4), "0")

      !all_gross = Format$(CSng(Nbsc) + CSng(!life) + CSng(!Exp) + CSng(!reprs) + CSng(!shft) + CSng(!emp_fire) + CSng(rgh) + CSng(!mohda) + CSng(!stove) + CSng(!Other_Alw), "0")

        '....................................................................bounus

      !bounus = (Format$(CSng(Nbsc) + CSng(!life) + CSng(!Exp) + CSng(!reprs) + CSng(!shft) + CSng(!emp_fire) + CSng(rgh) + CSng(!mohda) + CSng(!stove) + CSng(!Other_Alw), "0")) * 2

        '....................................................................TOTAL

!emp_gross = Format$(CSng(Nbsc) + CSng(!life) + CSng(!Exp) + CSng(!reprs) + CSng(!rent) + CSng(!shft) + CSng(!emp_fire) + CSng(!flt_enc) + CSng(!mohda) + CSng(!stove) + CSng(!Other_Alw), "0")

        '....................................................................SSF TOTAL

      stot = Format$(CSng(Nbsc) + CSng(!life) + CSng(!Exp) + CSng(!reprs) + CSng(!shft) + CSng(!emp_fire) + CSng(rgh) + CSng(!mohda) + CSng(!stove) + CSng(!Other_Alw) - CSng(!SSFminus), "0")

        '....................................................................SSF

        !SSF = Format$(CSng(stot) * 0.08, "0.00")

        !comssf = Format$(CSng(stot) * 0.17, "0.00")

        '....................................................................LPF

        If !LPF = True Then

            !LPFval = Format$(CSng(Nbsc) * (CSng(!LPFperc) / 100), "0.00") 'CSng(LPFtxt.Text)

        Else

            !LPFval = "0.00"

        End If

          '....................................................................Teckits

        If Trim(!all_gross) <> "" Then

        If Trim(!MARRIED) = "1" Then

        !ticket_V = Format$(CSng(!all_gross) * 3.5, "0")

        ElseIf Trim(!MARRIED) = "2" And Trim(!nochild) = "0" Then

        !ticket_V = Format$(CSng(!all_gross) * 4.5, "0")

        ElseIf Trim(!MARRIED) = "2" And Trim(!nochild) = "1" Or Trim(!nochild) = "2" Or Trim(!nochild) = "3" Then

        !ticket_V = Format$(CSng(!all_gross) * 5.75, "0")

        Else

        !ticket_V = Format$(CSng(!all_gross) * 7.75, "0")

        End If

         End If

        '....................................................................Letter

!increase = CSng(Nbsc) - CSng(!old_basic)

!d_date = txtdate


        '....................................................................End


         .UpdateBatch adAffectCurrent

.MoveNext

Loop

MsgBox "updated Successfully ", vbMsgBox + vbInformation, "Modify"

End With

  End If

   End If

cmdsavbsc.Enabled = False

hsab

End Sub

#7

الحمد لله الذى بنعمته تتم الصالحات

 

لقد تم الحل ولله الحمد أولاً وأخيراً ومن ثم الشكر لأخى المهندس  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

مواضيع مشابهة