hello

Tuesday, 17 July 2012

CLEARE FUNCATION IN VB.NET

  Public Sub clr()
        txtNOPFirstGo.Text = ""    
        ddlProduct.SelectedIndex = 0
     
    End Sub

.vb class for transaction sql

Imports System
Imports System.Data
Imports System.Configuration
Imports System.Data.SqlClient
Public Class clsConnection
    Public Sub New()
        '
        ' TODO: Add constructor logic here
        '
    End Sub
    Dim con As SqlConnection = New SqlConnection()
    Dim com As SqlCommand = New SqlCommand()
    Dim da As SqlDataAdapter = New SqlDataAdapter()
    Dim constr As String = "Data Source=servernaem\SQLEXPRESS;Initial Catalog=dbname  

    Public Function selectds(ByVal str As String) As DataSet
        Dim ds As DataSet = New DataSet()
        If con.State = ConnectionState.Closed Then
            con.ConnectionString = constr
            con.Open()
        End If
        com.CommandText = str
        com.Connection = con
        da.SelectCommand = com
        da.Fill(ds)
        con.Close()
        Return ds
    End Function

End Class

WORKING WITH VB.NET FULL EXAMPLE

Imports System
Imports System.Collections
Imports System.Configuration
Imports System.Data
Imports System.Data.SqlClient
Partial Public Class Default4
    Inherits System.Web.UI.Page

  
    Dim con As SqlConnection = New SqlConnection("Data Source=EV001F294E678D\SQLEXPRESS;Initial Catalog=oee;Integrated Security=True")
    Sub Page_Load(ByVal Sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        If Page.IsPostBack Then
        Else
            fill()
        End If
    End Sub
    Public Sub fill()
       
    End Sub

WORKING WITH VB.NET LOGIN EXAMPLE

Login Form.vb
Imports SystemImports System.CollectionsImports System.ConfigurationImports System.DataImports System.LinqImports System.WebImports System.Web.SecurityImports System.Web.UIImports System.Web.UI.HtmlControlsImports System.Web.UI.WebControlsImports System.Web.UI.WebControls.WebPartsImports System.Xml.LinqImports System.Data.SqlClientPartial




Public Class Default2Inherits System.Web.UI.PageDim c1 As clsConnection = New clsConnection()Dim ds As DataSet = New DataSet()Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)End Sub
Protected Sub btnLogin_Click(ByVal sender As Object, ByVal e As EventArgs)If txtLoginId.Text <> "" And txtPassword.Text <> "" ThenDim getAdmin As String = "select * from oee_LoginTable where signum_id='" + txtLoginId.Text + "' and Password='" + txtPassword.Text + "'"ds = c1.selectds(getAdmin)
If ds.Tables(0).Rows.Count > 0 Then
Dim utype As String = ds.Tables(0).Rows(0)("UserType").ToString()If utype = "1" ThenSession(
Response.Redirect(
"signumid") = ds.Tables(0).Rows(0)("signum_id").ToString()"User_Home.aspx")ElseEnd IfElse
End Ifclr()
ElseEnd IfEnd Sub
Response.Redirect(
Protected Sub btnBack_Click(ByVal sender As Object, ByVal e As EventArgs)"../Default.aspx")End Sub
txtLoginId.Text =
Public Sub clr()""txtPassword.Text = ""
End
End Sub Class

Wednesday, 27 June 2012

Exclereport by anil kumar aggarwal

using System;using System.Data;using System.Configuration;using System.Linq;using System.Web;using System.Web.Security;using System.Web.UI;using System.Web.UI.HtmlControls;using System.Web.UI.WebControls;using System.Web.UI.WebControls.WebParts;using System.Xml.Linq;///
///
<summary> Summary description for Exclereport/// </summary>public class Exclereport{

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

{





{

}

{


}


{



{

}

{


}

}

{


{

}

}


ds.Clear();


}

