visual studio 2010使用c# [英] visual studio 2010 using c#

查看:241
本文介绍了visual studio 2010使用c#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用c#在vs 2010中有一个Windows应用程序表单,在这里我有34个文本框和一个保存按钮。我正在使用Ms Accesd数据库在数据库中插入这些值。

这些值在我点击提交按钮时成功存储。

到此为止,它运行正常。现在我的要求是:



如果我点击保存按钮,如果文本框是空的,它必须显示一条消息请输入所需的字段。

如果文本框中填充了数据,那么当我点击提交按钮时,应显示:您确定要吗?保存这些数据?

如果成功存储在数据库中,显示消息...... 成功提交

I have a windows application form in vs 2010 using c#, In this I have 34 textboxes and a save button. I am using Ms Accesd database for inserting these values in database.
These values are storing Successfully when i click on Submit button.
Till here, it is working fine. now my requirement is:

If i click on save button and if the textboxes are empty, it must display a message "please enter the required fields."
if the textboxes are filled with data then, when i click the submit button this should be displayed: "Are you sure you want to Save this data ?"
if Successfully stored in DB, Display a message... Successfully Submitted.

推荐答案

如果你想检查它们,那很简单:

If you want to check them all it's pretty simple:
bool ok = true;
foreach (Control c in Controls)
   {
   TextBox tb = c as TextBox;
   if (tb != null && string.IsNullOrWhitespace(tb.Text))
      {
      ok = false;
      break;
      }
   }
if (!ok)
   {
   // Report the problem


这篇关于visual studio 2010使用c#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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