更新到文本框中的下一个值,因为它用于发票系统 [英] to update to next value in textbox as it is used for invoice system

查看:48
本文介绍了更新到文本框中的下一个值,因为它用于发票系统的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

先生,我想自动增加textbox2.text的价值,因为它用于发票编号.我想从1000开始增加,请帮助我如何增加.

谢谢inadvance,我是软件开发的新手,我衷心希望对会员的帮助不大,祝我2012年新年快乐.

sir i wanted to auto increment the textbox2.text as it is used for invoice no. i wanted to increment from 1000 and please help me how can i increment.

Thanks inadvance and i am new to software developing i hope little help from members n my heartly wishes to Very happy new year 2012.

推荐答案

CP中的类似问题
我如何动态地向自动递增字段? [ ^ ]
检查我的答案是否有可以使用SQL自动编号? [
Similar Question in CP
How can i dynamically add value to the auto increment field?[^]
Check mine answer for SQL Autonumbers possible?[^]


尽管可以,我不会这么做.

以这种方式执行操作取决于用户不修改值并插入非数字值.

最简单的方法是将当前发票号保留为类级别的整数变量,并在必要时将其递增,然后重新编写文本框的内容.
Although you can, I wouldn''t do it.

Doing it that way relies on the user not modifying the value and inserting a non-numeric value.

The easiest way is to keep the current invoice number as a class level integer variable, and increment it when necessary and re-write the contents of the text box.
private int invoiceNumber = 1000;
...
private void NextInvoice()
   {
   invoiceNumber++;
   TextBoxForInvoiceNumber.Text = invoiceNumber.ToString("000000");
   }


但是我会使用Label而不是TextBox,或者将TextBox ReadOnly属性设置为true.

如果必须使用TextBox内容,则必须执行以下操作:


But I would use either a Label instead of a TextBox, or make the TextBox ReadOnly property true.

If you must use the TextBox content, you have to do:

private void NextInvoice()
   {
   int invoiceNumber = int.Parse(TextBoxForInvoiceNumber.Text);
   invoiceNumber++;
   TextBoxForInvoiceNumber.Text = invoiceNumber.ToString("000000");
   }


并请记住添加错误陷阱等,以防止用户犯小错误时您的应用崩溃...


And remember to add error trapping and so forth to prevent your app falling over when the user makes a small mistake...


这篇关于更新到文本框中的下一个值,因为它用于发票系统的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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