条件不能正常工作,查询无效。怎么了。帮助我。感谢名单 [英] conditions are not working properly, query is not working. Whats wrong. help me with this. Thanx

查看:69
本文介绍了条件不能正常工作,查询无效。怎么了。帮助我。感谢名单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

if (cboaccount1.Text == "" && cboaccount2.Text == "" && cbotitle.Text == "" && cboname.Text == "")
           {
               MessageBox.Show("Plz Provide Some Field", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);

               cboaccount1.Focus();

           }
           else
           {

               if (cbotitle.Text != "" ||cboname.Text!="")
               {
               }
              else if (!Regex.Match(cboaccount1.Text, @"^[0-9]{4}$").Success)
               {
                   MessageBox.Show("Invalid Account NO\nShould be of type e.g 8459-5", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                   cboaccount1.SelectAll();
                   cboaccount1.Focus();
               }
               else if (!Regex.Match(cboaccount2.Text, @"^[0-9]{1}$").Success)
               {
                   MessageBox.Show("Invalid Account No", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                   cboaccount2.SelectAll();
                   cboaccount2.Focus();
               }

               else
               {
                   if (cboaccount1.Text != "" || cboaccount2.Text != "" || cbotitle.Text != "")
                   {
                   }

                   else if (!Regex.Match(cboname.Text, @"^[A-Za-z][A-Za-z. ]*$").Success)
                   {
                       MessageBox.Show("Invalid Name", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                       cboname.SelectAll();
                       cboname.Focus();
                   }
                   else
                   {
                       if (cboaccount1.Text != "" || cboaccount2.Text != "" || cboname.Text != "")
                       {
                       }
                       else if (!Regex.Match(cbotitle.Text, @"^[A-Za-z][A-Za-z. ]*$").Success)
                       {
                           MessageBox.Show("Invalid title", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                           cbotitle.SelectAll();
                           cbotitle.Focus();
                       }







                        SqlCommand cmd = new SqlCommand("Select * from Accounts where Account_No=''" + cboaccount1.Text + "-" + cboaccount2.Text + "''or Account_title= ''" + cbotitle.Text + "''or Name=''" + cboname.Text + "''", cn);
                           cmd.CommandType = CommandType.Text;
                           da = new SqlDataAdapter(cmd);
                           DataSet ds = new DataSet();
                           da.Fill(ds, "ss");

                           if (ds.Tables[0].Rows.Count == 0)
                           {
                               MessageBox.Show("No Record Exist", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                           }
                           else
                           {
                               acse.dataGridView1.DataSource = ds.Tables["ss"];
                               this.Hide();
                               acse.ShowDialog();
                               this.Close();




                       }
                   }
               }






           }

推荐答案

)。成功)
{
MessageBox.Show(无效帐户NO \ n应该是类型,例如8459-5,错误,MessageBoxButtons.OK,MessageBoxIcon.Error);
cboaccount1.SelectAll();
cboaccount1 .Focus();
}
else if(!Regex.Match(cboaccount2.Text,@^ [0-9] {1}
").Success) { MessageBox.Show("Invalid Account NO\nShould be of type e.g 8459-5", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); cboaccount1.SelectAll(); cboaccount1.Focus(); } else if (!Regex.Match(cboaccount2.Text, @"^[0-9]{1}


) .Success)
{
MessageBox.Show(Invalid Account No,Error,MessageBoxButtons.OK,MessageBoxIcon.Error);
cboaccount2.SelectAll();
cboaccount2 .Focus();
}

else
{
if(cboaccount1.Text!=|| cboac count2.Text!=|| cbotitle.Text!=)
{
}

else if(!Regex.Match(cboname.Text,@^ [A-Za-z] [A -Za-z。] *
").Success) { MessageBox.Show("Invalid Account No", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); cboaccount2.SelectAll(); cboaccount2.Focus(); } else { if (cboaccount1.Text != "" || cboaccount2.Text != "" || cbotitle.Text != "") { } else if (!Regex.Match(cboname.Text, @"^[A-Za-z][A-Za-z. ]*


)。成功)
{
MessageBox.Show(Invalid Name,Error,MessageBoxButtons.OK,MessageBoxIcon 。错误);
cboname.SelectAll();
cboname.Focus();
}
其他
{
if(cboaccount1.Text!=|| cboaccount2.Text!=|| cboname.Text!=)
{
}
else if(!Regex.Match(cbotitle.Text,@^ [A-Za-z] [A-Za-z。] *
").Success) { MessageBox.Show("Invalid Name", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); cboname.SelectAll(); cboname.Focus(); } else { if (cboaccount1.Text != "" || cboaccount2.Text != "" || cboname.Text != "") { } else if (!Regex.Match(cbotitle.Text, @"^[A-Za-z][A-Za-z. ]*


这篇关于条件不能正常工作,查询无效。怎么了。帮助我。感谢名单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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