示例#1
0
        private void button1_Click(object sender, EventArgs e)
        {
            SearchInfoVo searchInfoVo = new SearchInfoVo();

            if (!string.IsNullOrEmpty(textBox1.Text.Trim()))
            {
                searchInfoVo.lsh = textBox1.Text.Trim();
            }
            if (!string.IsNullOrEmpty(textBox2.Text.Trim()))
            {
                searchInfoVo.khxm = textBox2.Text.Trim();
            }
            if (!string.IsNullOrEmpty(textBox3.Text.Trim()))
            {
                searchInfoVo.lxdh = textBox3.Text.Trim();
            }
            if (!string.IsNullOrEmpty(textBox4.Text.Trim()))
            {
                searchInfoVo.fjbh = textBox4.Text.Trim();
            }
            if (!string.IsNullOrEmpty(textBox5.Text.Trim()))
            {
                searchInfoVo.sfzhm = textBox5.Text.Trim();
            }
            DataTable dataTable = Bll_Guset.GetRecordDataTable(searchInfoVo);

            dataGridView1.DataSource = dataTable;
        }
示例#2
0
        public static DataTable GetRecordDataTable(SearchInfoVo searchInfoVo)
        {
            string sql = "select a.lsh, a.fjbh, a.lxdh, b.yhxm, b.sfzhm, a.rzrq, a.rzts, a.ldrq from roomrecord a LEFT JOIN guestrecord b on a.lsh = b.lsh where 1 = 1";

            if (!string.IsNullOrEmpty(searchInfoVo.lsh))
            {
                sql += " and a.lsh = @lsh";
            }
            if (!string.IsNullOrEmpty(searchInfoVo.khxm))
            {
                sql += " and b.yhxm = @khxm";
            }
            if (!string.IsNullOrEmpty(searchInfoVo.sfzhm))
            {
                sql += " and b.sfzhm = @sfzhm";
            }
            if (!string.IsNullOrEmpty(searchInfoVo.fjbh))
            {
                sql += " and a.fjbh = @fjbh";
            }
            if (!string.IsNullOrEmpty(searchInfoVo.lxdh))
            {
                sql += " and a.lxdh = @lxdh";
            }

            MySqlParameter[] para =
            {
                new MySqlParameter("@lsh",   searchInfoVo.lsh),
                new MySqlParameter("@fjbh",  searchInfoVo.fjbh),
                new MySqlParameter("@khxm",  searchInfoVo.khxm),
                new MySqlParameter("@sfzhm", searchInfoVo.sfzhm),
                new MySqlParameter("@lxdh",  searchInfoVo.lxdh)
            };
            return(SqlHelper.GetDataSet(sql, CommandType.Text, para));
        }