public void Insert(SkillEntity t) { SqlConnection conn = null; SqlCommand cmd = null; try { conn = DALHelper.CreateSqlDbConnection(); cmd = new SqlCommand("usp_InsertSkill", conn); cmd.CommandType = System.Data.CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@EmployeeId", t.EmployeeId); cmd.Parameters.AddWithValue("@SkillName", t.SkillName); cmd.ExecuteNonQuery(); } catch (Exception) { throw; } finally { conn.Close(); cmd.Dispose(); conn.Dispose(); } }
public static void skillManagment(string employeeId, string value, string action) { if (string.IsNullOrEmpty(value)) { throw new Exception("You must supply a value."); } if (string.IsNullOrEmpty(action)) { throw new Exception("You must supply a action."); } if (action == "insert") { SkillEntity ent = new SkillEntity(){ EmployeeId= Convert.ToInt32(employeeId), SkillName= value}; new SkillMapper().Insert(ent); } else { SkillEntity ent = new SkillEntity() { EmployeeId = Convert.ToInt32(employeeId), SkillName = value }; new SkillMapper().Delete(ent); } }
public List<SkillEntity> List(int EmployeeId, string search) { SqlConnection conn = null; SqlCommand cmd = null; try { conn = DALHelper.CreateSqlDbConnection(); cmd = new SqlCommand("usp_ListSkillsByEmployeeId", conn); cmd.CommandType = System.Data.CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@EmployeeId", EmployeeId); cmd.Parameters.AddWithValue("@SkillName", search); SqlDataReader rdr = cmd.ExecuteReader(); List<SkillEntity> list = new List<SkillEntity>(); while (rdr.Read()) { SkillEntity entity = new SkillEntity(); entity.EmployeeId = Convert.ToInt32(rdr["EmployeeId"]); entity.SkillName = Convert.ToString(rdr["SkillName"]); list.Add(entity); } return list; } catch (Exception) { throw; } finally { conn.Close(); cmd.Dispose(); conn.Dispose(); } }