Ejemplo n.º 1
0
        public bool Delete(employee e)
        {
            bool isSuccess = false;

            SqlConnection conn = new SqlConnection(connection);

            try
            {
                string sql = "DELETE FROM Angajati WHERE Id=@ID";

                SqlCommand cmd = new SqlCommand(sql, conn);

                cmd.Parameters.AddWithValue("@ID", e.id);

                conn.Open();

                int rows = cmd.ExecuteNonQuery();

                if (rows > 0)
                {
                    isSuccess = true;
                }
                else
                {
                    isSuccess = false;
                }
            }
            catch (Exception ex)
            {
            }
            finally
            {
                conn.Close();
            }



            return(isSuccess);
        }
Ejemplo n.º 2
0
        public bool Insert(employee e)
        {
            bool          isSuccess = false;
            SqlConnection conn      = new SqlConnection(connection);

            try
            {
                string     sql = "INSERT INTO Angajati (Name, Surname, Role, Department) VALUES (@Name, @Surname, @Role, @Department)";
                SqlCommand cmd = new SqlCommand(sql, conn);

                cmd.Parameters.AddWithValue("@Name", e.name);
                cmd.Parameters.AddWithValue("@Surname", e.surname);
                cmd.Parameters.AddWithValue("@Role", e.role);
                cmd.Parameters.AddWithValue("@Department", e.department);

                conn.Open();
                int rows = cmd.ExecuteNonQuery();

                if (rows > 0)
                {
                    isSuccess = true;
                }

                else
                {
                    isSuccess = false;
                }
            }
            catch (Exception ex)
            {
            }
            finally
            {
                conn.Close();
            }
            return(isSuccess);
        }