Workshop enrollment dotnet ict
// TraineeBL.cs
// WorkShop Enrolement
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace WorkShopEnrollmentApp
{
//Write your code here
public class TraineeBL
{
public bool SaveTraineeDetails(TraineeBO objBO)
{
TraineeDA tDA = new TraineeDA();
bool res = tDA.AddTraineeDetails(objBO);
if (res)
return true;
else
return false;
}
}
}
————————————————————
TraineeBO
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace WorkShopEnrollmentApp
{
//Write your code here
public class TraineeBO
{
public long traineeId;
public string traineeName;
public string batchCode;
public long TraineeId { get; set; }
public string TraineeName { get; set; }
public string BatchCode { get; set; }
public TraineeBO()
{
}
public TraineeBO(long traineeId, string traineeName, string batchCode)
{
this.traineeId = traineeId;
this.traineeName = traineeName;
this.batchCode = batchCode;
}
}
}
——————————————
TraineeDA.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data.SqlClient;
using System.Data;
using System.Configuration;
namespace WorkShopEnrollmentApp
{
//Write your code here
public class TraineeDA
{
public string ConnectionString
{
get
{
return ConfigurationManager.ConnectionStrings["SqlCon"].ConnectionString;
}
}
public bool AddTraineeDetails(TraineeBO objBO)
{
try
{
SqlConnection con = new SqlConnection(ConnectionString);
con.Open();
string query = "insert into tblTrainee values("+objBO.TraineeId+",'"+objBO.TraineeName+"','"+objBO.BatchCode+"')";
SqlCommand cmd = new SqlCommand(query, con);
int i = cmd.ExecuteNonQuery();
if(i > 0)
return true;
else
return false;
}
catch(Exception e)
{
return false;
}
}
}
}
Comments
Post a Comment