我想自动生成值,我希望通过Cliking按钮在文本框中显示自动生成的值它将在文本框中显示为值 [英] I Want To Auto Generate The Values And I Want To Show That Auto Generated Value In Textbox By Cliking Button It Will Appear In Textbox As Value

查看:68
本文介绍了我想自动生成值,我希望通过Cliking按钮在文本框中显示自动生成的值它将在文本框中显示为值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试解决一个问题,请帮我找出它.....

我想自动生成从我的数据库中存储在表中的值。我想要要通过cliking按钮显示文本框中的自动生成值,它将在文本框中显示为文本框值.....

ex.last值为E185,下一个值应在文本框中显示为文本框值ieE186

Hi,I am trying to solve one query please help me to find out it.....
I want to auto generate the values which are stored in table from my database.i want to show that auto generated value in textbox by cliking button it will appear in textbox as textbox value.....
ex.last value is E185 and the next value should be show in textbox as textbox value i.e.E186

推荐答案

只需从数据库中取出最后插入的代码即可。

查询:SELECT TOP 1 EmpCode FROM tblEmployee ORDER BY EmpId DESC



这将为您提供最新的Emp Code。



现在你可以拆分代码

int iEmpCodeNo = Convert.ToInt(EmpCode.Substring(1));



这将为您提供EmpCodeNo。现在用此增加1并添加'E'

字符串NewEmpCode =E+(iEmpCodeNo + 1).ToString();



这将为您提供最新的代码。您可以在文本框中将其绑定。
Simply you take the Last inserted code from your database.
Query : SELECT TOP 1 EmpCode FROM tblEmployee ORDER BY EmpId DESC

This will give you the latest Emp Code.

Now you may split the Code
int iEmpCodeNo = Convert.ToInt(EmpCode.Substring(1));

This will give you the EmpCodeNo. Now increment 1 with this and add the 'E'
string NewEmpCode = "E" + (iEmpCodeNo + 1).ToString();

This will give you the latest code. You may simply bind this in your text box.


这篇关于我想自动生成值,我希望通过Cliking按钮在文本框中显示自动生成的值它将在文本框中显示为值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