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;
            }
  • 相关阅读:
    java中变量的内存分配
    类加载器的双亲委派机制
    缓存行对齐
    缓存一致性与MESI协议
    Mysql优化之join优化
    MySQL crc32 & crc64函数 提高字符串查询效率
    线程不安全
    学习爱上 systemd
    Ubuntu如何备份和恢复系统
    redis报错overcommit_memory is set to 0
  • 原文地址:https://www.cnblogs.com/sulong/p/4686925.html
Copyright © 2011-2022 走看看