基于更多文本框在窗体上过滤不显示我过滤的值是什么 [英] Filter Based On More Textbox On Form Not Show What I Filteres Values Proplem

查看:91
本文介绍了基于更多文本框在窗体上过滤不显示我过滤的值是什么的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好我根据动态存储过程进行动态搜索。它是成功的,但我需要当我制作过滤器



基于表格中的任何文本框告诉我你是按A和B和C AS过滤的例子



含义当textbox1有值A时,textbox2有值B,textbox3有值C



留言或标签告诉我你是基于A,B,C的过滤器



所以我需要循环遍历所有文本框,如果任何文本框有价值



消息显示或标签显示你是按a,b,c,d等过滤



我是怎么做的



我的功能动态搜索意思是你通过任何文本框搜索搜索都会起作用



这是我的功能



FleetManagment。





Fleet fleet = new FleetManagment.Fleet();





DataTable Table = fleet.SearchEmployeeAllDateBetween(Data Source =+ value1 +; Initial Catalog =+ value2 +; User ID =+ value3 +;密码= + value4 +,textBox1.Text,textBox2.Text,textBox5.Text,textBox28.Text,textBox7.Text,textBox8.Text,textBox9.Text,textBox10.Text,textBox11.Text,textBox12.Text,textBox13.Text ,textBox14.Text,textBox15.Text,textBox16.Text,textBox17.Text,textBox18.Text,textBox19.Text,textBox20.Text,textBox21.Text,textBox22.Text,textBox23.Text,textBox24.Text,textBox25.Text,textBox26 .Text,textBox31.Text,textBox32.Text,textBox27.Text,textBox30.Text,textBox29.Text,textBox6.Text,textBox4.Text,textBox33.Text,textBox53.Text,textBox3.Text,textBox34.Text,textBox56.Text ,textBox51.Text,label33.Text,label34.Text);

dataGridView1.DataSource = Table;



dataGridView1.Refresh();

Hi guys i make dynamic search based on dynamic stored procedure. it is working success but i need when i make filter

based on any textbox in form tell me you are filter by A And B and C AS Example

meaning when textbox1 has value A AND textbox2 has value B and textbox3 has value C

message or label tell me you are filter based on A,B,C

So that i need to loop throught all textboxes and if any textbox has value

message show or label show you are filter by a,b,c,d etc

How i do that

my function dynamic search meaning if you search by any textbox search will work

this is my function

FleetManagment.


Fleet fleet = new FleetManagment.Fleet();


DataTable Table = fleet.SearchEmployeeAllDateBetween("Data Source=" + value1 + ";Initial Catalog=" + value2 + ";User ID=" + value3 + ";Password=" + value4 + "", textBox1.Text, textBox2.Text, textBox5.Text, textBox28.Text, textBox7.Text, textBox8.Text, textBox9.Text, textBox10.Text, textBox11.Text, textBox12.Text, textBox13.Text, textBox14.Text, textBox15.Text, textBox16.Text, textBox17.Text, textBox18.Text, textBox19.Text, textBox20.Text, textBox21.Text, textBox22.Text, textBox23.Text, textBox24.Text, textBox25.Text, textBox26.Text, textBox31.Text, textBox32.Text, textBox27.Text, textBox30.Text, textBox29.Text, textBox6.Text, textBox4.Text, textBox33.Text, textBox53.Text, textBox3.Text, textBox34.Text, textBox56.Text, textBox51.Text, label33.Text, label34.Text);
dataGridView1.DataSource = Table;

dataGridView1.Refresh();

推荐答案

坦率地说?

不是那样的。



自己做一个赞成开始:停止使用VS默认名称。当你第一次添加控件时,它可能会节省你大约五秒钟的时间,但是后来浪费了大量的时间,因为它根本不清楚什么控件可以保存什么信息 - 而且你似乎在同一个表单上有56个文本框! br />
从用户的角度来看,这会很糟糕,但作为一名开发人员,这是一件非常愚蠢的事情。你今天可能还记得textBox37拥有用户名,但你不会在三周内完成,所以有时你在代码中找到textBoxNN,你需要切换到设计视图,找到textBoxNN并找出工作在您使用代码之前它拥有什么。使用合理的名称可以避免这种情况并帮助您的代码自我记录。



如果您通过连接字符串将这些文本框直接传递给SQL作为SQL命令的一部分给你带来的坏消息:你的用户只需输入你的表格就可以破坏你的数据库...



说真的:想想你的代码以及你想做什么 - 从任何角度来看,这都不是一个好主意!
Frankly?
Not like that.

Do yourself a favour to start with: stop using VS default names for everything. It may save you five seconds or so when you first add the control, but it wastes huge amounts of time later because it isn't at all obvious what control holds what information - and you appear to have 56 textboxes on the same form!
That would be bad enough from a user point of view, but as a developer it's a very silly thing to do. You may remember today that textBox37 holds the user name, but you won't do in three weeks time, so ever time you find a "textBoxNN" in you code you will need to switch to design view, find "textBoxNN" and work out what it holds before you can work with the code. using sensible names avoids that and helps your code become self documenting.

And if you are passing those textboxes directly to SQL as part of a SQL command by concatenating strings I have bad news for you: your users can destroy your database just by typing into your form...

Seriously: think about your code and what you are trying to do - this is not a good idea from any point of view!


这篇关于基于更多文本框在窗体上过滤不显示我过滤的值是什么的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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