Thursday, September 15, 2011

ASP.NET



AllAccount.aspx









AllAccount.aspx.cs


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

public partial class AllAccount : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{

}
protected void ListGrid_RowCommand(object sender, GridViewCommandEventArgs e)
{
if(e.CommandName=="delAcc"){
var ID = Convert.ToInt32(e.CommandArgument);

string query1 = "DELETE FROM AccData WHERE Id='"+ID+"'";
string query2="DELETE FROM Accounts WHERE Acc_Number='"+ID+"'";

Connect con = new Connect();
con.deleteAcc(query1, query2);
Response.Redirect("~/AllAccount.aspx",true);
}
}
}



Connect.cs



using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data.SqlClient;
using System.Data;
///
/// Summary description for Connect
///

public class Connect
{
SqlConnection sqlcon=null;
SqlDataAdapter Adptr = null;
public Connect()
{

}

public void connection()
{
string constr = "Data Source=SARANGA-PC;Initial Catalog=Accounts;User ID=sa;Password=saranga";
sqlcon = new SqlConnection(constr);
sqlcon.Open();
}

public void Insert(string sp,SqlParameter[] para)
{
connection();
SqlCommand cmd = new SqlCommand();
cmd.CommandType = CommandType.StoredProcedure;
cmd.CommandText = sp;
cmd.Connection = sqlcon;
for (int i=0; i {
cmd.Parameters.Add(para[i]);
}
cmd.ExecuteNonQuery();
sqlcon.Close();

}

public void update(string sp, SqlParameter[] para)
{
connection();
SqlCommand cmd = new SqlCommand();
cmd.CommandType = CommandType.StoredProcedure;
cmd.CommandText = sp;
cmd.Connection = sqlcon;
for (int i = 0; i < para.Length; i++)
{
cmd.Parameters.Add(para[i]);
}
cmd.ExecuteNonQuery();
sqlcon.Close();
}

public DataTable display(string query )
{
connection();

Adptr = new SqlDataAdapter(query, sqlcon);
DataSet ds = new DataSet();
DataTable dt = new DataTable();

Adptr.Fill(dt);
sqlcon.Close();

return dt;
}

public void deleteAcc(string q1,string q2)
{
connection();
SqlCommand cmd1 = new SqlCommand();
cmd1.CommandText = q1;
cmd1.Connection = sqlcon;
cmd1.ExecuteNonQuery();

SqlCommand cmd2 = new SqlCommand();
cmd2.CommandText = q1;
cmd2.Connection = sqlcon;
cmd2.ExecuteNonQuery();

sqlcon.Close();
}
}



NewAccount.aspx















NewAccount.aspx.cs


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

public partial class NewAccount : System.Web.UI.Page
{

protected void Page_Load(object sender, EventArgs e)
{

}
protected void btnApply_Click(object sender, EventArgs e)
{
int num=int.Parse(txtNum.Text);
string name=txtName.Text;
decimal depo= Convert.ToDecimal(txtDep.Text);
decimal withd = Convert.ToDecimal(txtwithdrowal.Text);
decimal Balance = Convert.ToDecimal(txtbalance.Text);
string type = DropType.SelectedValue ;

NewAcnt NewAc = new NewAcnt();
NewAc.CreateNew(num,name,depo,withd,Balance,type);
lblApplyStatus.Text = "Account Successfully Created";
}
}




NewAcnt.cs


using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data.SqlClient;
using System.Data;
///
/// Summary description for NewAccount
///

public class NewAcnt
{


public NewAcnt()
{

}

public void CreateNew(int num, string name, decimal depo,decimal withd,decimal balance, string type)
{

SqlParameter[] para = {new SqlParameter("@num",SqlDbType.Int),
new SqlParameter("@name",SqlDbType.VarChar,50),
new SqlParameter("@depo",SqlDbType.Decimal),
new SqlParameter("@withd",SqlDbType.Decimal),
new SqlParameter("@balance",SqlDbType.Decimal),
new SqlParameter("@type",SqlDbType.VarChar,50)};

para[0].Value = num;
para[1].Value = name;
para[2].Value = depo;
para[3].Value = withd;
para[4].Value = balance;
para[5].Value = type;

string sp= "SP_NewAcc";

Connect cont = new Connect();
cont.Insert(sp,para);
}
}




TransAccount.aspx













TransAccount.aspx.cs


using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
public partial class TransAccount : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
//$ConnectionStrings:AccountsConnectionString;
if(!IsPostBack){
dropNumber.ConnectionString = "Data Source=SARANGA-PC;Initial Catalog=Accounts;User ID=sa;Password=saranga";
dropNumber.SelectCommand = "SELECT [Acc_Number] FROM [Accounts]";
}
bind();
}
protected void btnbalance_Click(object sender, EventArgs e)
{
decimal withd = Convert.ToDecimal(txtupwithd.Text);
decimal depo = Convert.ToDecimal(txtupdepo.Text);
decimal baln = Convert.ToDecimal(txtupbalance.Text);

decimal finalbalance=baln+(depo-withd);
txtupbalance.Text = finalbalance.ToString();

}
protected void btnupdate_Click(object sender, EventArgs e)
{
int num = int.Parse(DropDownNumber.SelectedValue);
string name = txtupname.Text;
string type = txtuptype.Text;
decimal withd = Convert.ToDecimal(txtupwithd.Text);
decimal depo = Convert.ToDecimal(txtupdepo.Text);
decimal baln = Convert.ToDecimal(txtupbalance.Text);

Upadate up = new Upadate();
up.updateAcc(num, name, depo, withd, baln, type);
lblupstatus.Text = "Account Successfully Updated";

}
protected void btnsubmit_Click(object sender, EventArgs e)
{
Upadate up = new Upadate();
int ID =int.Parse(DropDownNumber.SelectedValue);
DataTable dt= up.drop(ID);

txtupname.Text = dt.Rows[0].ItemArray.GetValue(0).ToString();
txtuptype.Text = dt.Rows[0].ItemArray.GetValue(4).ToString();
txtupdepo.Text = dt.Rows[0].ItemArray.GetValue(1).ToString();
txtupwithd.Text=dt.Rows[0].ItemArray.GetValue(2).ToString();;
txtupbalance.Text = dt.Rows[0].ItemArray.GetValue(3).ToString(); ;
}

