C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Communities   Interview   Jobs   Projects   Offshore Development    
Silverlight Tutorials | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Revenue Sharing |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...

New Feature: Community Sites: Create your own .NET community website and start earning from Google AdSense ! It's Free !




plz urgent..............


Posted Date: 28 Aug 2008      Total Responses: 1

Posted By: radhamahi1       Member Level: Gold     Points: 1


i hv requirement in my form having txtboxes and three buttons like insertupdate,delete and search i am using sqlserver2005 i wanto implement these functionality using 3-tier architecture withoust using variables plz can u give me the breif functionality step by step .



Responses

Author: Athira Appukuttan    29 Aug 2008Member Level: DiamondRating:     Points: 6
Hi..


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;
using System.Data.SqlClient;

public partial class AddEmployee : System.Web.UI.Page
{
SQLHelper sq = new SQLHelper();
protected void Page_Load(object sender, EventArgs e)
{
if(!IsPostBack)
{
GetEmployee();
}
}
public void save_Records()
{
string strFname, strLname, strTitle, strCity, strQuey;
SQLHelper addEmployee = new SQLHelper();
strFname = txtFName.Text;
strLname = txtLName.Text;
strTitle = txtTitle.Text;
strCity = txtCity.Text;
if (Session["EmpId"] == null)
{
strQuey = "insert into employees(firstname,lastname,title,city)values('" + strFname + "','" + strLname + "','" + strTitle + "','" + strCity + "')";
}
else
{
strQuey = "update employees set firstname='" + strFname + "',lastname='" + strLname + "',title='" + strTitle + "',city='" + strCity + "' where employeeid='" + Session["EmpId"] + "'";
}
int rec=addEmployee.ExecuteNonQuery(strQuey);
if (rec > 0)
{
Response.Redirect("GridViewNew.aspx");
}

}

public void Delete_Record()
{

strQuey ="delete from employees where where employeeid='" + Session["EmpId"] + "'

int rec=addEmployee.ExecuteNonQuery(strQuey);
if (rec > 0)
{
Response.Redirect("GridViewNew.aspx");
}
}

protected void Button1_Click(object sender, EventArgs e)
{
save_Records();
}
private void GetEmployee()
{
if (Session["EmpId"] != null)
{
SQLHelper OldEmp = new SQLHelper();
SqlDataReader OldEmployee = OldEmp.ExecuteReader("select * from Ms_Candidate where id='" + Session["EmpId"] +"'");
while (OldEmployee.Read())
{
txtFName.Text = OldEmployee["firstname"].ToString();
txtLName.Text = OldEmployee["lastname"].ToString();
txtTitle.Text = OldEmployee["title"].ToString();
txtCity.Text = OldEmployee["city"].ToString();
}

}
}
private void clearControl()
{
txtFName.Text = "";
txtLName.Text = "";
txtTitle.Text = "";
txtCity.Text = "";
}
protected void Button2_Click(object sender, EventArgs e)
{
clearControl();
Response.Redirect("GridViewNew.aspx");
}
}



SQLHelper.cs.txt
Post Reply
You must Sign In to post a response.
Next : how to solve "Indexoutofrangeexception was unhandled by user code" this error?
Previous : resize the flash file (.swf)
Return to Discussion Forum
Post New Message
Category: ASP.NET

Related Messages



dotNet Slackers   BizTalk Adaptors    Web Design

efax

Contact Us    Privacy Policy    Terms Of Use