zoukankan      html  css  js  c++  java
  • 传智HRMS条件搜索

         private void btnSearch_Click(object sender, RoutedEventArgs e)
            {
                List<string> whereList = new List<string>();
                List<SqlParameter>paramslist=new List<SqlParameter>();
                if(cbSearchByOperator.IsChecked==true)
                {
                    if (cmbOperator.SelectedIndex < 0)
                    {
                        MessageBox.Show("请选择操作员");
                    }
                    whereList.Add("OperatorId=@OperatorId");
                    paramslist.Add(new SqlParameter("@OperatorId", cmbOperator.SelectedValue));
                }
                if (cbSearchByMakeDate.IsChecked == true)
                {
                    whereList.Add("MakeDate Between @BeginDate and @EndDate");
                    paramslist.Add(new SqlParameter("@BeginDate",dpBeginDate.SelectedDate));
                    paramslist.Add(new SqlParameter("@EndDate", dpEndDate.SelectedDate));
                }
                if (cbSearchByAction.IsChecked == true)
                {
                    whereList.Add("ActionDesc like @ActionDesc");
                    paramslist.Add(new SqlParameter("@ActionDesc",
                        "%"+txtAcionDesc.Text+"%"));
                }
                if (whereList.Count <= 0)
                {
                    MessageBox.Show("至少选择一个查询条件");
                }
                string sql = "select * from T_OperationLog where "
                    + string.Join(" and ", whereList);//whereList是一个字符串,它保存了查询条件
                T_OperationLog[] logs =
                               new T_OperationLogDAL().Search(sql, paramslist.ToArray());//转为数组类型
                datagrid.ItemsSource = logs;
            }
  • 相关阅读:
    Ubuntu安装最新版的nodejs
    Mac安装并破解OmniGraffle7
    Mac安装并破解StarUML
    Windows10使用Chocolatey安装mysql之后无法使用的解决办法
    Visual Studio编辑类模板的位置
    VS2017连接到中国区的Azure
    Windows上包管理器之Chocolatey初体验
    CENTOS7.3 64位架设使用MYSQL数据库的ASP.NET CORE网站
    从无到有开发自己的Wordpress博客主题---主页模板
    c# 获得方法的所属类(或调用者)的类名,方法名
  • 原文地址:https://www.cnblogs.com/sulong/p/4686925.html
Copyright © 2011-2022 走看看