i have a logs table which have the following fields like username , id , checkintime, checkOuttime and date so i want to select a start date and end date from the calender and then click submit button so it can search data from data base and display data start from the start date to the end date

View Log Sequence Diagram Description
In which if user want to view log in Manage log screen so first he/she has to Choose Start date and End Date from Calendar then press submit button. Submit button calls viewLog function which process the request display the logs to the user.
cs code

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.Sql;
using System.Data.SqlClient;
using System.Configuration;

namespace manage_logs
{
    public partial class _Default : System.Web.UI.Page
    {
        //StreamReader myReader = new StreamReader("logfile");

          
        protected void Page_Load(object sender, EventArgs e)
        {
            GridView1.Visible = false;
        }

        protected void Login1_Authenticate(object sender, AuthenticateEventArgs e)
        {

        }

        protected void Button1_Click1(object sender, EventArgs e)
        {
            SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString);
        SqlCommand cmd = new SqlCommand("select * from [Logs] where Date = @startDate and Date = @enddate", conn);
try
{
using (conn)
{
conn.Open();
SqlParameter param1 = new SqlParameter();
    SqlParameter param2 = new SqlParameter();
param1.ParameterName = "@startdate";
param1.SqlDbType = System.Data.SqlDbType.Date;
param1.Value = Calendar1.SelectedDate;
cmd.Parameters.Add(param1);
param2 = new SqlParameter();
param2.ParameterName = "@date";
param2.SqlDbType = System.Data.SqlDbType.Date;
param2.Value = Calendar2.SelectedDate;
cmd.Parameters.Add(param2);
GridView1.DataSource = cmd.ExecuteReader();
GridView1.DataBind();
GridView1.Visible = true;
}

}
catch (Exception ex)
{
Response.Write(ex.Message);
}

} 
                 


    }
}

source Code

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="ViewLog.aspx.cs" Inherits="manage_logs._Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    </head>
<body>
    <form id="form1" runat="server">
    <p>
        Manage Logs ( View Log)</p>
    <p>
        &nbsp;</p>
    <p>
        &nbsp;</p>
    <p>
        <asp:Label ID="Label2" runat="server" 
            style="z-index: 1; left: 231px; top: 123px; position: absolute; height: 19px; width: 81px" 
            Text="Start Date"></asp:Label>
    </p>
    <p>
        <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" 
            DataSourceID="SqlDataSource1" EnableModelValidation="True" 
            
            style="z-index: 1; left: 596px; top: 205px; position: absolute; height: 147px; width: 629px">
            <Columns>
                <asp:BoundField DataField="MangerId" HeaderText="MangerId" 
                    SortExpression="MangerId" />
                <asp:BoundField DataField="UserName" HeaderText="UserName" 
                    SortExpression="UserName" />
                <asp:BoundField DataField="CheckIntime" HeaderText="CheckIntime" 
                    SortExpression="CheckIntime" />
                <asp:BoundField DataField="CheckOuttime" HeaderText="CheckOuttime" 
                    SortExpression="CheckOuttime" />
                <asp:BoundField DataField="Date" HeaderText="Date" SortExpression="Date" />
            </Columns>
        </asp:GridView>
        <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
            ConnectionString="<%$ ConnectionStrings:ConnectionString %>" 
            SelectCommand="SELECT * FROM [Logs]"></asp:SqlDataSource>
    </p>
    <asp:Calendar ID="Calendar1" runat="server" 
        
        style="z-index: 1; left: 351px; top: 32px; position: absolute; height: 205px; width: 9px">
        
    </asp:Calendar>
    <p>
        &nbsp;</p>
    <p>
        &nbsp;</p>
    <asp:Calendar ID="Calendar2" runat="server" 
         
        style="z-index: 1; left: 348px; top: 260px; position: absolute; height: 205px; width: 9px">
    </asp:Calendar>
    <p>
        <asp:Label ID="Label3" runat="server" 
            style="z-index: 1; left: 232px; top: 288px; position: absolute" Text="End Date"></asp:Label>
    </p>
    <p>
        &nbsp;</p>
    <p>
        &nbsp;</p>
    <p>
        <asp:Button ID="Button1" runat="server" onclick="Button1_Click1" 
            style="z-index: 1; left: 303px; top: 522px; position: absolute; width: 91px; margin-bottom: 62px" 
            Text="Submit" />
    </p>
    <p>
        &nbsp;</p>
    </form>
</body>
</html>

waiting for reply...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.