Thursday, September 6, 2012

Useful Web sites

Codeguru
Codeplex
exforsys

Monday, February 13, 2012

Open new window in ASP.NET

----------------------------------------------------
Page.ClientScript.RegisterStartupScript(this.GetType(), "ale", "window.open('http://www.google.com',null,'height=600,width=800');", true);

Class File : Export.cs

---------------------------------------------------------
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.IO;
using System.Configuration;
using System.Web.UI;
using System.Web.UI.WebControls;

///
/// Summary description for Export
///

public class Export
{
string attachment;

public Export()
{

}
public void Exportfn(GridView grdvw)
{
//Dataread drgrd = new Dataread();
//drgrd.fileread(sqlquery, grdvw);
attachment = "attachment; filename=AVAYA.xls";
System.Web.HttpContext.Current.Response.ClearContent();
System.Web.HttpContext.Current.Response.AddHeader("content-disposition", attachment);
System.Web.HttpContext.Current.Response.ContentType = "application/ms-excel";
StringWriter sw = new StringWriter();
HtmlTextWriter htw = new HtmlTextWriter(sw);
grdvw.RenderControl(htw);
System.Web.HttpContext.Current.Response.Write(sw.ToString());
System.Web.HttpContext.Current.Response.End();

}



}

Thursday, January 26, 2012

Class File : Navigation.cs

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

///
/// Summary description for Navigation
///

public class Navigation
{
public Navigation()
{
//
// TODO: Add constructor logic here
//
}

public void nav_fn(System.Web.UI.WebControls.Menu mn)
{
if (mn.SelectedValue == "Home")
{
System.Web.HttpContext.Current.Response.Redirect("~/Reporter.aspx");

}
else if (mn.SelectedValue == "Dashboards")
{
System.Web.HttpContext.Current.Response.Redirect("~/Dashboards.aspx");

}
else if (mn.SelectedValue == "Settings")
{
System.Web.HttpContext.Current.Response.Redirect("~/Settings.aspx");

}
else if (mn.SelectedValue == "Logout")
{
System.Web.HttpContext.Current.Response.Cookies["AVAYA_Realtime"].Expires = DateTime.Now.AddDays(-1);
System.Web.HttpContext.Current.Response.Redirect("~/login.aspx");


}

}
}

Class File : MSColumn3D.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using InfoSoftGlobal;
using MySql.Data.MySqlClient;
using MySql.Data;
using System.Collections.Generic;
using System.Configuration;
///
/// Summary description for MSColumn3D
///

public class MSColumn3D
{
MySqlCommand cmd;
MySqlDataReader dr;

public string strXML = "";


public MSColumn3D()
{

}
public string MSCol3D_Charts(string sqlstr, string charttype, string chartid, string xaxis, string pyaxis, string syaxis)
{
strXML = "";
strXML += "";

string connectionInfo = ConfigurationManager.AppSettings["ConnectionInfo"];
MySqlConnection con = new MySqlConnection(connectionInfo);
con.Open();

//cmd = new MySqlCommand("select * from avaya_rt_db where `" + xaxis + "` like 'Bel%' and " + yaxis + "!=0", con);
cmd = new MySqlCommand(sqlstr, con);
dr = cmd.ExecuteReader();

strXML += "";

while (dr.Read())
{
strXML += "";

}
dr.Close();
strXML += "
";

strXML += "";

cmd = new MySqlCommand(sqlstr, con);
dr = cmd.ExecuteReader();
while (dr.Read())
{
strXML += "";

}
dr.Close();
strXML += "
";

strXML += "";

cmd = new MySqlCommand(sqlstr, con);
dr = cmd.ExecuteReader();
while (dr.Read())
{
strXML += "";
}
dr.Close();
strXML += "
";

strXML += "
";

con.Close();


return FusionCharts.RenderChartHTML(charttype, "", strXML, chartid, "400", "300", false);

}
}

Class File : login_class.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.IO;
using MySql.Data.MySqlClient;
using MySql.Data;
using System.Configuration;

///
/// Summary description for login_class
///

public class login_class
{
public string loginID;
public string password;
public string ename;
MySqlCommand cmd;

public login_class()
{

}
public void loginfn(string sqlstr)
{

string connectionInfo = ConfigurationManager.AppSettings["ConnectionInfo"];
MySqlConnection con = new MySqlConnection(connectionInfo);

con.Open();
cmd = new MySqlCommand(sqlstr, con);


MySqlDataReader dr = cmd.ExecuteReader();
while (dr.Read())
{
loginID = dr["Userid"].ToString();
password = dr["Password"].ToString();
ename = dr["Username"].ToString();

}

con.Close();

}
}

Class File : Dropdown.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using MySql.Data.MySqlClient;
using MySql.Data;
using System.Data;
using System.Configuration;
using System.Web.UI.WebControls;
using System.IO;

///
/// Summary description for Dropdown
///

public class Dropdown
{
MySqlCommand cmd;
MySqlDataReader dr;

public Dropdown()
{
//
// TODO: Add constructor logic here
//
}
public void dataread(string sqlstr, DropDownList list, string fieldname)
{
try
{
list.Items.Clear();
list.Items.Add("All");
list.SelectedValue = "All";

string connectionInfo = ConfigurationManager.AppSettings["ConnectionInfo"];
MySqlConnection con = new MySqlConnection(connectionInfo);
con.Open();

cmd = new MySqlCommand(sqlstr, con);
dr = cmd.ExecuteReader();
while (dr.Read())
{
list.Items.Add(dr[fieldname].ToString());
}
dr.Close();

con.Close();
}
catch (Exception ex)
{
ex.ToString();
}
}
}