public void Insert() { Student obj = new Student(); Console.Write("Enter ID: "); obj.ID = int.Parse(Console.ReadLine()); Console.Write("Enter Name: "); obj.Name = Console.ReadLine(); studentDataObject.Insert(obj); Query(); }
public void Update(Student obj) { string insertCommand = "UPDATE Student SET Name = @Name " + "WHERE ID = @ID"; SqlCommand command = new SqlCommand(insertCommand); SqlParameter idParameter = new SqlParameter("@ID", SqlDbType.Int); idParameter.Value = obj.ID; SqlParameter nameParameter = new SqlParameter("@Name", SqlDbType.NVarChar, 50); nameParameter.Value = obj.Name; command.Parameters.Add(idParameter); command.Parameters.Add(nameParameter); _da.Execute(command); }
public void Insert(Student obj) { string insertCommand = "INSERT INTO Student (ID, Name) " + "VALUES (@ID, @Name)"; SqlCommand command = new SqlCommand(insertCommand); SqlParameter idParameter = new SqlParameter("@ID", SqlDbType.Int); idParameter.Value = obj.ID; SqlParameter nameParameter = new SqlParameter("@Name", SqlDbType.NVarChar, 50); nameParameter.Value = obj.Name; command.Parameters.Add(idParameter); command.Parameters.Add(nameParameter); _da.Execute(command); }
public void DeleteOneRegistraion() { Registration regObj = new Registration(); Student studentObj = new Student(); studnetUI.Query(); Console.Write("Enter Student ID: "); regObj.STUDENTID = int.Parse(Console.ReadLine()); studentObj.ID = regObj.STUDENTID; registraionData.QueryByStudent(studentObj); Console.Write("Enter Course ID: "); regObj.COURSEID = int.Parse(Console.ReadLine()); registraionData.DeleteOneRegistraion(regObj); }
public List<Student> GetList() { SqlCommand command = new SqlCommand("SELECT * FROM Student"); DataTable dt = _da.Query(command); List<Student> studentList = new List<Student>(); for (int i = 0; i < dt.Rows.Count; i++) { Student obj = new Student(); obj.ID = int.Parse(dt.Rows[i][0].ToString()); obj.Name = dt.Rows[i][1].ToString(); studentList.Add(obj); } return studentList; }
public void Update() { Student objToUpdate = new Student(); Console.Write("Enter ID: "); objToUpdate.ID = int.Parse(Console.ReadLine()); Console.Write("Enter Name: "); objToUpdate.Name = Console.ReadLine(); studentDataObject.Update(objToUpdate); Query(); }
public void QueryByStudent() { Student studentObj = new Student(); studnetUI.Query(); Console.WriteLine(); Console.Write("Enter Student ID: "); studentObj.ID = int.Parse(Console.ReadLine()); registraionData.QueryByStudent(studentObj); }
public void QueryByStudent(Student studentObje) { string studentQuery = "SELECT * FROM Student WHERE ID = @ID"; string registrationQuery = "SELECT COURSEID FROM Registraton WHERE STUDENTID = @ID"; SqlCommand studentCommand = new SqlCommand(studentQuery); SqlCommand registrationCommand = new SqlCommand(registrationQuery); SqlParameter studentIDParam = new SqlParameter("@ID", SqlDbType.Int); SqlParameter courSeIDParam = new SqlParameter("@ID", SqlDbType.Int); studentIDParam.Value = studentObje.ID; courSeIDParam.Value = studentObje.ID; studentCommand.Parameters.Add(studentIDParam); registrationCommand.Parameters.Add(courSeIDParam); Console.WriteLine("Studnet Info: "); CommonUI.ShowTable(dataAccess.Query(studentCommand)); Console.WriteLine("Registration: "); ShowCourseName(dataAccess.Query(registrationCommand)); }