//Bussiness Class Layer//
using System;
using System.Collections.Generic;
using System.Linq; using System.Text;
using System.Data;
using System.Data.SqlClient;
namespace BussinessLayer
{
public class BLLCounter
{
string ConnectionStr = “Data Source=SINGH-LAPTOP;Initial Catalog=Bank;Persist Security Info=True;User ID=sa;Password=microsoft;Pooling=False;”;
public int CreateCounter(string CounterId, string CounterName)
{
SqlConnection con = new SqlConnection(ConnectionStr);
string sql = “insert into tblCounter(CounterId,CounterName) values(@CounterId,@COunterName)”;
SqlCommand cmd = new SqlCommand(sql, con);
cmd.Parameters.AddWithValue(“@CounterId”, CounterId);
cmd.Parameters.AddWithValue(“@CounterName”, CounterName);
try
{
con.Open();
return cmd.ExecuteNonQuery();//insert update delete
}
catch (Exception)
{
throw;
}
finally
{
con.Close();
}
}
//Event on Add Button….//
private void btnAdd_Click(object sender, EventArgs e){
if (txtCounterId.Text == “” || cboCounterName.Text== “”)
{
MessageBox.Show(“Counter Id or Name Missing.”,”Important Notice”,MessageBoxButtons.OK,MessageBoxIcon.Exclamation,MessageBoxDefaultButton.Button1);
}
else
{
add();
}
}
//Function add……//
public void add(){
int i = blu.CreateCounter(txtCounterId.Text, cboCounterName.Text);
if (i > 0)
{
MessageBox.Show(“Create Counter”);
}
else
{
MessageBox.Show(“Cannot create Counter”);
}
}
0 comments:
Post a Comment