public List <SubjectM> GetSubjects() { List <SubjectM> subjects = new List <SubjectM>(); _command.CommandText = "SELECT * FROM Subject"; _command.Parameters.Clear(); PrepareSql(); SqlDataReader reader = null; reader = _command.ExecuteReader(); if (reader.HasRows) { while (reader.Read()) { SubjectM ls1 = new SubjectM(); ls1.Id = reader["ID"] != DBNull.Value ? Convert.ToInt32(reader["ID"]) : default(int); ls1.Name = reader["Name"] != DBNull.Value ? reader["Name"].ToString() : string.Empty; ls1.HoursEstimate = reader["HoursEstimate"] != DBNull.Value ? Convert.ToInt32(reader["HoursEstimate"]) : default(int); ls1.Price = reader["Price"] != DBNull.Value ? Convert.ToDecimal(reader["Price"]) : default(decimal); ls1.TimeEstimate = reader["TimeEstimate"] != DBNull.Value ? Convert.ToInt32(reader["TimeEstimate"]) : default(int); subjects.Add(ls1); } } _connection.Close(); return(subjects); }
public List <SubjectM> GetEmployeeSubjectsById(int id) { List <SubjectM> fields = new List <SubjectM>(); _command.CommandText = "SELECT * FROM Subject WHERE [ID] IN " + "(SELECT Subject_ID FROM Specialization WHERE Employee_ID = @id)"; _command.Parameters.Clear(); _command.Parameters.Add(new SqlParameter("@id", id)); PrepareSql(); SqlDataReader reader = null; reader = _command.ExecuteReader(); if (reader.HasRows) { while (reader.Read()) { SubjectM f = new SubjectM(); f.Id = Convert.ToInt32(reader["ID"]); f.Name = reader["Name"].ToString(); fields.Add(f); } } _connection.Close(); return(fields); }
internal int UpdateSubject(int id, string name, int hours, int time, decimal price) { SubjectM subject = new SubjectM(); subject.Id = id; subject.Name = name; subject.HoursEstimate = hours; subject.TimeEstimate = time; subject.Price = price; return(_dbSubject.UpdateSubject(subject)); }
public int NewSubject(SubjectM subject) { string sqlString = "INSERT INTO Subject (Name, HoursEstimate, Price, TimeEstimate) VALUES " + " (@Name, @HoursEstimate, @Price, @TimeEstimate)"; _command.CommandText = sqlString; _command.Parameters.Clear(); _command.Parameters.Add(new SqlParameter("@Name", subject.Name)); _command.Parameters.Add(new SqlParameter("@HoursEstimate", subject.HoursEstimate)); _command.Parameters.Add(new SqlParameter("@Price", subject.Price)); _command.Parameters.Add(new SqlParameter("@TimeEstimate", subject.TimeEstimate)); return(ExecuteNonQuery()); }
public int UpdateSubject(SubjectM subject) { _command.CommandText = "UPDATE Subject SET Name = @name, HoursEstimate = @hours, TimeEstimate = @time," + " Price = @price WHERE ID = @id"; _command.Parameters.Clear(); _command.Parameters.Add(new SqlParameter("@id", subject.Id)); _command.Parameters.Add(new SqlParameter("@name", subject.Name)); _command.Parameters.Add(new SqlParameter("@hours", subject.HoursEstimate)); _command.Parameters.Add(new SqlParameter("@time", subject.TimeEstimate)); _command.Parameters.Add(new SqlParameter("@price", subject.Price)); return(ExecuteNonQuery()); }
public int UpdateSubject(SubjectM ls) { return(1); }
public int NewSubject(SubjectM subject) { return(1); }