Search This Blog

Friday, November 30, 2012

Creating database for .net framework login system







Print own text on current date in calendar in c#







Print own text on current date.

#region DayRender
  
    protected void Calendar1_DayRender(object sender, DayRenderEventArgs e)
    {
     if (e.Day.IsToday)
            {
               e.Cell.Text = "today is chandra day";
            }
    }
    #endregion

Print own text on current date in calendar in c# (put text in textbox).



Print own text on current date (put text in textbox).

#region DayRender
  
    protected void Calendar1_DayRender(object sender, DayRenderEventArgs e)
    {
     if (e.Day.IsToday)
            {
                e.Cell.Text = TextBox1.Text;
            }
    }

    #endregion

On Selection change print date in label in calendar in c#



On Selection change print date in label.

protected void Calendar1_SelectionChanged(object sender, EventArgs e)
    {
        Label1.Text = "Your Date" + Calendar1.SelectedDate.ToLongDateString();

    }

Calendar show weekend disable in c#




Calendar show weekend disable.

     //code for day is weekend so disable to select event that day.
            if (e.Day.IsWeekend)
            {
                e.Cell.BackColor = System.Drawing.Color.White;
                e.Cell.ForeColor = System.Drawing.Color.Brown;
                e.Day.IsSelectable = false;
                e.Cell.Text = "Holyday";
            }

Calendar month change then print “your month change” in c#






Calendar month change then print “your month change”


protected void Calendar1_VisibleMonthChanged(object sender, MonthChangedEventArgs e)
    {
        Label1.Text = "Your month change";
    }

Calendar show date with disable link on date 1,2,3,4,5,6,7,8,9,10 in c#


       
Calendar  show date with disable link on date 1,2,3,4,5,6,7,8,9,10.


if (dr["D" + i].ToString() == "1")
                            {
                                e.Cell.BackColor = Color.Green;
                                e.Day.IsSelectable = false;

                            }

Calendar show with different color of date depends on database value in c#



         

Calendar show with different color of date depends on database value.

  #region DayRender
   protected void Calendar1_DayRender(object sender, DayRenderEventArgs e)
    {
        {
            if (!e.Day.IsOtherMonth)
            {
                int Fmonth = e.Day.Date.Month;
                string Enroll = "123abcd";
                string sql = "select * from Atendence where Amonth=" + Fmonth + " and EnrollNo='" + Enroll.ToString() + "'";
                SqlDataReader dr = dut.ExecuteReader(sql);
                if (dr.Read())
                {
                    int i;
                    for (i = 1; i <= 31; i++)
                    {
                        if (e.Day.Date.Day == i)
                        {
                            if (dr["D" + i].ToString() == "1")
                            {
                                e.Cell.BackColor = Color.Green;
                            }
                            else if (dr["D" + i].ToString() == "0")
                            {
                                e.Cell.BackColor = Color.Red;
                            }
                            else if (dr["D" + i].ToString() == "2")
                            {
                                e.Cell.BackColor = Color.Yellow;
                            }
                            else
                            {
                                e.Cell.BackColor = Color.White;
                            }
                        }
                    }
                }

            }
            else

    { e.Cell.Text = ""; }

Calendar show text place of date in c#


       
Calendar show text place of date.
//***********************************day render create cell load time**********
protected void Calendar1_DayRender(object sender, DayRenderEventArgs e)
if (dr.Read())
                {
                    int i;
                    for (i = 1; i <= 31; i++)
                    {
                        if (e.Day.Date.Day == i)
                        {
                            if (dr["D" + i].ToString() == "1")
                            {
e.Cell.Text = "P";
                            }
                            else if (dr["D" + i].ToString() == "0")
                            {
                               e.Cell.Text = "A";
    }
                            else if (dr["D" + i].ToString() == "2")
                            {
e.Cell.Text = "H";                      
          }
                            else
                            {
                                e.Cell.BackColor = Color.White;
                          }
                      }
                  }
   }
            }
            else

 { e.Cell.Text = ""; }

Calendar show only current month date in c#




Calendar show only current month date.
//***********************************day render create cell load time**********
 protected void Calendar1_DayRender(object sender, DayRenderEventArgs e)
 if (dr.Read())
                {
                    int i;
                    for (i = 1; i <= 31; i++)
                    {
                        if (e.Day.Date.Day == i)
                        {
                            if (dr["D" + i].ToString() == "1")
                            {
                                e.Cell.BackColor = Color.Green;

                            }
                            else if (dr["D" + i].ToString() == "0")
                            {
                                e.Cell.BackColor = Color.Red;
                            }
                            else if (dr["D" + i].ToString() == "2")
                            {
                                e.Cell.BackColor = Color.Yellow;
                            }
                            else
                            {
                                e.Cell.BackColor = Color.White;
                          }
                      }
                  }
   }
            }
            else
  { 
e.Cell.Text = ""
}

How can manage calendar object in asp.net with c#


How can manage calendar object in asp.net with c#

1. Calendar add on page.


using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class Webadmin_Atendence_calt : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
}


Monday, November 5, 2012

Hit Counter for Total number of Current Visitors on website

Total No of Current Visitors :

For current visitors hit we can use Global.asax file and Application variable :

Global.asax :


using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.SessionState;
using System.Data.SqlClient;
using System.Text;
using System.IO;

namespace SRTT_HEALTH
{
    public class Global : System.Web.HttpApplication
    {

        protected void Application_Start(object sender, EventArgs e)
        {
            // Code that runs on application startup
            Application["Visitors"] = 0;
         
        }

        protected void Session_Start(object sender, EventArgs e)
        {
            // Code that runs when a new session is started
            Application.Lock();
            Application["Visitors"] = Convert.ToInt32(Application["Visitors"]) + 1;
            int users = Convert.ToInt32(Application["Visitors"]);
            Application.UnLock();
         
        }

        protected void Application_BeginRequest(object sender, EventArgs e)
        {

        }

        protected void Application_AuthenticateRequest(object sender, EventArgs e)
        {

        }

        protected void Application_Error(object sender, EventArgs e)
        {
         
        }

        protected void Session_End(object sender, EventArgs e)
        {

        }

        protected void Application_End(object sender, EventArgs e)
        {

        }
    }
}

Other page code where show visitors number:


protected void Page_Load(object sender, EventArgs e)
        {
         
            Label1.Text=Application["Visitors"].ToString();
         
        }



Hit counter for application (Total Visit of Web Application)

Hit Counter for Application without Database:

count.ascx :


<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="count.ascx.cs" Inherits="SRTT_HEALTH.uiControl.count" %>
<tr>
<td align="center" height="20">Total Visit of Web Application : <asp:Label ID="lblCounter" runat="server"></asp:Label><br>

Total No of Current Visitors : <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
    </td>
</tr>

count.ascx.cs :


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

namespace HEALTH.uiControl
{
    public partial class count : System.Web.UI.UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {
           
            Label1.Text=Application["Visitors"].ToString();
           
            this.hitcount();

            DataSet DS = new DataSet();
            DS.ReadXml(Server.MapPath("~/ErrorLog/counter.xml"));

            lblCounter.Text = DS.Tables[0].Rows[0]["hits"].ToString();
           
        }

        private void hitcount()
        {
            DataSet DS = new DataSet();
            DS.ReadXml(Server.MapPath("~/ErrorLog/counter.xml"));

            int hits = Int32.Parse(DS.Tables[0].Rows[0]["hits"].ToString());

            hits += 1;

            DS.Tables[0].Rows[0]["hits"] = hits.ToString();

            DS.WriteXml(Server.MapPath("~/ErrorLog/counter.xml"));
         
        }
    }
}