{





public void Excelreport(DataSet ds)HttpContext.Current.Response.AppendHeader("Content-Disposition", "attachment; filename=Report.xls");HttpContext.Current.Response.ContentType = "application/ms-excel";HttpContext.Current.Response.Write("<table border='1px'>");HttpContext.Current.Response.Write("<tr>");for (int i = 0; i < ds.Tables[0].Columns.Count; i++)HttpContext.Current.Response.Write("<td align='center' style='font-family: Calibri; font-size: 18px; font-weight: bold; color: #FFFFFF; background-color: #006699' >" + ds.Tables[0].Columns[i].ColumnName + "</td>");for (int i = 0; i < 100; i++)HttpContext.Current.Response.Write("<td></td>");HttpContext.Current.Response.Write("</tr>");for (int i = 0; i < ds.Tables[0].Rows.Count; i++)HttpContext.Current.Response.Write("<tr>");DataRow row = ds.Tables[0].Rows[i];for (int j = 0; j < ds.Tables[0].Columns.Count; j++)HttpContext.Current.Response.Write("<td align='left' >" + row[j] + "</td>");for (int k = 0; k < 100; k++)HttpContext.Current.Response.Write("<td></td>");HttpContext.Current.Response.Write("</tr>");for (int i = 0; i < 50; i++)HttpContext.Current.Response.Write("<tr>");for (int j = 0; j < 105; j++)HttpContext.Current.Response.Write("<td></td>");HttpContext.Current.Response.Write("</tr>");HttpContext.Current.Response.Write("</table>");HttpContext.Current.Response.End();public void ExcelreportHrTraining(DataSet ds)HttpContext.Current.Response.AppendHeader("Content-Disposition", "attachment; filename=Report.xls");HttpContext.Current.Response.ContentType = "application/ms-excel";HttpContext.Current.Response.Write("<table border='1px'>");HttpContext.Current.Response.Write("<tr>");//HttpContext.Current.Response.Write("<td align='center' colspan=" + ds.Tables[0].Columns.Count+1 + " style='font-family: Calibri; font-size: 18px; font-weight: bold; color: Black ;background-color: #808080; border: 0px none #808080' >For the Period : January '11 to December '11 <br/>CDP</td>");


{


}




HttpContext.Current.Response.Write("<td align='center' colspan='15' style='font-family: Calibri; font-size: 18px; font-weight: bold; color: Black ;background-color: #808080; border: 0px none #808080' >For the Period : January '11 to December '11 <br/>CDP</td>");for (int i = 0; i < 100; i++)HttpContext.Current.Response.Write("<td></td>");HttpContext.Current.Response.Write("</tr>");HttpContext.Current.Response.Write("<tr>");//for (int i = 0; i < ds.Tables[0].Columns.Count; i++)//{// HttpContext.Current.Response.Write("<td align='center' valign='top' style='font-family: Calibri; font-size: 11px; ; color: #FFFFFF; background-color: #003366' >" + ds.Tables[0].Columns[i].ColumnName + "</td>");





HttpContext.Current.Response.Write("<td align='center' valign='top' style='font-family: Calibri; font-size: 13px; width:80px;font-weight: bold; color: #FFFFFF; background-color: #003366' >Month</td>");HttpContext.Current.Response.Write("<td align='center' valign='top' style='font-family: Calibri; font-size: 13px; width:80px; font-weight: bold;color: #FFFFFF; background-color: #003366' >No of Trainings</td>");HttpContext.Current.Response.Write("<td align='center' valign='top' style='font-family: Calibri; font-size: 13px; width:80px;font-weight: bold; color: #FFFFFF; background-color: #003366' >Planned Participants</td>");HttpContext.Current.Response.Write("<td align='center' valign='top' style='font-family: Calibri; font-size: 13px; width:80px;font-weight: bold; color: #FFFFFF; background-color: #003366' >Actual Participants</td>");HttpContext.Current.Response.Write("<td align='center' valign='top' style='font-family: Calibri; font-size: 13px; width:80px;font-weight: bold; color: #FFFFFF; background-color: #003366' >Training Absenteeism</td>");HttpContext.Current.Response.Write("<td align='center' valign='top' style='font-family: Calibri; font-size: 13px; width:80px;font-weight: bold; color: #FFFFFF; background-color: #003366' >Total Training Person Days (B*C)</td>");//HttpContext.Current.Response.Write("<td align='center' valign='top' style='font-family: Calibri; font-size: 13px; width:80px;font-weight: bold; color: #FFFFFF; background-color: #003366' >Emp. Strength Month Beginning</td>");//HttpContext.Current.Response.Write("<td align='center' valign='top' style='font-family: Calibri; font-size: 13px; width:80px;font-weight: bold; color: #FFFFFF; background-color: #003366' >Emp. Strength Month End</td>");//HttpContext.Current.Response.Write("<td align='center' valign='top' style='font-family: Calibri; font-size: 13px; width:80px;font-weight: bold; color: #FFFFFF; background-color: #003366' >Avg Emp Strength</td>");//HttpContext.Current.Response.Write("<td align='center' valign='top' style='font-family: Calibri; font-size: 13px; width:80px;font-weight: bold; color: #FFFFFF; background-color: #003366' >Per Person Training Days</td>");
HttpContext.Current.Response.Write("<td align='center' valign='top' style='font-family: Calibri; font-size: 13px; width:80px;font-weight: bold; color: #FFFFFF; background-color: #003366' >Total Training Expenses</td>");//HttpContext.Current.Response.Write("<td align='center' valign='top' style='font-family: Calibri; font-size: 13px; width:80px;font-weight: bold; color: #FFFFFF; background-color: #003366' >Training Cost per Employee</td>");




HttpContext.Current.Response.Write("<td align='center' valign='top' style='font-family: Calibri; font-size: 13px; width:80px;font-weight: bold; color: #FFFFFF; background-color: #003366' >Training Program Score</td>");HttpContext.Current.Response.Write("<td align='center' valign='top' style='font-family: Calibri; font-size: 13px; width:80px;font-weight: bold; color: #FFFFFF; background-color: #003366' >Trainer Score</td>");HttpContext.Current.Response.Write("<td align='center' valign='top' style='font-family: Calibri; font-size: 13px; width:80px;font-weight: bold; color: #FFFFFF; background-color: #003366' >Overall Feedback Score</td>");//}
{


}


{





{


}

{


}

}

{


{

}

}


ds.Clear();


}

