Private Sub btnAdd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAdd.Click
        Dim pid As Integer = Convert.ToInt32(txtProductId.Text)
        Dim Qty As Integer
        If txtProductQuantity.Text = "" Then
            Qty = 1
        Else
            Qty = Convert.ToInt32(txtProductQuantity.Text)
        End If
        cmd.CommandText = "select * from tblprod where pid=" & pid
        cmd.Connection = con
        Dim datareader As SqlDataReader = cmd.ExecuteReader
        If  datareader.HasRows = True Then
            datareader.Read()
            datareader.Close()
         
            cmd.CommandText = "insert into tblWindow values(" & pid & "," & Qty & ")"
            cmd.CommandType = CommandType.Text
            cmd.ExecuteNonQuery()
            cmd.CommandText = "select Pid,PrdName,Price from tblProd where Pid=" & pid
            Dim ds As New Data.DataSet
            Dim adp As New  SqlDataAdapter
            adp.SelectCommand = cmd
            adp.Fill(ds, "table")
            DataGrid_ProductDetail.DataSource = ds
            'datagridview1.DataMember = "tablename"
            'DataGrid_ProductDetail.DataBindings()
            DataGrid_ProductDetail.DataMember = "table"
            lblCheckPrd.Visible = False
        Else
            lblCheckPrd.Visible = True
            lblCheckPrd.Text = "Invalid  Pid"
            cmd.Dispose()
            datareader.Close()
        End If
        cmd.Dispose()
        datareader.Close()
    End Sub
Sunday, February 1, 2009
Subscribe to:
Post Comments (Atom)
 
No comments:
Post a Comment