hai.... i am doing inventory project. if sell a product it should afffect the stock. so i need a coding to retrieve the stock quantity and i have to change the value according to sales then i have to update the values into the stock table and also if no stock i need a message is to be shown

Where's your codes

1

 Private Sub CmdSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CmdSave.Click
        Try
            If TxtNo.Text <> "" And TxtCustCode.Text <> "" And TxtItemCode.Text <> "" And TxtQty.Text <> "" And TxtPricePerUnit.Text <> "" And TxtTotal.Text <> "" And CmbBillNo.Text <> "" And DTPSalesDate.Text <> "" And TxtCusName.Text <> "" And TxtItemName.Text <> "" Then
                db.query_execute("insert into Sales VALUES ('" + TxtNo.Text + "'," + TxtCustCode.Text + "," + TxtItemCode.Text + "," + TxtQty.Text + "," + TxtPricePerUnit.Text + "," + TxtTotal.Text + "," + CmbBillNo.Text + ",'" + DTPSalesDate.Value.Date + "','" + TxtCusName.Text + "','" + TxtItemName.Text + "')")
                MessageBox.Show("DATA SAVED SUCCESFULLY")

                Dim A As String
                cn.Open()
                Dim cmd As SqlCommand
                cmd = New SqlCommand("select Quantity from Stock WHERE ItemCode=" + TxtItemCode.Text + " ", cn)
                A = cmd.ExecuteScalar()
                A = (A) - (TxtQty.Text)
                db.query_execute("update Stock set Quantity='" + A + "' where ItemCode=" + TxtItemCode.Text + "")
                cn.Close()
                clear_control()
                fill_grid()
                bind_control()
            Else
                MessageBox.Show("FIRST FILL ALL THE FEILD")
                End If
        Catch ex As Exception
            MsgBox(ex.Message)
        End Try
    End Sub

If TxtNo.Text <> "" And TxtCustCode.Text <> "" And TxtItemCode.Text <> "" And TxtQty.Text <> "" And TxtPricePerUnit.Text <> "" And TxtTotal.Text <> "" And CmbBillNo.Text <> "" And DTPSalesDate.Text <> "" And TxtCusName.Text <> "" And TxtItemName.Text <> "" Then

                db.query_execute("insert into Sales VALUES ('" + TxtNo.Text + "'," + TxtCustCode.Text + "," + TxtItemCode.Text + "," + TxtQty.Text + "," + TxtPricePerUnit.Text + "," + TxtTotal.Text + "," + CmbBillNo.Text + ",'" + DTPSalesDate.Value.Date + "','" + TxtCusName.Text + "','" + TxtItemName.Text + "')")


            MessageBox.Show("DATA SAVED SUCCESFULLY")

            Dim A As String
            cn.Open()
            Dim cmd As SqlCommand
            cmd = New SqlCommand("select Quantity from Stock WHERE ItemCode=" + TxtItemCode.Text + " ", cn)
            A = cmd.ExecuteScalar()
            A = (A) - (TxtQty.Text)
            db.query_execute("update Stock set Quantity='" + A + "' where ItemCode=" + TxtItemCode.Text + "")
            cn.Close()
            clear_control()
            fill_grid()
            bind_control()
        Else
            MessageBox.Show("FIRST FILL ALL THE FEILD")
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.