01-05-19, 03:34 PM
السلام عليكم ورحمة الله وبركاتة
انا لدي كود لتعبية داتاجريد فيو كمبوبوكس
وشغال والحمد لله لكن
ابغى المستخدم لما يختار من الكمبوبكس
الحقول الاخرة تتعبة حسب الاختيار
وهذا كود تعبيئة الكمبوبوكس
كود :
Sub getItemunits(ItemsID As String)
Dim adp As New SqlClient.SqlDataAdapter("select * from TBLItems where ItemsID =N'" & ItemsID & "'", SqlConn)
Dim ds As New DataSet
adp.Fill(ds)
Dim dt = ds.Tables(0)
If dt.Rows.Count > 0 Then
Dim DGV As DataGridViewComboBoxCell
DGV = DGVK.Rows(DGVK.Rows.Count - 1).Cells(2)
DGV.Items.Clear()
DGV.Items.Add(dt.Rows(0).Item("ItemsUnit1"))
If dt.Rows(0).Item("ItemsUnit2").ToString <> "" Then DGV.Items.Add(dt.Rows(0).Item("ItemsUnit2"))
If dt.Rows(0).Item("ItemsUnit3").ToString <> "" Then DGV.Items.Add(dt.Rows(0).Item("ItemsUnit3"))
DGVK.ClearSelection()
DGVK.Rows(DGVK.Rows.Count - 1).Cells(2).Selected = True
End If
End Subوهذا التابل
كود :
USE [Antaj]
GO
/****** Object: Table [dbo].[TBLItems] Script Date: 05/01/2019 14:29:57 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[TBLItems](
[ID] [int] IDENTITY(1,1) NOT NULL,
[ItemsID] [nvarchar](50) NULL,
[ItemsName] [nvarchar](50) NULL,
[ItemsBarcode] [int] NULL,
[ItemsCategories] [nvarchar](50) NULL,
[ItemsQTY] [int] NULL,
[SuplersID] [int] NULL,
[ItemsUnit1] [nvarchar](50) NULL,
[ItemsUnit1QTY] [int] NULL,
[ItemsUnit1PRICE] [decimal](18, 0) NULL,
[ItemsUnit2] [nvarchar](50) NULL,
[ItemsUnit2QTY] [int] NULL,
[ItemsUnit2PRICE] [decimal](18, 0) NULL,
[ItemsUnit3] [nvarchar](50) NULL,
[ItemsUnit3QTY] [int] NULL,
[ItemsUnit3PRICE] [decimal](18, 0) NULL,
[ItemsCostprice] [decimal](18, 0) NULL,
[ItemsSaleprice] [decimal](18, 0) NULL,
[Itemsactive] [bit] NULL,
[ItemsPhoto] [image] NULL,
[PORK] [int] NULL,
CONSTRAINT [PK_TBLItems] PRIMARY KEY CLUSTERED
(
[ID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GOاتمنى احد يساعدني وولو بجملة IF الشرطية

