private void Insert() { Teacher teacherObj = new Teacher(); Console.Write("Insert Name: "); teacherObj.NAME = Console.ReadLine(); teacherDataObject.Insert(teacherObj); Query(); }
public void Insert(Teacher teacherObj) { string insertCommand = "INSERT INTO Teacher (NAME) VALUES (@NAME)"; SqlCommand sqlCommand = new SqlCommand(insertCommand); SqlParameter nameParam = new SqlParameter("@NAME", SqlDbType.VarChar); nameParam.Value = teacherObj.NAME; sqlCommand.Parameters.Add(nameParam); dataAccess.Execute(sqlCommand); }
public void Update(Teacher teacherObj) { string updateCommand = "UPDATE Teacher SET NAME = @NAME WHERE ID = @ID"; SqlCommand sqlCommand = new SqlCommand(updateCommand); SqlParameter nameParam = new SqlParameter("@NAME", SqlDbType.VarChar); nameParam.Value = teacherObj.NAME; SqlParameter idParam = new SqlParameter("@ID", SqlDbType.Int); idParam.Value = teacherObj.ID; sqlCommand.Parameters.Add(nameParam); sqlCommand.Parameters.Add(idParam); dataAccess.Execute(sqlCommand); }
private void Update() { Teacher teacherObj = new Teacher(); Console.Write("Insert ID: "); teacherObj.ID = int.Parse(Console.ReadLine()); Console.Write("Insert Name: "); teacherObj.NAME = Console.ReadLine(); teacherDataObject.Update(teacherObj); Query(); }