تقييم الموضوع :
  • 0 أصوات - بمعدل 0
  • 1
  • 2
  • 3
  • 4
  • 5
احتاج مساعدة ضرورية لنقل 7 اعمدة من DataGridViwe متعددة في DataGridViwe واحدة فقط
#14
الله يعافيك
العفو ما سويت لك شيء يذكر
الاستفهامات تمثل عدد الحقول ومالها دخل بالتاريخ
لاجل كتابة التاريخ دوت الوقت
PHP كود :
TextBox1.TextDate.Now.ToString("dd/MM/yyyy"
زي كذا كيف يعني؟
بارك الله فيك اضفت حقل في الجدول عشان تحفظ فيه التواريخ؟
ممكن نشوف محاولاتك في التعديل؟
رح لقاعدة البيانات واضف حقل جديد سمه
Dates
وانسخ كامل كود الفورم من هنا
PHP كود :
Imports System.Data.OleDb

Public Class Form1
    
Public Cn As New OleDbConnection("provider=microsoft.Ace.oledb.12.0;data source=  " Application.StartupPath "\database.accdb")

    Private 
Sub Button1_Click(ByVal sender As System.ObjectByVal e As System.EventArgsHandles Button1.Click
        DataGridView1
.ColumnCount 3
        DataGridView1
.Columns(0).Name "Code"
        
DataGridView1.Columns(1).Name "Sciences"
        
DataGridView1.Columns(2).Name "Mathematics"
        
Dim row As String() = New String() {"1""5""10"}
        
DataGridView1.Rows.Add(row)
        
row = New String() {"3""20""30"}
        
DataGridView1.Rows.Add(row)
        
DataGridView2.ColumnCount 3
        DataGridView2
.Columns(0).Name "Code"
        
DataGridView2.Columns(1).Name "Programming"
        
DataGridView2.Columns(2).Name "computerscience"
        
DataGridView2.Rows.Add(row)
        
row = New String() {"2""40""30"}
        
DataGridView2.Rows.Add(row)
    
End Sub

    
Private Sub Form1_Load(ByVal sender As System.ObjectByVal e As System.EventArgsHandles MyBase.Load
        
'TODO: This line of code loads data into the 'DatabaseDataSet.SAVE1' table. You can move, or remove it, as needed.
        Me.SAVE1TableAdapter.Fill(Me.DatabaseDataSet.SAVE1)
        '
TODOThis line of code loads data into the 'DatabaseDataSet.Reports1' tableYou can move, or remove it, as needed.
        
Me.Reports1TableAdapter.Fill(Me.DatabaseDataSet.Reports1)
    
End Sub
    
Private Sub Reports1BindingNavigatorSaveItem_Click(ByVal sender As System.ObjectByVal e As System.EventArgs)
        
Me.Validate()
        
Me.Reports1BindingSource.EndEdit()
        
Me.TableAdapterManager.UpdateAll(Me.DatabaseDataSet)
    
End Sub

    
Private Sub Button2_Click(sender As System.ObjectAs System.EventArgsHandles Button2.Click
        SAVE1DataGridView
.DataSource Nothing
        SAVE1DataGridView
.ColumnCount 8
        SAVE1DataGridView
.Columns(7).Name "Date"
        
For As Integer 0 To Reports1DataGridView.Rows.Count 2
            SAVE1DataGridView
.Rows.Add(Reports1DataGridView.Rows(i).Cells(0).ValueReports1DataGridView.Rows(i).Cells(1).Value,
Reports1DataGridView.Rows(i).Cells(2).Value
)
            For 
As Integer 0 To DataGridView1.Rows.Count 2
                
If Reports1DataGridView.Rows(i).Cells(0).Value DataGridView1.Rows(u).Cells(0).Value Then
                    SAVE1DataGridView
.Rows(i).Cells(4).Value = (DataGridView1.Rows(u).Cells(1).Value)
                    
SAVE1DataGridView.Rows(i).Cells(3).Value = (DataGridView1.Rows(u).Cells(2).Value)
                
End If
            
Next

            
For As Integer 0 To DataGridView1.Rows.Count 2
                
If Reports1DataGridView.Rows(i).Cells(0).Value DataGridView2.Rows(G).Cells(0).Value Then
                    SAVE1DataGridView
.Rows(i).Cells(5).Value = (DataGridView2.Rows(G).Cells(2).Value)
                    
SAVE1DataGridView.Rows(i).Cells(6).Value = (DataGridView2.Rows(G).Cells(1).Value)
                
End If
                
' here new column for viewing date
                SAVE1DataGridView.Rows(i).Cells(7).Value = Date.Now.ToString("dd/MM/yyyy")

                ' 
for saving it you need create new field in Table

            Next

        Next

    End Sub

    
Private Sub Button3_Click(sender As System.ObjectAs System.EventArgsHandles Button3.Click
        
For As Integer 0 To SAVE1DataGridView.Rows.Count 2
            Dim Cmd 
As New OleDbCommand("Insert into SAVE(code,name,class,Mathematics,Sciences,computerscience,Programming,dates)values(?,?,?,?,?,?,?,?)"Cn)
            If 
Cn.State Then Cn.Close()
            
Cn.Open()

            
Cmd.Parameters.AddWithValue("@code"SAVE1DataGridView.Rows(i).Cells(0).Value)
            
Cmd.Parameters.AddWithValue("@name"SAVE1DataGridView.Rows(i).Cells(1).Value)
            
Cmd.Parameters.AddWithValue("@class"SAVE1DataGridView.Rows(i).Cells(2).Value)
            
Cmd.Parameters.AddWithValue("@Mathematics"Val(SAVE1DataGridView.Rows(i).Cells(3).Value))
            
Cmd.Parameters.AddWithValue("@Sciences"Val(SAVE1DataGridView.Rows(i).Cells(4).Value))
            
Cmd.Parameters.AddWithValue("@computerscience"Val(SAVE1DataGridView.Rows(i).Cells(5).Value))
            
Cmd.Parameters.AddWithValue("@Programming"Val(SAVE1DataGridView.Rows(i).Cells(6).Value))
            
' here you should write values to new filed in Table
            Cmd.Parameters.AddWithValue("@Dates", Val(SAVE1DataGridView.Rows(i).Cells(7).Value))
            Cmd.ExecuteNonQuery()
        Next
    End Sub
End Class 
واحذف جميع كود الفورم واعمل لصق
شغل المشروع وشوف
بالتوفيق
سبحان الله والحمدلله ولا إله إلا الله والله أكبر
 اللهم اغْفِرْ لِلمؤمنين والمؤمنات والمسلمين والمسلمات الأحياء منهم والأموات
الرد }}}
تم الشكر بواسطة: moh61 , moh61


الردود في هذا الموضوع
RE: احتاج مساعدة ضرورية لنقل 7 اعمدة من DataGridViwe متعددة في DataGridViwe واحدة فقط - بواسطة أبو عمر - 13-10-15, 05:24 AM


التنقل السريع :


يقوم بقرائة الموضوع: