DECLARE @startDate DATETIME
DECLARE @endDate DATETIME
SET @startDate = '2011-01-01'
SET @endDate = '2011-01-31';
WITH dates(Date) AS
(
SELECT @startdate as Date
UNION ALL
SELECT DATEADD(d,1,[Date])
FROM dates
WHERE DATE < @enddate
)
SELECT Date
FROM dates
OPTION (MAXRECURSION 0)
GO
Search This Blog
Monday, April 1, 2013
Resolve Multiple Browser issue in asp.net
protected void btnsndforapp_Click(object sender, EventArgs e)
{
lock (this)
{
try
{
//
stripadd = HttpContext.Current.Request.UserHostAddress;
DataTable dt = new DataTable();
sqlcon.Open();
sqlcmd = sqlcon.CreateCommand();
transaction = sqlcon.BeginTransaction(IsolationLevel.ReadCommitted);
sqlcmd.Connection = sqlcon;
sqlcmd.Transaction = transaction;
sqlcmd.CommandText = "select * from TaAS_USER_LOG where USERID='" + SPContext.Current.Web.CurrentUser.Name.Trim() + "'";
da = new SqlDataAdapter(sqlcmd);
dt.Clear();
da.Fill(dt);
// Response.Write(dt.Rows.Count);
// Response.End();
if (dt.Rows.Count > 0)
{
string strLogStatus = dt.Rows[0][2].ToString();
DateTime dtLogin = Convert.ToDateTime(dt.Rows[0][3].ToString());
if (strLogStatus.ToLower() == "y")
{
double _Min = (DateTime.Now - dtLogin).TotalMinutes;
if (_Min >= 30)
{
sqlcmd.CommandText = "update TaAS_USER_LOG set IN_TIME=getdate(),IP_ADD='" + stripadd + "' where USERID='" + SPContext.Current.Web.CurrentUser.Name.Trim() + "'";
sqlcmd.CommandType = CommandType.Text;
sqlcmd.ExecuteNonQuery();
transaction.Commit();
SendforApproval();
}
else
{
Page.RegisterStartupScript("66", "<script>alert('You are not allowed to apply for leaves as you are using multiple browsers!')</script>");
Session.Abandon();
Response.Cookies.Clear();
FormsAuthentication.SignOut();
Response.Redirect("/../signout.aspx");
}
}
else if (dt.Rows[0][2].ToString() == "N")
{
sqlcmd.CommandText = "update TaAS_USER_LOG set status='Y',IN_TIME=getdate(),IP_ADD='" + stripadd + "' where USERID='" + SPContext.Current.Web.CurrentUser.Name.Trim() + "'";
sqlcmd.CommandType = CommandType.Text;
sqlcmd.ExecuteNonQuery();
transaction.Commit();
SendforApproval();
//Response.Redirect("Default2.aspx");
}
}
else
{
// Response.Write("No records");
//Response.End();
sqlcmd.CommandType = CommandType.StoredProcedure;
sqlcmd.CommandText = "SYNPROD.INSERT_TaAS_LOG";
sqlcmd.Parameters.AddWithValue("@USERID", SPContext.Current.Web.CurrentUser.Name.Trim());
sqlcmd.Parameters.AddWithValue("@IP", stripadd);
sqlcmd.ExecuteNonQuery();
transaction.Commit();
//Response.Write("suersh");
//Response.End();
SendforApproval();
}
}
catch (Exception ex)
{
Response.Write(ex.Message);
try
{
transaction.Rollback();
}
catch (SqlException ex1)
{
if (transaction.Connection != null)
{
Response.Write("An exception of type " + ex1.GetType() + " was encountered while attempting to roll back the transaction.");
}
}
//transaction.Rollback();
// login.FailureText = "system exception";
// login.FailureText = ex.Message + "1";
}
finally
{
sqlcmd.CommandText = "update synprod.TaAS_USER_LOG set status='N',OUT_TIME=getdate() where USERID='" + SPContext.Current.Web.CurrentUser.Name.Trim() + "'";
sqlcmd.CommandType = CommandType.Text;
sqlcmd.ExecuteNonQuery();
sqlcon.Close();
}
}
}
Subscribe to:
Posts (Atom)