在插入数据并在Massge框中显示我时如何显示Massge [英] How to appear massge when insert data and show me in massge box

查看:165
本文介绍了在插入数据并在Massge框中显示我时如何显示Massge的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

伙计们
你好吗?

我有问题
我有关于库的项目Windows表单
这里的问题
当我想插入学生信息时,他要三遍借书,他也想再拿另一本书.

我想做一个验证,告诉我这个学生只能以三倍为限.

通过比较借阅开始日期和结束日期

告诉我该怎么办
:(

hi guys
how are you?

I have question
I have project windows form about library
Here question
when I want to insert student information that he borrow book three time and he also want to take other book.

I want to do validation that tell me this student only can take three time as limit

by compare borrow start date and end date

tell me What should I do, please
:(

推荐答案

您可以尝试以下方式:

You can try this way:

DateTime dt1 = new DateTime(2010, 1, 1),
         dt2 = new DateTime(2010, 1, 5);

TimeSpan ts = dt2.Subtract(dt1);

if (ts > new TimeSpan(3, 0, 0, 0))
{
    //this validation
    MessageBox.Show("your message");
    //or this one for throw a custom exception
    //throw new Exception("your message");
}


这篇关于在插入数据并在Massge框中显示我时如何显示Massge的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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