在datagridview中选择的日期是否存在于另一个表中 [英] In datagridview selected date to be present in another table or not

查看:65
本文介绍了在datagridview中选择的日期是否存在于另一个表中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在数据库记录中如下;





教师代码日(表名留下)



AKR周三

DOC周一

LSG周三





我有另一个设计屏幕,如下所示。





教师代码组合框(在组合框中,所有教师从离职表中检索)



日历(月历)



当我选择那个月时,所有日期都显示在datagridview中。



输出如下。



选择月份(姓名)





复选框1/2/2013

to

28/2/2013



当用户选择教师并在datagridview中选择星期三日期时,

想要显示该日期教师的消息不可用。



因为周三日出现在L eave表。



我如何验证。



请帮助我。



问候,

Narasiman P.



注意它是windows应用程序。

in Database records as follows;


Faculty Code Day (table name Leave)

AKR Wednesday
DOC Monday
LSG Wednesday


I have another Design screen as follows.


Faculty Code Combobox(in combobox all faculty retrieved from Leave table)

Calendar(Month Calendar)

when i select that month all date is display in datagridview.

Output as follows.

Select Month (name)


checkbox 1/2/2013
to
28/2/2013

when user select the faculty and select the Wednesday Date in datagridview means,
want to show the message for that date faculty is not available.

Because Wednesday Day is present in Leave Table.

How can i validate.

Please help me.

Regards,
Narasiman P.

Note it is windows application.

推荐答案

嗨伙伴



有很多方法可以做这个任务可能有人告诉你聪明的方式或某些不是那个方式,但根据我的逻辑,你有两个任务...



1.当用户选择第一个表的日期然后你必须采取该日期在一个变量(sql查询)中。



2.然后在第二个和主要任务中使用sql select with where =''+ your variable +''conditon query你必须在secound表中阅读那天,如果得到HasRow = true或datareader dr.read()make true ...那么你必须最后弹出你的massegeDate Not Allowed..



你得到的是我真正想与你分享的内容....有任何疑问下面的plz评论或者想要l ogic从我的结束然后...但第一次尝试从你的结束...



乐意帮助
hi buddy

there is many way to do this task may some one told you smart way or some one not that way but over all as per my logic for this you have two task...

1. when user select the date of 1st table then you have to take that date in a variable(sql query).

2. and in 2nd and main task then using sql select with where=''"+your variable+"'' conditon query you have to read that day in secound table and if get HasRow= true or datareader dr.read() make true...then you have to finally pop up your massege that "Date Not Allowed"..

Are you getting na that what actually i want to share with you....have any doubt plz comment below or want logic from my end then also...but 1st try from your end...

Happy to help


喜欢这个...



like this...

string selecdate; //in this variable get the selected date from gridview...
string query="select * from Leave where Codeday ='"+selecdate+"' and faculty_Name ='"+combobox1.slectedtext+"' "; 
con.open()
SqlCommand cmd=new sqlcommand(con,query)
sqlDataReader dr=cmd.executeReader(); 
 
if(dr.read())
{
messageBox.show("this faculty not available on this day");
}
else
{
messageBox.show("This faculty available on this day");
}
con.close();


这篇关于在datagridview中选择的日期是否存在于另一个表中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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