Tuesday, 6 September 2011

.NET WINDOWS APPLICATION

.NET WINDOWS APPLICATION TEXT BOX AUTO COMPLETE:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.Odbc;
using lib1;
namespace attendence
{
    public partial class Form1 : Form
    {
        Attendance at = new Attendance();
        DataTable dt=new DataTable();
        AutoCompleteStringCollection Collection = new AutoCompleteStringCollection();
        DataTable dt3=new DataTable();
     
        public Form1()
        {
            InitializeComponent();
        
        }
        public void FillAuto()
        {
            dt3=at.FillData2("select employeecode from employees");
            foreach(DataRow dr in dt3.Rows)
            {
                Collection.Add(dr["EmployeeCode"].ToString());
            }
          
        }
        private void button1_Click(object sender, EventArgs e)
        {
          
            String q;
            String code = this.textBox1.Text;
            String fdate = dateTimePicker1.Text;
            String tdate = dateTimePicker2.Text;
        
         
            q = "select attendancedate,intime from attendancelogs where attendancedate between #"+fdate+"# and #"+tdate+"# and employeeid=(select employeeid from employees where employeecode='"+code+"') order by attendancedate";
            dt=at.FillData(q);
     
           dataGridView1.DataSource = dt;
         
          
        }

        private void textBox1_TextChanged(object sender, EventArgs e)
        {

            //FillAuto();
        }

        private void Form1_Load(object sender, EventArgs e)
        {

            textBox1.AutoCompleteCustomSource = Collection;
            FillAuto();

        }

     
    }
}

1 comment: