I ask for help to do the following, I make an insert via procedure after saving I want to fill the textbox with the id created so I can use it to associate with my item
Ijustneedtheordercodetoenterthetextbox.Thanksinadvanceforyourhelp.NewButtonEvent
privatevoidbtnNovoPedido_Click(objectsender,EventArgse){try{intcodigoCli=Convert.ToInt32(txtCodCliente.Text);DateTimedtIni=DateTime.Now;intidCliente=int.Parse(txtCodCliente.Text);cc.pInserirPedido(0,dtIni,null,idCliente);//procedureparacriarpedidoMessageBox.Show("Pedido gerado" );
}
catch (Exception ex)
{
MessageBox.Show("Erro:" + ex.Message);
}
}
ALTER PROC [dbo]. [pRegistered]
@Decimal ValueTotal (8,2),
@dtEnter datetime,
@dtSaida datetime,
@idCliente int
the
insert into TB_PEDIDOS (VAL_PEDIDO,
HOR_PEDIDO_ENTRADA, HOR_PEDIDO_SAIDA, ID_CLIENTE)
values (@valorTotal, @dtEntry, @dtSaida, @idClient)
IF @@ ERROR < > 0
-
SELECT -1 will return -1 if there is an error
ELSE
SELECT MAX (ORDER_ID) as 'CURRENT ORDER' FROM TB_PEDIDOS
GO
the last ID added
SoIstilldonotknowhowtogetthevaluedisplayedinsqlandplayinthefield