{
System.IO.
System.Web.UI.


dgGrid.DataSource = dsExport;
for (int i = 0; i < 100; i++)HttpContext.Current.Response.Write("<td></td>");HttpContext.Current.Response.Write("</tr>");for (int i = 0; i < ds.Tables[0].Rows.Count; i++)HttpContext.Current.Response.Write("<tr>");DataRow row = ds.Tables[0].Rows[i];for (int j = 0; j < ds.Tables[0].Columns.Count-1; j++)HttpContext.Current.Response.Write("<td align='left' >" + row[j+1] + "</td>");for (int k = 0; k < 100; k++)HttpContext.Current.Response.Write("<td></td>");HttpContext.Current.Response.Write("</tr>");for (int i = 0; i < 50; i++)HttpContext.Current.Response.Write("<tr>");for (int j = 0; j < 105; j++)HttpContext.Current.Response.Write("<td></td>");HttpContext.Current.Response.Write("</tr>");HttpContext.Current.Response.Write("</table>");HttpContext.Current.Response.End();public void exlRet(DataSet dsExport)StringWriter tw = new System.IO.StringWriter();HtmlTextWriter hw =new System.Web.UI.HtmlTextWriter(tw);DataGrid dgGrid = new DataGrid();//Report Header//hw.WriteLine("<b><u><font size='5'>" + // "Report for the Fiscal year: " + txtFY.Text + // "</font></u></b>");// hw.WriteLine("<br>&mp;nbsp;");// Get the HTML for the control.dgGrid.HeaderStyle.Font.Bold =
dgGrid.DataBind();
dgGrid.RenderControl(hw);
true;// Write the HTML back to the browser.

HttpContext.Current.Response.AppendHeader("Content-Disposition", "attachment; filename=Report.xls");HttpContext.Current.Response.ContentType = "application/vnd.ms-excel";// this.EnableViewState = false;

}
}
HttpContext.Current.Response.Write(tw.ToString());HttpContext.Current.Response.End();

.cs class for transaction sql by anil kumar aggarwal (soft. dov.)

using System;using System.Data;using System.Configuration;using System.Linq;using System.Web;using System.Web.Security;using System.Web.UI;using System.Web.UI.HtmlControls;using System.Web.UI.WebControls;using System.Web.UI.WebControls.WebParts;using System.Xml.Linq;using System.Data.SqlClient;using System.IO;using System.Net.Mail;using System.Diagnostics;using System.Net;///
///
<summary> Summary description for clsConnection/// </summary>public class clsConnection{

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






{
SqlConnection con = new SqlConnection();SqlCommand com = new SqlCommand();SqlDataAdapter da = new SqlDataAdapter();string constr = "Data Source=150.236.12.34;Initial Catalog=PMS; User Id=pms;Password=smp;";MailMessage mail;public static string connectget{

}
}

{


{
con.ConnectionString = constr;
con.Open();
}
com.CommandText = str;
com.Connection = con;
da.SelectCommand = com;
da.Fill(ds);
con.Close();

}







{


{
con.ConnectionString = constr;
con.Open();
}
com.CommandText = str;
com.Connection = con;
da.SelectCommand = com;
s1 =
con.Close();

}

{

{
con.ConnectionString = constr;
con.Open();
}
com.CommandText = str;
com.Connection = con;
da.SelectCommand = com;
com.ExecuteNonQuery();
con.Close();
}

{
return "Data Source=150.236.12.34;Initial Catalog=PMS; User Id=pms;Password=smp;";public DataSet selectds(string str)DataSet ds = new DataSet();if (con.State == ConnectionState.Closed)return ds;public string SelectScalar(string str)string s1;if (con.State == ConnectionState.Closed)Convert.ToString(com.ExecuteScalar());return s1;public void ExecuteQuery(string str)if (con.State == ConnectionState.Closed)public void fillRadioButtonList(String query, RadioButtonList objDDL, String colfield, String valField)try{

{
con.ConnectionString = constr;
con.Open();
}

objDDL.Items.Clear();
da =
da.Fill(ds);

objDDL.DataSource = ds.Tables[0];
objDDL.DataTextField = colfield;
objDDL.DataValueField = valField;
objDDL.DataBind();
}

}

