Click here to Skip to main content
15,917,859 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
VB
Private Sub AddStocksInUpdating()
        If txtItemNo.Text = "" Then
            MsgBox("Please select item to add stocks.", MsgBoxStyle.Critical, "Select Item")
            Exit Sub
        End If
        Dim strStocksIn As String

        strStocksIn = InputBox("Enter number of items : ", "Stocks In")
        txtQuantity.Text = Val(txtQuantity.Text) + Val(strStocksIn)
        Try
            sqL = "INSERT INTO StocksIn(ItemNo, ItemQuantity, SIDate, CurrentStocks) VALUES('" & txtItemNo.Text & "', '" & strStocksIn & "', '" & Format(Date.Now, "Short Date") & "', " & txtQuantity.Text & ")"
            ConnDB()
            cmd = New OleDbCommand(sqL, conn)
            Dim i As Integer

            i = cmd.ExecuteNonQuery()
            If i > 0 Then
                MsgBox("Stocks added successfully", MsgBoxStyle.Information, "Stocks In")
                Updateproduct()
            End If
        Catch ex As Exception
            MsgBox(ex.Message)
        Finally
            cmd.Dispose()
            conn.Close()
        End Try
    End Sub
Posted

1 solution

try this site
Convert VB.NET to C#[^]

C#
private void AddStocksInUpdating()
{
	if (string.IsNullOrEmpty(txtItemNo.Text)) {
		Interaction.MsgBox("Please select item to add stocks.", MsgBoxStyle.Critical, "Select Item");
		return;
	}
	string strStocksIn = null;

	strStocksIn = Interaction.InputBox("Enter number of items : ", "Stocks In");
	txtQuantity.Text = Conversion.Val(txtQuantity.Text) + Conversion.Val(strStocksIn);
	try {
		System.Data.sqL = "INSERT INTO StocksIn(ItemNo, ItemQuantity, SIDate, CurrentStocks) VALUES('" + txtItemNo.Text + "', '" + strStocksIn + "', '" + Strings.Format(System.DateTime.Now, "Short Date") + "', " + txtQuantity.Text + ")";
		ConnDB();
		cmd = new OleDbCommand(System.Data.sqL, conn);
		int i = 0;

		i = cmd.ExecuteNonQuery();
		if (i > 0) {
			Interaction.MsgBox("Stocks added successfully", MsgBoxStyle.Information, "Stocks In");
			Updateproduct();
		}
	} catch (Exception ex) {
		Interaction.MsgBox(ex.Message);
	} finally {
		cmd.Dispose();
		conn.Close();
	}
}
 
Share this answer
 
v3
Comments
Member 10720633 11-Apr-14 5:30am    
i already use it but if i use changed code there is error interaction , Inputbox like this
Member 10720633 11-Apr-14 5:34am    
look this C# code
private void AddStocksInUpdating()
{
if (string.IsNullOrEmpty(txtItemNo.Text)) {
Interaction.MsgBox("Please select item to add stocks.", MsgBoxStyle.Critical, "Select Item");
return;
}
string strStocksIn = null;

strStocksIn = Interaction.InputBox("Enter number of items : ", "Stocks In");
txtQuantity.Text = Conversion.Val(txtQuantity.Text) + Conversion.Val(strStocksIn);
try {
System.Data.sqL = "INSERT INTO StocksIn(ItemNo, ItemQuantity, SIDate, CurrentStocks) VALUES('" + txtItemNo.Text + "', '" + strStocksIn + "', '" + Strings.Format(System.DateTime.Now, "Short Date") + "', " + txtQuantity.Text + ")";
ConnDB();
cmd = new OleDbCommand(System.Data.sqL, conn);
int i = 0;

i = cmd.ExecuteNonQuery();
if (i > 0) {
Interaction.MsgBox("Stocks added successfully", MsgBoxStyle.Information, "Stocks In");
Updateproduct();
}
} catch (Exception ex) {
Interaction.MsgBox(ex.Message);
} finally {
cmd.Dispose();
conn.Close();
}
}
hansoctantan 11-Apr-14 5:41am    
Add a reference to Microsoft.VisualBasic and try to use this
Microsoft.VisualBasic.Interaction.InputBox

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900