public void bind()
{

}
}





Upadate.cs




using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data.SqlClient;
using System.Data;

///
/// Summary description for Upadate
///

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

public DataTable drop(int ID)
{

string query = "SELECT dbo.Accounts.Acc_Name, dbo.Accounts.Acc_Deposit, dbo.AccData.Withdrowal, dbo.AccData.Balance,dbo.Accounts.Acc_Type FROM dbo.AccData INNER JOIN dbo.Accounts ON dbo.AccData.Id = dbo.Accounts.Acc_Number WHERE AccData.Id='"+ID+"'";
Connect cont = new Connect();

DataTable dt = new DataTable();
dt = cont.display(query);
return dt;
}

public void updateAcc(int num, string name, decimal depo, decimal withd, decimal balance, string type)
{
SqlParameter[] para = {new SqlParameter("@num",SqlDbType.Int),
new SqlParameter("@name",SqlDbType.VarChar,50),
new SqlParameter("@depo",SqlDbType.Decimal),
new SqlParameter("@withd",SqlDbType.Decimal),
new SqlParameter("@balance",SqlDbType.Decimal),
new SqlParameter("@type",SqlDbType.VarChar,50)};

para[0].Value = num;
para[1].Value = name;
para[2].Value = depo;
para[3].Value = withd;
para[4].Value = balance;
para[5].Value = type;

string sp = "SP_Update";

Connect cont = new Connect();
cont.update(sp, para);
}
}

css templte

HOME.ASPX










Style.css



body
{
background-color: Gray;
}
#Div1
{
margin-left:200px;
}

#Banner
{
width:890px;
height:100px;
background-color:#104E8B;
}

#home
{
width:890px;
height:700px;
}

#side
{
width:150px;
height:700px;
background-color: #528B8B ;
margin-top:1px;
float :left;
}

.menu
{
position :relative;
width:120px;
height:20px;
background-color:Menu;
margin-left:150px;
margin-top :100px;

}

.row
{
width:200px;
height:50px;
}
#menuitem
{
position:relative;
top:1px;
width:739px;
float:left;
left: 1px;
background-color:Menu;
}

#content
{
height:670px;
position:relative;
top:2px;
width:739px;
float:left;
left: 1px;
background-color:Menu;
}

#data
{
height:500px;
position:relative;
top:100px;
width:600px;
float:left;
left: 100px;
background-color:Menu;
}

Wednesday, April 13, 2011

...........................~ ? ~.............................


සඳක් වගේ පායා බැස ගියා..
සුවඳක් වගේ දැනිලා ඈතට ගියා...
පිනි බිඳුවක් වගේ සිසිලවී සැගවි ගියා....
සිහිනෙන් වගේ පෙනිලා නොපෙනී ගියා......
දේදුන්නක් වගේ වර්ණවී බොදව ගියා....
රළ වගේ වෙරළ සිප ආපසු ගියා...
ගීයක් වගේ ඇසිලා නෑසී ගියා..

Monday, December 6, 2010

.. අවිදු අඳුර දුරලූ නුවණ පහන නිවුණා..

මුලු විශ්වයටම

ජීවය දෙන

අහස් කුස සිපින

මහා රුක්ෂයෝ

මුලින් උදුරා

බිම හෙළති

වැඩගම්මකට නැති

මහා බොල්

සැඩ සුළන්

සිත් පිත් නැතිව.





video

Saturday, November 6, 2010

....පිළිම....

කාක්කන්

වසරු හෙළුවද

ගල් පිළිමය

නිරුත්තරය......

උවැසියන්

මල් පුදා

වැන්දද

ගල් පිළිමය

නිරුත්තරය

Tuesday, October 19, 2010

ifo++


.....ඔබ සැමට ආරාධනා.....

Tuesday, September 14, 2010

??? ?.. . ඔබ . ..? ???



ඇසින් නොව
ඔබ
සිතින් දකිමින්…...
ඔබ ?
සොයා සිත
දුර ගිහින්……
කුමරියයි
ඔබ ?
මසිත සනසන
එනු මැන
පියවි ලොකෙට
එතෙක් මා
හිදිමි
ඔබ ?
එනතුරා......