You are on page 1of 4

using using using using using using using using using

System; System.Collections.Generic; System.Linq; System.Text; Microsoft.Practices.EnterpriseLibrary.Data; Microsoft.Practices.EnterpriseLibrary.Common; System.Data.Common; System.Data; System.Windows.Forms;

namespace kHRM.DAL { public class DInterview { internal static System.Data.DataTable allCandidates() { DataTable dt = new DataTable(); try { //Create a database instance from Enterprise Library. Database db = DatabaseFactory.CreateDatabase(); //Command isntance is created and call the GetSqlStringCommand of Enterprise Lib. To assign the command DbCommand cmd = db.GetSqlStringCommand("SELECT * FROM M_Interview"); //ExecuteDataSet to get a table of jobs List. dt = db.ExecuteDataSet(cmd).Tables[0]; } //To cathc The Error catch (Exception ex) { //messaging When Error occured. MessageBox.Show("Error:", ex.Message); } return dt; } internal static string SaveCandidates(kHRM.BAL.BInterview bInterview) { string msg = ""; try { //Create a database instance from Enterprise Library. Database db = DatabaseFactory.CreateDatabase(); //Command isntance is created and call the GetSqlStringCommand of Enterprise Lib. To assign the command DbCommand cmd = db.GetStoredProcCommand("SaveCandidates"); //adding parameters to the command using AddInParameter of Enterprise Lib. db.AddInParameter(cmd, "@paramIID", DbType.Int32, bInterview.appID); db.AddInParameter(cmd, "@paramAID",DbType.Int32,bInterview.appID); db.AddInParameter(cmd, "@paramSS", DbType.String, bInterview.ResulutStaus);

db.AddInParameter(cmd, "@paramFood",DbType.Boolean,bInterview.food); db.AddInParameter(cmd, "@paramAcc",DbType.Boolean,bInterview.accomodation); db.AddInParameter(cmd, "@paramSalary",DbType.Decimal,bInterview.salary); db.AddInParameter(cmd, "@paramINV",DbType.String,bInterview.Interviewer); db.AddInParameter(cmd, "@paramSign",DbType.String,bInterview.singnature); db.AddInParameter(cmd, "@paramRemarks", DbType.String, bInterview.Remarks); //call ExecuteNonQuery o fEnterprise Lib to execute the command and get a result as a no of Rows affected. int n = db.ExecuteNonQuery(cmd); //Processing for Successfull Data Messesing if (n > 0) { msg = "Data Added SuccesFully"; } else { msg = "There is Error to Add New Data"; } } catch (Exception ex) { MessageBox.Show("There is Error:" + ex.Message); } return msg; } internal static string UpdateCandidates(kHRM.BAL.BInterview bInterview) { string msg = ""; try { //Create a database instance from Enterprise Library. Database db = DatabaseFactory.CreateDatabase(); //Command isntance is created and call the GetSqlStringCommand of Enterprise Lib. To assign the command DbCommand cmd = db.GetStoredProcCommand("UpdateCandidates"); //adding parameters to the command using AddInParameter of Enterprise Lib. db.AddInParameter(cmd, "@paramIID", DbType.Int32, bInterview.appID); db.AddInParameter(cmd, "@paramAID", DbType.Int32, bInterview.appID); db.AddInParameter(cmd, "@paramSS", DbType.String, bInterview.ResulutStaus); db.AddInParameter(cmd, "@paramFood", DbType.Boolean, bInterview.food);

db.AddInParameter(cmd, bInterview.accomodation); db.AddInParameter(cmd, bInterview.salary); db.AddInParameter(cmd, bInterview.Interviewer); db.AddInParameter(cmd, bInterview.singnature); db.AddInParameter(cmd, bInterview.Remarks);

"@paramAcc", DbType.Boolean, "@paramSalary", DbType.Decimal, "@paramINV", DbType.String, "@paramSign", DbType.String, "@paramRemarks", DbType.String,

//call ExecuteNonQuery o fEnterprise Lib to execute the command and get a result as a no of Rows affected. int n = db.ExecuteNonQuery(cmd); //Processing for Successfull Data Messesing if (n > 0) { msg = "Data Added SuccesFully"; } else { msg = "There is Error to Add New Data"; } } catch (Exception ex) { MessageBox.Show("There is Error:" + ex.Message); } return msg; } internal static int getNewCandidate() { int id = 0; try { Database db = DatabaseFactory.CreateDatabase(); DbCommand cmd = db.GetStoredProcCommand("getNewCandidate"); object n = db.ExecuteScalar(cmd); id = Convert.ToInt32(n); } catch (Exception ex) { MessageBox.Show(ex.Message); } return id; } internal static int ApplicantForCandidate(int candidateno) { int appID = 0; try { Database db = DatabaseFactory.CreateDatabase();

DbCommand cmd = db.GetSqlStringCommand("SELECT Inv_ApplicantId FROM M_Interview where Inv_Id=@paramINID"); db.AddInParameter(cmd, "@paramINID", DbType.Int32, candidateno); object m = db.ExecuteScalar(cmd); appID = Convert.ToInt32(m); } catch (Exception ex) { MessageBox.Show(ex.Message); } return appID;

} } }

You might also like