如何在Windows应用程序的一个TIme中检查条件? [英] How to Check Condition at One TIme in Windows Application?

查看:93
本文介绍了如何在Windows应用程序的一个TIme中检查条件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个输入员工姓名的表格.单击按钮时,我检查输入的名称是否为已知的重复名称.

如果重复输入,则会显示一条错误消息.没关系.

问题是,如果输入不是重复项,则应显示下一个表格.但是相反,我需要再次按下相应的按钮才能实现.

以下是我的代码

I have a Form to enter an employee name. On button click, I check the entered name for a duplicate already known.

In case of a duplicate entry, an error message is shown. That''s OK.

Problem is, if the input is not a duplicate entry, the next Form should be shown. But instead I need to press the corresponding button a second time to achieve that.

below is my code

public static bool duplicatecheck_first_middle_last_name(string firstname, string middlename, string lastname)
      {
          //Data.dc = "NO";
          if (firstname == "MANOHAR" && middlename == "SAMBHAJI" && lastname == "KHILLARE")
          {
              DuplicateData dd = new DuplicateData();
              //dd.MdiParent = (Home.ActiveForm);
              dd.ShowDialog();

              return true;
          }
          else
          {
              // Data.dc  = "YES";
              return false;

          }
      }


按钮单击事件


button click event

private void btnnext_Click(object sender, EventArgs e)
{
duplicatecheck_first_middle_last_name(txtfirstname.Text, txtmiddlename.Text, txtlastname.Text);
Employee_Personal_Details ep = new Employee_Personal_Detail();                       ep.displayemployeepersonaldetails();
this.Hide();
ep.ShowDialog();

} 

推荐答案



首先,您用于查找重复值的代码不正确.为什么您静态指定了FirstName,MiddleName和LastName.并且建议不要从存储过程中检查此类代码(如果有的话),而不是从代码中进行检查.

现在来解决您的实际问题,我无法用您的代码找出此类问题.尝试通过放置断点来调试应用程序.通过它,您可以找到您的问题.

谢谢
-Amit Gajjar
Hi,

First of all, your code for finding duplicate value is incorrect. Why you have specified FirstName,MiddleName and LastName statically. And Instead of checking from code, i suggest you to check such code from Stored Procedure(if you have).

Now come to your actual problem, i can''t figure out such issue with your code. try to debug your application by placing breakpoints. through that you can find your issue.

Thanks
-Amit Gajjar


这篇关于如何在Windows应用程序的一个TIme中检查条件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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