using System;
using System.Data;
using System.Configuration;
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.OracleClient;
public partial class _Default : System.Web.UI.Page
{
OracleConnection objConn;
OracleCommand objCmd;
String strSQL;
protected void Page_Load(object sender, EventArgs e)
{
String strConnString;
strConnString = "Data Source=pcrm195;User Id=wllnew;Password=wllnew;";
objConn = new OracleConnection(strConnString);
objConn.Open();
if (!Page.IsPostBack)
{
BindData();
}
}
protected void BindData()
{
String strSQL;
strSQL = "SELECT * FROM WLLPACKAGE";
OracleDataReader dtReader;
objCmd = new OracleCommand(strSQL, objConn);
dtReader = objCmd.ExecuteReader();
//*** BindData to DataGrid ***//
myDataGrid.DataSource = dtReader;
myDataGrid.DataBind();
dtReader.Close();
dtReader = null;
}
protected void myDataGrid_CancelCommand(object sender, DataGridCommandEventArgs e)
{
myDataGrid.EditItemIndex = -1;
myDataGrid.ShowFooter = true;
BindData();
}
protected void myDataGrid_EditCommand(object sender, DataGridCommandEventArgs e)
{
myDataGrid.EditItemIndex = e.Item.ItemIndex;
myDataGrid.ShowFooter = false;
BindData();
}
protected void myDataGrid_DeleteCommand(object sender, DataGridCommandEventArgs e)
{
strSQL = "DELETE FROM WLLPACKAGE WHERE WLLPACKAGEID = '" + myDataGrid.DataKeys[e.Item.ItemIndex]+"'";
objCmd = new OracleCommand(strSQL, objConn);
objCmd.ExecuteNonQuery();
myDataGrid.EditItemIndex = -1;
BindData();
}
protected void myDataGrid_UpdateCommand(object sender, DataGridCommandEventArgs e)
{
TextBox txtWLLPACKAGEID = (TextBox)e.Item.FindControl("txtEditWLLPACKAGEID");
TextBox txtWLLPACKAGECODE = (TextBox)e.Item.FindControl("txtWLLPACKAGECODE");
TextBox txtWLLPACKAGENAME = (TextBox)e.Item.FindControl("txtEditWLLPACKAGENAME");
TextBox txtWLLPACKAGEDESC = (TextBox)e.Item.FindControl("txtEditWLLPACKAGEDESC");
TextBox txtSDATE = (TextBox)e.Item.FindControl("txtSDATE");
TextBox txtEDATE = (TextBox)e.Item.FindControl("txtEditEDATE");
TextBox txtSTATUS = (TextBox)e.Item.FindControl("txtEditSTATUS");
TextBox txtBRANDID = (TextBox)e.Item.FindControl("txtEditBRANDID");
strSQL = "UPDATE WLLPACKAGE SET WLLPACKAGEID = '" + txtWLLPACKAGEID.Text + "' " +
" ,WLLPACKAGECODE = '" + txtWLLPACKAGECODE.Text + "' " +
" ,WLLPACKAGENAME = '" + txtWLLPACKAGENAME.Text + "' " +
" ,WLLPACKAGEDESC = '" + txtWLLPACKAGEDESC.Text + "' " +
" ,SDATE= '" + txtSDATE.Text + "' " +
" ,EDATE= '" + txtEDATE.Text + "' " +
" ,STATUS= '" + txtSTATUS.Text + "' " +
" ,BRANDID = '" + txtBRANDID.Text + "' " +
" WHERE WLLPACKAGEID = '" + myDataGrid.DataKeys[e.Item.ItemIndex] + "'";
objCmd = new OracleCommand(strSQL, objConn);
objCmd.ExecuteNonQuery();
myDataGrid.EditItemIndex = -1;
myDataGrid.ShowFooter = true;
BindData();
}
protected void myDataGrid_ItemCommand(object sender, DataGridCommandEventArgs e)
{
if (e.CommandName == "Add")
{
TextBox txtWLLPACKAGEID = (TextBox)e.Item.FindControl("txtAddWLLPACKAGEID");
TextBox txtWLLPACKAGECODE = (TextBox)e.Item.FindControl("txtAddWLLPACKAGECODE");
TextBox txtWLLPACKAGENAME = (TextBox)e.Item.FindControl("txtAddWLLPACKAGENAME");
TextBox txtWLLPACKAGEDESC = (TextBox)e.Item.FindControl("txtAddWLLPACKAGEDESC");
TextBox txtSDATE = (TextBox)e.Item.FindControl("txtAddSDATE");
TextBox txtEDATE = (TextBox)e.Item.FindControl("txtAddEDATE");
TextBox txtSTATUS = (TextBox)e.Item.FindControl("txtAddSTATUS");
TextBox txtBRANDID = (TextBox)e.Item.FindControl("txtAddBRANDID");
strSQL = "INSERT INTO WLLPACKAGE (WLLPACKAGEID,WLLPACKAGECODE,WLLPACKAGENAME,WLLPACKAGEDESC,SDATE,EDATE,STATUS,BRANDID) " +
" VALUES ('" + txtWLLPACKAGEID.Text + "','" + txtWLLPACKAGECODE.Text + "','" + txtWLLPACKAGENAME.Text +"','" + txtWLLPACKAGEDESC.Text + "','" + txtSDATE.Text + "','" + txtEDATE.Text + "','" + txtSTATUS.Text + "','" + txtBRANDID.Text + "')";
objCmd = new OracleCommand(strSQL, objConn);
objCmd.ExecuteNonQuery();
BindData();
}
}
}
ayeshakhan 0 Newbie Poster
rohand 1 Posting Whiz in Training
Lusiphur 185 Practically a Posting Shark Team Colleague Featured Poster
malashukla 0 Light Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.