如何使用文本框执行两个不同的功能 [英] how to do two different functions with a textbox

查看:69
本文介绍了如何使用文本框执行两个不同的功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在窗口表单中使用与数据库连接的文本框名称发票。 。 。 。现在我希望如果值输入存在于数据库中,那么它会收集有关该值的所有信息 并填充其他文本框但如果该值不存在则手动填充所有文本框然后保存。 。 。 。 。 。 。现在我有一个问题,我不知道该怎么做。 。 。 .plzzzz帮帮我

i am using a text box name invoice in window forms which is connected with database. . . .now i want that if the value enter is present in database then it collect all information regarding that value and fill other text boxes but if the value is not present then manually fill all text boxes and then save it. . . . . . .now i have a problem i don't have any idea how to do it. . . .plzzzz help me out

推荐答案

我建​​议你通过这个教程来了解如何使用C#.NET,ADO.NET和MS Access创建Windows应用程序 [ ^ ]
I suggest you walk through this tutorial to learn about how to creat a windows application using C#.NET, ADO.NET and MS Access[^]


确定以下是您可以执行的操作

如果文本框值在数据库中,请填写剩余的文本框。如果数据库中没有值,则显示弹出窗口,要求用户填写详细信息。



数据集dsresult = Checkinoyour数据库查询

如果dsresult有行填充其他文本框

如果dsresult没有行,则显示要求填充文本框的弹出窗口

就这么简单。
Ok Here is what you can do
If Textbox value is in Database fill out the remaining Text box. If value is not present in DB show a pop up asking user to fill the details.

Dataset dsresult = Checkinoyour Database query
if dsresult has rows fill the other textboxes
if dsresult doesn't have rows, show a pop asking to fill the textboxes
As simple as that.


我有一个项目,我必须做几乎相同。



在下面的例子中,一个文本文件用作数据库,一个 textbox1 是主要文本框。



I had a project in which I had to make almost the same.

In the following example, a text file is used as database and a textbox1 is the main textbox.

if(textBox1.Text == File.ReadAllLines(@"C:/database.txt")//if your textbox has a line from database...
{
     MessageBox.Show("One match found: " + textBox1.Text); //Show messageBox

}else //if the textbox has no match with a line from database...
     {
     MessageBox.Show("No match found! Added to database instead."); //Show messageBox
     StreamWriter sw = new StreamWriter(@"C:/database.txt"); //Create StreamWriter to modify database
     sw.WriteLine(textBox1.Text); //Add the new value to database
     sw.Close(); //Close the streamWriter
}





希望这会有所帮助!干杯 - CCB



Hope this helps! Cheers - CCB


这篇关于如何使用文本框执行两个不同的功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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