{
if (con.State == ConnectionState.Closed)DataSet ds = new DataSet();new SqlDataAdapter(query, con);catch { }public void FillDropdownListwithvalue(String query, DropDownList objDDL, String colfield, String valField)try{

{ con.ConnectionString = constr; con.Open(); }

objDDL.Items.Clear();
da =
da.Fill(ds);


NewRow[colfield] =
newtbl = ds.Tables[0];
newtbl.Rows.InsertAt(NewRow, 0);
newtbl.AcceptChanges();
newtbl = newtbl.Copy();
objDDL.DataSource = ds.Tables[0];
objDDL.DataTextField = colfield;
objDDL.DataValueField = valField;
objDDL.DataBind();
}

}

{

{
con.ConnectionString = constr;
con.Open();
}



}
}
if (con.State == ConnectionState.Closed)DataSet ds = new DataSet();new SqlDataAdapter(query, con);DataTable newtbl = new DataTable();DataRow NewRow = ds.Tables[0].NewRow();"-Please Select-";catch { }public int getmaxid(string str)if (con.State == ConnectionState.Closed)SqlCommand commm = new SqlCommand(str, con);int maxid = Convert.ToInt32(commm.ExecuteScalar()) + 1;return maxid;

Tuesday, 12 June 2012

create reminder in c# (anil kumar software doveloper alwar rajasthan)

File
>globle
<%@ Application Language="C#" %><script RunAt="server">
{
System.Timers.
void Application_Start(object sender, EventArgs e)Timer myTimer = new System.Timers.Timer();// Set the Interval to 5 seconds (5000 milliseconds).myTimer.Interval = 36000000;
myTimer.AutoReset =
myTimer.Elapsed +=
myTimer.Enabled =
}

{

bjcls.Reminder();
}
true;new System.Timers.ElapsedEventHandler(myTimer_Elapsed);true;public void myTimer_Elapsed(object source, System.Timers.ElapsedEventArgs e)clsConnection objcls = new clsConnection();</
app code .cs
public
{


{



{
con.ConnectionString = constr;
con.Open();
}


com.CommandText = str;
com.Connection = con;
da.SelectCommand = com;
da.Fill(ds);
con.Close();


{



{
con.ConnectionString = constr;
con.Open();
}

com.CommandText = str2;
com.Connection = con;
da.SelectCommand = com;
s1 =
con.Close();
mailsend1(s1);

{
con.ConnectionString = constr;
con.Open();
}


com.CommandText = str22;
com.Connection = con;
da.SelectCommand = com;
da.Fill(ds2);
con.Close();

{


{ con.ConnectionString = constr; con.Open(); }

com.CommandText = str222;
com.Connection = con;
da.SelectCommand = com;
s12 =
con.Close();
mailsend1(s12);
}
}
}
}


{
mail =
mail.From =
mail.To.Add(
mail.Subject =
mail.Body =

smtpMail.Port = 25;
smtpMail.Host =
smtpMail.Send(mail);
}
void Reminder()string d = System.DateTime.Now.Hour.ToString();if (d == "14")string s1;string s12;if (con.State == ConnectionState.Closed)DataSet ds = new DataSet();string str = "SELECT * FROM RAIL_ACTION_DETAIL where REMINDER_DATE='" + System.DateTime.Now.ToString("MM/dd/yyyy") + "'";int i;for (i = 0; i <= ds.Tables[0].Rows.Count - 1; i++)String m = ds.Tables[0].Rows[i].ItemArray[0].ToString();String m1 = ds.Tables[0].Rows[i].ItemArray[3].ToString();if (con.State == ConnectionState.Closed)string str2 = "SELECT e.mail_id FROM RAIL_ACTION_MST as m left outer join hr_emp_mst as e on e.signm_id=m.ASSIGNER_SIGNUM where ACTION_ID='" + m + "'";Convert.ToString(com.ExecuteScalar());if (con.State == ConnectionState.Closed)DataSet ds2 = new DataSet();string str22 = "SELECT * FROM RAIL_SUPPORT_TEAM where ACTION_ID='" + m + "'";for (i = 0; i <= ds2.Tables[0].Rows.Count - 1; i++)String m12 = ds2.Tables[0].Rows[i].ItemArray[2].ToString();if (con.State == ConnectionState.Closed)string str222 = "SELECT mail_id from hr_emp_mst where signm_id='" + m12 + "'";Convert.ToString(com.ExecuteScalar());public void mailsend1(string tomailid)new MailMessage();new MailAddress("anil.j.kumar@ericsson.com ");new MailAddress(tomailid));" PEMINDER FOR ROAILING ACTION ITEM LIST";"Message";SmtpClient smtpMail = new SmtpClient();"hostname";
script>