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

بناء الادوات فى ال RunTime من ال DataBase

بدأه omar ali في 3 مايو 2010 · 2 رد · 534 مشاهدة · في Microsoft Visual Basic.NET
مشاركة: واتساب X فيسبوك تيليجرام
#1 صاحب الموضوع

السلام عليكم

عندى مشكلة يا اخوانى ارجو السماعدة

فى البداية سوف اشرح الفكرة

فانا انشأ شاشة تأخذ بيانات من جدول فى الداتا بيز وبناء عليه ينشأ الادوات على الفورمة

البيانات هى لمول تجارى مقسم لادوار

فانا قمت ببناء الدور الاول والثان ولكن لا استطيع ان اوجد شرط بناء عليه يبنى بقية الادوار بمعنى

ان كل محل ينشأ له بانيل ويضع عليها بياناته وكل محل فى دور واحد يوضع على نفس السطر

فلا اجد طريقة او شرط اجعله عندما يجده ينتقل على الدور التالى وبنائ عليه يعطى مكان معين على الفورمة

هذا هوه الكود

Public Class Form1
    Public s As Integer
    Public cmd As New SqlCommand
    Public cmdRoomCount As New SqlCommand
    Public CmdFloorsNo As New SqlCommand
    Public dr As SqlDataReader
    Public drRoomCount As SqlDataReader
    Dim x As Integer
    Dim y As Integer
    Dim pan As System.Windows.Forms.Panel
    Dim lblRoomNo As Label
    Dim LblGuestName As Label
    Dim LblRoomType As Label
    Dim PicRoomStatus As PictureBox
    Dim PicCleaned As PictureBox
    Dim PicSpear As PictureBox
    Dim isMove As Boolean = False
    Public cn As New SqlConnection("Data Source=NawaziServer\EKAD;Initial Catalog=EkadHotel;Persist Security Info=True;MultipleActiveResultSets=True;User ID=sa;Password=123;")
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        CreateChart()
    End Sub
    Public Sub CreateChart()
        Dim FloorNo As Integer
        Dim FloorCount As Integer
        Dim Roomcount As Integer
        Dim PanWidth As Integer
        Dim PanHight As Integer
        Dim c As Control
        cmd.Connection = cn
        cmdRoomCount.Connection = cn
        CmdFloorsNo.Connection = cn
        If cn.State = ConnectionState.Closed Then cn.Open()
        cmd.CommandText = "Select * from Test Order By FloorNo"
        CmdFloorsNo.CommandText = "Select Max(FloorNO) from Test"
        FloorCount = cmd.ExecuteScalar
        dr = cmd.ExecuteReader
        For i As Integer = 1 To FloorCount
            cmdRoomCount.CommandText = "Select Count(TestID)as Rooms,FloorNo From Test where FloorNo=" + i.ToString + " Group By FloorNo"
            drRoomCount = cmdRoomCount.ExecuteReader
            FloorNo = 0
            Roomcount = 0
            While drRoomCount.Read = True
                FloorNo = drRoomCount(1)
                Roomcount = drRoomCount(0)
            End While
            While dr.Read = True
                PanWidth = Me.Size.Width / Roomcount
                PanHight = Me.Size.Height / FloorCount
                pan = New System.Windows.Forms.Panel
                With pan
                    .Name = "panel" + dr(0).ToString
                    .Size = New System.Drawing.Size((PanWidth - 3), 45)
                    .BorderStyle = BorderStyle.FixedSingle
                    .BackColor = Color.Gainsboro
                    .Visible = True
                    .Tag = dr("FloorNo")
                    .AllowDrop = True
                    If dr(0) = 1 Then
                        .Location = New System.Drawing.Point((Me.Size.Width - (.Size.Width + 7)), Me.y + 2)
                    Else
                        For Each c In Me.Controls
                            If TypeOf c Is Panel Then
                                If FloorNo = c.Tag Then
                                    .Location = New System.Drawing.Point(x, y)
                                ElseIf c.Tag < FloorNo Then
                                    .Location = New System.Drawing.Point((Me.Size.Width - (.Size.Width + 7)), (c.Size.Height + 3))
                                End If
                            End If
                        Next

                    End If
                    AddHandler pan.Click, New EventHandler(AddressOf Panel_click)
                    AddHandler pan.MouseMove, AddressOf pan_MouseMove
                    x = (.Location.X - PanWidth)
                    If Me.Size.Width = pan.Location.X Then
                        x -= 3
                    End If
                    y = (.Location.Y)
                    Dim PanY As Integer = 0
                    Dim PanX As Integer = 0
                    PanY = .Size.Height / 10
                    PanX = .Size.Width / 30
                    lblRoomNo = New System.Windows.Forms.Label
                    With lblRoomNo
                        .Name = "LblRN" + dr(0).ToString
                        .Size = New System.Drawing.Size(pan.Size.Width, pan.Size.Height / 3)
                        .Location = New System.Drawing.Point(PanX, PanY)
                        .TextAlign = ContentAlignment.MiddleCenter
                        .Text = dr(1).ToString
                        .Font = New System.Drawing.Font("Tahoma", 7, FontStyle.Bold, GraphicsUnit.Point, CType(0, Byte))
                    End With
                    PanY += 10
                    PanX -= 10
                    pan.Controls.Add(lblRoomNo)
                    LblGuestName = New System.Windows.Forms.Label
                    With LblGuestName
                        .Name = "LblGN" + dr(0).ToString
                        .Size = New System.Drawing.Size(pan.Size.Width + (pan.Size.Width / 4), pan.Size.Height - ((pan.Size.Height - .Size.Height) + (pan.Size.Height / 6)))
                        .Location = New System.Drawing.Point(PanX, PanY)
                        .TextAlign = ContentAlignment.MiddleCenter
                        .Text = dr(2).ToString
                        .Font = New System.Drawing.Font("Tahoma", 6, FontStyle.Bold, GraphicsUnit.Point, CType(0, Byte))
                    End With
                    PanY += 16
                    PanX += 53
                    pan.Controls.Add(LblGuestName)
                    LblRoomType = New System.Windows.Forms.Label
                    With LblRoomType
                        .Name = "LblRT" + dr(0).ToString
                        .Size = New System.Drawing.Size(pan.Size.Width - 45, pan.Size.Height - 30)
                        .Location = New System.Drawing.Point(PanX, PanY)
                        .Text = dr(12).ToString
                        .Font = New System.Drawing.Font("Tahoma", 6, FontStyle.Bold, GraphicsUnit.Point, CType(0, Byte))
                        .BorderStyle = BorderStyle.FixedSingle
                    End With
                    PanX -= 47
                    pan.Controls.Add(LblRoomType)
                    PicRoomStatus = New System.Windows.Forms.PictureBox
                    With PicRoomStatus
                        .Name = "PicRS" + dr(0).ToString
                        .Size = New System.Drawing.Size(16, 15)
                        .Location = New System.Drawing.Point(PanX, PanY)
                        If dr(4) = 0 Then
                            .BackColor = Color.Red
                        Else
                            .BackColor = Color.Green
                        End If
                        .BorderStyle = BorderStyle.FixedSingle
                    End With
                    PanX += 16
                    pan.Controls.Add(PicRoomStatus)
                    PicCleaned = New System.Windows.Forms.PictureBox
                    With PicCleaned
                        .Name = "PicCl" + dr(0).ToString
                        .Size = New System.Drawing.Size(16, 15)
                        .Location = New System.Drawing.Point(PanX, PanY)
                        If dr(7) = 1 Then
                            '    .BackgroundImage = System.Drawing.Image.FromFile("..\..\Resources\spellcheck.png")
                        Else
                            ' .BackgroundImage = System.Drawing.Image.FromFile("..\..\Resources\Clean.jpg")
                        End If
                        .BackgroundImageLayout = ImageLayout.Stretch
                        .BorderStyle = BorderStyle.FixedSingle
                    End With
                    PanX += 16
                    pan.Controls.Add(PicCleaned)
                    PicSpear = New System.Windows.Forms.PictureBox
                    With PicSpear
                        .Name = "PicSp" + dr(0).ToString
                        .Size = New System.Drawing.Size(15, 15)
                        .Location = New System.Drawing.Point(PanX, PanY)
                        If dr(7) = 1 Then
                            .BackColor = Color.AliceBlue
                        Else
                            .BackColor = Color.Aqua
                        End If
                        .BackgroundImageLayout = ImageLayout.Stretch
                        .BorderStyle = BorderStyle.FixedSingle
                    End With
                    pan.Controls.Add(PicSpear)
                    Me.Controls.Add(pan)
                End With
                If Not drRoomCount Is Nothing Then drRoomCount.Close()
            End While
        Next
        If Not dr Is Nothing Then dr.Close()
        If cn.State = ConnectionState.Open Then cn.Close()
    End Sub

