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.OleDb;
namespace WindowsFormsApplication1
{
public partial class Form6 : Form
{
public Form6()
{
InitializeComponent();
}
private void logBindingNavigatorSaveItem_Click(object sender, EventArgs e)
{
this.Validate();
this.logBindingSource.EndEdit();
this.tableAdapterManager.UpdateAll(this.internetCafe2DataSet);
}
private void Form6_Load(object sender, EventArgs e)
{
// TODO: This line of code loads data into the 'internetCafe2DataSet.Log' table. You can move, or remove it, as needed.
this.logTableAdapter.Fill(this.internetCafe2DataSet.Log);
// TODO: This line of code loads data into the 'internetCafe2DataSet.Log' table. You can move, or remove it, as needed.
this.logTableAdapter.Fill(this.internetCafe2DataSet.Log);
}
private void logBindingNavigatorSaveItem_Click_1(object sender, EventArgs e)
{
this.Validate();
this.logBindingSource.EndEdit();
this.tableAdapterManager.UpdateAll(this.internetCafe2DataSet);
}
private void button1_Click(object sender, EventArgs e)
{
Form5 frm = new Form5();
frm.Show();
this.Hide();
}
private void button2_Click(object sender, EventArgs e)
{
string StrConn = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=D:/oil/ite-304/project/test/WindowsFormsApplication1/InternetCafe2.accdb;Persist Security Info=False";
OleDbConnection Conn = new OleDbConnection(StrConn);
Conn.Open();
StringBuilder sb = new StringBuilder();
sb.Append("SELECT ID,[DateTime],[Number],RCredit");
sb.Append(" FROM log");
sb.Append(" WHERE [DateTime]");
sb.Append(" between @DateTime1 and @DateTime2");
string login = sb.ToString();
OleDbCommand com = new OleDbCommand(login, Conn);
com.Parameters.Clear();
com.Parameters.Add("@DateTime1", SqlDbType.NVarChar).Value = dateTimePicker1.Text.Trim();
com.Parameters.Add("@DateTime2", SqlDbType.NVarChar).Value = dateTimePicker2.Text.Trim();
OleDbDataReader dr = com.ExecuteReader();
if (dr.HasRows)
{
string StrCon = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=D:/oil/ite-304/project/test/WindowsFormsApplication1/InternetCafe2.accdb;Persist Security Info=False";
OleDbConnection Con = new OleDbConnection(StrConn);
Con.Open();
dr.Read();
dr.Close();
OleDbCommand con1 = new OleDbCommand();
con1.Connection = Con;
con1.CommandType = CommandType.Text;
con1.CommandText = "select * from customer where [DateTime] between dateTimePicker1.Text and dateTimePicker2.Text";
DataSet ds1 = new DataSet();
OleDbDataAdapter adp1 = new OleDbDataAdapter(con1);
adp1.Fill(ds1,"customer");
logDataGridView.DataSource = ds1;
logDataGridView.DataMember = "customer";
Con.Close();
}
else
{
MessageBox.Show("Invalid");
}
}
}
}