Exemplo n.º 1
0
 public void Add(Rank entity)
 {
     using (SqlCommand cmd = new SqlCommand("INSERT INTO Ranks VALUES (@RankName)"))
     {
         cmd.Parameters.AddWithValue("RankName", entity.RankName);
         VTYS.SqlExecuteNonQuery(cmd);
     }
 }
Exemplo n.º 2
0
 public void Delete(Employee entity)
 {
     using (SqlCommand cmd =
                new SqlCommand("DELETE FROM Employees where Id = @Id"))
     {
         cmd.Parameters.AddWithValue("Id", entity.Id);
         VTYS.SqlExecuteNonQuery(cmd);
     }
 }
Exemplo n.º 3
0
 public void Delete(Rank entity)
 {
     using (SqlCommand cmd =
                new SqlCommand("DELETE FROM Ranks where RankId = @RankId"))
     {
         cmd.Parameters.AddWithValue("Id", entity.RankId);
         VTYS.SqlExecuteNonQuery(cmd);
     }
 }
Exemplo n.º 4
0
 public void Update(Rank entity)
 {
     using (SqlCommand cmd =
                new SqlCommand("UPDATE Ranks set RankId = @RankId, RankName = @RankName,  where RankId = @RankId"))
     {
         cmd.Parameters.AddWithValue("RankId", entity.RankId);
         cmd.Parameters.AddWithValue("RankName", entity.RankName);
         VTYS.SqlExecuteNonQuery(cmd);
     }
 }
Exemplo n.º 5
0
 public void Add(Employee entity)
 {
     using (SqlCommand cmd =
                new SqlCommand("INSERT INTO Employees (FirstName,LastName,Salary, RankId) VALUES (@FirstName,@LastName,@salary, @RankIdd)"))
     {
         cmd.Parameters.AddWithValue("FirstName", entity.FirstName);
         cmd.Parameters.AddWithValue("LastName", entity.LastName);
         cmd.Parameters.AddWithValue("Salary", entity.Salary);
         cmd.Parameters.AddWithValue("RankId", entity.RankId);
         VTYS.SqlExecuteNonQuery(cmd);
     }
 }
Exemplo n.º 6
0
 public void Update(Employee entity)
 {
     using (SqlCommand cmd =
                new SqlCommand("UPDATE Employees set FirstName = @FirstName, LastName = @LastName, Salary = @Salary, RankId = @RankId, where Id = @Id"))
     {
         cmd.Parameters.AddWithValue("Id", entity.Id);
         cmd.Parameters.AddWithValue("FirstName", entity.FirstName);
         cmd.Parameters.AddWithValue("LastName", entity.LastName);
         cmd.Parameters.AddWithValue("Salary", entity.Salary);
         cmd.Parameters.AddWithValue("RankId", entity.RankId);
         VTYS.SqlExecuteNonQuery(cmd);
     }
 }
Exemplo n.º 7
0
        public List <Rank> GetAll()
        {
            var        categoryList = new List <Rank>();
            SqlCommand cmd          = new SqlCommand("Select * from Ranks");

            SqlDataReader reader = VTYS.SqlExecuteReader(cmd);

            while (reader.Read())
            {
                Rank category = new Rank()
                {
                    RankId   = Convert.ToInt32(reader[0]),
                    RankName = reader[1].ToString(),
                };

                categoryList.Add(category);
            }
            return(categoryList);
        }
Exemplo n.º 8
0
        public Rank Get(int id)
        {
            SqlCommand cmd = new SqlCommand("Select * from Ranks where Id = @RankId");

            cmd.Parameters.AddWithValue("RankId", id);

            SqlDataReader reader = VTYS.SqlExecuteReader(cmd);

            while (reader.Read())
            {
                Rank category = new Rank()
                {
                    RankId   = Convert.ToInt32(reader[0]),
                    RankName = reader[1].ToString(),
                };

                return(category);
            }
            return(null);
        }
Exemplo n.º 9
0
        public List <Employee> GetAll()
        {
            var        empList = new List <Employee>();
            SqlCommand cmd     = new SqlCommand("Select * from Employees");

            SqlDataReader reader = VTYS.SqlExecuteReader(cmd);

            while (reader.Read())
            {
                Employee emp = new Employee
                {
                    Id        = Convert.ToInt32(reader[0]),
                    FirstName = reader[1].ToString(),
                    LastName  = reader[2].ToString(),
                    Salary    = Convert.ToDecimal(reader[3]),
                    RankId    = Convert.ToInt32(reader[4]),
                };

                empList.Add(emp);
            }
            return(empList);
        }
Exemplo n.º 10
0
        public Employee Get(int id)
        {
            SqlCommand cmd = new SqlCommand("Select * from Employees where Id = @Id");

            cmd.Parameters.AddWithValue("Id", id);

            SqlDataReader reader = VTYS.SqlExecuteReader(cmd);

            while (reader.Read())
            {
                Employee emp = new Employee
                {
                    Id        = Convert.ToInt32(reader[0]),
                    FirstName = reader[1].ToString(),
                    LastName  = reader[2].ToString(),
                    Salary    = Convert.ToDecimal(reader[3]),
                    RankId    = Convert.ToInt32(reader[4]),
                };

                return(emp);
            }
            return(null);
        }