هذه هى الجزئية التى يجب ان اكتب فيها الشرط وانى حاولت على ان اوجد شرط فكتبت كالاتى

With pan
                    .Name = "panel" + dr(0).ToString
                    .Size = New System.Drawing.Size((PanWidth - 3), 45)
                    .BorderStyle = BorderStyle.FixedSingle
                    .BackColor = Color.Gainsboro
                    .Visible = True
                    .Tag = dr("FloorNo")
                    .AllowDrop = True
                    If dr(0) = 1 Then
                        .Location = New System.Drawing.Point((Me.Size.Width - (.Size.Width + 7)), Me.y + 2)
                    Else
                        For Each c In Me.Controls
                            If TypeOf c Is Panel Then
                                If FloorNo = c.Tag Then
                                    .Location = New System.Drawing.Point(x, y)
                                ElseIf c.Tag < FloorNo Then
                                    .Location = New System.Drawing.Point((Me.Size.Width - (.Size.Width + 7)), (c.Size.Height + 3))
                                End If
                            End If
                        Next

                    End If

أرجو المساعدة فى اقرب وقت يا اخوانى

علما بأن لكل غرفة سكر فى الجدول وجزاكم الله خيرا

#2

ايه يا جماعة فين الردود

لكل بانيل هيكون محل او غرفة فى المول

ولكل محل او غرفة سطر فى الجدول

والجدول بيحتوى على (رقم الغرفة - الدور - اسم صاحب المحل - الحالة(متأجر ام خالى))

#3

ايه يا جماعة هوه محدش فاضى يبص فى الكود بتاعى ولا ايه

على العموم خير انا لقيت الحل خلاص

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

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