using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace DL580_9130
{
    public partial class frmfind1 : Form
    {
        frmrecords mefrm = null;
        public frmfind1(frmrecords frm)
        {
            InitializeComponent();
            mefrm = frm;
        }

        private void button2_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            string findstr = "'%" + textBox1.Text + "%'";
            string sqlstr = "select * from cardno where [cardno] like " + findstr;
            if (checkBox1.Checked)
            {
                string sdate = date1.Value > date2.Value ? date2.Value.ToShortDateString(): date1.Value.ToShortDateString ();
                string edate = date1.Value > date2.Value ? date1.Value.ToShortDateString () : date2.Value.ToShortDateString ();
                sdate = sdate + " 00:00:00";
                edate = edate + "23:59:59";
                sqlstr = sqlstr + " and [date] between '" + sdate + "' and '" + edate + "'";
            }
            mefrm.refreshow(sqlstr);
        }

        private void checkBox1_CheckedChanged(object sender, EventArgs e)
        {
            date1.Enabled = date2.Enabled = checkBox1.Checked;
        }
    }
}
